06-01-2014, 06:15 AM
I wrote an enemy auto-transformations script...
...and discovered that Minkoff's Animated Battlers doesn't properly update when Game_Enemy#transform method is used, leaving an active battler with no graphic loaded. With some help from DerVVulfman, I've written the following...
^I aliased the method Game_Enemy#transform accordingly, but it doesn't solve the problem like we thought it would. The battler graphic stays blank until they move in for an attack or perform another action.
Enemy.Transform
Code:
#===============================================================================
# * Enemy : Transform
#===============================================================================
#-------------------------------------------------------------------------------
# * SDK Log
#-------------------------------------------------------------------------------
if Object.const_defined?(:SDK)
SDK.log('Enemy.Transform', 'Kain Nobel ©', 4.0, '2014.05.22')
end
#===============================================================================
# ** Game_Enemy
#===============================================================================
class Game_Enemy
#-----------------------------------------------------------------------------
# * Transformations = {enemy_id => Proc.new {|enemy, attacker|, ...}, ...}
#-----------------------------------------------------------------------------
Transformations = {
################################################################################
# ~** Configuration : BEGIN **~ #
################################################################################
#-----------------------------------------------------------------------------
# * Oily Body => Flame Soul
# Condition : Skill effect is Fire elemental
# Effect : Transform into Fire Soul. Retain HP%, MP%, States.
#-----------------------------------------------------------------------------
6 => Proc.new {|a, b|
# Get skill object
skill = $data_skills[b.current_action.skill_id]
# If skill is valid and contains Fire element
if skill.is_a?(RPG::Skill) && skill.element_set.include?(1)
# Save old HP%, SP% and states
old_hp, old_sp, old_states = a.hp_percent, a.sp_percent, a.states.dup
# Transform into Flame Soul
a.transform(7)
# Adjust HP and SP according to percentage of current VS max
a.hp_percent, a.sp_percent = old_hp, old_sp
# Re-apply status effects
old_states.each {|state| a.add_state(state)}
end
},
#-----------------------------------------------------------------------------
# * Armed Trooper => Naked Trooper
# Condition : The Steal/Mug effect is successful
# Effect : Transform into Naked Trooper. Set to full health/immortal to
# ensure an embarrassing escape.
#-----------------------------------------------------------------------------
15 => Proc.new {|a, b|
# If opponent performs a successful steal
if b.steal_success?
# Transform into Naked Trooper
a.transform(16)
# Fully replenish HP, SP and states
a.recover_all
# Set trooper to immortal
a.immortal = true
end
},
#-----------------------------------------------------------------------------
# * Heli Trooper => Heli Trooper (Grounded)
# Condition : Trooper's HP is less than 30%, random 1/4 chance.
# Effect : Transform into Heli Trooper (Grounded). Retain HP%, MP%, States.
#-----------------------------------------------------------------------------
21 => Proc.new {|a, b|
# If HP is less than or equal to 30%
if a.hp_percent <= 30 && rand(4) == rand(4)
# Save old HP%, SP% and states
old_hp, old_sp, old_states= a.hp_percent, a.sp_percent, a.states.dup
# Transform into Heli Trooper (Grounded)
a.transform(22)
# Adjust HP and SP according to percentage of current VS max
a.hp_percent, a.sp_percent = old_hp, old_sp
# Re-apply status effects
old_states.each {|state| a.add_state(state)}
end
}
################################################################################
# ~** Configuration : END **~ #
################################################################################
}
#-----------------------------------------------------------------------------
# * Transform Effect
#-----------------------------------------------------------------------------
def transform_effect(b)
# End method if enemy isn't defined within hash
return unless Transformations.has_key?(id)
# Call transformation effect
Transformations[id].call(self, b)
end
end
#===============================================================================
# ** Game_Battler
#===============================================================================
class Game_Battler
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :enemytransformations_gmbattler_attackeffect, :attack_effect
alias_method :enemytransformations_gmbattler_skilleffect, :skill_effect
alias_method :enemytransformations_gmbattler_itemeffect, :item_effect
#-----------------------------------------------------------------------------
# * Attack Effect
#-----------------------------------------------------------------------------
def attack_effect(attacker)
# Get original attack effect results
result = enemytransformations_gmbattler_attackeffect(attacker)
# Call transformation effect if conditions are met
transform_effect(attacker) if result && self.is_a?(Game_Enemy)
# Return result
result
end
#-----------------------------------------------------------------------------
# * Skill Effect
#-----------------------------------------------------------------------------
def skill_effect(user, skill)
# Get original skill effect results
result = enemytransformations_gmbattler_skilleffect(user, skill)
# Call transformation effect if conditions are met
transform_effect(user) if result && self.is_a?(Game_Enemy)
# Return result
result
end
#-----------------------------------------------------------------------------
# * Item Effect
#-----------------------------------------------------------------------------
def item_effect(user, item)
# Get original item effect results
result = enemytransformations_gmbattler_itemeffect(user, item)
# Call transformation effect if conditions are met
transform_effect(user) if result && self.is_a?(Game_Enemy)
# Return result
result
end
end
...and discovered that Minkoff's Animated Battlers doesn't properly update when Game_Enemy#transform method is used, leaving an active battler with no graphic loaded. With some help from DerVVulfman, I've written the following...
New Minkoff Snippet
This goes into Part 4 of the Minkoff system, most likely titled as "4 - Misc Code".
Code:
#==============================================================================
# ** Animated Battlers - Enhanced ver. 13.7 (01-03-2012)
#
#------------------------------------------------------------------------------
# * (4) Miscellaneous: Formations, Viewport and various Detection routines.
#==============================================================================
#============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
# This class handles temporary data that is not included with save data.
# Refer to "$game_temp" for the instance of this class.
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :advantage_set # holds value for sideview systems
attr_accessor :mnk_battlers_reloaded # if battler spriteset resets
end
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles data surrounding the system. Backround music, etc.
# is managed here as well. Refer to "$game_system" for the instance of
# this class.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
# Auto-Detection Values
attr_accessor :mnk_det_abs_detect # Trickster's ATB System Detection
attr_accessor :mnk_det_acb_detect # Action Cost Battlesystem Detection
attr_accessor :mnk_det_claihms_ts # Claihm's Tactical Skills Detection
attr_accessor :mnk_det_para_spell # ParaDog Detection
attr_accessor :mnk_det_cfc_detect # Charlie Fleed's CTB Detection
attr_accessor :mnk_det_rtab_attck # Connected Attacking Detection
attr_accessor :mnk_det_rtab_systm # RTAB Detection
attr_accessor :mnk_det_trtab_syst # TRTAB Detection
attr_accessor :mnk_det_sd_casting # DBS Skill Delay Detection
# Inter-Class variables
attr_accessor :sv_angle # sideview system angle
attr_accessor :victory # victory boolean
attr_accessor :defeat # defeat boolean
# Additional values for the $global's save/load feature
attr_accessor :mnk_sm # sideview mirror
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias mnk_init initialize
def initialize
# Perform the original call
mnk_init
# Create the savable values
@mnk_sm = 0
end
end
#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
# This interpreter runs event commands. This class is used within the
# Game_System class and the Game_Event class.
#==============================================================================
class Interpreter
#-------------------------------------------------------------------------
# * Change Party Member
#--------------------------------------------------------------------------
alias mnk_c129 command_129
def command_129
$game_temp.mnk_battlers_reloaded = nil
mnk_c129
end
end
#==============================================================================
# ** Scene_Save
#------------------------------------------------------------------------------
# This class performs save screen processing.
#==============================================================================
class Scene_Save
#--------------------------------------------------------------------------
# * Write Save Data
# file : write file object (opened)
#--------------------------------------------------------------------------
alias mnk_wsd write_save_data
def write_save_data(file)
# Store the globals
$game_system.mnk_sm = $sideview_mirror
# Perform the original call
mnk_wsd(file)
end
end
#==============================================================================
# ** Scene_Load
#------------------------------------------------------------------------------
# This class performs load screen processing.
#==============================================================================
class Scene_Load
#--------------------------------------------------------------------------
# * Read Save Data
# file : file object for reading (opened)
#--------------------------------------------------------------------------
alias mnk_rsd read_save_data
def read_save_data(file)
#Perform the original call
mnk_rsd(file)
# ReStore the globals
$sideview_mirror = $game_system.mnk_sm
end
end
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
# This class deals with battlers. It's used as a superclass for the Game_Actor
# and Game_Enemy classes.
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :attacking # if attacking
attr_accessor :casted # if spell is casted
attr_accessor :casting # if currently casting
attr_accessor :skill_casted # ID of skill used
attr_accessor :strike_skill
attr_accessor :strike_item
attr_accessor :struck_weapon
attr_accessor :struck_skill
attr_accessor :struck_item
attr_accessor :skill_used
attr_accessor :item_used
attr_accessor :jump
attr_accessor :wait
attr_accessor :display_x
attr_accessor :display_y
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias mnk_init initialize
def initialize
@attacking = false
@casted = false
@casting = false
@skill_casted = 0
@strike_skill = 0
@strike_item = 0
@struck_weapon = 0
@struck_skill = 0
@struck_item = 0
@skill_used = 0
@item_used = 0
@display_x = 0
@display_y = 0
@jump = nil
mnk_init
# Detection (ParaDog, DBS Delay, Fomar, Trickster's AT, Charlie, TRTAB)
$game_system.mnk_det_para_spell = true if defined?(spelling?)
$game_system.mnk_det_sd_casting = true if @sd_casting != nil
$game_system.mnk_det_acb_detect = true if @vitality != nil
$game_system.mnk_det_abs_detect = true if @at_bonus != nil
$game_system.mnk_det_cfc_detect = true if $charlie_lee_ctb
$game_system.mnk_det_trtab_syst = true if defined?(SDK.enabled?('RTAB Battle System'))
end
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles the actor. It's used within the Game_Actors class
# ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================
class Game_Actor
alias mnk_ini initialize
def initialize(actor_id)
mnk_ini(actor_id)
$game_system.mnk_det_rtab_attck = true if defined?(change_weapon)
end
#--------------------------------------------------------------------------
# * Actor X Coordinate
#--------------------------------------------------------------------------
def screen_x
# Return 0 if index is nil
return 0 if self.index.nil?
# Branch out by position
case self.position
when 0 ; return 448 # Front row
when 1 ; return 480 # Middle row
when 2 ; return 512 # Back row
end
end
#--------------------------------------------------------------------------
# * Actor Y Coordinate
#--------------------------------------------------------------------------
def screen_y
# Return 0 if index nil
return 0 if self.index.nil?
# Return screen Y based off self index
((self.index + 1) * 40) + 176
end
#--------------------------------------------------------------------------
# * Actor Z Coordinate
#--------------------------------------------------------------------------
def screen_z
screen_y
end
end
#==============================================================================
# ** Game_Enemy
#------------------------------------------------------------------------------
# This class handles enemies. It's used within the Game_Troop class
# ($game_troop).
#==============================================================================
class Game_Enemy
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias_method :mnk_enemy_transform, :transform
#--------------------------------------------------------------------------
# * Get Battle Screen X-Coordinate
#--------------------------------------------------------------------------
def screen_x
if self.index != nil
if $game_system.sv_angle == 1
return 640 - $data_troops[@troop_id].members[@member_index].x
else
return $data_troops[@troop_id].members[@member_index].x
end
end
end
#--------------------------------------------------------------------------
# * Actor Z Coordinate
#--------------------------------------------------------------------------
def screen_z
screen_y
end
#--------------------------------------------------------------------------
# * Transform
#--------------------------------------------------------------------------
def transform(enemy_id)
mnk_enemy_transform(enemy_id)
return unless $scene.is_a?(Scene_Battle)
pose = $scene.pose_obtain(self, MNK_POSE1, MNK_APOSE1, MNK_EPOSE1)
$scene.spriteset.battler(self).pose = pose
end
end
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
# This class handles the party. It includes information on amount of gold
# and items. Refer to "$game_party" for the instance of this class.
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :party_size
end
#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
# This class brings together battle screen sprites. It's used within
# the Scene_Battle class.
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# * Change Enemy Viewport
#--------------------------------------------------------------------------
alias mnk_initialize initialize
def initialize
mnk_initialize
# Determine if RTAB system in use
$game_system.mnk_det_rtab_systm = true if @real_zoom != nil
# Reset Screentones
@enemy_sprites = []
for enemy in $game_troop.enemies.reverse
if SCREENTONE_ENEMY_MATCH
@enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
else
@enemy_sprites.push(Sprite_Battler.new(@viewport2, enemy))
end
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias mnk_update update
def update
# Set current number of battlers
mnkps = 4
mnkps = $game_party.party_size if $game_party.party_size != nil
# Added routine to load battlers during combat
unless $game_temp.mnk_battlers_reloaded
@actor_sprites = []
@viewport1.update
@viewport2.update
for i in 0...mnkps
if SCREENTONE_ACTOR_MATCH
@actor_sprites.push(Sprite_Battler.new(@viewport1))
else
@actor_sprites.push(Sprite_Battler.new(@viewport2))
end
end
$game_temp.mnk_battlers_reloaded = true
end
# Perform the original call
mnk_update
# 'Re-'Update actor sprite contents (corresponds with actor switching)
for i in 0...mnkps
@actor_sprites[i].battler = $game_party.actors[i]
end
end
#--------------------------------------------------------------------------
# * Find Sprite From Battler Handle
#--------------------------------------------------------------------------
def battler(handle)
for sprite in @actor_sprites + @enemy_sprites
return sprite if sprite.battler == handle
end
end
end
#==============================================================================
# ** Arrow_Base
#------------------------------------------------------------------------------
# This sprite is used as an arrow cursor for the battle screen. This class
# is used as a superclass for the Arrow_Enemy and Arrow_Actor classes.
#==============================================================================
class Arrow_Base
#--------------------------------------------------------------------------
# * Reposition Arrows
#--------------------------------------------------------------------------
alias mnk_initialize initialize
def initialize(viewport)
mnk_initialize(viewport)
self.ox = MNK_ARROW_X
self.oy = MNK_ARROW_Y
end
end
#===============================================================================
# ** Arrow_Actor
#===============================================================================
class Arrow_Actor
alias mnk_arrowactor_update update
def update
mnk_arrowactor_update
return unless @actor.is_a?(Game_Actor)
self.x = @actor.screen_x + @actor.display_x
self.y = @actor.screen_y + @actor.display_y
end
end
#===============================================================================
# ** Arrow_Enemy
#===============================================================================
class Arrow_Enemy
alias mnk_arrowenemy_update update
def update
mnk_arrowenemy_update
return unless @enemy.is_a?(Game_Enemy)
self.x = @enemy.screen_x + @enemy.display_x
self.y = @enemy.screen_y + @enemy.display_y
end
end
^I aliased the method Game_Enemy#transform accordingly, but it doesn't solve the problem like we thought it would. The battler graphic stays blank until they move in for an attack or perform another action.