Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
- # #
- # V's Promotion System #
- # Version 0.2 #
- # #
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
- # Written By: V #
- # Last Edited: January 5, 2013 #
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
- # #
- #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
- #==============================================================================#
- #------------------------------------------------------------------------------#
- # ** Disclaimer #
- #------------------------------------------------------------------------------#
- # #
- # This script was intended for Non-commercial use only, if you wish to use #
- # this script in a commercial game please PM me at which ever site you found #
- # this script. Either way please give me credit in your game script as the #
- # writer of this script, and send me a PM abuot the release of the game/demo. #
- # #
- # Wooden Prize Wheel Image and Wooden Background Image found inside of the #
- # demo was drawn and contributed by Cap'n K'nuckles, and can only be used #
- # on his terms. #
- # #
- #------------------------------------------------------------------------------#
- # ** How To Use #
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
- # #
- # * Set-Up the promotions use the following tag in an actors note box as many #
- # times as you desire. #
- # #
- # <Promotion: Level, Graphic_Name, Graphic_Index, Cost, Class> #
- # #
- # #
- # * To call the Promotion scene use the following command in a script call. #
- # #
- # promote #
- # #
- # #
- # * To check for promotable party members scene use the following command in #
- # a conditional branch's script call. #
- # #
- # check_if_members_are_promotable #
- # #
- # #
- #------------------------------------------------------------------------------#
- # ** Description #
- #------------------------------------------------------------------------------#
- # #
- # v0.1 #
- # ~=~=~=~ #
- # * This script creates a promotion scene and feature for the game. When an #
- # actor reaches a set level thy will not be able to gain more exp until #
- # they are promoted. Upon promoting the graphic and classes can be changed. #
- # #
- # v0.2 #
- # ~=~=~=~ #
- # * I fixed a bug with the promotions not working right. #
- # #
- #------------------------------------------------------------------------------#
- #==============================================================================#
- #==============================================================================#
- #------------------------------------------------------------------------------#
- # Existing Class #
- #------------------------------------------------------------------------------#
- #==============================================================================#
- #==============================================================================
- # ** Game_Actor
- #------------------------------------------------------------------------------
- # This class handles actors. It is used within the Game_Actors class
- # ($game_actors) and is also referenced from the Game_Party class ($game_party).
- #==============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :needs_promotion # Actor needs promotion
- attr_accessor :actor_note # Actors promotion note
- attr_accessor :promotion_cost # Actors promotion cost
- attr_accessor :next_promotion_name # Actors next promotion graphic name
- attr_accessor :next_promotion_index # Actors next promotion graphic index
- attr_accessor :next_promotion_class # Actors next promotion class
- #--------------------------------------------------------------------------
- # * Alaising Method: Setup
- #--------------------------------------------------------------------------
- alias :s434 :setup
- #--------------------------------------------------------------------------
- # * Setup
- #--------------------------------------------------------------------------
- def setup(actor_id)
- @needs_promotion = false
- @promotion_cost = 0
- @next_promotion_name = ""
- @next_promotion_index = 0
- @next_promotion_class = 0
- set_up_actor_note(actor_id)
- s434(actor_id)
- end
- #~ #--------------------------------------------------------------------------
- #~ # * Alaising Method: Gain EXP
- #~ #--------------------------------------------------------------------------
- #~ alias :ge434 :gain_exp
- #--------------------------------------------------------------------------
- # * Gain EXP (Account for Experience Rate)
- #--------------------------------------------------------------------------
- def gain_exp(exp)
- ge434(exp) unless promotable?
- end
- #--------------------------------------------------------------------------
- # * Change Experience
- # show : Level up display flag
- #--------------------------------------------------------------------------
- def change_exp(exp, show)
- @exp[@class_id] = [exp, 0].max unless promotable?
- last_level = @level
- last_skills = skills
- level_up while !max_level? && self.exp >= next_level_exp
- level_down while self.exp < current_level_exp
- display_level_up(skills - last_skills) if show && @level > last_level
- refresh
- end
- #--------------------------------------------------------------------------
- # * Alaising Method: Level Up
- #--------------------------------------------------------------------------
- alias :lu434 :level_up
- #--------------------------------------------------------------------------
- # * Level Up
- #--------------------------------------------------------------------------
- def level_up
- lu434() unless promotable?
- check_for_promotion
- end
- #--------------------------------------------------------------------------
- # * Sets up the actor's note
- #--------------------------------------------------------------------------
- def set_up_actor_note(actor_id)
- note= /<Promotion:\s*(\d*)\S*\s*(\w*)\S*\s*(\d*)\S*\s*(\d*)\S*\s*(\d*)>/i
- @actors_note = $data_actors[actor_id].note.scan(note)
- end
- #--------------------------------------------------------------------------
- # * Check For Promotions
- #--------------------------------------------------------------------------
- def check_for_promotion
- @actors_note.size.times { |i| @needs_promotion = true if @level == @actors_note[i][0].to_i } &&
- @actors_note.size.times { |i| @promotion_cost = @actors_note[i][3].to_i if @level == @actors_note[i][0].to_i } &&
- @actors_note.size.times { |i| @next_promotion_name = @actors_note[i][1] if @level == @actors_note[i][0].to_i } &&
- @actors_note.size.times { |i| @next_promotion_index = @actors_note[i][2].to_i if @level == @actors_note[i][0].to_i } &&
- @actors_note.size.times { |i| @next_promotion_class = @actors_note[i][4].to_i if @level == @actors_note[i][0].to_i }
- end
- #--------------------------------------------------------------------------
- # * Checks if actor is promotable
- #--------------------------------------------------------------------------
- def promotable?
- @needs_promotion == true
- end
- #--------------------------------------------------------------------------
- # * Promote Proccessing
- #--------------------------------------------------------------------------
- def promote
- @needs_promotion = false
- @actors_note.size.times { |i| @character_name = @actors_note[i][1] if @level == @actors_note[i][0].to_i } &&
- @actors_note.size.times { |i| @character_index = @actors_note[i][2].to_i if @level == @actors_note[i][0].to_i } &&
- @actors_note.size.times { |i| change_class(@actors_note[i][4].to_i, true) if @level == @actors_note[i][0].to_i }
- $game_party.lose_gold(promotion_cost?)
- $game_player.refresh
- end
- #--------------------------------------------------------------------------
- # * Promote Proccessing
- #--------------------------------------------------------------------------
- def promotion_cost?
- return @promotion_cost
- end
- end #<--- End Class============================================================
- #==============================================================================#
- #------------------------------------------------------------------------------#
- # Existing Class #
- #------------------------------------------------------------------------------#
- #==============================================================================#
- #==============================================================================
- # ** Game_Interpreter
- #------------------------------------------------------------------------------
- # An interpreter for executing event commands. This class is used within the
- # Game_Map, Game_Troop, and Game_Event classes.
- #==============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # * Method to call the Promotion Scene
- #--------------------------------------------------------------------------
- def promote
- SceneManager.call( V_Promotion_Scene )
- end
- #--------------------------------------------------------------------------
- # * Method to check if party members are promotable
- #--------------------------------------------------------------------------
- def check_if_members_are_promotable
- anwser = false
- members = $game_party.members
- members.size.times { |i| anwser = true if members[i].promotable? }
- return anwser
- end
- end #<--- End Class============================================================
- #==============================================================================#
- #------------------------------------------------------------------------------#
- # Existing Class #
- #------------------------------------------------------------------------------#
- #==============================================================================#
- #==============================================================================
- # ** Window_Base
- #------------------------------------------------------------------------------
- # This is a super class of all windows within the game.
- #==============================================================================
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # * Draw Class
- #--------------------------------------------------------------------------
- def draw_actor_class(actor, x, y, width = 112)
- change_color(normal_color)
- draw_text(x, y, width, line_height, actor.class.name)
- end
- #--------------------------------------------------------------------------
- # * Alaising Method: Draw Level
- #--------------------------------------------------------------------------
- alias :dal434 :draw_actor_level
- #--------------------------------------------------------------------------
- # * Draw Level
- #--------------------------------------------------------------------------
- def draw_actor_level(actor, x, y)
- dal434(actor, x, y)
- if actor.promotable?
- draw_v_text(x, y + 25, 150, line_height, "Promotable", 0, 24, crisis_color)
- end
- end
- #--------------------------------------------------------------------------
- # * Draw V Level
- #--------------------------------------------------------------------------
- def draw_v_text(x, y, width, height, text, alignment, size, color = normal_color)
- reset_font_settings
- contents.font.size = size
- change_color(color)
- contents.draw_text(x, y, width, height, text, alignment)
- reset_font_settings
- end
- #--------------------------------------------------------------------------
- # * Draw Zoomed Character
- #--------------------------------------------------------------------------
- def draw_zoomed_character(character_name, character_index, x, y, zoom)
- return unless character_name
- bitmap = Cache.character(character_name)
- sign = character_name[/^[\!\$]./]
- if sign && sign.include?('$')
- cw = bitmap.width / 3
- ch = bitmap.height / 4
- else
- cw = bitmap.width / 12
- ch = bitmap.height / 8
- end
- n = character_index
- src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
- actor = Rect.new(x, y, cw * zoom, ch * zoom)
- contents.stretch_blt(actor, bitmap, src_rect)
- end
- #--------------------------------------------------------------------------
- # * Draw Zoomed Actor
- #--------------------------------------------------------------------------
- def draw_zoomed_actor_graphic(actor, x, y, zoom)
- draw_zoomed_character(actor.character_name, actor.character_index, x, y, zoom)
- end
- end #<--- End Class============================================================
- #==============================================================================#
- #------------------------------------------------------------------------------#
- # New Class #
- #------------------------------------------------------------------------------#
- #==============================================================================#
- #==============================================================================
- # ** Promotion_Header_Window
- #------------------------------------------------------------------------------
- # This class handles all of the Promotion Header Window processing.
- #==============================================================================
- class Promotion_Header_Window < Window_Base
- #--------------------------------------------------------------------------
- # * Initialize Proccessing
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super(x, y, width, height)
- draw_contents
- end
- #--------------------------------------------------------------------------
- # * Draw Contents
- #--------------------------------------------------------------------------
- def draw_contents
- draw_v_text(-10, -15, Graphics.width, 75, "Who Do You Want To Promote?", 1, 34)
- end
- end #<--- End Class============================================================
- #==============================================================================#
- #------------------------------------------------------------------------------#
- # New Class #
- #------------------------------------------------------------------------------#
- #==============================================================================#
- #==============================================================================
- # ** Promotion_Info_Window
- #------------------------------------------------------------------------------
- # This class handles all of the Promotion Info Window processing.
- #==============================================================================
- class Promotion_Info_Window < Window_Base
- #--------------------------------------------------------------------------
- # * Initialize Proccessing
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super(x, y, width, height)
- @index = 0
- set_up_promotion_vars
- end
- #--------------------------------------------------------------------------
- # * Refresh (Index)
- #--------------------------------------------------------------------------
- def refresh(index)
- contents.clear
- @index = index if index != @index
- draw_actor_info(@index)
- end
- #--------------------------------------------------------------------------
- # * Set up promotional variable
- #--------------------------------------------------------------------------
- def set_up_promotion_vars
- @promotables = []
- $game_party.members.size.times { |i| @promotables.push $game_party.members[i] if $game_party.members[i].promotable? }
- end
- #--------------------------------------------------------------------------
- # * Draws actors info
- #--------------------------------------------------------------------------
- def draw_actor_info(index)
- actor = @promotables[@index]
- cost = "Cost: " + actor.promotion_cost?.to_s
- draw_v_text(120, 55, (Graphics.width / 3) * 2, 75, actor.name, 0, 45)
- draw_actor_face(actor, 10, 10)
- draw_zoomed_actor_graphic(actor, 40, 150, 2)
- draw_v_text(-105, 200, (Graphics.width / 3) * 2, 75, $data_classes[actor.class_id].name, 1, 22)
- draw_v_text(-10, 150, (Graphics.width / 3) * 2, 75, ">", 1, 55)
- draw_zoomed_character(actor.next_promotion_name, actor.next_promotion_index, 230, 150, 2)
- draw_v_text(85, 200, (Graphics.width / 3) * 2, 75, $data_classes[actor.next_promotion_class].name, 1, 22)
- draw_v_text(-10, 250, (Graphics.width / 3) * 2, 75, cost, 1, 40)
- end
- end #<--- End Class============================================================
- #==============================================================================#
- #------------------------------------------------------------------------------#
- # New Class #
- #------------------------------------------------------------------------------#
- #==============================================================================#
- #==============================================================================
- # ** Promotion_Command_Window
- #------------------------------------------------------------------------------
- # This class handles all of the Promotion Command Window processing.
- #==============================================================================
- class Promotion_Command_Window < Window_Command
- #--------------------------------------------------------------------------
- # * Set up promotional variable
- #--------------------------------------------------------------------------
- def set_up_promotion_vars
- @promotables = []
- $game_party.members.size.times { |i| @promotables.push $game_party.members[i] if $game_party.members[i].promotable? }
- end
- #--------------------------------------------------------------------------
- # * Make Command List
- #--------------------------------------------------------------------------
- def make_command_list
- set_up_promotion_vars
- @promotables.size.times { |i| add_command(@promotables[i].name, @promotables[i].name.to_sym, afford?(i)) }
- end
- #--------------------------------------------------------------------------
- # * Window Width
- #--------------------------------------------------------------------------
- def window_width
- return Graphics.width / 3
- end
- #--------------------------------------------------------------------------
- # * Window Height
- #--------------------------------------------------------------------------
- def window_height
- return Graphics.height - 75
- end
- #--------------------------------------------------------------------------
- # * Checks if party has enough to but promotion
- #--------------------------------------------------------------------------
- def afford?(id)
- $game_party.gold > @promotables[id].promotion_cost?
- end
- end #<--- End Class============================================================
- #==============================================================================#
- #------------------------------------------------------------------------------#
- # New Class #
- #------------------------------------------------------------------------------#
- #==============================================================================#
- #==============================================================================
- # ** Promotion_Command_Window
- #------------------------------------------------------------------------------
- # This class handles all of the Promotion Command Window processing.
- #==============================================================================
- class Promotion_Confirm_Window < Window_Command
- #--------------------------------------------------------------------------
- # * Select Last Index
- #--------------------------------------------------------------------------
- def select_last
- select(0)
- end
- #--------------------------------------------------------------------------
- # * Make Command List
- #--------------------------------------------------------------------------
- def make_command_list
- add_command("Confirm", :confirm)
- add_command("Cancel", :cancel)
- end
- #--------------------------------------------------------------------------
- # * Window Width
- #--------------------------------------------------------------------------
- def window_width
- return (Graphics.width / 5) * 3
- end
- #--------------------------------------------------------------------------
- # * Window Height
- #--------------------------------------------------------------------------
- def window_height
- return 50
- end
- #--------------------------------------------------------------------------
- # * Maximum number of colums
- #--------------------------------------------------------------------------
- def col_max
- return item_max
- end
- #--------------------------------------------------------------------------
- # * Visible line number
- #--------------------------------------------------------------------------
- def visible_line_number
- 1
- end
- #--------------------------------------------------------------------------
- # * Alignment
- #--------------------------------------------------------------------------
- def alignment
- return 1
- end
- end #<--- End Class============================================================
- #==============================================================================#
- #------------------------------------------------------------------------------#
- # New Class #
- #------------------------------------------------------------------------------#
- #==============================================================================#
- #==============================================================================
- # ** Promotion_Header_Window
- #------------------------------------------------------------------------------
- # This class handles all of the Promotion Header Window processing.
- #==============================================================================
- class Promotion_Confirm_Text_Window < Window_Base
- #--------------------------------------------------------------------------
- # * Initialize Proccessing
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super(x, y, width, height)
- draw_contents
- end
- #--------------------------------------------------------------------------
- # * Draw Contents
- #--------------------------------------------------------------------------
- def draw_contents
- draw_v_text(0, -15, (Graphics.width / 5) * 3, 75, "Are you sure?", 1, 28)
- end
- end #<--- End Class============================================================
- #==============================================================================#
- #------------------------------------------------------------------------------#
- # New Class #
- #------------------------------------------------------------------------------#
- #==============================================================================#
- #==============================================================================
- # ** V_Promotion_Scene
- #------------------------------------------------------------------------------
- # This class handles all of the Promotion Scene processing.
- #==============================================================================
- class V_Promotion_Scene < Scene_Base
- #--------------------------------------------------------------------------
- # * Initialize Proccessing
- #--------------------------------------------------------------------------
- def initialize
- super
- set_up_promotion_vars
- setup_promotion_windows
- end
- #--------------------------------------------------------------------------
- # * Set up promotional variable
- #--------------------------------------------------------------------------
- def set_up_promotion_vars
- @promotables = []
- $game_party.members.each_index { |i| @promotables.push $game_party.members[i] if $game_party.members[i].promotable? }
- end
- #--------------------------------------------------------------------------
- # * Sets up all windows
- #--------------------------------------------------------------------------
- def setup_promotion_windows
- @promotion_header_window = Promotion_Header_Window.new(0, 0, Graphics.width, 75)
- @promotion_header_window.back_opacity = 200
- @promotion_info_window = Promotion_Info_Window.new(Graphics.width / 3, 75, (Graphics.width / 3) * 2, Graphics.height - 75)
- @promotion_info_window.back_opacity = 200
- @promotion_command_window = Promotion_Command_Window.new(0, 75)
- @promotion_command_window.back_opacity = 200
- @promotables.size.times { |i| @promotion_command_window.set_handler(@promotables[i].name.to_sym, method(:command_confirm)) }
- @promotion_conformation_window = Promotion_Confirm_Window.new(Graphics.width / 5, 183)
- @promotion_conformation_window.set_handler(:confirm, method(:command_promote))
- @promotion_conformation_window.set_handler(:cancel, method(:command_cancel))
- @promotion_conformation_window.openness = 0
- @promotion_conformation_window.unselect
- @promotion_conformation_text_window = Promotion_Confirm_Text_Window.new((Graphics.width / 5) - 15, 108, ((Graphics.width / 5) * 3) + 30, 75)
- @promotion_conformation_text_window.openness = 0
- end
- #--------------------------------------------------------------------------
- # * Promotion Confirm Processing
- #--------------------------------------------------------------------------
- def command_confirm
- @promotion_conformation_text_window.open
- @promotion_conformation_window.open
- @promotion_conformation_window.activate
- @promotion_conformation_window.select_last
- end
- #--------------------------------------------------------------------------
- # * Promotion Command Processing
- #--------------------------------------------------------------------------
- def command_promote
- @promotables.size.times { |i| @promotables[i].promote if @promotion_command_window.current_symbol.to_s == @promotables[i].name }
- return_scene
- end
- #--------------------------------------------------------------------------
- # * Promotion Cancel Processing
- #--------------------------------------------------------------------------
- def command_cancel
- return_scene
- end
- #--------------------------------------------------------------------------
- # * Update Info Window Actor
- #--------------------------------------------------------------------------
- def update_info_window
- @promotion_info_window.refresh((@promotion_command_window.index))
- end
- #--------------------------------------------------------------------------
- # * Update Processing
- #--------------------------------------------------------------------------
- def update
- super
- update_info_window
- return_scene if Input.trigger?(:B)
- end
- end #<--- End Class============================================================
- #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
- # #
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
- # End of Script #
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
- # #
- #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
Advertisement
Add Comment
Please, Sign In to add comment