Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # * Módulo Lums V 1.0
- #------------------------------------------------------------------------------
- # COnfigure the lum system here
- #==============================================================================
- module Lums
- #------------------------------------------------------------------------------
- # * The main part of elements
- #-----------------------------------------------------------------------------
- # element id => "Element's name",
- #------------------------------------------------------------------------------
- ELEMENT_NAMES = {
- 1=>"Water",
- 2=>"Fire",
- }
- #------------------------------------------------------------------------------
- # * ELEMENT ICON
- # element id => text color(from windowskin);
- #-----------------------------------------------------------------------------
- ELEMENT_COLORS = {
- 1=>3,
- 2=>1,
- }
- #------------------------------------------------------------------------------
- # * ELEMENT ICON
- # element id => icon index;
- #-----------------------------------------------------------------------------
- ELEMENT_ICON = {
- -1=>0,
- 1=>55,
- 2=>56,
- }
- #------------------------------------------------------------------------------
- # * Class change for lums:
- # class id => {element id 1 => lums needed, element id 2 => lums needed, etc}
- #-----------------------------------------------------------------------------
- CLASS_CHANGE = {
- 2 => {1=>1},
- 3 => {2=>1},
- }
- #------------------------------------------------------------------------------
- # * When someone exchanges Lums, renew the class's skills ?
- #-----------------------------------------------------------------------------
- RENEW_SKILLS = true
- #------------------------------------------------------------------------------
- # * Name for the Lums (Singular)
- #-----------------------------------------------------------------------------
- LUM_NAME = "Lum"
- #------------------------------------------------------------------------------
- # * Plural name of Lums
- #-----------------------------------------------------------------------------
- LUM_PLURAL = "Lums"
- #------------------------------------------------------------------------------
- # * Text than you use in the menu and when a lum joins you
- #-----------------------------------------------------------------------------
- JOIN_TEXT = "The %s with %s powers, \\c[%s]%s\\c[0]\x00 is with %s now."
- HELP_CHANGE = "Choose Lum to exchange."
- HELP_CHANGE2 = "Exchange for?"
- HELP_CHANGE3 = "Sure? 'C' = YEAH 'B' = NO"
- end
- </pre>
- '''System'''
- <pre>
- #==============================================================================
- # ** Lum
- #------------------------------------------------------------------------------
- # Contiene toda la informacion de las criaturas
- #==============================================================================
- class Lum
- #------------------------------------------------------------------------------
- # * Publicación de variables
- #------------------------------------------------------------------------------
- attr_reader :element
- attr_reader :name
- attr_reader :skill
- attr_reader :atk
- attr_reader :def
- attr_reader :spi
- attr_reader :agi
- #------------------------------------------------------------------------------
- # * Inicio de objetos
- #------------------------------------------------------------------------------
- def initialize(element,name,skill,atk,df,spi,agi)
- @element = element
- @name = name
- @skill = skill
- @atk = atk
- @def = df
- @spi = spi
- @agi = agi
- end
- end
- #==============================================================================
- # ** Game_Actor
- #------------------------------------------------------------------------------
- # Contiene toda la información sobre los Actores
- #==============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # * Publicación de variables
- #--------------------------------------------------------------------------
- attr_accessor :lums
- attr_reader :org_class_id # class ID
- #--------------------------------------------------------------------------
- # * Metodos con alias
- #--------------------------------------------------------------------------
- alias ramiro_lum_game_actor_setup setup
- alias ramiro_lum_base_atk base_atk
- alias ramiro_lum_base_def base_def
- alias ramiro_lum_base_spi base_spi
- alias ramiro_lum_base_agi base_agi
- alias ramiro_lum_learned skill_learn?
- #--------------------------------------------------------------------------
- # * Iicio del actor
- #--------------------------------------------------------------------------
- def setup(actor_id)
- @lums = []
- ramiro_lum_game_actor_setup(actor_id)
- @org_class_id = @class_id
- end
- #--------------------------------------------------------------------------
- # * Determine if Finished Learning Skill
- # skill : skill
- #--------------------------------------------------------------------------
- def skill_learn?(skill)
- value = ramiro_lum_learned(skill)
- for lum in @lums
- value = true if lum.skill == skill.id
- end
- return value
- end
- #--------------------------------------------------------------------------
- # * Get Basic Attack
- #--------------------------------------------------------------------------
- def base_atk
- plus = 0
- for lum in @lums.compact do plus += lum.atk end
- return ramiro_lum_base_atk + plus
- end
- #--------------------------------------------------------------------------
- # * Get Basic Defense
- #--------------------------------------------------------------------------
- def base_def
- plus = 0
- for lum in @lums.compact do plus += lum.def end
- return ramiro_lum_base_def + plus
- end
- #--------------------------------------------------------------------------
- # * Get Basic Spirit
- #--------------------------------------------------------------------------
- def base_spi
- plus = 0
- for lum in @lums.compact do plus += lum.spi end
- return ramiro_lum_base_spi + plus
- end
- #--------------------------------------------------------------------------
- # * Get Basic Agility
- #--------------------------------------------------------------------------
- def base_agi
- plus = 0
- for lum in @lums.compact do plus += lum.agi end
- return ramiro_lum_base_agi + plus
- end
- #--------------------------------------------------------------------------
- # * Añadir un lum al Actor
- #--------------------------------------------------------------------------
- def add_lum(lum)
- @lums.push(lum)
- end
- #--------------------------------------------------------------------------
- # * Determine Usable Skills
- # skill : skill
- #--------------------------------------------------------------------------
- def lum_can_use?(skill)
- return false unless skill.is_a?(RPG::Skill)
- return false unless movable?
- return false if silent? and skill.spi_f > 0
- return false if (calc_mp_cost(skill) > mp)
- if $game_temp.in_battle
- return skill.battle_ok?
- else
- return skill.menu_ok?
- end
- end
- #--------------------------------------------------------------------------
- # * Fits the actor to a new class
- #--------------------------------------------------------------------------
- def fit_class
- total = {}
- for lum in @lums
- total[lum.element] = 0 if total[lum.element] == nil
- total[lum.element] += 1
- end
- for key in Lums::CLASS_CHANGE.keys
- get = Lums::CLASS_CHANGE[key]
- if get.keys == total.keys and get.values == total.values
- @class_id = key
- break
- return
- end
- @class_id = @org_class_id
- end
- if Lums::RENEW_SKILLS
- @skills = []
- for i in self.class.learnings
- learn_skill(i.skill_id) if i.level <= @level
- end
- end
- end
- end
- #==============================================================================
- # ** Game_party
- #------------------------------------------------------------------------------
- # Contiene informacion sobre el grupo de actores
- #==============================================================================
- class Game_Party < Game_Unit
- include Lums
- #--------------------------------------------------------------------------
- # * Adds automatically a Lum to the party
- #--------------------------------------------------------------------------
- def join_lum(lum)
- size = -1
- memeb = members.sort {|a,b| a.lums.size<=>b.lums.size }
- memeb[0].add_lum(lum)
- $game_message.texts = []
- $game_message.texts.push(sprintf(JOIN_TEXT,
- LUM_NAME,
- ELEMENT_NAMES[lum.element],
- ELEMENT_COLORS[lum.element], lum.name,
- memeb[0].name))
- $game_message.face_name = memeb[0].face_name
- $game_message.face_index = memeb[0].face_index
- memeb[0].fit_class
- end
- def max_lums
- memeb = members.sort {|a,b| b.lums.size<=>a.lums.size }
- return memeb[0].lums.size
- end
- end
- #==============================================================================
- # ** Scene_Battle
- #------------------------------------------------------------------------------
- # This class performs battle screen processing.
- #==============================================================================
- class Scene_Battle < Scene_Base
- #--------------------------------------------------------------------------
- # * Update Actor Command Selection
- #--------------------------------------------------------------------------
- def update_actor_command_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- prior_actor
- elsif Input.trigger?(Input::C)
- case @actor_command_window.commands[@actor_command_window.index]
- when Vocab::attack # Attack
- Sound.play_decision
- @active_battler.action.set_attack
- start_target_enemy_selection
- when Vocab::skill, @active_battler.class.skill_name # Skill
- Sound.play_decision
- start_skill_selection
- when Vocab::guard # Guard
- Sound.play_decision
- @active_battler.action.set_guard
- next_actor
- when Vocab::item # Item
- Sound.play_decision
- start_item_selection
- when Lums::LUM_PLURAL # Lums
- Sound.play_decision
- start_lum_selection
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Start Lum Selection
- #--------------------------------------------------------------------------
- def start_lum_selection
- @help_window = Window_Help.new
- @lum_window = Window_Lums.new(0, 56, 544, 232, @active_battler)
- @lum_window.help_window = @help_window
- @actor_command_window.active = false
- end
- #--------------------------------------------------------------------------
- # * End Lum Selection
- #--------------------------------------------------------------------------
- def end_lum_selection
- if @lum_window != nil
- @lum_window.dispose
- @lum_window = nil
- @help_window.dispose
- @help_window = nil
- end
- @actor_command_window.active = true
- end
- #--------------------------------------------------------------------------
- # * Update Skill Selection
- #--------------------------------------------------------------------------
- def update_lum_selection
- @lum_window.active = true
- @lum_window.update
- @help_window.update
- if Input.trigger?(Input::B)
- Sound.play_cancel
- end_lum_selection
- elsif Input.trigger?(Input::C)
- @skill = @lum_window.skill
- if @active_battler.lum_can_use?(@skill)
- Sound.play_decision
- determine_lum
- else
- Sound.play_buzzer
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super
- update_basic(true)
- update_info_viewport # Update information viewport
- if $game_message.visible
- @info_viewport.visible = false
- @message_window.visible = true
- end
- unless $game_message.visible # Unless displaying a message
- return if judge_win_loss # Determine win/loss results
- update_scene_change
- if @target_enemy_window != nil
- update_target_enemy_selection # Select target enemy
- elsif @target_actor_window != nil
- update_target_actor_selection # Select target actor
- elsif @lum_window != nil
- update_lum_selection # Select lum
- elsif @skill_window != nil
- update_skill_selection # Select skill
- elsif @item_window != nil
- update_item_selection # Select item
- elsif @party_command_window.active
- update_party_command_selection # Select party command
- elsif @actor_command_window.active
- update_actor_command_selection # Select actor command
- else
- process_battle_event # Battle event processing
- process_action # Battle action
- process_battle_event # Battle event processing
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Confirm Lum
- #--------------------------------------------------------------------------
- def determine_lum
- @active_battler.action.set_skill(@skill.id)
- @lum_window.active = false
- if @skill.need_selection?
- if @skill.for_opponent?
- start_target_enemy_selection
- else
- start_target_actor_selection
- end
- else
- end_lum_selection
- next_actor
- end
- end
- #--------------------------------------------------------------------------
- # * Update Target Enemy Selection
- #--------------------------------------------------------------------------
- def update_target_enemy_selection
- @target_enemy_window.update
- if Input.trigger?(Input::B)
- Sound.play_cancel
- end_target_enemy_selection
- elsif Input.trigger?(Input::C)
- Sound.play_decision
- @active_battler.action.target_index = @target_enemy_window.enemy.index
- end_target_enemy_selection
- end_skill_selection
- end_item_selection
- end_lum_selection
- next_actor
- end
- end
- end
- #==============================================================================
- # ** Window_ActorCommand
- #------------------------------------------------------------------------------
- # This window is used to select actor commands, such as "Attack" or "Skill".
- #==============================================================================
- class Window_ActorCommand < Window_Command
- attr_accessor :commands
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- super(128, [], 1, 4)
- self.active = false
- end
- #--------------------------------------------------------------------------
- # * Setup
- # actor : actor
- #--------------------------------------------------------------------------
- def setup(actor)
- s1 = Vocab::attack
- s2 = Vocab::skill
- s3 = Vocab::guard
- s4 = Vocab::item
- if actor.class.skill_name_valid # Skill command name is valid?
- s2 = actor.class.skill_name # Replace command name
- end
- @commands = [s1, s2, s3, s4]
- @commands.push(Lums::LUM_PLURAL) if actor.lums.size > 0
- @item_max = @commands.size
- create_contents
- refresh
- self.index = 0
- end
- end
- #==============================================================================
- # ** Window_Lums
- #------------------------------------------------------------------------------
- # Muestra las habilidades de los lums
- #==============================================================================
- class Window_Lums < Window_Selectable
- #--------------------------------------------------------------------------
- # * Object Initialization
- # x : window x-coordinate
- # y : window y-coordinate
- # width : window width
- # height : window height
- # actor : actor
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height, actor)
- super(x, y, width, height)
- @actor = actor
- @column_max = 2
- self.index = 0
- refresh
- end
- #--------------------------------------------------------------------------
- # * Get Skill
- #--------------------------------------------------------------------------
- def skill
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- @data = []
- skills = []
- for lum in @actor.lums
- skills.push($data_skills[lum.skill])
- end
- for skill in skills
- @data.push(skill)
- if skill.id == @actor.last_skill_id
- self.index = @data.size - 1
- end
- end
- @item_max = @data.size
- create_contents
- for i in 0...@item_max
- draw_item(i)
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- # index : item number
- #--------------------------------------------------------------------------
- def draw_item(index)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- skill = @data[index]
- if skill != nil
- rect.width -= 4
- enabled = @actor.lum_can_use?(skill)
- draw_item_name(skill, rect.x, rect.y, enabled)
- self.contents.draw_text(rect, @actor.calc_mp_cost(skill), 2)
- end
- end
- #--------------------------------------------------------------------------
- # * Update Help Text
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(skill == nil ? "" : skill.description)
- end
- end
- #==============================================================================
- # ** Window_ActorLum
- #------------------------------------------------------------------------------
- # Controla a los actores
- #==============================================================================
- class Window_ActorLum < Window_Selectable
- def initialize
- super(0,56+WLH,544,WLH+32)
- self.back_opacity = 0
- self.opacity = 0
- self.index = 0
- self.active = true
- @column_max = 4
- @item_max = $game_party.members.size
- refresh
- end
- def refresh
- contents.font.size = 16
- for i in 0...@item_max
- rect = item_rect(i)
- actor = $game_party.members[i]
- draw_actor_graphic(actor,rect.x+16,rect.y+32)
- contents.draw_text(rect.x+32,rect.y,rect.width-32,rect.height,actor.name,1)
- end
- end
- end
- #==============================================================================
- # ** Window_LumControl
- #------------------------------------------------------------------------------
- # Controla a los lums
- #==============================================================================
- class Window_LumControl < Window_Selectable
- def initialize(actor)
- super(actor.index * (544 / 4),56*2,(544 / 4),416-(WLH*2+64))
- self.back_opacity = 0
- self.opacity = 0
- self.active = false
- self.index = 0
- @column_max = 1
- @actor = actor
- @item_max = $game_party.max_lums
- refresh
- end
- def refresh
- @item_max = $game_party.max_lums
- contents.font.size = 16
- self.contents.clear
- for i in 0...@actor.lums.size
- lum = @actor.lums[i]
- next if !lum
- x = 0
- y = i * WLH
- draw_icon(Lums::ELEMENT_ICON[lum.element],x,y)
- contents.draw_text(x+32,y,contents.width-32,WLH,lum.name,1)
- end
- end
- end
- #==============================================================================
- # ** Window_LumExchange
- #------------------------------------------------------------------------------
- # Muestra que Lums se intercambian
- #==============================================================================
- class Window_LumExchange < Window_Base
- def initialize(actor1,actor2,old_lum,new_lum)
- super(0,56,544,416-56)
- @actor1 = actor1
- @actor2 = actor2
- @actor1_lum = old_lum
- @actor2_lum = new_lum
- refresh
- end
- def refresh
- self.contents.clear
- x = 0
- y = 0
- draw_actor_changes(@actor1,@actor1_lum,@actor2_lum,x,y+32)
- x += contents.width / 2
- draw_actor_changes(@actor2,@actor2_lum,@actor1_lum,x,y+32)
- end
- def draw_actor_changes(actor,lum_less,lum_more,x,y)
- if lum_less == nil
- lum_less = Lum.new(-1,"",0,0,0,0,0)
- end
- if lum_more == nil
- lum_more = Lum.new(-1,"",0,0,0,0,0)
- end
- self.contents.font.color = normal_color
- draw_actor_face(actor,x,y)
- draw_actor_name(actor,x+96,y+32*2)
- self.contents.font.color = system_color
- self.contents.draw_text(x, y+96+WLH ,96,WLH,Vocab.atk)
- self.contents.draw_text(x, y+96+WLH*2 ,96,WLH,Vocab.def)
- self.contents.draw_text(x, y+96+WLH*3 ,96,WLH,Vocab.spi)
- self.contents.draw_text(x, y+96+WLH*4 ,96,WLH,Vocab.agi)
- self.contents.font.color = normal_color
- x += 96
- self.contents.draw_text(x, y+96+WLH, 96,WLH,actor.atk)
- self.contents.draw_text(x, y+96+WLH*2, 96,WLH,actor.def)
- self.contents.draw_text(x, y+96+WLH*3, 96,WLH,actor.spi)
- self.contents.draw_text(x, y+96+WLH*4, 96,WLH,actor.agi)
- self.contents.font.color = system_color
- x += 64
- self.contents.draw_text(x,y+96+WLH, 96,WLH,"->")
- self.contents.draw_text(x,y+96+WLH*2, 96,WLH,"->")
- self.contents.draw_text(x,y+96+WLH*3, 96,WLH,"->")
- self.contents.draw_text(x,y+96+WLH*4, 96,WLH,"->")
- self.contents.font.color = normal_color
- x += 32
- new_atk = actor.atk+lum_more.atk-lum_less.atk
- new_def = actor.def+lum_more.def-lum_less.def
- new_spi = actor.spi+lum_more.spi-lum_less.spi
- new_agi = actor.agi+lum_more.agi-lum_less.agi
- renew_colour(actor.atk,new_atk)
- self.contents.draw_text(x,y+96+WLH, 96,WLH,new_atk)
- renew_colour(actor.def,new_def)
- self.contents.draw_text(x,y+96+WLH*2, 96,WLH,new_def)
- renew_colour(actor.spi,new_spi)
- self.contents.draw_text(x,y+96+WLH*3, 96,WLH,new_spi)
- renew_colour(actor.agi,new_agi)
- self.contents.draw_text(x,y+96+WLH*4, 96,WLH,new_agi)
- self.contents.font.color = normal_color
- end
- def renew_colour(old,new)
- if (old > new)
- contents.font.color = knockout_color
- elsif (old < new)
- contents.font.color = crisis_color
- else
- contents.font.color = normal_color
- end
- end
- end
- #==============================================================================
- # ** Scene_Lums
- #------------------------------------------------------------------------------
- # Controla a los lums
- #==============================================================================
- class Scene_Lums < Scene_Base
- include Lums
- def start
- @help_window = Window_Help.new
- @dummy_window = Window_Base.new(0,56,544,416-56)
- @lum_windows = []
- for actor in $game_party.members
- @lum_windows.push(Window_LumControl.new(actor))
- end
- @actor_window = Window_ActorLum.new
- @actor_window.update
- @changing = false
- end
- def update
- @actor_window.update
- for i in 0...@lum_windows.size
- @lum_windows[i].active = (@actor_window.index == i)
- @lum_windows[i].update
- end
- if @changing
- update_change
- else
- update_selection
- end
- end
- def update_change
- @help_window.set_text(HELP_CHANGE2,1)
- if Input.trigger?(Input::C)
- return Sound.play_buzzer if @actor == $game_party.members[@actor_window.index]
- @new_actor = $game_party.members[@actor_window.index]
- @new_lum = @new_actor.lums[@lum_windows[@actor_window.index].index]
- @exchange_window = Window_LumExchange.new(@actor,@new_actor,@selected_lum,@new_lum)
- while @changing
- Graphics.update
- Input.update
- confirm_exchange
- end
- @exchange_window.dispose
- elsif Input.trigger?(Input::B)
- Sound.play_cancel
- @changing = false
- end
- end
- def confirm_exchange
- @help_window.set_text(HELP_CHANGE3,1)
- if Input.trigger?(Input::C)
- Sound.play_decision
- @actor.lums.push(@new_lum)
- @new_actor.lums.push(@selected_lum)
- @new_actor.lums.delete(@new_lum)
- @actor.lums.delete(@selected_lum)
- @new_actor.lums.compact!
- @actor.lums.compact!
- @changing = false
- for w in @lum_windows
- w.refresh
- end
- @actor = nil
- @stored_index = nil
- @selected_lum = nil
- @new_actor = nil
- @new_lum = nil
- elsif Input.trigger?(Input::B)
- Sound.play_cancel
- @changing = false
- end
- end
- def update_selection
- @help_window.set_text(HELP_CHANGE,1)
- if Input.trigger?(Input::C)
- @changing = true
- @actor = $game_party.members[@actor_window.index]
- @stored_index = @actor_window.index
- @selected_lum = @actor.lums[@lum_windows[@actor_window.index].index]
- elsif Input.trigger?(Input::B)
- Sound.play_cancel
- $scene = Scene_Map.new
- end
- end
- def terminate
- @dummy_window.dispose
- for w in @lum_windows
- w.dispose
- end
- @help_window.dispose
- @actor_window.dispose
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment