Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # =============================================================================
- # Theolized Sideview Battle System (TSBS)
- # Version : 0.9
- # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
- # (This script documentation is written in informal indonesian language)
- # -----------------------------------------------------------------------------
- # Requires : Theo - Basic Modules v1.4
- # >> Basic Functions
- # >> Movement
- # >> Core Fade
- # >> Clone Image
- # >> Rotate Image
- # =============================================================================
- # Script info :
- # -----------------------------------------------------------------------------
- # Known Compatibility :
- # >> YEA - Core Engine
- # >> YEA - Battle Engine (RECOMMENDED!)
- # -----------------------------------------------------------------------------
- # Known Incompatibility :
- # >> YEA - Lunatic Object
- # >> Maybe, most of battle related scripts (ATB, or such...)
- # -----------------------------------------------------------------------------
- # This section is mainly aimed for scripters. There's nothing to do unless
- # you know what you're doing.
- # =============================================================================
- module TSBS
- # --------------------------------------------------------------------------
- # Constantas
- # --------------------------------------------------------------------------
- BusyPhases = [:intro, :skill, :prepare, :evade]
- # Phase that considered as busy and wait for finish
- Temporary_Phase = [:hurt, :evade, :return, :intro]
- # Phase that will be replaced by :idle when finished
- EmptyTone = Tone.new(0,0,0,0)
- # Tone that replace the battler tone if battler has no state tone
- EmptyColor = Color.new(0,0,0,0)
- # Color that replace the battler color blend if battler has no state color
- EmptyBitmap = Bitmap.new(24,24)
- # Bitmap that filled the sprite for show icon
- # -------------------------------------------------------------------------
- # Sequence Constants. Want to simplify the mode symbols? edit this section
- # -------------------------------------------------------------------------
- SEQUENCE_POSE = :pose
- SEQUENCE_MOVE = :move
- SEQUENCE_SLIDE = :slide
- SEQUENCE_RESET = :goto_oripost
- SEQUENCE_MOVE_TO_TARGET = :move_to_target
- SEQUENCE_SCRIPT = :script
- SEQUENCE_WAIT = :wait
- SEQUENCE_DAMAGE = :target_damage
- SEQUENCE_SHOW_ANIMATION = :show_anim
- SEQUENCE_CAST = :cast
- SEQUENCE_VISIBLE = :visible
- SEQUENCE_AFTERIMAGE = :afterimage
- SEQUENCE_FLIP = :flip
- SEQUENCE_ACTION = :action
- SEQUENCE_PROJECTILE = :projectile
- SEQUENCE_PROJECTILE_SETUP = :proj_setup
- SEQUENCE_USER_DAMAGE = :user_damage
- SEQUENCE_LOCK_Z = :lock_z
- SEQUENCE_ICON = :icon
- SEQUENCE_SOUND = :sound
- SEQUENCE_IF = :if
- SEQUENCE_ELSE = :else
- SEQUENCE_END = :end
- SEQUENCE_TIMED_HIT = :timed_hit
- SEQUENCE_SCREEN = :screen
- SEQUENCE_ADD_STATE = :add_state
- SEQUENCE_REM_STATE = :rem_state
- SEQUENCE_CHANGE_TARGET = :change_target
- SEQUENCE_SHOW_PICTURE = :show_pic
- SEQUENCE_TARGET_MOVE = :target_move
- SEQUENCE_TARGET_SLIDE = :target_slide
- SEQUENCE_TARGET_RESET = :target_reset
- SEQUENCE_BLEND = :blend
- SEQUENCE_FOCUS = :focus
- SEQUENCE_UNFOCUS = :unfocus
- # Screen sub-modes
- Screen_Tone = :tone
- Screen_Shake = :shake
- Screen_Flash = :flash
- Screen_Normalize = :normalize
- # Projectile setup
- ProjSetup_Feet = :feet
- ProjSetup_Middle = :middle
- ProjSetup_Head = :head
- # -------------------------------------------------------------------------
- # Regular Expression (REGEXP) Constants. Want to simplify notetags? edit
- # this section. If only you understand the ruby regular expression
- # -------------------------------------------------------------------------
- AnimGuard = /<anim[_\s]+guard\s*:\s*(\d+)>/i
- # Notetag for animation guard
- SkillGuard = /<skill[_\s]+guard\s*:\s*(\d+)>/i
- # Notetag for skill guard
- IgnoreSkillGuard = /<ignore[-\s]skill[-\s]guard>/i
- # Notetag for skill that ignore state skill guard
- IgnoreAnimGuard = /<ignore[-\s]anim[-\s]guard>/i
- # Notetag for skill that ignore state skill guard
- StateOpacity = /<opacity\s*:\s*(\d+)>/i
- # Notetag for state Opacity
- SequenceREGX = /\\sequence\s*:\s*(.+)/i
- # Action sequence notetag in skill
- PrepareREGX = /\\preparation\s*:\s*(.+)/i
- # Preparation move for skill
- ReflectAnim = /<reflect(?:_*|\s*)anim\s*:\s*(\d+)>/i
- # Reflect animation for skill
- AreaTAG = /<area>/i
- # Tag for area skill
- NoReturnTAG = /<no return>/i
- # Tag for no return sequence for skill
- AbsoluteTarget = /<abs[-_\s]+target>/i
- # Tag for absolute targeting
- ToneREGX =
- /<tone:\s*(-|\+*)(\d+),\s*(-|\+*)(\d+),\s*(-|\+*)(\d+),\s*(-|\+*)(\d+)>/i
- # Regular expression for state tone tag
- ColorREGX =
- /<color:\s*(-|\+*)(\d+),\s*(-|\+*)(\d+),\s*(-|\+*)(\d+),\s*(-|\+*)(\d+)>/i
- # Regular expression for state color blend
- SBS_Start = /<sideview>/i # Starting Sideview Tag
- SBS_Start_S = /<sideview\s*:\s*(.+)>/i # Starting with string
- SBS_End = /<\/sideview>/i # End of sideview tag
- # ---------------------------------------------
- # Sideview tags
- # ---------------------------------------------
- SBS_Idle = /\s*idle\s*:\s*(.+)/i
- SBS_Critical = /\s*critical\s*:\s*(.+)/i
- SBS_Evade = /\s*evade\s*:\s*(.+)/i
- SBS_Hurt = /\s*hurt\s*:\s*(.+)/i
- SBS_Return = /\s*return\s*:\s*(.+)/i
- SBS_Dead = /\s*dead\s*:\s*(.+)/i
- SBS_Escape = /\s*escape\s*:\s*(.+)/i
- SBS_Win = /\s*victory\s*:\s*(.+)/i
- SBS_Intro = /\s*intro\s*:\s*(.+)/i
- # -------------------------------------------------------------------------
- # Error Handler
- # -------------------------------------------------------------------------
- def self.error(symbol, params)
- text = %Q{ #{symbol} mode need at least #{params} parameters }
- msgbox text
- exit
- end
- end
- # ----------------------------------------------------------------------------
- # Kernel method to get scene spriteset
- # ----------------------------------------------------------------------------
- def get_spriteset
- SceneManager.scene.instance_variable_get("@spriteset")
- end
- # ----------------------------------------------------------------------------
- # Kernel method for chance
- # ----------------------------------------------------------------------------
- def chance(percent)
- return rand(100) <= percent
- end
- # ----------------------------------------------------------------------------
- # Copy method
- # ----------------------------------------------------------------------------
- def copy(object)
- Marshal.load(Marshal.dump(object))
- end
- #==============================================================================
- # ** DataManager
- #------------------------------------------------------------------------------
- # This module manages the database and game objects. Almost all of the
- # global variables used by the game are initialized by this module.
- #==============================================================================
- class << DataManager
- # --------------------------------------------------------------------------
- # Alias method : load database
- # --------------------------------------------------------------------------
- alias theo_tsbs_load_db load_database
- def load_database
- theo_tsbs_load_db
- load_tsbs
- end
- # --------------------------------------------------------------------------
- # New Method : Load TSBS caches
- # --------------------------------------------------------------------------
- def load_tsbs
- ($data_skills + $data_items + $data_states +
- $data_actors + $data_enemies).compact.each do |item|
- item.load_tsbs
- end
- end
- end
- #==============================================================================
- # ** BattleManager
- #------------------------------------------------------------------------------
- # This module manages battle progress.
- #==============================================================================
- class << BattleManager
- # --------------------------------------------------------------------------
- # Alias method : Battle Start
- # --------------------------------------------------------------------------
- alias tsbs_battle_start battle_start
- def battle_start
- tsbs_battle_start
- if $imported["YEA-BattleEngine"] && !YEA::BATTLE::MSG_ENEMY_APPEARS
- swindow = SceneManager.scene.instance_variable_get("@status_window")
- swindow.open if swindow
- # Open status window if encounter message is disabled
- end
- SceneManager.scene.wait_for_sequence
- # wait for intro sequence
- end
- # --------------------------------------------------------------------------
- # Alias method : process victory
- # --------------------------------------------------------------------------
- alias tsbs_process_victory process_victory
- def process_victory
- $game_party.alive_members.each do |member|
- member.battle_phase = :victory
- end
- tsbs_process_victory
- end
- # ---------------------------------------------------------------------------
- # Overwrite method : process escape
- # ---------------------------------------------------------------------------
- def process_escape
- $game_message.add(sprintf(Vocab::EscapeStart, $game_party.name))
- success = @preemptive ? true : (rand < @escape_ratio)
- Sound.play_escape
- if success
- process_abort
- $game_party.alive_members.each do |member|
- member.battle_phase = :escape
- end
- else
- @escape_ratio += 0.1
- $game_message.add('\.' + Vocab::EscapeFailure)
- $game_party.clear_actions
- end
- wait_for_message
- return success
- end
- end
- #==============================================================================
- # ** RPG::State
- #------------------------------------------------------------------------------
- # This class handles database for states
- #==============================================================================
- class RPG::State < RPG::BaseItem
- attr_accessor :tone # State Tone
- attr_accessor :color # State Color
- attr_accessor :anim_guard # Animation Guard
- attr_accessor :skill_guard # Skill Guard
- attr_accessor :max_opac # Max Opacity
- attr_accessor :sequence # State sequence
- # --------------------------------------------------------------------------
- # New method : load TSBS notetags
- # --------------------------------------------------------------------------
- def load_tsbs
- @anim_guard = 0
- @skill_guard = 0
- @max_opac = 255
- @sequence = ""
- note.split(/[\r\n]+/).each do |line|
- case line
- when TSBS::ToneREGX
- @tone = Tone.new
- @tone.red = $2.to_i * ($1.to_s == "-" ? -1 : 1)
- @tone.green = $4.to_i * ($3.to_s == "-" ? -1 : 1)
- @tone.blue = $6.to_i * ($5.to_s == "-" ? -1 : 1)
- @tone.gray = $8.to_i * ($7.to_s == "-" ? -1 : 1)
- when TSBS::ColorREGX
- @color = Color.new
- @color.red = $2.to_i * ($1.to_s == "-" ? -1 : 1)
- @color.green = $4.to_i * ($3.to_s == "-" ? -1 : 1)
- @color.blue = $6.to_i * ($5.to_s == "-" ? -1 : 1)
- @color.alpha = $8.to_i * ($7.to_s == "-" ? -1 : 1)
- when TSBS::AnimGuard
- @anim_guard = $1.to_i
- when TSBS::SkillGuard
- @skill_guard = $1.to_i
- when TSBS::StateOpacity
- @max_opac = $1.to_i
- when TSBS::SequenceREGX
- @sequence = $1.to_s
- end
- end
- end
- end
- #==============================================================================
- # ** RPG::UsableItem
- #------------------------------------------------------------------------------
- # This class handles database for skills and items
- #==============================================================================
- class RPG::UsableItem < RPG::BaseItem
- attr_accessor :seq_key # Sequence keys
- attr_accessor :prepare_key # Preparation keys
- attr_accessor :reflect_anim # Reflect animations
- # --------------------------------------------------------------------------
- # New method : load TSBS notetags
- # --------------------------------------------------------------------------
- def load_tsbs
- @seq_key = TSBS::Default_SkillSequence
- @seq_key = TSBS::Default_ItemSequence if is_a?(RPG::Item)
- @prepare_key = ""
- @reflect_anim = TSBS::Default_Reflect
- first_time = true
- note.split(/[\r\n]+/).each do |line|
- case line
- when TSBS::SequenceREGX
- if first_time
- @seq_key = [$1.to_s]
- first_time = false
- else
- @seq_key.push($1.to_s)
- end
- when TSBS::PrepareREGX
- @prepare_key = $1.to_s
- when TSBS::ReflectAnim
- @reflect_anim = $1.to_i
- end
- end
- end
- # --------------------------------------------------------------------------
- # New method : Determine if item / skill is area attack
- # --------------------------------------------------------------------------
- def area?
- !note[TSBS::AreaTAG].nil?
- end
- # --------------------------------------------------------------------------
- # New method : Determine if item / skill doesn't require subject to return
- # --------------------------------------------------------------------------
- def no_return?
- !note[TSBS::NoReturnTAG].nil?
- end
- # --------------------------------------------------------------------------
- # New method : Determine if item / skill has absolute target
- # --------------------------------------------------------------------------
- def abs_target?
- !note[TSBS::AbsoluteTarget].nil? && for_random?
- end
- # --------------------------------------------------------------------------
- # New method : Determine if skill is ignoring skill guard effect
- # --------------------------------------------------------------------------
- def ignore_skill_guard?
- !note[TSBS::IgnoreSkillGuard].nil?
- end
- # --------------------------------------------------------------------------
- # New method : Determine if skill is ignoring anim guard effect
- # --------------------------------------------------------------------------
- def ignore_anim_guard?
- !note[TSBS::IgnoreAnimGuard].nil?
- end
- end
- #==============================================================================
- # ** RPG::Actor
- #------------------------------------------------------------------------------
- # This class handles actors database
- #==============================================================================
- class RPG::Actor < RPG::BaseItem
- attr_accessor :idle_key
- attr_accessor :critical_key
- attr_accessor :evade_key
- attr_accessor :hurt_key
- attr_accessor :return_key
- attr_accessor :dead_key
- attr_accessor :escape_key
- attr_accessor :victory_key
- attr_accessor :intro_key
- attr_accessor :use_sprite
- # --------------------------------------------------------------------------
- # New method : load TSBS notetags
- # --------------------------------------------------------------------------
- def load_tsbs
- @idle_key = TSBS::Default_Idle
- @critical_key = TSBS::Default_Critical
- @evade_key = TSBS::Default_Evade
- @hurt_key = TSBS::Default_Hurt
- @return_key = TSBS::Default_Return
- @dead_key = TSBS::Default_Dead
- @escape_key = TSBS::Default_Escape
- @victory_key = TSBS::Default_Victory
- @intro_key = TSBS::Default_Intro
- @use_sprite = true
- load_sbs = false
- note.split(/[\r\n]+/).each do |line|
- if line =~ TSBS::SBS_Start
- load_sbs = true
- elsif line =~ TSBS::SBS_End
- load_sbs = false
- end
- next unless load_sbs
- case line
- when TSBS::SBS_Idle
- @idle_key = $1.to_s
- when TSBS::SBS_Critical
- @critical_key = $1.to_s
- when TSBS::SBS_Evade
- @evade_key = $1.to_s
- when TSBS::SBS_Hurt
- @hurt_key = $1.to_s
- when TSBS::SBS_Return
- @return_key = $1.to_s
- when TSBS::SBS_Dead
- @dead_key = $1.to_s
- when TSBS::SBS_Escape
- @escape_key = $1.to_s
- when TSBS::SBS_Win
- @victory_key = $1.to_s
- when TSBS::SBS_Intro
- @intro_key = $1.to_s
- end
- end
- end
- end
- #==============================================================================
- # ** RPG::Enemy
- #------------------------------------------------------------------------------
- # This class handles enemies database
- #==============================================================================
- class RPG::Enemy < RPG::BaseItem
- attr_accessor :idle_key
- attr_accessor :critical_key
- attr_accessor :evade_key
- attr_accessor :hurt_key
- attr_accessor :return_key
- attr_accessor :dead_key
- attr_accessor :use_sprite
- attr_accessor :intro_key
- attr_accessor :sprite_name
- # --------------------------------------------------------------------------
- # New method : load TSBS notetags
- # --------------------------------------------------------------------------
- def load_tsbs
- @idle_key = TSBS::Default_Idle
- @critical_key = TSBS::Default_Critical
- @evade_key = TSBS::Default_Evade
- @hurt_key = TSBS::Default_Hurt
- @return_key = TSBS::Default_Return
- @dead_key = TSBS::Default_Dead
- @intro_key = TSBS::Default_Intro
- @sprite_name = ""
- @use_sprite = false
- load_sbs = false
- note.split(/[\r\n]+/).each do |line|
- if line =~ TSBS::SBS_Start_S
- load_sbs = true
- @use_sprite = true
- @sprite_name = $1.to_s
- elsif line =~ TSBS::SBS_Start
- load_sbs = true
- elsif line =~ TSBS::SBS_End
- load_sbs = false
- end
- next unless load_sbs
- case line
- when TSBS::SBS_Idle
- @idle_key = $1.to_s
- when TSBS::SBS_Critical
- @critical_key = $1.to_s
- when TSBS::SBS_Evade
- @evade_key = $1.to_s
- when TSBS::SBS_Hurt
- @hurt_key = $1.to_s
- when TSBS::SBS_Return
- @return_key = $1.to_s
- when TSBS::SBS_Dead
- @dead_key = $1.to_s
- when TSBS::SBS_Intro
- @intro_key = $1.to_s
- end
- end
- end
- end
- #==============================================================================
- # ** Game_Temp
- #------------------------------------------------------------------------------
- # This class handles temporary data that is not included with save data.
- # The instance of this class is referenced by $game_temp.
- #==============================================================================
- class Game_Temp
- attr_accessor :invoke_method # Store item apply method call
- attr_accessor :actors_fiber # Store actor Fibers thread
- attr_accessor :enemies_fiber # Store enemy Fibers thread
- attr_accessor :battler_targets # Store Current targets
- # --------------------------------------------------------------------------
- # Alias method : Initialize
- # --------------------------------------------------------------------------
- alias tsbs_init initialize
- def initialize
- tsbs_init
- clear_tsbs
- end
- # --------------------------------------------------------------------------
- # New method : clear TSBS infos
- # --------------------------------------------------------------------------
- def clear_tsbs
- @invoke_method = nil
- @actors_fiber = {}
- @enemies_fiber = {}
- @battler_targets = []
- end
- end
- #==============================================================================
- # ** Game_Action
- #------------------------------------------------------------------------------
- # This class handles battle actions. This class is used within the
- # Game_Battler class.
- #==============================================================================
- class Game_Action
- # --------------------------------------------------------------------------
- # Alias method : targets for opponents
- # --------------------------------------------------------------------------
- alias tsbs_trg_for_opp targets_for_opponents
- def targets_for_opponents
- return abs_target if item.abs_target?
- return tsbs_trg_for_opp
- end
- # --------------------------------------------------------------------------
- # New method : Absolute target
- # --------------------------------------------------------------------------
- def abs_target
- opponents_unit.abs_target(item.number_of_targets)
- end
- end
- #==============================================================================
- # ** Game_Unit
- #------------------------------------------------------------------------------
- # This class handles units. It's used as a superclass of the Game_Party and
- # and Game_Troop classes.
- #==============================================================================
- class Game_Unit
- # --------------------------------------------------------------------------
- # New method : Make absolute target candidate
- # --------------------------------------------------------------------------
- def abs_target(number)
- candidate = alive_members.shuffle
- ary = []
- [number,candidate.size].min.times do
- ary.push(candidate.shift) if !candidate[0].nil?
- end
- return ary
- end
- end
- #==============================================================================
- # ** Game_Battler
- #------------------------------------------------------------------------------
- # A battler class with methods for sprites and actions added. This class
- # is used as a super class of the Game_Actor class and Game_Enemy class.
- #==============================================================================
- class Game_Battler < Game_BattlerBase
- # --------------------------------------------------------------------------
- # Basic modules
- # --------------------------------------------------------------------------
- include THEO::Movement # Import basic module for battler movements
- include TSBS # Import constantas
- # --------------------------------------------------------------------------
- # New public attributes
- # --------------------------------------------------------------------------
- attr_accessor :animation_array # Store animation sequence
- attr_accessor :battler_index # Store battler filename index
- attr_accessor :anim_index # Pointer for animation array
- attr_accessor :anim_cell # Battler image index
- attr_accessor :item_in_use # Currently used item
- attr_accessor :visible # Visible flag
- attr_accessor :flip # Mirror flag
- attr_accessor :area_flag # Area damage flag
- attr_accessor :afterimage # Afterimage flag
- attr_accessor :refresh_opacity # Refresh opacity flag
- attr_accessor :icon_key # Store icon key
- # --------------------------------------------------------------------------
- # New public attributes (access only)
- # --------------------------------------------------------------------------
- attr_reader :target # Current target
- attr_reader :target_array # Overall target
- attr_reader :battle_phase # Battle Phase
- attr_reader :finish # Sequence finish flag
- attr_reader :blend # Blend
- # --------------------------------------------------------------------------
- # Alias method : initialize
- # --------------------------------------------------------------------------
- alias theo_tsbs_batt_init initialize
- def initialize(*args)
- theo_tsbs_batt_init(*args)
- set_obj(self)
- clear_tsbs
- end
- # --------------------------------------------------------------------------
- # New method : default flip
- # --------------------------------------------------------------------------
- def default_flip
- return false
- end
- # --------------------------------------------------------------------------
- # New method : Store targets in array
- # --------------------------------------------------------------------------
- def target_array=(targets)
- @target_array = targets
- @ori_targets = targets.clone
- end
- # --------------------------------------------------------------------------
- # New method : Store current target
- # --------------------------------------------------------------------------
- def target=(target)
- @target = target
- @ori_target = target
- end
- # --------------------------------------------------------------------------
- # New method : Reset to original position
- # --------------------------------------------------------------------------
- def reset_pos(dur = 30, jump = 0)
- goto(@ori_x, @ori_y, dur, jump)
- end
- # --------------------------------------------------------------------------
- # New method : Clear TSBS infos
- # --------------------------------------------------------------------------
- def clear_tsbs
- @animation_array = []
- @finish = false
- @anim_index = 0
- @anim_cell = 0
- @battler_index = 1
- @battle_phase = nil
- @target = nil
- @ori_target = nil
- @target_array = []
- @ori_targets = []
- @item_in_use = nil
- @visible = true
- @flip = default_flip
- @area_flag = false
- @afterimage = false
- @proj_start = :middle
- @proj_end = :middle
- @proj_icon = 0
- @refresh_opacity = false
- @screen_z = 0
- @lock_z = false
- @icon_key = ""
- @timed_hit = false
- @timed_hit_count = 0
- @skip_else = false
- @ary = []
- @blend = 0
- @used_sequence = ""
- end
- # --------------------------------------------------------------------------
- # New method : Battler update
- # --------------------------------------------------------------------------
- def update
- update_move # Update movements (Basic Module)
- if fiber_obj
- fiber_obj.resume # Update Fiber thread
- end
- end
- # --------------------------------------------------------------------------
- # New method : Fiber object
- # --------------------------------------------------------------------------
- def fiber_obj
- return nil
- end
- # --------------------------------------------------------------------------
- # New method : Set battle phase
- # --------------------------------------------------------------------------
- def battle_phase=(phase)
- @battle_phase = phase
- @used_sequence = phase_sequence[phase].call
- @anim_index = 0
- @anim_index = rand(get_animloop_array.size - 1) if phase == :idle
- @finish = false
- @animation_array = get_animloop_array.dup
- fiber = Fiber.new { update_anim_index }
- insert_fiber(fiber)
- end
- # --------------------------------------------------------------------------
- # Alias method : On battle start
- # --------------------------------------------------------------------------
- alias theo_on_bs_start on_battle_start
- def on_battle_start
- theo_on_bs_start
- @screen_z = screen_z_formula
- unless intro_key.empty?
- self.battle_phase = :intro
- update
- else
- self.battle_phase = :idle
- end
- end
- # --------------------------------------------------------------------------
- # New method : Store fiber in $game_temp
- # --------------------------------------------------------------------------
- def insert_fiber(fiber)
- if actor?
- $game_temp.actors_fiber[index] = fiber
- else
- $game_temp.enemies_fiber[index] = fiber
- end
- end
- # --------------------------------------------------------------------------
- # New method : Refers to battler database
- # --------------------------------------------------------------------------
- def data_battler
- return nil
- end
- # --------------------------------------------------------------------------
- # New method : Determine if battler is in critical condition
- # --------------------------------------------------------------------------
- def critical?
- hp_rate <= Critical_Rate
- end
- # --------------------------------------------------------------------------
- # New method : Phase sequence key
- # --------------------------------------------------------------------------
- def phase_sequence
- hash = {
- :idle => method(:idle),
- :victory => method(:victory),
- :hurt => method(:hurt),
- :skill => method(:skill),
- :evade => method(:evade),
- :return => method(:return),
- :escape => method(:escape_key),
- :prepare => method(:prepare_key),
- :intro => method(:intro_key),
- }
- return hash
- end
- # --------------------------------------------------------------------------
- # New method : Idle sequence key
- # --------------------------------------------------------------------------
- def idle
- return data_battler.dead_key if dead? && actor?
- return data_battler.critical_key if critical? &&
- !data_battler.critical_key.empty?
- return state_sequence if state_sequence
- return data_battler.idle_key
- end
- # --------------------------------------------------------------------------
- # New method : Escape sequence key
- # --------------------------------------------------------------------------
- def escape_key
- return data_battler.escape_key
- end
- # --------------------------------------------------------------------------
- # New method : Victory sequence key
- # --------------------------------------------------------------------------
- def victory
- return data_battler.victory_key
- end
- # --------------------------------------------------------------------------
- # New method : Hurt sequence key
- # --------------------------------------------------------------------------
- def hurt
- return data_battler.hurt_key
- end
- # --------------------------------------------------------------------------
- # New method : Skill sequence key
- # --------------------------------------------------------------------------
- def skill
- return item_in_use.seq_key[rand(item_in_use.seq_key.size)]
- end
- # --------------------------------------------------------------------------
- # New method : Evade sequence key
- # --------------------------------------------------------------------------
- def evade
- return data_battler.evade_key
- end
- # --------------------------------------------------------------------------
- # New method : Return sequence key
- # --------------------------------------------------------------------------
- def return
- return data_battler.return_key
- end
- # --------------------------------------------------------------------------
- # New method : Preparation key
- # --------------------------------------------------------------------------
- def prepare_key
- return item_in_use.prepare_key
- end
- # --------------------------------------------------------------------------
- # New method : Intro sequence key
- # --------------------------------------------------------------------------
- def intro_key
- return data_battler.intro_key
- end
- # --------------------------------------------------------------------------
- # Debug only : print current action sequence
- # --------------------------------------------------------------------------
- def print_current_action
- p phase_sequence[battle_phase].call
- end
- # --------------------------------------------------------------------------
- # Main animation sequence goes here
- # --------------------------------------------------------------------------
- def update_anim_index
- # ----- Start ------ #
- @finish = false
- @flip = @animation_array[0][2] if !@animation_array[0][2].nil?
- @afterimage = @animation_array[0][1]
- @skip_else = false
- @timed_hit = false
- @timed_hit_count = 0
- # ----- end of start ---- #
- loop do
- @ary = animloop
- @screen_z = screen_z_formula unless @lock_z # update screen z
- case @ary[0]
- # ----------- Sequence goes here ---------------- #
- when SEQUENCE_POSE; setup_pose
- when SEQUENCE_MOVE; setup_move
- when SEQUENCE_SLIDE; setup_slide
- when SEQUENCE_RESET; setup_reset
- when SEQUENCE_MOVE_TO_TARGET; setup_move_to_target
- when SEQUENCE_SCRIPT; eval(@ary[1])
- when SEQUENCE_WAIT; @ary[1].times { method_wait }
- when SEQUENCE_DAMAGE; setup_damage
- when SEQUENCE_CAST; setup_cast
- when SEQUENCE_VISIBLE; @visible = @ary[1]
- when SEQUENCE_SHOW_ANIMATION; setup_anim
- when SEQUENCE_AFTERIMAGE; @afterimage = @ary[1]
- when SEQUENCE_FLIP; setup_flip
- when SEQUENCE_ACTION; setup_action
- when SEQUENCE_PROJECTILE_SETUP; setup_projectile
- when SEQUENCE_PROJECTILE; show_projectile
- when SEQUENCE_USER_DAMAGE; setup_user_damage
- when SEQUENCE_LOCK_Z; @lock_z = @ary[1]
- when SEQUENCE_ICON; setup_icon
- when SEQUENCE_SOUND; setup_sound
- when SEQUENCE_IF; setup_branch
- when SEQUENCE_ELSE; check_else
- when SEQUENCE_END; @skip_else = false
- when SEQUENCE_TIMED_HIT; setup_timed_hit
- when SEQUENCE_SCREEN; setup_screen
- when SEQUENCE_ADD_STATE; setup_add_state
- when SEQUENCE_REM_STATE; setup_rem_state
- when SEQUENCE_CHANGE_TARGET; setup_change_target
- when SEQUENCE_SHOW_PICTURE; setup_show_picture
- when SEQUENCE_TARGET_MOVE; setup_target_move
- when SEQUENCE_TARGET_SLIDE; setup_target_slide
- when SEQUENCE_TARGET_RESET; setup_target_reset
- when SEQUENCE_BLEND; @blend = @ary[1]
- when SEQUENCE_FOCUS; setup_focus
- when SEQUENCE_UNFOCUS; setup_unfocus
- else; custom_sequence_handler(@ary)
- end
- end_phase # Do end ~
- end
- end
- # --------------------------------------------------------------------------
- # New method : End fiber loop phase
- # --------------------------------------------------------------------------
- def end_phase
- next_anim_index
- @finish = @anim_index == 0
- if temporary_phase? && @finish
- self.battle_phase = :idle
- end
- Fiber.yield while @finish && !loop?
- end
- # --------------------------------------------------------------------------
- # New method : Setup pose
- # --------------------------------------------------------------------------
- def setup_pose
- return TSBS.error(@ary[0], 3) if @ary.size < 4
- @battler_index = @ary[1]
- @anim_cell = @ary[2]
- @icon_key = @ary[4] if @ary[4]
- @icon_key = @ary[5] if @ary[5] && flip
- @ary[3].times do
- method_wait
- end
- end
- # --------------------------------------------------------------------------
- # New method : Setup movement
- # --------------------------------------------------------------------------
- def setup_move
- return TSBS.error(@ary[0], 4) if @ary.size < 5
- goto(@ary[1], @ary[2], @ary[3], @ary[4])
- end
- # --------------------------------------------------------------------------
- # New method : Setup slide
- # --------------------------------------------------------------------------
- def setup_slide
- return TSBS.error(@ary[0], 4) if @ary.size < 4
- xpos = (flip ? -@ary[1] : @ary[1])
- ypos = @ary[2]
- slide(xpos, ypos, @ary[3], @ary[4])
- end
- # --------------------------------------------------------------------------
- # New method : Setup reset
- # --------------------------------------------------------------------------
- def setup_reset
- goto(@ori_x, @ori_y, @ary[1], @ary[2])
- end
- # --------------------------------------------------------------------------
- # New method : Setup move to target
- # --------------------------------------------------------------------------
- def setup_move_to_target
- if area_flag
- end_phase
- return
- end
- return TSBS.error(@ary[0], 4) if @ary.size < 5
- xpos = target.x + (flip ? -@ary[1] : @ary[1])
- ypos = target.y
- goto(xpos, ypos, @ary[3], @ary[4])
- end
- # --------------------------------------------------------------------------
- # New method : Setup damage
- # --------------------------------------------------------------------------
- def setup_damage
- item = copy(item_in_use)
- if @ary[1].is_a?(String)
- item.damage.formula = @ary[1]
- elsif @ary[1].is_a?(Integer)
- item = $data_skills[@ary[1]]
- elsif @ary[1].is_a?(Float)
- item.damage.formula = "(#{item.damage.formula}) * #{@ary[1]}"
- end
- if area_flag && target_array
- target_array.uniq.each do |target|
- $game_temp.invoke_method.call(target, item)
- end
- elsif target
- $game_temp.invoke_method.call(target, item)
- end
- end
- # --------------------------------------------------------------------------
- # New method : Setup cast
- # --------------------------------------------------------------------------
- def setup_cast
- return TSBS.error(@ary[0], 1) if @ary.size < 2
- self.animation_id = @ary[1]
- self.animation_mirror = flip || @ary[2]
- end
- # --------------------------------------------------------------------------
- # New method : Setup animation
- # --------------------------------------------------------------------------
- def setup_anim
- if area_flag
- target_array.uniq.each do |target|
- setup_target_anim(target, @ary)
- end
- else
- setup_target_anim(target, @ary)
- end
- end
- # --------------------------------------------------------------------------
- # New method : Setup target animation
- # --------------------------------------------------------------------------
- def setup_target_anim(target, ary)
- anim_id = target.anim_guard_id
- is_self = target == self
- condition = !is_self && anim_id && !item_in_use.damage.recover? &&
- !item_in_use.ignore_anim_guard? && !ary[3]
- if ary[1]
- result_anim = (condition && ary[1] > 0 ? anim_id : ary[1])
- target.animation_id = result_anim
- target.animation_mirror = flip || ary[2]
- elsif self.is_a?(Game_Actor) && item_in_use.animation_id == -1
- result_anim = (condition ? anim_id : atk_animation_id1)
- target.animation_id = result_anim
- target.animation_mirror = flip || ary[2]
- else
- result_anim = (condition ? anim_id : item_in_use.animation_id)
- target.animation_id = result_anim
- target.animation_mirror = flip || ary[2]
- end
- end
- # --------------------------------------------------------------------------
- # New method : Setup battler flip
- # --------------------------------------------------------------------------
- def setup_flip
- return TSBS.error(@ary[0], 1) if @ary.size < 2
- if @ary[1] == :toggle
- @flip = !@flip
- else
- @flip = @ary[1]
- end
- end
- # --------------------------------------------------------------------------
- # New method : Setup actions
- # --------------------------------------------------------------------------
- def setup_action
- return TSBS.error(@ary[0], 1) if @ary.size < 2
- actions = TSBS::AnimLoop[@ary[1]]
- if actions.nil?
- show_action_error(@ary[1])
- end
- index = @anim_index + 1
- actions.each do |act|
- next unless act[0].is_a?(Symbol)
- index += 1
- @animation_array.insert(index, act)
- end
- end
- # --------------------------------------------------------------------------
- # New method : Setup projectile
- # --------------------------------------------------------------------------
- def setup_projectile
- return TSBS.error(@ary[0], 2) if @ary.size < 3
- @proj_start = @ary[1]
- @proj_end = @ary[2]
- end
- # --------------------------------------------------------------------------
- # New method : Show projectile
- # --------------------------------------------------------------------------
- def show_projectile
- return TSBS.error(@ary[0], 3) if @ary.size < 4
- spr_self = get_spriteset.get_sprite(self)
- if area_flag
- target_array.uniq.each do |target|
- spr_target = get_spriteset.get_sprite(target)
- proj = Sprite_Projectile.new
- proj.x = self.x
- case @proj_start
- when :feet
- proj.y = self.y
- when :middle
- proj.y = self.y - spr_self.height/2
- when :head
- proj.y = self.y - spr_self.height
- end
- proj.subject = self
- proj.target = target
- proj.item = item_in_use
- proj.icon = @ary[4] || 0
- tx = target.x
- case @proj_end
- when :feet
- ty = target.y
- when :middle
- ty = target.y - spr_target.height/2
- when :head
- ty = target.y - spr_target.height
- end
- anim = $data_animations[@ary[1]]
- dur = @ary[2]
- jump = @ary[3]
- proj.angle_speed = @ary[5] || 0
- proj.goto(tx,ty,dur,jump)
- proj.start_animation(anim)
- get_spriteset.add_projectile(proj)
- end
- else
- spr_target = get_spriteset.get_sprite(target)
- proj = Sprite_Projectile.new
- proj.x = self.x
- case @proj_start
- when :feet
- proj.y = self.y
- when :middle
- proj.y = self.y - spr_self.height/2
- when :head
- proj.y = self.y - spr_self.height
- end
- proj.subject = self
- proj.target = target
- proj.item = item_in_use
- proj.icon = @ary[4] || 0
- tx = target.x
- case @proj_end
- when :feet
- ty = target.y
- when :middle
- ty = target.y - spr_target.height/2
- when :head
- ty = target.y - spr_target.height
- end
- anim = $data_animations[@ary[1]]
- dur = @ary[2]
- jump = @ary[3]
- proj.angle_speed = @ary[5] || 0
- proj.goto(tx,ty,dur,jump)
- proj.start_animation(anim)
- get_spriteset.add_projectile(proj)
- end
- end
- # --------------------------------------------------------------------------
- # New method : User damage
- # --------------------------------------------------------------------------
- def setup_user_damage
- item = item_in_use
- if @ary[1].is_a?(String)
- item.damage.formula = @ary[1]
- elsif @ary[1].is_a?(Integer)
- item = $data_skills[@ary[1]]
- elsif @ary[1].is_a?(Float)
- item.damage.formula = "(#{item.damage.formula}) * #{@ary[1]}"
- end
- invoke_item.call(self, item)
- end
- # --------------------------------------------------------------------------
- # New method : Setup weapon icon
- # --------------------------------------------------------------------------
- def setup_icon
- @icon_key = @ary[1]
- @icon_key = @ary[2] if @ary[2] && flip
- end
- # --------------------------------------------------------------------------
- # New method : Setup sound
- # --------------------------------------------------------------------------
- def setup_sound
- name = @ary[1]
- vol = @ary[2] || 100
- pitch = @ary[3] || 100
- RPG::SE.new(name,vol,pitch).play
- end
- # --------------------------------------------------------------------------
- # New method : Setup conditional branch
- # --------------------------------------------------------------------------
- def setup_branch
- unless eval(@ary[1])
- next_anim_index until next_is?(SEQUENCE_ELSE) ||
- next_is?(SEQUENCE_END)
- else
- @skip_else = true
- end
- end
- # --------------------------------------------------------------------------
- # New method : Setup timed hit system (BETA)
- # --------------------------------------------------------------------------
- def setup_timed_hit
- @timed_hit = false
- @timed_hit_count = @ary[1]
- end
- # --------------------------------------------------------------------------
- # New method : Check branch
- # --------------------------------------------------------------------------
- def check_else
- if @skip_else
- next_anim_index until next_is?(SEQUENCE_END)
- else
- @skip_else = false
- end
- end
- # --------------------------------------------------------------------------
- # New method : Setup screen
- # --------------------------------------------------------------------------
- def setup_screen
- screen = $game_troop.screen
- case @ary[1]
- when Screen_Tone
- tone = @ary[2]
- duration = @ary[3]
- screen.start_tone_change(tone, duration)
- when Screen_Shake
- power = @ary[2]
- speed = @ary[3]
- duration = @ary[4]
- screen.start_shake(power, speed, duration)
- when Screen_Flash
- color = @ary[2]
- duration = @ary[3]
- screen.start_flash(color, duration)
- when Screen_Normalize
- tone = Tone.new
- duration = @ary[2]
- screen.start_tone_change(tone, duration)
- end
- end
- # --------------------------------------------------------------------------
- # New method : Setup add state
- # --------------------------------------------------------------------------
- def setup_add_state
- if chance(@ary[2])
- if area_flag
- target_array.each do |t|
- t.add_state(@ary[1])
- end
- return
- end
- target.add_state(@ary[1])
- end
- end
- # --------------------------------------------------------------------------
- # New method : Setup remove state
- # --------------------------------------------------------------------------
- def setup_rem_state
- if chance(@ary[2])
- if area_flag
- target_array.each do |t|
- t.remove_state(@ary[1])
- end
- return
- end
- target.remove_state(@ary[1])
- end
- end
- # --------------------------------------------------------------------------
- # New method : Setup change target
- # --------------------------------------------------------------------------
- def setup_change_target
- case @ary[1]
- # --------------------
- when 0 # Original Target
- self.area_flag = item_in_use.area?
- @target = @ori_target
- @target_array = @ori_targets.clone
- # -------------------
- when 1 # All Battler
- self.area_flag = true
- t = $game_party.alive_members + $game_troop.alive_members
- @target_array = t
- $game_temp.battler_targets += t
- # -------------------
- when 2 # All Battler except user
- self.area_flag = true
- t = $game_party.alive_members + $game_troop.alive_members
- t -= [self]
- @target_array = t
- $game_temp.battler_targets += t
- # -------------------
- when 3 # All Enemies
- self.area_flag = true
- t = opponents_unit.alive_members
- @target_array = t
- $game_temp.battler_targets += t
- # -------------------
- when 4 # All Enemies except current target
- self.area_flag = true
- t = opponents_unit.alive_members
- t -= [target]
- @target_array = t
- $game_temp.battler_targets += t
- # -------------------
- when 5 # All Allies
- self.area_flag = true
- t = friends_unit.alive_members
- @target_array = t
- $game_temp.battler_targets += t
- # -------------------
- when 6 # All Allies except user
- self.area_flag = true
- t = friends_unit.alive_members
- t -= [self]
- @target_array = t
- $game_temp.battler_targets += t
- # -------------------
- when 7 # Next random enemy
- self.area_flag = false
- @target = opponents_unit.random_target
- $game_temp.battler_targets += [@target]
- # -------------------
- when 8 # Next random ally
- self.area_flag = false
- @target = friends_unit.random_target
- $game_temp.battler_targets += [@target]
- # -------------------
- when 9 # Absolute Targets (Enemies)
- self.area_flag = true
- @target_array = opponents_unit.abs_target(@ary[2])
- @target_array -= [target] if @ary[3]
- $game_temp.battler_targets += @target_array
- # -------------------
- when 10 # Absolute Target (Allies)
- self.area_flag = true
- @target_array = friends_unit.abs_target(@ary[2])
- @target_array -= [target] if @ary[3]
- $game_temp.battler_targets += @target_array
- # -------------------
- when 11 # self
- self.area_flag = false
- @target = self
- $game_temp.battler_targets += [@target]
- end
- end
- # --------------------------------------------------------------------------
- # New method : Setup new picture (BETA)
- # --------------------------------------------------------------------------
- def setup_show_picture
- pictures = $game_troop.screen.pictures
- id = @ary[1]
- name = @ary[2]
- ori = @ary[3]
- xpos = @ary[4]
- ypos = @ary[5]
- zx = @ary[6]
- zy = @ary[7]
- op = @ary[8]
- blend = @ary[9]
- args = [name, ori, xpos, ypos, zx, zy, op, blend]
- pictures[id].show(*args)
- end
- # --------------------------------------------------------------------------
- # New method : Setup target movement
- # --------------------------------------------------------------------------
- def setup_target_move
- args = [@ary[1], @ary[2], @ary[3], @ary[4]]
- if area_flag
- target_array.each do |target|
- target.goto(*args)
- end
- return
- end
- target.goto(*args)
- end
- # --------------------------------------------------------------------------
- # New method : Setup target slide
- # --------------------------------------------------------------------------
- def setup_target_slide
- args = [@ary[1], @ary[2], @ary[3], @ary[4]]
- if area_flag
- target_array.each do |target|
- target.slide(*args)
- end
- return
- end
- target.slide(*args)
- end
- # --------------------------------------------------------------------------
- # New method : Setup target reset
- # --------------------------------------------------------------------------
- def setup_target_reset
- if area_flag
- target_array.each do |target|
- target.reset_pos(@ary[1],@ary[2])
- end
- return
- end
- target.reset_pos(@ary[1],@ary[2])
- end
- # --------------------------------------------------------------------------
- # New method : Setup focus
- # --------------------------------------------------------------------------
- def setup_focus
- sprset = get_spriteset
- rect = sprset.focus_bg.bitmap.rect
- color = @ary[2] || Focus_BGColor
- sprset.focus_bg.bitmap.fill_rect(rect,color)
- sprset.focus_bg.fadein(@ary[1])
- sprset.battler_sprites.select do |spr|
- !spr.battler.nil?
- end.each do |spr|
- if spr.battler != self && spr.battler.alive?
- spr.fadeout(@ary[1]) if !target_array.include?(spr.battler)
- spr.fadein(@ary[1]) if target_array.include?(spr.battler)
- end
- end
- end
- # --------------------------------------------------------------------------
- # New method : Setup unfocus
- # --------------------------------------------------------------------------
- def setup_unfocus
- sprset = get_spriteset
- sprset.focus_bg.fadeout(@ary[1])
- sprset.battler_sprites.select do |spr|
- !spr.battler.nil?
- end.each do |spr|
- spr.fadein(@ary[1]) if spr.battler.alive? || spr.battler.actor?
- end
- end
- # --------------------------------------------------------------------------
- # New method : Method for wait
- # --------------------------------------------------------------------------
- def method_wait
- Fiber.yield
- update_timed_hit if @timed_hit_count > 0
- end
- # --------------------------------------------------------------------------
- # New method : Get next symbol
- # --------------------------------------------------------------------------
- def next_is?(symbol)
- next_ary = animation_array[@anim_index + 2]
- return next_ary[0] == symbol
- end
- # --------------------------------------------------------------------------
- # New method : Forward sequence pointer
- # --------------------------------------------------------------------------
- def next_anim_index
- @anim_index = (@anim_index + 1) % (@animation_array.size - 1)
- end
- # --------------------------------------------------------------------------
- # New method : Update for timed hit
- # --------------------------------------------------------------------------
- def update_timed_hit
- if Input.trigger?(:C)
- @timed_hit = true
- @timed_hit_count = 1
- self.animation_id = TimedHit_Anim
- on_timed_hit_success
- end
- @timed_hit_count -= 1
- end
- # --------------------------------------------------------------------------
- # New method : On timed hit success
- # --------------------------------------------------------------------------
- def on_timed_hit_success
- end
- # --------------------------------------------------------------------------
- # New method : Determine if current phase is temporary phase
- # --------------------------------------------------------------------------
- def temporary_phase?
- Temporary_Phase.any? do |phase|
- battle_phase == phase
- end
- end
- # --------------------------------------------------------------------------
- # New method : Get animation sequence
- # --------------------------------------------------------------------------
- def get_animloop_array
- result = AnimLoop[phase_sequence[battle_phase].call]
- return result if result
- return rescued_error
- end
- # --------------------------------------------------------------------------
- # New method : Get current action
- # --------------------------------------------------------------------------
- def animloop
- animation_array[@anim_index + 1]
- end
- # --------------------------------------------------------------------------
- # New method : Loop?
- # --------------------------------------------------------------------------
- def loop?
- get_animloop_array[0][0]
- end
- # --------------------------------------------------------------------------
- # New method : Addons... if anyone is interested
- # --------------------------------------------------------------------------
- def custom_sequence_handler(ary)
- # For addon maybe ?
- end
- # --------------------------------------------------------------------------
- # New method : User error handler
- # --------------------------------------------------------------------------
- def rescued_error
- RPG::SE.new("Buzzer1",100,100).play
- id = data_battler.id
- seq_key = phase_sequence[battle_phase].call
- phase = (dead? ? :dead : battle_phase)
- klass = data_battler.class
- result = "Error occured on #{klass} in ID #{id}\n" +
- "Undefined sequence key \"#{seq_key}\" for #{phase} phase\n\n" +
- "This is your fault. Not this script error!"
- msgbox result
- exit
- end
- # --------------------------------------------------------------------------
- # New method : Action call error handler
- # --------------------------------------------------------------------------
- def show_action_error(string)
- RPG::SE.new("Buzzer1",100,100).play
- text = "Sequence key : #{phase_sequence[battle_phase].call}\n" +
- "Uninitalized Constant for #{string} in :action mode"
- msgbox text
- exit
- end
- # --------------------------------------------------------------------------
- # New method : Determine if battler is busy
- # --------------------------------------------------------------------------
- def busy?
- BusyPhases.any? {|phase| battle_phase == phase }
- end
- # --------------------------------------------------------------------------
- # Alias method : Make base result (Basic Module - Core Result)
- # --------------------------------------------------------------------------
- alias tsbs_make_base_result make_base_result
- def make_base_result(user, item)
- tsbs_make_base_result(user, item)
- return unless data_battler.use_sprite
- return if user == self
- return if busy?
- if item.damage.recover? || item.damage.type == 0
- self.battle_phase = :idle # Refresh idle key
- return
- end
- self.battle_phase = :hurt if @result.hit?
- self.battle_phase = :evade if @result.evaded
- end
- # --------------------------------------------------------------------------
- # New method : Get state tone
- # --------------------------------------------------------------------------
- def state_tone
- states.each do |state|
- return state.tone if state.tone
- end
- return EmptyTone
- end
- # --------------------------------------------------------------------------
- # New method : Get state color
- # --------------------------------------------------------------------------
- def state_color
- states.each do |state|
- return state.color if state.color
- end
- return EmptyColor
- end
- # --------------------------------------------------------------------------
- # New method : Get animation guard
- # --------------------------------------------------------------------------
- def anim_guard_id
- states.each do |state|
- return state.anim_guard if state && state.anim_guard > 0
- end
- return nil
- end
- # --------------------------------------------------------------------------
- # New method : Get skills guard
- # --------------------------------------------------------------------------
- def skills_guard
- skill_guard = []
- states.each do |state|
- skill_guard.push(state.skill_guard) if state.skill_guard > 0
- end
- skill_guard.uniq.collect {|skill_id| $data_skills[skill_id]}
- end
- # --------------------------------------------------------------------------
- # New method : Get maximum opacity
- # --------------------------------------------------------------------------
- def max_opac
- unless states.empty?
- return states.collect do |state|
- state.max_opac
- end.min
- end
- return 255
- end
- # --------------------------------------------------------------------------
- # New method : Screen Z
- # --------------------------------------------------------------------------
- def screen_z
- [@screen_z,3].max
- end
- # --------------------------------------------------------------------------
- # New method : Screen Z Formula
- # --------------------------------------------------------------------------
- def screen_z_formula
- return screen_y * 2 + (battle_phase == :idle || battle_phase == :hurt ?
- 0 : 2)
- end
- # --------------------------------------------------------------------------
- # Alias method : Add state
- # --------------------------------------------------------------------------
- alias tsbs_add_state add_state
- def add_state(state_id)
- tsbs_add_state(state_id)
- if battle_phase == :idle && @used_sequence != phase_sequence[:idle].call
- self.battle_phase = :idle
- end
- @refresh_opacity = true
- end
- # --------------------------------------------------------------------------
- # Alias method : Remove state
- # --------------------------------------------------------------------------
- alias tsbs_rem_state remove_state
- def remove_state(state_id)
- tsbs_rem_state(state_id)
- if battle_phase == :idle && @used_sequence != phase_sequence[:idle].call
- self.battle_phase = :idle
- end
- @refresh_opacity = true
- end
- # --------------------------------------------------------------------------
- # New method : State Sequence
- # --------------------------------------------------------------------------
- def state_sequence
- states.each do |state|
- return state.sequence unless state.sequence.empty?
- end
- return nil
- end
- end
- #==============================================================================
- # ** 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. Compatibility with Basic Movement
- # --------------------------------------------------------------------------
- attr_accessor :x
- attr_accessor :y
- # --------------------------------------------------------------------------
- # Alias method : setup
- # --------------------------------------------------------------------------
- alias theo_tsbs_actor_setup setup
- def setup(id)
- self.x = 0
- self.y = 0
- theo_tsbs_actor_setup(id)
- end
- # --------------------------------------------------------------------------
- # Overwrite method : Fiber object thread
- # --------------------------------------------------------------------------
- def fiber_obj
- $game_temp.actors_fiber[index]
- end
- # --------------------------------------------------------------------------
- # Alias method : On Battle Start
- # --------------------------------------------------------------------------
- alias tsbs_on_bs_start on_battle_start
- def on_battle_start
- self.x = original_x
- self.y = original_y
- @ori_x = x
- @ori_y = y
- tsbs_on_bs_start
- end
- # --------------------------------------------------------------------------
- # New method : Original X position
- # --------------------------------------------------------------------------
- def original_x
- ActorPos[index][0]
- end
- # --------------------------------------------------------------------------
- # New method : Original Y position
- # --------------------------------------------------------------------------
- def original_y
- ActorPos[index][1]
- end
- # --------------------------------------------------------------------------
- # New method : Screen X
- # --------------------------------------------------------------------------
- def screen_x
- return x
- end
- # --------------------------------------------------------------------------
- # New method : Screen Y
- # --------------------------------------------------------------------------
- def screen_y
- return y
- end
- # --------------------------------------------------------------------------
- # New method : Screen Z
- # --------------------------------------------------------------------------
- def screen_z
- super
- end
- # --------------------------------------------------------------------------
- # Overwrite method : use sprite
- # --------------------------------------------------------------------------
- def use_sprite?
- return true
- end
- # --------------------------------------------------------------------------
- # New method : Actor's battler bame
- # --------------------------------------------------------------------------
- def battler_name
- return "#{name}_#{battler_index}"
- end
- # --------------------------------------------------------------------------
- # New method : Actor's Hue
- # --------------------------------------------------------------------------
- def battler_hue
- return 0
- end
- # --------------------------------------------------------------------------
- # New method : Data Battler
- # --------------------------------------------------------------------------
- def data_battler
- actor
- end
- # --------------------------------------------------------------------------
- # Overwrite method : Remove perform damage effect
- # --------------------------------------------------------------------------
- def perform_damage_effect
- end
- end
- #==============================================================================
- # ** Game_Enemy
- #------------------------------------------------------------------------------
- # This class handles enemies. It used within the Game_Troop class
- # ($game_troop).
- #==============================================================================
- class Game_Enemy < Game_Battler
- # --------------------------------------------------------------------------
- # Alias methods : Compatibility with Basic Movement
- # --------------------------------------------------------------------------
- alias x screen_x
- alias y screen_y
- # --------------------------------------------------------------------------
- # Alias method : On Battle Start
- # --------------------------------------------------------------------------
- alias tsbs_on_bs_start on_battle_start
- def on_battle_start
- tsbs_on_bs_start
- @ori_x = x
- @ori_y = y
- return unless data_battler.use_sprite
- @anim_index = rand(get_animloop_array.size - 1) rescue rescued_error
- end
- # --------------------------------------------------------------------------
- # Overwrite method : Fiber object thread
- # --------------------------------------------------------------------------
- def fiber_obj
- $game_temp.enemies_fiber[index]
- end
- # --------------------------------------------------------------------------
- # New method : Set X Position
- # --------------------------------------------------------------------------
- def x=(x)
- @screen_x = x
- end
- # --------------------------------------------------------------------------
- # New method : Set Y Position
- # --------------------------------------------------------------------------
- def y=(y)
- @screen_y = y
- end
- # --------------------------------------------------------------------------
- # New method : Data Battler
- # --------------------------------------------------------------------------
- def data_battler
- enemy
- end
- # --------------------------------------------------------------------------
- # Alias method : Battler Name
- # --------------------------------------------------------------------------
- alias tsbs_ename battler_name
- def battler_name
- return "#{data_battler.sprite_name}_#{battler_index}" if
- data_battler.use_sprite
- return tsbs_ename
- end
- # --------------------------------------------------------------------------
- # Overwrite method : Screen Z
- # --------------------------------------------------------------------------
- def screen_z
- super
- end
- # --------------------------------------------------------------------------
- # New method : Default flip
- # --------------------------------------------------------------------------
- def default_flip
- return TSBS::Enemy_Default_Flip
- end
- # --------------------------------------------------------------------------
- # Overwrite method : Delete perform damage effect
- # --------------------------------------------------------------------------
- def perform_damage_effect
- end
- end
- #==============================================================================
- # ** Game_Party
- #------------------------------------------------------------------------------
- # This class handles parties. Information such as gold and items is included.
- # Instances of this class are referenced by $game_party.
- #==============================================================================
- class Game_Party < Game_Unit
- # --------------------------------------------------------------------------
- # Overwrite method : actor maximum battle members
- # --------------------------------------------------------------------------
- def max_battle_members
- TSBS::ActorPos.size
- end
- end
- #==============================================================================
- # ** Sprite_Battler
- #------------------------------------------------------------------------------
- # This sprite is used to display battlers. It observes an instance of the
- # Game_Battler class and automatically changes sprite states.
- #==============================================================================
- class Sprite_Battler < Sprite_Base
- include TSBS
- # --------------------------------------------------------------------------
- # Alias method : Initialize
- # --------------------------------------------------------------------------
- alias tsbs_init initialize
- def initialize(*args)
- tsbs_init(*args)
- @used_bitmap = []
- end
- # --------------------------------------------------------------------------
- # New method : Sprite is an actor?
- # --------------------------------------------------------------------------
- def actor?
- @battler && @battler.is_a?(Game_Actor)
- end
- # --------------------------------------------------------------------------
- # Alias method : bitmap=
- # --------------------------------------------------------------------------
- alias tsbs_bitmap= bitmap=
- def bitmap=(bmp)
- self.tsbs_bitmap = bmp
- @used_bitmap.push(bmp)
- @used_bitmap.uniq!
- return unless @battler && @battler.data_battler.use_sprite && bitmap
- wr = bitmap.width / self.class::MaxCol
- hr = bitmap.height / self.class::MaxRow
- yr = 0
- xr = 0
- src_rect.set(xr,yr,wr,hr)
- update_flip
- end
- # --------------------------------------------------------------------------
- # Overwrite method : update origin
- # --------------------------------------------------------------------------
- def update_origin
- if bitmap
- unless @battler && @battler.data_battler.use_sprite
- self.ox = bitmap.width / 2
- self.oy = bitmap.height
- else
- src_rect.y = (@battler.anim_cell / MaxCol) * height
- src_rect.x = (@battler.anim_cell % MaxCol) * width
- self.ox = src_rect.width/2
- self.oy = height
- end
- end
- end
- # --------------------------------------------------------------------------
- # Overwrite method : revert to normal
- # --------------------------------------------------------------------------
- def revert_to_normal
- self.blend_type = 0
- self.color.set(0, 0, 0, 0)
- self.opacity = 255
- update_origin
- end
- # --------------------------------------------------------------------------
- # Alias method : Init visibility
- # --------------------------------------------------------------------------
- alias tsbs_init_visible init_visibility
- def init_visibility
- return if actor? && !@battler.data_battler.dead_key.empty?
- tsbs_init_visible
- end
- # --------------------------------------------------------------------------
- # Overwrite method : afterimage
- # --------------------------------------------------------------------------
- def afterimage
- super || @battler.afterimage rescue false
- end
- # --------------------------------------------------------------------------
- # New method : update afterimage info
- # --------------------------------------------------------------------------
- def update_afterimage_info
- @afterimage_opac = 20
- @afterimage_rate = 3
- end
- # --------------------------------------------------------------------------
- # Alias method : update
- # --------------------------------------------------------------------------
- alias theo_tsbs_update update
- def update
- theo_tsbs_update
- update_afterimage_info
- update_visible
- update_flip
- update_tone
- update_color unless effect?
- update_opacity if @battler && @battler.refresh_opacity
- update_blending if @battler && (@effect_type.nil? ||
- @effect_type == :whiten)
- end
- # --------------------------------------------------------------------------
- # New method : Battler is busy?
- # --------------------------------------------------------------------------
- def busy?
- @battler && BusyPhases.any? do |phase|
- phase == @battler.battle_phase
- end && !@battler.finish || (@battler && @battler.moving?)
- end
- # --------------------------------------------------------------------------
- # New method : update visibility
- # --------------------------------------------------------------------------
- def update_visible
- self.visible = @battler.visible if @battler
- end
- # --------------------------------------------------------------------------
- # New method : update flip
- # --------------------------------------------------------------------------
- def update_flip
- self.mirror = @battler.flip if @battler
- end
- # --------------------------------------------------------------------------
- # New method : update battler tone
- # --------------------------------------------------------------------------
- def update_tone
- if @battler
- self.tone.set(@battler.state_tone)
- end
- end
- # --------------------------------------------------------------------------
- # New method : update battler color
- # --------------------------------------------------------------------------
- def update_color
- if @battler
- self.color.set(@battler.state_color)
- end
- end
- # --------------------------------------------------------------------------
- # New method : update battler opacity
- # --------------------------------------------------------------------------
- def update_opacity
- self.opacity = @battler.max_opac
- @battler.refresh_opacity = false
- end
- # --------------------------------------------------------------------------
- # New method : update battler blend
- # --------------------------------------------------------------------------
- def update_blending
- self.blend_type = @battler.blend
- end
- # --------------------------------------------------------------------------
- # Alias method : Opacity=
- # --------------------------------------------------------------------------
- alias tsbs_opacity= opacity=
- def opacity=(value)
- result = [value, max_opac].min
- self.tsbs_opacity = result
- end
- # --------------------------------------------------------------------------
- # New method : Maximum opacity
- # --------------------------------------------------------------------------
- def max_opac
- return @battler.max_opac if @battler
- return 255
- end
- # --------------------------------------------------------------------------
- # Alias method : update boss collapse
- # --------------------------------------------------------------------------
- alias tsbs_boss_collapse update_boss_collapse
- def update_boss_collapse
- return tsbs_boss_collapse unless @battler && @battler.use_sprite?
- alpha = @effect_duration * 120 / height
- self.ox = width / 2 + @effect_duration % 2 * 4 - 2
- self.blend_type = 1
- self.color.set(255, 255, 255, 255 - alpha)
- self.opacity = alpha
- self.src_rect.y -= 1
- Sound.play_boss_collapse2 if @effect_duration % 20 == 19
- end
- # --------------------------------------------------------------------------
- # Alias method : dispose
- # --------------------------------------------------------------------------
- alias tsbs_dispose dispose
- def dispose
- tsbs_dispose
- @used_bitmap.each do |bmp|
- bmp.dispose unless bmp.disposed?
- end
- end
- end
- #==============================================================================
- # ** Sprite_Projectile
- #------------------------------------------------------------------------------
- # This sprite is used to display projectile. This class is used within the
- # Spriteset_Battle class
- #==============================================================================
- class Sprite_Projectile < Sprite_Base
- # --------------------------------------------------------------------------
- # Public accessors
- # --------------------------------------------------------------------------
- attr_accessor :subject # Battler subject
- attr_accessor :target # Battler target
- attr_accessor :item # Carried item / skill
- attr_accessor :angle_speed # Angle speed rotation
- # --------------------------------------------------------------------------
- # Import TSBS constantas
- # --------------------------------------------------------------------------
- include TSBS
- # --------------------------------------------------------------------------
- # Initialize
- # --------------------------------------------------------------------------
- def initialize(viewport = nil)
- super
- @angle = 0.0
- end
- # --------------------------------------------------------------------------
- # Set icon
- # --------------------------------------------------------------------------
- def icon=(icon_index)
- icon_bitmap = Cache.system("Iconset")
- rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
- bmp = EmptyBitmap.clone
- bmp.blt(0, 0, icon_bitmap, rect, 255)
- self.bitmap = bmp
- self.ox = width/2
- self.oy = height/2
- end
- # --------------------------------------------------------------------------
- # Record last coordinate
- # --------------------------------------------------------------------------
- def update_last_coordinate
- @last_x = x
- @last_y = y
- end
- # --------------------------------------------------------------------------
- # Update
- # --------------------------------------------------------------------------
- def update
- super
- @angle += angle_speed
- self.angle = @angle
- process_dispose if need_dispose?
- end
- # --------------------------------------------------------------------------
- # Alias method : update movement
- # --------------------------------------------------------------------------
- def update_move
- update_last_coordinate
- super
- move_animation(diff_x, diff_y)
- end
- # --------------------------------------------------------------------------
- # Need dispose flag
- # --------------------------------------------------------------------------
- def need_dispose?
- !moving?
- end
- # --------------------------------------------------------------------------
- # Disposing sprite
- # --------------------------------------------------------------------------
- def process_dispose
- anim_id = target.anim_guard_id
- condition = anim_id && !item.damage.recover? && !item.ignore_anim_guard?
- target.animation_id = (condition ? anim_id : item.animation_id)
- target.animation_mirror = subject.flip
- $game_temp.invoke_method.call(target, item)
- dispose
- end
- # --------------------------------------------------------------------------
- # Difference from last X coordinate
- # --------------------------------------------------------------------------
- def diff_x
- self.x - @last_x
- end
- # --------------------------------------------------------------------------
- # Difference from last Y coordinate
- # --------------------------------------------------------------------------
- def diff_y
- self.y - @last_y
- end
- # --------------------------------------------------------------------------
- # Move animation
- # --------------------------------------------------------------------------
- def move_animation(dx, dy)
- if @animation && @animation.position != 3
- @ani_ox += dx
- @ani_oy += dy
- @ani_sprites.each do |sprite|
- sprite.x += dx
- sprite.y += dy
- end
- end
- end
- end
- #==============================================================================
- # ** Sprite_Icon
- #------------------------------------------------------------------------------
- # This sprite is used to display battler's Icon. It observes icon key from
- # Game_Battler class and automatically changes sprite display when triggered.
- #==============================================================================
- class Sprite_Icon < Sprite_Base
- attr_reader :battler # Battler
- include TSBS # Import TSBS constantas
- # --------------------------------------------------------------------------
- # Initialize
- # --------------------------------------------------------------------------
- def initialize(battler, viewport = nil)
- super(viewport)
- @battler = battler
- @afterimage_opac = 20
- @afterimage_rate = 3
- @x_plus = 0
- @y_plus = 0
- @above_char = false
- @used_key = ""
- self.anchor = 0
- self.icon_index = 0
- end
- # --------------------------------------------------------------------------
- # Set anchor origin
- # --------------------------------------------------------------------------
- def anchor=(value)
- @anchor_origin = value
- update_anchor(value)
- end
- # --------------------------------------------------------------------------
- # Set icon index
- # --------------------------------------------------------------------------
- def icon_index=(index)
- @icon_index = index
- icon_bitmap = Cache.system("Iconset")
- rect = Rect.new(index % 16 * 24, index / 16 * 24, 24, 24)
- bmp = EmptyBitmap.clone
- bmp.blt(0, 0, icon_bitmap, rect, 255)
- self.bitmap = bmp
- end
- # --------------------------------------------------------------------------
- # Overwrite bitmap=
- # --------------------------------------------------------------------------
- def bitmap=(bmp)
- update_anchor(@anchor_origin)
- super
- end
- # --------------------------------------------------------------------------
- # Update anchor origin
- # --------------------------------------------------------------------------
- def update_anchor(value)
- case value
- when 0 # Center
- self.ox = self.oy = 12
- when 1 # Upper Left
- self.ox = self.oy = 0
- when 2 # Upper Right
- self.ox = 24
- self.oy = 0
- when 3 # Bottom Left
- self.ox = 0
- self.oy = 24
- when 4 # Bottom Right
- self.ox = self.oy = 24
- else
- point = TSBS::IconAnchor[value]
- self.ox = point[0]
- self.oy = point[1]
- end
- end
- # --------------------------------------------------------------------------
- # Update
- # --------------------------------------------------------------------------
- def update
- super
- update_placement
- update_key unless battler.icon_key.empty?
- end
- # --------------------------------------------------------------------------
- # Update placement related to battler
- # --------------------------------------------------------------------------
- def update_placement
- self.x = battler.screen_x + @x_plus
- self.y = battler.screen_y + @y_plus
- self.z = battler.screen_z + (@above_char ? 10 : -10)
- end
- # --------------------------------------------------------------------------
- # Update icon key
- # --------------------------------------------------------------------------
- def update_key
- @used_key = battler.icon_key
- array = TSBS::Icons[@used_key]
- self.anchor = array[0]
- @x_plus = (battler.flip ? -array[1] : array[1])
- @y_plus = array[2]
- @above_char = array[3]
- update_placement
- self.angle = array[4]
- target = array[5]
- duration = array[6]
- if array[7] >= 0
- icon_index = array[7]
- elsif array[7] < 0 || array[7].nil?
- icon_index = (battler.weapons[0].icon_index rescue 0)
- end
- self.icon_index = icon_index
- change_angle(target, duration)
- battler.icon_key = ""
- end
- end
- #==============================================================================
- # ** Spriteset_Battle
- #------------------------------------------------------------------------------
- # This class brings together battle screen sprites. It's used within the
- # Scene_Battle class.
- #==============================================================================
- class Spriteset_Battle
- # --------------------------------------------------------------------------
- # Public instance method
- # --------------------------------------------------------------------------
- attr_reader :projectiles # Projectiles array
- attr_reader :focus_bg # Focus background
- # --------------------------------------------------------------------------
- # Alias method : Initialize
- # --------------------------------------------------------------------------
- alias tsbs_init initialize
- def initialize
- @projectiles = []
- tsbs_init
- end
- # --------------------------------------------------------------------------
- # Alias method : Create viewports
- # --------------------------------------------------------------------------
- alias tsbs_icon_create_viewport create_viewports
- def create_viewports
- tsbs_icon_create_viewport
- @icons = []
- battlers = $game_party.members + $game_troop.members
- battlers.each do |battler|
- icon = Sprite_Icon.new(battler, @viewport1)
- @icons.push(icon)
- end
- @focus_bg = Sprite_Screen.new(@viewport1)
- @focus_bg.bitmap.fill_rect(@focus_bg.bitmap.rect, Color.new(255,255,255))
- @focus_bg.z = 3
- @focus_bg.opacity = 0
- end
- # --------------------------------------------------------------------------
- # New method : spriteset is busy?
- # --------------------------------------------------------------------------
- def busy?
- (@enemy_sprites + @actor_sprites).any? do |sprite|
- sprite.busy?
- end
- end
- # --------------------------------------------------------------------------
- # Overwrite method : actor sprites
- # --------------------------------------------------------------------------
- def create_actors
- @actor_sprites = Array.new($game_party.max_battle_members) do
- Sprite_Battler.new(@viewport1)
- end
- end
- # --------------------------------------------------------------------------
- # Alias method : update
- # --------------------------------------------------------------------------
- alias tsbs_update update
- def update
- tsbs_update
- @focus_bg.update
- update_projectiles
- update_icons
- end
- # --------------------------------------------------------------------------
- # New method : update projectiles
- # --------------------------------------------------------------------------
- def update_projectiles
- @projectiles.delete_if do |proj|
- proj.update
- proj.disposed?
- end
- end
- # --------------------------------------------------------------------------
- # New method : update icons
- # --------------------------------------------------------------------------
- def update_icons
- @icons.each do |icon|
- icon.update
- end
- end
- # --------------------------------------------------------------------------
- # New method : add projectiles
- # --------------------------------------------------------------------------
- def add_projectile(proj)
- proj.viewport = viewport1
- proj.z = 300
- @projectiles.push(proj)
- end
- # --------------------------------------------------------------------------
- # New method : is projectile avalaible?
- # --------------------------------------------------------------------------
- def projectile?
- !projectiles.empty?
- end
- # --------------------------------------------------------------------------
- # New method : get battler sprite
- # --------------------------------------------------------------------------
- def get_sprite(battler)
- battler_sprites.each do |spr|
- return spr if spr.battler == battler
- end
- return nil
- end
- alias tsbs_dispose dispose
- def dispose
- (@icons + [@focus_bg]).each do |extra|
- extra.dispose unless extra.disposed?
- end
- tsbs_dispose
- end
- end
- #==============================================================================
- # ** Scene_Battle
- #------------------------------------------------------------------------------
- # This class performs battle screen processing.
- #==============================================================================
- class Scene_Battle < Scene_Base
- # --------------------------------------------------------------------------
- # Alias method : update basic
- # --------------------------------------------------------------------------
- alias theo_tsbs_update_basic update_basic
- def update_basic
- theo_tsbs_update_basic
- @damage.update
- ($game_party.members + $game_troop.members).each do |batt_member|
- batt_member.update
- end
- end
- # --------------------------------------------------------------------------
- # Overwrite method : use item
- # --------------------------------------------------------------------------
- def use_item
- item = @subject.current_action.item
- @log_window.display_use_item(@subject, item)
- @subject.use_item(item)
- refresh_status
- targets = @subject.current_action.make_targets.compact
- show_action_sequences(targets, item)
- end
- # --------------------------------------------------------------------------
- # New method : wait for sequence
- # --------------------------------------------------------------------------
- def wait_for_sequence
- update_for_wait
- update_for_wait while @spriteset.busy?
- end
- # --------------------------------------------------------------------------
- # New method : show action sequence
- # --------------------------------------------------------------------------
- def show_action_sequences(targets, item)
- $game_temp.battler_targets = targets.clone
- @subject.target_array = targets
- @subject.item_in_use = copy(item)
- if !item.prepare_key.empty?
- @subject.battle_phase = :prepare
- wait_for_sequence
- end
- if !item.area?
- @subject.area_flag = false
- targets.each do |target|
- @subject.target = target
- @subject.battle_phase = :skill
- wait_for_sequence
- end
- else
- @subject.area_flag = true
- @subject.battle_phase = :skill
- wait_for_sequence
- @subject.area_flag = false
- end
- @subject.item_in_use = nil
- @subject.target = nil
- unless item.no_return?
- @subject.battle_phase = :return
- wait_for_sequence
- else
- @subject.battle_phase = :idle
- end
- $game_temp.battler_targets += [@subject]
- $game_temp.battler_targets.uniq.each do |target|
- @log_window.display_action_results(target, item)
- next if target.actor?
- target.perform_collapse_effect if target.state?(target.death_state_id) ||
- ($imported["YEA-BattleEngine"] && target.can_collapse?)
- end
- @damage.reset_value
- wait(rand_range(30,60))
- end
- # --------------------------------------------------------------------------
- # Alias method : battle start
- # --------------------------------------------------------------------------
- alias tsbs_bs_start battle_start
- def battle_start
- $game_temp.invoke_method = method(:tsbs_invoke_item)
- tsbs_bs_start
- end
- # --------------------------------------------------------------------------
- # New method : Invoke item for TSBS
- # --------------------------------------------------------------------------
- def tsbs_invoke_item(target, item)
- if rand < target.item_cnt(@subject, item)
- tsbs_invoke_counter(target, item)
- elsif rand < target.item_mrf(@subject, item)
- tsbs_invoke_mreflect(target, item)
- else
- tsbs_apply_item(apply_substitute(target, item), item)
- end
- end
- # --------------------------------------------------------------------------
- # New method : Invoke counter for TSBS (doesn't finished yet)
- # --------------------------------------------------------------------------
- def tsbs_invoke_counter(target, item)
- attack_skill = $data_skills[target.attack_skill_id]
- @subject.item_apply(target, attack_skill)
- if $imported["YEA-BattleEngine"]
- status_redraw_target(@subject)
- status_redraw_target(target) unless target == @subject
- else
- refresh_status
- end
- end
- # --------------------------------------------------------------------------
- # New method : Invoke reflect for TSBS
- # --------------------------------------------------------------------------
- def tsbs_invoke_mreflect(target, item)
- @subject.magic_reflection = true
- tsbs_apply_item(@subject, item)
- @subject.animation_id = item.reflect_anim
- @log_window.add_text(TSBS::Attack_Reflected)
- @subject.magic_reflection = false
- end
- # --------------------------------------------------------------------------
- # New method : Apply item for TSBS
- # --------------------------------------------------------------------------
- def tsbs_apply_item(target, item)
- target.item_apply(@subject, item)
- return if (item.is_a?(RPG::Skill) && item.id == target.guard_skill_id)
- check_skill_guard(target, item) unless item.is_a?(RPG::Item)
- @damage.start(target.result)
- if target.actor?
- @status_window.refresh
- end
- if $imported["YEA-BattleEngine"]
- status_redraw_target(@subject)
- status_redraw_target(target) unless target == @subject
- else
- refresh_status
- end
- end
- # --------------------------------------------------------------------------
- # New method : Check skill guard
- # --------------------------------------------------------------------------
- def check_skill_guard(target, item)
- return if target == @subject
- return if item.ignore_skill_guard?
- target.skills_guard.each do |skill|
- @subject.item_apply(target, skill)
- end
- end
- # --------------------------------------------------------------------------
- # Alias method : start
- # --------------------------------------------------------------------------
- alias tsbs_start start
- def start
- tsbs_start
- @damage = DamageResults.new(@viewport)
- end
- # --------------------------------------------------------------------------
- # Alias method : terminate
- # --------------------------------------------------------------------------
- alias tsbs_terminate terminate
- def terminate
- tsbs_terminate
- @damage.dispose
- $game_temp.clear_tsbs
- end
- # --------------------------------------------------------------------------
- # For future features
- # --------------------------------------------------------------------------
- if $imported["YEA-CommandEquip"]
- alias tsbs_command_equip command_equip
- def command_equip
- tsbs_command_equip
- $game_party.battle_members[@status_window.index].battle_phase = :idle
- end
- end
- end
- #==============================================================================
- # ** DamageResult
- #------------------------------------------------------------------------------
- # This sprite is used to display damage counter result. It's used inside
- # Scene_Battle. Automatically appear when triggered
- #==============================================================================
- class DamageResult < Sprite
- # --------------------------------------------------------------------------
- # Initialize
- # --------------------------------------------------------------------------
- def initialize(viewport = nil)
- super
- self.bitmap = Bitmap.new(200,100)
- bitmap.font.size = 30
- self.ox = width/2
- self.oy = height/2
- @value = 0
- self.opacity = 0
- @show = 0
- self.z = 250
- end
- # --------------------------------------------------------------------------
- # Start showing number
- # --------------------------------------------------------------------------
- def start(value)
- @value = value
- @show = 60
- self.opacity = 255
- self.zoom_x = 1.5
- self.zoom_y = 1.5
- bitmap.clear
- bitmap.draw_text(bitmap.rect, value, 1)
- end
- # --------------------------------------------------------------------------
- # Update
- # --------------------------------------------------------------------------
- def update
- @show -= 1
- self.zoom_x = [zoom_x - 0.1, 1.0].max
- self.zoom_y = [zoom_x - 0.1, 1.0].max
- if @show < 0
- self.opacity -= 24
- end
- end
- end
- #==============================================================================
- # ** DamageResults
- #------------------------------------------------------------------------------
- # This class brings DamageResult instance object together in Scene_Battle
- #==============================================================================
- class DamageResults
- # --------------------------------------------------------------------------
- # Initialize
- # --------------------------------------------------------------------------
- def initialize(viewport)
- @value = 0
- @hit_count = 0
- # ---------------------------------------------------------------
- # Make damage counter
- # ---------------------------------------------------------------
- @damage_text = Sprite.new(viewport)
- @damage_text.bitmap = Bitmap.new(100,200)
- @damage_text.bitmap.font.color = TSBS::TotalDamage_Color
- @damage_text.bitmap.draw_text(0,0,100,TSBS::TotalDamage_Size,
- TSBS::TotalDamage_Vocab)
- @damage_text.y = TSBS::TotalDamage_Pos[0][0]
- @damage_text.x = TSBS::TotalDamage_Pos[0][1]
- @damage_text.opacity = 0
- @damage = DamageResult.new(viewport)
- @damage.x = TSBS::TotalDamage_Pos[1][0]
- @damage.y = TSBS::TotalDamage_Pos[1][1]
- # ---------------------------------------------------------------
- # Make hit counter
- # ---------------------------------------------------------------
- @hit_text = Sprite.new(viewport)
- @hit_text.bitmap = Bitmap.new(100,200)
- @hit_text.bitmap.font.color = TSBS::TotalHit_Color
- @hit_text.bitmap.draw_text(0,0,100,TSBS::TotalHit_Size,
- TSBS::TotalHit_Vocab)
- @hit_text.y = TSBS::TotalHit_Pos[0][0]
- @hit_text.x = TSBS::TotalHit_Pos[0][1]
- @hit = DamageResult.new(viewport)
- @hit.x = TSBS::TotalHit_Pos[1][0]
- @hit.y = TSBS::TotalHit_Pos[1][1]
- # ---------------------------------------------------------------
- update
- end
- # --------------------------------------------------------------------------
- # Start showing number
- # --------------------------------------------------------------------------
- def start(result)
- @value += result.hp_damage
- @value += result.mp_damage
- @hit_count += 1 if result.hit?
- @damage.start(@value) if @value > 0
- @hit.start(@hit_count)
- end
- # --------------------------------------------------------------------------
- # Update
- # --------------------------------------------------------------------------
- def update
- @damage.update
- @hit.update
- @damage_text.opacity = @damage.opacity
- @hit_text.opacity = @hit.opacity
- end
- # --------------------------------------------------------------------------
- # Dispose
- # --------------------------------------------------------------------------
- def dispose
- @damage.bitmap.dispose
- @damage.dispose
- @damage_text.bitmap.dispose
- @damage_text.dispose
- @hit.bitmap.dispose
- @hit.dispose
- @hit_text.bitmap.dispose
- @hit_text.dispose
- end
- # --------------------------------------------------------------------------
- # Reset value
- # --------------------------------------------------------------------------
- def reset_value
- @value = 0
- @hit_count = 0
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment