Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Yanfly Monster Animation
FenrirWolf123
post Feb 23 2012, 03:18 PM
Post #1


Level 1
Group Icon

Group: Member
Posts: 6
Type: Developer
RM Skill: Beginner




I was seeing the demo of the yanfly scripts, and i found out that he uses a animation to make the loop of the monster (like the elemental).
I want do the same but i don't discovery what is the script, so i asking help here!
Go to the top of the page
 
+Quote Post
   
MinoanRoyal
post Feb 23 2012, 08:07 PM
Post #2


Level 1
Group Icon

Group: Member
Posts: 13
Type: Developer
RM Skill: Beginner




You will need all five parts of Battle Engine Melody for it to work. You can get them HERE, though i'm only putting the link here for those without the scripts.

If you look in lines 551 to 601 of Battle Engine Melody I, you will find the information you need for animated enemies.
Go to the top of the page
 
+Quote Post
   
FenrirWolf123
post Feb 24 2012, 03:56 AM
Post #3


Level 1
Group Icon

Group: Member
Posts: 6
Type: Developer
RM Skill: Beginner




Thanks!! I tried but appear an error in Engine IV, line 3500 "for key in $scene.enemychars"
Help me!
Go to the top of the page
 
+Quote Post
   
MinoanRoyal
post Feb 24 2012, 01:36 PM
Post #4


Level 1
Group Icon

Group: Member
Posts: 13
Type: Developer
RM Skill: Beginner




There is nothing like that in any of my scripts. DOuble check that error message for the script and line. Better yet, post EXACTLY what it says when it occurs.
Go to the top of the page
 
+Quote Post
   
FenrirWolf123
post Feb 25 2012, 03:05 AM
Post #5


Level 1
Group Icon

Group: Member
Posts: 6
Type: Developer
RM Skill: Beginner





this is what appear, but i don't get the 'each', I checked in the script but none of it...
Go to the top of the page
 
+Quote Post
   
Pillanious
post Feb 26 2012, 03:50 AM
Post #6


Level 8
Group Icon

Group: Revolutionary
Posts: 125
Type: Musician
RM Skill: Beginner




QUOTE (FenrirWolf123 @ Feb 25 2012, 06:05 AM) *

this is what appear, but i don't get the 'each', I checked in the script but none of it...


Can you post a copy of your script? Perhaps you made an edit thereto, and didn't realize it.
Go to the top of the page
 
+Quote Post
   
FenrirWolf123
post Feb 28 2012, 04:01 PM
Post #7


Level 1
Group Icon

Group: Member
Posts: 6
Type: Developer
RM Skill: Beginner




[spoiler="spoiler
"]#=========================================================================
======
#
# Yanfly Engine Melody - Battle Engine Melody - Part IV - Visuals
# Last Date Updated: 2010.05.01
# Level: Phantasm
#
# This section contains most of the visual aspects of Battle Engine Melody.
# Therefore, this section will include mostly sprite information, window data,
# and minor Game_Battler info and data that is used for visuals. This section
# is excluded from the core coding to allow easier access.
#
#===============================================================================
# Updates
# -----------------------------------------------------------------------------
# o 2010.02.12 to 2010.05.01 - Started and Finished Script.
#===============================================================================

module YEM
module DEFAULT_ACTIONS

#===========================================================================
# Default Attack Actions
# -------------------------------------------------------------------------
# These are the default attack actions for your enemies and weapons if they
# don't have any tags to overwrite their programming.
#===========================================================================
ATTACK_SETUP =[
["MESSAGE", ["COMMAND ATTACK"]],
["MOVE USER", ["FORWARD", "WAIT"]],
["EFFECT", ["USER", "WHITE FLASH"]],
] # Do not remove this.
ATTACK_WHOLE =[
["IMMORTAL", ["TARGETS", "TRUE"]],
] # Do not remove this.
ATTACK_TARGET =[
["MOVE USER", ["TARGET", "MIDDLE", "WAIT"]],
["AUTOMELODY", ["SINGLE SWING"]],
["AUTOMELODY", ["ATTACK FULL"]],
] # Do not remove this.
ATTACK_FOLLOW =[
["WAIT FOR MOVE"],
["IMMORTAL", ["TARGETS", "FALSE"]],
] # Do not remove this.
ATTACK_FINISH =[
["ICON DELETE", ["USER", "WEAPON"]],
["AUTOMELODY", ["RETURN ORIGIN"]],
["WAIT", [45, "SKIP"]],
] # Do not remove this.

#===========================================================================
# Default Magical Skill Actions
# -------------------------------------------------------------------------
# The following is the default setup for magical skills. This is applied to
# any skill that doesn't have Physical Attack checked in the database. If
# Physical Attack is checked, it will use a different action list setup.
#===========================================================================
MAGIC_SETUP =[
["MESSAGE", ["COMMAND SKILL"]],
["MOVE USER", ["FORWARD", "WAIT"]],
["AUTOMELODY", ["CAST ANIMATION"]],
] # Do not remove this.
MAGIC_WHOLE =[
["IMMORTAL", ["TARGETS", "TRUE"]],
["AUTOMELODY", ["SKILL FULL"]],
] # Do not remove this.
MAGIC_TARGET =[
] # Do not remove this.
MAGIC_FOLLOW =[
["WAIT FOR MOVE"],
["IMMORTAL", ["TARGETS", "FALSE"]],
] # Do not remove this.
MAGIC_FINISH =[
["COMMON EVENT", ["SKILL"]],
["AUTOMELODY", ["RETURN ORIGIN"]],
["WAIT", [45, "SKIP"]],
] # Do not remove this.

#===========================================================================
# Default Physical Skill Actions
# -------------------------------------------------------------------------
# The following is the default setup for physical skills. This is applied
# to any skill that has Physical Attack checked in the database. If Physical
# Attack is not checked, it will use a different action list setup.
#===========================================================================
PHYSICAL_SETUP =[
["MESSAGE", ["COMMAND SKILL"]],
["MOVE USER", ["FORWARD", "WAIT"]],
["CAST ANIMATION", ["WAIT"]],
] # Do not remove this.
PHYSICAL_WHOLE =[
] # Do not remove this.
PHYSICAL_TARGET =[
["IMMORTAL", ["TARGETS", "TRUE"]],
["ICON DELETE", ["USER", "WEAPON"]],
["MOVE USER", ["TARGET", "BODY", "WAIT"]],
["AUTOMELODY", ["SINGLE SWING"]],
["AUTOMELODY", ["SKILL FULL"]],
["IMMORTAL", ["TARGETS", "FALSE"]],
] # Do not remove this.
PHYSICAL_FOLLOW =[
["WAIT FOR MOVE"],
] # Do not remove this.
PHYSICAL_FINISH =[
["COMMON EVENT", ["SKILL"]],
["ICON DELETE", ["USER", "WEAPON"]],
["AUTOMELODY", ["RETURN ORIGIN"]],
["WAIT", [45, "SKIP"]],
] # Do not remove this.

#===========================================================================
# Default Item Actions
# -------------------------------------------------------------------------
# The following is the default setup for using items. This is applied to
# both physical and non-physical items.
#===========================================================================
ITEM_SETUP =[
["MESSAGE", ["COMMAND ITEM"]],
["MOVE USER", ["FORWARD", "WAIT"]],
["AUTOMELODY", ["ITEM FLOAT"]],
] # Do not remove this.
ITEM_WHOLE =[
["IMMORTAL", ["TARGETS", "TRUE"]],
["AUTOMELODY", ["ITEM FULL"]],
] # Do not remove this.
ITEM_TARGET =[
] # Do not remove this.
ITEM_FOLLOW =[
["WAIT FOR MOVE"],
["IMMORTAL", ["TARGETS", "FALSE"]],
] # Do not remove this.
ITEM_FINISH =[
["COMMON EVENT", ["ITEM"]],
["AUTOMELODY", ["RETURN ORIGIN"]],
["WAIT", [45, "SKIP"]],
] # Do not remove this.

#===========================================================================
# Guard Mini-Actions
# -------------------------------------------------------------------------
# This is the action command list for guarding. These are applied to every
# enemy and every shield's selection.
#===========================================================================
GUARD_ACTIONS =[
["MESSAGE", ["COMMAND GUARD"]],
["EFFECT", ["USER", "WHITE FLASH"]],
["WAIT", [45, "SKIP"]],
] # Do not remove this.

#===========================================================================
# Wait Mini-Actions
# -------------------------------------------------------------------------
# This is the action command when for waiting battlers. These aren't unique
# for each weapon or item or enemy. This is universal amongst all waits.
#===========================================================================
WAIT_ACTIONS =[
["MESSAGE", ["COMMAND WAIT"]],
["EFFECT", ["USER", "WHITE FLASH"]],
["WAIT", [45, "SKIP"]],
] # Do not remove this.

#===========================================================================
# Enemy Escape Mini-Actions
# -------------------------------------------------------------------------
# This is only applied to enemies who can escape. These aren't unique for
# each enemy. All escaping enemies will draw from the same action list.
#===========================================================================
ENEMY_ESCAPE_ACTIONS =[
["MESSAGE", ["COMMAND ESCAPE"]],
["SE", ["PLAY ESCAPE"]],
["TURN USER", ["BACKWARD"]],
["STANCE", ["USER", "RETURN"]],
["MOVE USER", ["BACKWARD", 32, 30]],
["WAIT", [30, "SKIP"]],
["ESCAPE EFFECT", ["USER"]],
["WAIT", [60, "SKIP"]],
] # Do not remove this.

#===========================================================================
# Actor Escape Mini-Actions
# -------------------------------------------------------------------------
# This is only applied to the party when an escape is successful. This will
# be applied to the whole party at once, but only non-dead members will
# visually run away.
#===========================================================================
ACTOR_ESCAPE_ACTIONS =[
["TURN PARTY", ["BACKWARD"]],
["STANCE", ["PARTY", "RETURN"]],
["MOVE PARTY", ["BACKWARD", 256, 60, "WAIT"]],
] # Do not remove this.

#===========================================================================
# Critical Mini-Actions
# -------------------------------------------------------------------------
# This is what will occur when a critical hit occurs. These actions aren't
# unique per character. All critical hits will play the same action.
#===========================================================================
CRITICAL_ACTIONS =[
# ["POPUP", ["TARGET", "POP_CRITICAL"]],
["MESSAGE", ["COMMAND CRITICAL"]],
] # Do not remove this.

#===========================================================================
# Miss Mini-Actions
# -------------------------------------------------------------------------
# This is what will occur when a miss event occurs. These actions aren't
# unique per character. All miss cases will play the same action.
#===========================================================================
MISS_ACTIONS =[
["STANCE", ["TARGET", "EVADE"]],
["POSE", ["TARGET", "EVADE"]],
["POPUP", ["TARGET", "POP_MISS"]],
["MESSAGE", ["COMMAND MISS"]],
["SE", ["PLAY MISS"]],
] # Do not remove this.

#===========================================================================
# Evade Mini-Actions
# -------------------------------------------------------------------------
# This is what will occur when a evasion occurs. These actions aren't
# unique per character. All evasion cases will play the same action.
#===========================================================================
EVADE_ACTIONS =[
["STANCE", ["TARGET", "EVADE"]],
["POSE", ["TARGET", "EVADE"]],
["POPUP", ["TARGET", "POP_EVADE"]],
["MESSAGE", ["COMMAND EVADE"]],
["SE", ["PLAY EVADE"]],
] # Do not remove this.

#===========================================================================
# Fail Mini-Actions
# -------------------------------------------------------------------------
# When skills fail or items fail, the fail actions will be called upon to
# produce a series of actions. All fail cases will play the same action.
#===========================================================================
FAIL_ACTIONS =[
["POPUP", ["TARGET", "POP_FAIL"]],
["MESSAGE", ["COMMAND FAIL"]],
] # Do not remove this.

#===========================================================================
# HP Damage Mini-Actions
# -------------------------------------------------------------------------
# The following sets the HP damage series. These are the actions played
# when a target takes 0 HP damage, receives healing, or the takes damage.
# Absorption is taken into consideration for healing and damage.
#===========================================================================
HP_DAMAGE_NONE =[
["POPUP", ["TARGET", "HP_NONE"]],
["MESSAGE", ["COMMAND HP DAMAGE", "NONE"]],
] # Do not remove this.
HP_DAMAGE_HEAL =[
["POPUP", ["TARGET", "HP_HEAL"]],
["MESSAGE", ["COMMAND HP DAMAGE", "HEAL"]],
["SE", ["PLAY RECOVERY"]],
] # Do not remove this.
HP_DAMAGE_DMG =[
["STANCE", ["TARGET", "DAMAGE"]],
["POSE", ["TARGET", "DAMAGE"]],
["POPUP", ["TARGET", "HP_DMG"]],
["MESSAGE", ["COMMAND HP DAMAGE", "DAMAGE"]],
["SE", ["PLAY ACTOR DAMAGE", "if target.actor?"]],
["SE", ["PLAY ENEMY DAMAGE", "if target.enemy?"]],
] # Do not remove this.

#===========================================================================
# MP Damage Mini-Actions
# -------------------------------------------------------------------------
# The following sets the MP damage series. These are the actions played
# when a target takes 0 MP damage, receives healing, or the takes damage.
# Absorption is taken into consideration for healing and damage.
#===========================================================================
MP_DAMAGE_HEAL =[
["POPUP", ["TARGET", "MP_HEAL"]],
["MESSAGE", ["COMMAND MP DAMAGE", "HEAL"]],
["SE", ["PLAY RECOVERY"]],
] # Do not remove this.
MP_DAMAGE_DMG =[
["POPUP", ["TARGET", "MP_DMG"]],
["MESSAGE", ["COMMAND MP DAMAGE", "DAMAGE"]],
["SE", ["PLAY ACTOR DAMAGE", "if target.actor?"]],
["SE", ["PLAY ENEMY DAMAGE", "if target.enemy?"]],
] # Do not remove this.

#===========================================================================
# State Change Mini-Actions
# -------------------------------------------------------------------------
# The following sets the state change series. These actions are played
# whenever a target receives a state change through an executed action.
#===========================================================================
ADD_STATE =[
["POPUP", ["TARGET", "POP_ADDSTATE"]],
["MESSAGE", ["COMMAND STATES", "ADDED"]],
] # Do not remove this.
REM_STATE =[
["POPUP", ["TARGET", "POP_REMSTATE"]],
["MESSAGE", ["COMMAND STATES", "REMOVE"]],
] # Do not remove this.
DUR_STATE =[
["POPUP", ["TARGET", "POP_DURSTATE"]],
["MESSAGE", ["COMMAND STATES", "REMAINED"]],
] # Do not remove this.

end # DEFAULT_ACTIONS
end # YEM

#===============================================================================
# Editting anything past this point may potentially result in causing computer
# damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
# Therefore, edit at your own risk.
#===============================================================================

#===============================================================================
# module Icon
#===============================================================================

module Icon

#--------------------------------------------------------------------------
# self.element
#--------------------------------------------------------------------------
def self.element(element_id)
icon = YEM::BATTLE_ENGINE::ELEMENT_ICONS[element_id]
return (icon == nil) ? 0 : icon
end

#--------------------------------------------------------------------------
# self.stat
#--------------------------------------------------------------------------
def self.stat(actor, item)
limit = actor.parameter_limit
icon = 0
case item
when :atk
if actor.atk > actor.base_atk
icon = Icon.stat_up(item)
elsif actor.atk < actor.base_atk and actor.atk != limit
icon = Icon.stat_dn(item)
end

when :def
if actor.def > actor.base_def
icon = Icon.stat_up(item)
elsif actor.def < actor.base_def and actor.def != limit
icon = Icon.stat_dn(item)
end

when :spi
if actor.spi > actor.base_spi
icon = Icon.stat_up(item)
elsif actor.spi < actor.base_spi and actor.spi != limit
icon = Icon.stat_dn(item)
end

when :res
return icon unless $imported["RES Stat"]
if actor.res > actor.base_res
icon = Icon.stat_up(item)
elsif actor.res < actor.base_res and actor.res != limit
icon = Icon.stat_dn(item)
end

when :dex
return icon unless $imported["DEX Stat"]
if actor.dex > actor.base_dex
icon = Icon.stat_up(item)
elsif actor.dex < actor.base_dex and actor.dex != limit
icon = Icon.stat_dn(item)
end

when :agi
if actor.agi > actor.base_agi
icon = Icon.stat_up(item)
elsif actor.agi < actor.base_agi and actor.agi != limit
icon = Icon.stat_dn(item)
end
end
return icon
end

#--------------------------------------------------------------------------
# self.stat_up
#--------------------------------------------------------------------------
def self.stat_up(item = nil)
return YEM::BATTLE_ENGINE::STAT_ICONS[:stat_up]
end

#--------------------------------------------------------------------------
# self.stat_dn
#--------------------------------------------------------------------------
def self.stat_dn(item = nil)
return YEM::BATTLE_ENGINE::STAT_ICONS[:stat_dn]
end

#--------------------------------------------------------------------------
# self.normal_state
#--------------------------------------------------------------------------
def self.normal_state
return YEM::BATTLE_ENGINE::STAT_ICONS[:normal]
end

#--------------------------------------------------------------------------
# self.mp_cost
#--------------------------------------------------------------------------
def self.mp_cost
return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:mp_icon]
end

#--------------------------------------------------------------------------
# self.hp_cost
#--------------------------------------------------------------------------
def self.hp_cost
return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:hp_icon]
end

#--------------------------------------------------------------------------
# self.gold_cost
#--------------------------------------------------------------------------
def self.gold_cost
return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:gold_icon]
end

#--------------------------------------------------------------------------
# self.rage_cost
#--------------------------------------------------------------------------
def self.rage_cost
return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:rage_icon]
end

#--------------------------------------------------------------------------
# self.cooldown
#--------------------------------------------------------------------------
def self.cooldown
return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:cooldown_icon]
end

#--------------------------------------------------------------------------
# self.limited_use
#--------------------------------------------------------------------------
def self.limited_use
return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:limited_icon]
end

end # Icon

#===============================================================================
# Game_Battler
#===============================================================================

class Game_Battler

#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :battler_animation_id
attr_accessor :battler_icon
attr_accessor :pseudo_ani_id
attr_accessor :popup_array
attr_accessor :sub_animation_id
attr_accessor :vanish_case

#--------------------------------------------------------------------------
# alias method: clear_sprite_effects
#--------------------------------------------------------------------------
alias clear_sprite_effects_bem clear_sprite_effects unless $@
def clear_sprite_effects
clear_sprite_effects_bem
@pseudo_ani_id = 0
end

#--------------------------------------------------------------------------
# new method: state_animation_zoom
#--------------------------------------------------------------------------
def state_animation_zoom; return 100; end

#--------------------------------------------------------------------------
# new method: reload_state_animation
#--------------------------------------------------------------------------
def reload_state_animation
return unless $scene.is_a?(Scene_Battle)
@state_animation_id = 0
for state in states
next unless state.state_ani > 0
@state_animation_id = state.state_ani
break
end
end

#--------------------------------------------------------------------------
# new method: create_popup
#--------------------------------------------------------------------------
def create_popup(value, rules = "DEFAULT", flags = [])
return unless $scene.is_a?(Scene_Battle)
if flags.include?("critical") and $scene.ptb?
bonus = YEM::BATTLE_ENGINE::PTB_RULES[:regain_critical]
action.opponents_unit.gain_bonus($scene.active_battler, bonus)
end
array = [value, rules, flags]
@popup_array = [] if @popup_array == nil
@popup_array.push(array)
end

#--------------------------------------------------------------------------
# new method: white_flash=
#--------------------------------------------------------------------------
def white_flash=(value)
return unless exist?
@white_flash = value
end

#--------------------------------------------------------------------------
# new methods: bitmap_height and bitmap_width
#--------------------------------------------------------------------------
def bitmap_height; return Integer(spriteset.height * zoom); end
def bitmap_width; return Integer(spriteset.width * zoom); end

#--------------------------------------------------------------------------
# new method: spriteset
#--------------------------------------------------------------------------
def spriteset
return $scene.spriteset.enemy_sprites.reverse[self.index]
end

#--------------------------------------------------------------------------
# new method: attack_icon
#--------------------------------------------------------------------------
def attack_icon
return YEM::BATTLE_ENGINE::ICON_MESSAGE[:atk_icon]
end

#--------------------------------------------------------------------------
# new method: guard_icon
#--------------------------------------------------------------------------
def guard_icon
return YEM::BATTLE_ENGINE::ICON_MESSAGE[:grd_icon]
end

#--------------------------------------------------------------------------
# new method: sprite_movable?
#--------------------------------------------------------------------------
def sprite_movable?
return false if !exist?
return true
end

#--------------------------------------------------------------------------
# new method: mirror?
#--------------------------------------------------------------------------
def mirror?; return false; end

#--------------------------------------------------------------------------
# new method: zoom
#--------------------------------------------------------------------------
def zoom; return 1.0; end

#--------------------------------------------------------------------------
# use_battler_animations?
#--------------------------------------------------------------------------
def use_battler_animations?; return false; end

#--------------------------------------------------------------------------
# battler_animation_stance
#--------------------------------------------------------------------------
def battler_animation_stance(string); return; end

end # Game_Battler

#===============================================================================
# Game_Actor
#===============================================================================

class Game_Actor < Game_Battler

#--------------------------------------------------------------------------
# quick methods: use_sprite? screen_z battler_name battler_hue
#--------------------------------------------------------------------------
def use_sprite?; return true; end
def battler_name; return ""; end
def battler_hue; return 0; end

#--------------------------------------------------------------------------
# alias method: atk_animation_id
#--------------------------------------------------------------------------
alias atk_animation_id_bem atk_animation_id unless $@
def atk_animation_id
return @cache_atk_animation[1] if @cache_atk_animation[1] != nil
@cache_atk_animation[1] = atk_animation_id_bem
for state in states
next unless state.attack_animation > 0
@cache_atk_animation[1] = state.attack_animation
break
end
return @cache_atk_animation[1]
end

#--------------------------------------------------------------------------
# alias method: atk_animation_id2
#--------------------------------------------------------------------------
alias atk_animation_id2_bem atk_animation_id2 unless $@
def atk_animation_id2
return @cache_atk_animation[2] if @cache_atk_animation[2] != nil
@cache_atk_animation[2] = atk_animation_id2_bem
return @cache_atk_animation[2] if @cache_atk_animation[2] == 0
for state in states
next unless state.attack_animation > 0
@cache_atk_animation[2] = state.attack_animation
break
end
return @cache_atk_animation[2]
end

#--------------------------------------------------------------------------
# new method: state_animation_zoom
#--------------------------------------------------------------------------
def state_animation_zoom
return YEM::BATTLE_ENGINE::STATE_SETTINGS[:actor_ani_zoom]
end

#--------------------------------------------------------------------------
# new method: screen_x
#--------------------------------------------------------------------------
def screen_x
return 0 unless $scene.is_a?(Scene_Battle)
if $scene.emptyview? or character == nil
calc = Graphics.width - 128 - 32
max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
maximum = [$game_party.members.size, max_members].max
calc /= maximum
width = calc
n = index * width + width/2 + 16
n += 128
n -= $scene.info_viewport.ox if $scene.info_viewport != nil
return n
end
return character.screen_x
end

#--------------------------------------------------------------------------
# new method: screen_x=
#--------------------------------------------------------------------------
def screen_x=(value); character.screen_x = value; end

#--------------------------------------------------------------------------
# new method: origin_x
#--------------------------------------------------------------------------
def origin_x
return 0 unless $scene.is_a?(Scene_Battle)
return screen_x if $scene.emptyview?
return character.origin_x
end

#--------------------------------------------------------------------------
# new method: screen_y
#--------------------------------------------------------------------------
def screen_y
return 0 unless $scene.is_a?(Scene_Battle)
if $scene.emptyview? or character == nil
n = Graphics.height - 128
return n
end
return character.screen_y
end

#--------------------------------------------------------------------------
# new method: screen_y=
#--------------------------------------------------------------------------
def screen_y=(value); character.screen_y = value; end

#--------------------------------------------------------------------------
# new method: origin_y
#--------------------------------------------------------------------------
def origin_y
return 0 unless $scene.is_a?(Scene_Battle)
return screen_y if $scene.emptyview?
return character.origin_y
end

#--------------------------------------------------------------------------
# new method: screen_z
#--------------------------------------------------------------------------
def screen_z
return 100 unless $scene.is_a?(Scene_Battle)
return 100 if $scene.emptyview? or character == nil
return character.screen_z + character.screen_y
end

#--------------------------------------------------------------------------
# new method: screen_z=
#--------------------------------------------------------------------------
def screen_z=(value); character.screen_z = value; end

#--------------------------------------------------------------------------
# new method: spriteset
#--------------------------------------------------------------------------
def spriteset
return $scene.spriteset.actor_sprites[self.index]
end

#--------------------------------------------------------------------------
# new method: character
#--------------------------------------------------------------------------
def character
return nil unless $scene.is_a?(Scene_Battle)
return $scene.characters[self.index]
end

#--------------------------------------------------------------------------
# new method: attack_icon
#--------------------------------------------------------------------------
def attack_icon
return super if weapons.compact == []
return weapon1_icon
end

#--------------------------------------------------------------------------
# new method: guard_icon
#--------------------------------------------------------------------------
def guard_icon
for armor in armors.compact
next unless armor.kind == 0
return armor.icon_index
end
return super
end

#--------------------------------------------------------------------------
# new method: battler_icon
#--------------------------------------------------------------------------
def battler_icon
if YEM::BATTLE_ENGINE::BATTLER_ACTOR_ICONS.include?(@actor_id)
return YEM::BATTLE_ENGINE::BATTLER_ACTOR_ICONS[@actor_id]
elsif YEM::BATTLE_ENGINE::BATTLER_CLASS_ICONS.include?(@class_id)
return YEM::BATTLE_ENGINE::BATTLER_CLASS_ICONS[@class_id]
end
return YEM::BATTLE_ENGINE::DEFAULT_ACTOR_ICON
end

#--------------------------------------------------------------------------
# new method: weapon1_icon
#--------------------------------------------------------------------------
def weapon1_icon
return @cache_weapon_icon[1] if @cache_weapon_icon[1] != nil
icon = 0
icon = weapons[0].icon_index if weapons.compact.size > 0
for state in states
next unless state.weapon_icon > 0
icon = state.weapon_icon
break
end
@cache_weapon_icon[1] = icon
return @cache_weapon_icon[1]
end

#--------------------------------------------------------------------------
# new method: weapon2_icon
#--------------------------------------------------------------------------
def weapon2_icon
return @cache_weapon_icon[2] if @cache_weapon_icon[2] != nil
icon = 0
icon = weapons[1].icon_index if weapons.compact.size > 1
for state in states
next unless state.weapon_icon > 0
icon = state.weapon_icon
break
end
@cache_weapon_icon[2] = icon
return @cache_weapon_icon[2]
end

#--------------------------------------------------------------------------
# use_battler_animations?
#--------------------------------------------------------------------------
def use_battler_animations?
array = [@character_name, @character_index]
return YEM::BATTLE_ENGINE::ANIMATION_BATTLER_ACTORS.include?(array)
end

#--------------------------------------------------------------------------
# battler_animation_stance
#--------------------------------------------------------------------------
def battler_animation_stance(string)
array = [@character_name, @character_index]
hash = YEM::BATTLE_ENGINE::ANIMATION_BATTLER_ACTORS[array]
return unless hash.include?(string)
@battler_animation_id = hash[string]
end

end # Game_Actor

#===============================================================================
# Game_Enemy
#===============================================================================

class Game_Enemy < Game_Battler

#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :direction
attr_accessor :origin_x
attr_accessor :origin_y

#--------------------------------------------------------------------------
# new method: screen_x
#--------------------------------------------------------------------------
def screen_x
return character == nil ? @screen_x : character.screen_x
end

#--------------------------------------------------------------------------
# new method: screen_x=
#--------------------------------------------------------------------------
def screen_x=(value)
@screen_x = value if character == nil
character.screen_x = value if character != nil
end

#--------------------------------------------------------------------------
# new method: screen_y
#--------------------------------------------------------------------------
def screen_y
return character == nil ? @screen_y : character.screen_y
end

#--------------------------------------------------------------------------
# new method: screen_y=
#--------------------------------------------------------------------------
def screen_y=(value)
@screen_y = value if character == nil
character.screen_y = value if character != nil
end

#--------------------------------------------------------------------------
# alias method: screen_z
#--------------------------------------------------------------------------
alias screen_z_enemy screen_z unless $@
def screen_z
return @battle_screen_z if @battle_screen_z != nil
return screen_z_enemy + self.screen_y
end

#--------------------------------------------------------------------------
# new method: screen_z=
#--------------------------------------------------------------------------
def screen_z=(value)
@battle_screen_z = value if character == nil
character.screen_z = value if character != nil
end

#--------------------------------------------------------------------------
# new method: character
#--------------------------------------------------------------------------
def character
if enemy.character_name == "" or !$scene.is_a?(Scene_Battle)
return nil
else
return $scene.enemychars[self]
end
end

#--------------------------------------------------------------------------
# new method: character_name
#--------------------------------------------------------------------------
def character_name; return enemy.character_name; end

#--------------------------------------------------------------------------
# new method: character_index
#--------------------------------------------------------------------------
def character_index; return enemy.character_index; end

#--------------------------------------------------------------------------
# new method: screen_z=
#--------------------------------------------------------------------------
def screen_z=(value); @battle_screen_z = value; end

#--------------------------------------------------------------------------
# new method: state_animation_zoom
#--------------------------------------------------------------------------
def state_animation_zoom; return enemy.state_zoom; end

#--------------------------------------------------------------------------
# new method: atk_animation_id
#--------------------------------------------------------------------------
def atk_animation_id
return @cache_atk_animation[1] if @cache_atk_animation[1] != nil
@cache_atk_animation[1] = enemy.attack_animation
for state in states
next unless state.attack_animation > 0
@cache_atk_animation[1] = state.attack_animation
break
end
return @cache_atk_animation[1]
end

#--------------------------------------------------------------------------
# new method: attack_icon
#--------------------------------------------------------------------------
def attack_icon
return enemy.weapons[0].icon_index if enemy.weapons.compact.size > 0
return super
end

#--------------------------------------------------------------------------
# new method: weapon1_icon
#--------------------------------------------------------------------------
def weapon1_icon
return enemy.weapons[0].icon_index if enemy.weapons.compact.size > 0
return 0
end

#--------------------------------------------------------------------------
# new method: weapon2_icon
#--------------------------------------------------------------------------
def weapon2_icon
return enemy.weapons[1].icon_index if enemy.weapons.compact.size > 1
return 0
end

#--------------------------------------------------------------------------
# new method: guard_icon
#--------------------------------------------------------------------------
def guard_icon
if enemy.shield != nil and enemy.shield.icon_index != 0
return enemy.shield.icon_index
end
return super
end

#--------------------------------------------------------------------------
# new method: battler_icon
#--------------------------------------------------------------------------
def battler_icon; return enemy.enemy_icon; end

#--------------------------------------------------------------------------
# new method: mirror?
#--------------------------------------------------------------------------
def mirror?
return false unless $scene.is_a?(Scene_Battle)
case $scene.view_type
when 0; return enemy.view_mirror[:empty]
when 1; return enemy.view_mirror[:front]
when 2; return enemy.view_mirror[:side]
when 3; return enemy.view_mirror[:angle]
end
return false
end

#--------------------------------------------------------------------------
# new method: zoom
#--------------------------------------------------------------------------
def zoom
return false unless $scene.is_a?(Scene_Battle)
case $scene.view_type
when 0; return enemy.view_zoom[:empty]
when 1; return enemy.view_zoom[:front]
when 2; return enemy.view_zoom[:side]
when 3; return enemy.view_zoom[:angle]
end
return false
end

#--------------------------------------------------------------------------
# use_battler_animations?
#--------------------------------------------------------------------------
def use_battler_animations?
return enemy.animation_stance.include?("IDLE")
end

#--------------------------------------------------------------------------
# battler_animation_stance
#--------------------------------------------------------------------------
def battler_animation_stance(string)
return unless enemy.animation_stance.include?(string)
@battler_animation_id = enemy.animation_stance[string]
end

#--------------------------------------------------------------------------
# new method: sprite_movable?
#--------------------------------------------------------------------------
def sprite_movable?
return false if enemy.unmoving
return super
end

#--------------------------------------------------------------------------
# new method: weapons
#--------------------------------------------------------------------------
def weapons; return enemy.weapons; end

#--------------------------------------------------------------------------
# new method: armor1_id
#--------------------------------------------------------------------------
def armor1_id; return enemy.shield == nil ? 0 : enemy.shield.id; end

end # Game_Enemy

#===============================================================================
# Game_Troop
#===============================================================================

class Game_Troop < Game_Unit

#--------------------------------------------------------------------------
# overwrite method: setup
#--------------------------------------------------------------------------
def setup(troop_id)
clear
@troop_id = troop_id
@enemies = []
case $game_variables[YEM::BATTLE_ENGINE::VIEW_TYPE_VARIABLE]
when 1; type = :front
when 2; type = :side
when 3; type = :angle
else type = :empty
end
offsets = YEM::BATTLE_ENGINE::AUTO_POSITION_ADJUSTMENTS[type]
offsets = [0,0,1.0,0.0,0.0,1.0] if !YEM::BATTLE_ENGINE::AUTO_ENEMY_POSITIONS
for member in troop.members
next if $data_enemies[member.enemy_id] == nil
enemy = Game_Enemy.new(@enemies.size, member.enemy_id)
enemy.hidden = member.hidden
enemy.immortal = member.immortal
#---
result_x = (member.x * offsets[2]) + (member.y * offsets[4])
result_x += offsets[0] # Offset X
#---
result_y = (member.x * offsets[3]) + (member.y * offsets[5])
result_y += offsets[1] # Offset Y
#---
enemy.screen_x = Integer(result_x)
enemy.screen_y = Integer(result_y)
enemy.origin_x = enemy.screen_x
enemy.origin_y = enemy.screen_y
@enemies.push(enemy)
end
make_unique_names
end

end # Game_Troop

#===============================================================================
# Game_Map
#===============================================================================

class Game_Map

#--------------------------------------------------------------------------
# alias method: loop_horizontal?
#--------------------------------------------------------------------------
alias loop_horizontal_bem loop_horizontal? unless $@
def loop_horizontal?
return false if $game_temp.in_battle
return loop_horizontal_bem
end

#--------------------------------------------------------------------------
# alias method: loop_vertical?
#--------------------------------------------------------------------------
alias loop_vertical_bem loop_vertical? unless $@
def loop_vertical?
return false if $game_temp.in_battle
return loop_vertical_bem
end

end # Game_Map

#===============================================================================
# Game_Character
#===============================================================================

class Game_Character

#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :mirror
attr_accessor :opacity
attr_accessor :origin_x
attr_accessor :origin_y
attr_accessor :step_anime

#--------------------------------------------------------------------------
# alias method: screen_x
#--------------------------------------------------------------------------
alias screen_x_character_bem screen_x unless $@
def screen_x
return @battle_screen_x if @battle_screen_x != nil
return screen_x_character_bem
end

#--------------------------------------------------------------------------
# new method: screen_x=
#--------------------------------------------------------------------------
def screen_x=(value); @battle_screen_x = value; end

#--------------------------------------------------------------------------
# alias method: screen_y
#--------------------------------------------------------------------------
alias screen_y_character_bem screen_y unless $@
def screen_y
return @battle_screen_y if @battle_screen_y != nil
return screen_y_character_bem
end

#--------------------------------------------------------------------------
# new method: screen_y=
#--------------------------------------------------------------------------
def screen_y=(value); @battle_screen_y = value; end

#--------------------------------------------------------------------------
# alias method: screen_z
#--------------------------------------------------------------------------
alias screen_z_character_bem screen_z unless $@
def screen_z
return @battle_screen_z if @battle_screen_z != nil
return screen_z_character_bem
end

#--------------------------------------------------------------------------
# new method: screen_z=
#--------------------------------------------------------------------------
def screen_z=(value); @battle_screen_z = value; end

end # Game_Character

#===============================================================================
# Sprite_Base
#===============================================================================

class Sprite_Base < Sprite

#--------------------------------------------------------------------------
# constants
#--------------------------------------------------------------------------
RATE = $imported["CoreFixesUpgradesMelody"] ? YEM::FIXES::ANIMATION_RATE : 4
@@sub_animations = []

#--------------------------------------------------------------------------
# alias method: initialize
#--------------------------------------------------------------------------
alias initialize_sprite_base_bem initialize unless $@
def initialize(viewport = nil)
initialize_sprite_base_bem(viewport)
@no_effect = false
@banimation_duration = 0
@sub_animation_duration = 0
end

#--------------------------------------------------------------------------
# alias method: dispose
#--------------------------------------------------------------------------
alias dispose_sprite_base_bem dispose unless $@
def dispose
dispose_sprite_base_bem
dispose_sub_animation
end

#--------------------------------------------------------------------------
# alias method: update
#--------------------------------------------------------------------------
alias update_sprite_base_bem update unless $@
def update
update_sprite_base_bem
update_sub_animation if @sub_animation != nil
@@sub_animations.clear
end

#--------------------------------------------------------------------------
# alias method: start_animation
#--------------------------------------------------------------------------
alias start_animation_bem start_animation unless $@
def start_animation(animation, mirror = false)
@no_effect = false
start_animation_bem(animation, mirror)
end

#--------------------------------------------------------------------------
# new method: start_pseudo_ani
#--------------------------------------------------------------------------
def start_pseudo_ani(animation, mirror = false)
dispose_animation
@animation = animation
return if @animation == nil
@no_effect = true
@animation_mirror = mirror
@animation_duration = @animation.frame_max * RATE + 1
@animation_sprites = []
end

#--------------------------------------------------------------------------
# overwrite method: animation_process_timing
#--------------------------------------------------------------------------
def animation_process_timing(timing)
timing.se.play unless @no_effect
case timing.flash_scope
when 1
if @battler_animation == nil
self.flash(timing.flash_color, timing.flash_duration * RATE)
end
battler_animation_flash(timing) if @battler_animation != nil
when 2
return if @no_effect
if viewport != nil
viewport.flash(timing.flash_color, timing.flash_duration * RATE)
end
when 3
self.flash(nil, timing.flash_duration * RATE)
battler_animation_flash(timing) if @battler_animation != nil
end
end

#--------------------------------------------------------------------------
# new method: start_sub_animation
#--------------------------------------------------------------------------
def start_sub_animation(animation, mirror = false)
dispose_sub_animation
@sub_animation = animation
return if @sub_animation == nil
@sub_animation_mirror = mirror
@sub_animation_duration = @sub_animation.frame_max * RATE + 1
load_sub_animation_bitmap
@sub_animation_sprites = []
if @sub_animation.position != 3 or not @@sub_animations.include?(animation)
if @use_sprite
for i in 0..15
sprite = ::Sprite.new(self.viewport)
sprite.visible = false
@sub_animation_sprites.push(sprite)
end
unless @@sub_animations.include?(animation)
@@sub_animations.push(animation)
end
end
end
if @sub_animation.position == 3
if viewport == nil
@sub_animation_ox = Graphics.width / 2
@sub_animation_oy = Graphics.height / 2
else
@sub_animation_ox = viewport.rect.width / 2
@sub_animation_oy = viewport.rect.height / 2
end
else
@sub_animation_ox = x - ox + width / 2
@sub_animation_oy = y - oy + height / 2
if @sub_animation.position == 0
@sub_animation_oy -= height / 2
elsif @sub_animation.position == 2
@sub_animation_oy += height / 2
end
end
end

#--------------------------------------------------------------------------
# new method: load_sub_animation_bitmap
#--------------------------------------------------------------------------
def load_sub_animation_bitmap
animation1_name = @sub_animation.animation1_name
animation1_hue = @sub_animation.animation1_hue
animation2_name = @sub_animation.animation2_name
animation2_hue = @sub_animation.animation2_hue
@sub_animation_bitmap1 = Cache.animation(animation1_name, animation1_hue)
@sub_animation_bitmap2 = Cache.animation(animation2_name, animation2_hue)
if @@_reference_count.include?(@sub_animation_bitmap1)
@@_reference_count[@sub_animation_bitmap1] += 1
else
@@_reference_count[@sub_animation_bitmap1] = 1
end
if @@_reference_count.include?(@sub_animation_bitmap2)
@@_reference_count[@sub_animation_bitmap2] += 1
else
@@_reference_count[@sub_animation_bitmap2] = 1
end
Graphics.frame_reset
end

#--------------------------------------------------------------------------
# new method: dispose_sub_animation
#--------------------------------------------------------------------------
def dispose_sub_animation
if @sub_animation_bitmap1 != nil
@@_reference_count[@sub_animation_bitmap1] -= 1
if @@_reference_count[@sub_animation_bitmap1] == 0
@sub_animation_bitmap1.dispose
end
end
if @sub_animation_bitmap2 != nil
@@_reference_count[@sub_animation_bitmap2] -= 1
if @@_reference_count[@sub_animation_bitmap2] == 0
@sub_animation_bitmap2.dispose
end
end
if @sub_animation_sprites != nil
for sprite in @sub_animation_sprites
sprite.dispose
end
@sub_animation_sprites = nil
@sub_animation = nil
end
@sub_animation_bitmap1 = nil
@sub_animation_bitmap2 = nil
end

#--------------------------------------------------------------------------
# new method: update_sub_animation
#--------------------------------------------------------------------------
def update_sub_animation
@sub_animation_duration -= 1
return unless @sub_animation_duration % RATE == 0
if @sub_animation_duration > 0
frame_index = @sub_animation.frame_max
frame_index -= (@sub_animation_duration+RATE-1)/RATE
sub_animation_set_sprites(@sub_animation.frames[frame_index])
for timing in @sub_animation.timings
next unless timing.frame == frame_index
animation_process_timing(timing)
end
return
end
dispose_sub_animation
end

#--------------------------------------------------------------------------
# new method: sub_animation_set_sprites
#--------------------------------------------------------------------------
def sub_animation_set_sprites(frame)
cell_data = frame.cell_data
for i in 0..15
sprite = @sub_animation_sprites[i]
next if sprite == nil
pattern = cell_data[i, 0]
if pattern == nil or pattern == -1
sprite.visible = false
next
end
if pattern < 100
sprite.bitmap = @sub_animation_bitmap1
else
sprite.bitmap = @sub_animation_bitmap2
end
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192,
pattern % 100 / 5 * 192, 192, 192)
if @sub_animation_mirror
sprite.x = @sub_animation_ox - cell_data[i, 1]
sprite.y = @sub_animation_oy + cell_data[i, 2]
sprite.angle = (360 - cell_data[i, 4])
sprite.mirror = (cell_data[i, 5] == 0)
else
sprite.x = @sub_animation_ox + cell_data[i, 1]
sprite.y = @sub_animation_oy + cell_data[i, 2]
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
end
sprite.z = self.z + 250 + i
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
sprite.blend_type = cell_data[i, 7]
end
end

end # Sprite_Base

#===============================================================================
# Sprite_Battler
#===============================================================================

class Sprite_Battler < Sprite_Base

#--------------------------------------------------------------------------
# constants
#--------------------------------------------------------------------------
RATE = $imported["CoreFixesUpgradesMelody"] ? YEM::FIXES::ANIMATION_RATE : 4
@@battler_animations = []
@@state_animations = []

#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :character_death_duration
attr_accessor :character_sprite
attr_accessor :icon_weapon1
attr_accessor :icon_weapon2
attr_accessor :icon_sprites
attr_accessor :icon_shield
attr_accessor :icon_item
attr_accessor :icon_last
attr_accessor :jump_duration
attr_accessor :move_to_x
attr_accessor :move_to_y
attr_accessor :popups

#--------------------------------------------------------------------------
# alias method: initialize
#--------------------------------------------------------------------------
alias initialize_sprite_battler_bem initialize unless $@
def initialize(viewport, battler = nil)
initialize_sprite_battler_bem(viewport, battler)
@popups = []
@popup_flags = []
@state_animation_duration = 0
return if @battler == nil
self.mirror = @battler.mirror?
self.zoom_x = @battler.zoom
self.zoom_y = @battler.zoom
end

#--------------------------------------------------------------------------
# alias method: dispose
#--------------------------------------------------------------------------
alias dispose_sprite_battler_bem dispose
def dispose
@character_sprite.dispose if @character_sprite != nil
dispose_popups
dispose_sprite_battler_bem
dispose_state_animation
dispose_battler_animation
return if @icon_sprites == nil
for icon_sprite in @icon_sprites; icon_sprite.dispose; end
end

#--------------------------------------------------------------------------
# alias method: update
#--------------------------------------------------------------------------
alias update_sprite_battler_bem update unless $@
def update
update_sprite_battler_bem
update_battler_animation
update_state_animation
return if @battler == nil
update_popups
update_jump
update_move_to
update_character_sprite
update_character_death
update_icon_sprites
end

#--------------------------------------------------------------------------
# alias method: setup_new_effect
#--------------------------------------------------------------------------
alias setup_new_effect_bem setup_new_effect unless $@
def setup_new_effect
start_character_death if @battler.collapse
setup_new_effect_bem unless anti_whiten
#---
if @battler.vanish_case == 1
@battler.vanish_case = nil
@effect_type = DISAPPEAR
@effect_duration = 32
elsif @battler.vanish_case == 2
@battler.vanish_case = nil
@effect_type = APPEAR
@effect_duration = 16
elsif @battler.vanish_case == 3
@battler.vanish_case = nil
self.opacity = 0
@battler.character.opacity = 0 if @character_sprite != nil
elsif @battler.vanish_case == 4
@battler.vanish_case = nil
self.opacity = 255
@battler.character.opacity = 255 if @character_sprite != nil
end
#---
if @battler.popup_array != [] and @battler.popup_array != nil
array = @battler.popup_array.shift
create_popup(array[0], array[1], array[2])
end
#---
if @battler.pseudo_ani_id != 0 and @battler.pseudo_ani_id != nil
animation = $data_animations[@battler.pseudo_ani_id]
start_pseudo_ani(animation)
@battler.pseudo_ani_id = 0
end
#---
if @battler.state_animation_id != nil
if @battler.state_animation_id == 0
dispose_state_animation
else
start_state_animation($data_animations[@battler.state_animation_id])
end
end
#---
if @battler.battler_animation_id != nil
start_battler_animation($data_animations[@battler.battler_animation_id])
end
#---
if @battler.sub_animation_id != nil
start_sub_animation($data_animations[@battler.sub_animation_id])
@battler.sub_animation_id = nil
end
end

#--------------------------------------------------------------------------
# alias method: update_appear
#--------------------------------------------------------------------------
alias update_appear_bem update_appear unless $@
def update_appear
update_appear_bem
return if @character_sprite == nil
@battler.character.opacity = (16 - @effect_duration) * 16
end

#--------------------------------------------------------------------------
# alias method: update_disappear
#--------------------------------------------------------------------------
alias update_disappear_bem update_disappear unless $@
def update_disappear
update_disappear_bem
return if @character_sprite == nil
@battler.character.opacity = 256 - (32 - @effect_duration) * 10
end

#--------------------------------------------------------------------------
# alias method: update_collapse
#--------------------------------------------------------------------------
alias update_collapse_bem update_collapse unless $@
def update_collapse
if @battler.actor?
@effect_duration = 0
return
end
update_collapse_bem
end

#--------------------------------------------------------------------------
# new method: anti_whiten
#--------------------------------------------------------------------------
def anti_whiten
if @battler.white_flash and @battler.state?(1)
if @battler.collapse
@effect_type = COLLAPSE
@effect_duration = 48
@battler.collapse = false
@battler_visible = false
end
return true
end
return false
end

#--------------------------------------------------------------------------
# new method: start_animation
#--------------------------------------------------------------------------
def start_animation(animation, mirror = false)
if @character_sprite != nil
@character_sprite.start_animation(animation, mirror)
return
end
super(animation, mirror)
end

#--------------------------------------------------------------------------
# new method: start_pseudo_ani
#--------------------------------------------------------------------------
def start_pseudo_ani(animation, mirror = false)
if @character_sprite != nil
@character_sprite.start_pseudo_ani(animation, mirror)
return
end
super(animation, mirror)
end

#--------------------------------------------------------------------------
# new method: start_state_animation
#--------------------------------------------------------------------------
def start_state_animation(animation)
return if @state_animation != nil and @state_animation.id == animation.id
dispose_state_animation
@state_animation = animation
return if @state_animation == nil
@state_frame_index = 0
@state_animation_mirror = false
@state_animation_duration = @state_animation.frame_max * RATE + 1
load_state_animation_bitmap
@state_animation_sprites = []
if @state_animation.position != 3 or !@@state_animations.include?(animation)
if @use_sprite
for i in 0..15
sprite = ::Sprite.new(self.viewport)
sprite.visible = false
@state_animation_sprites.push(sprite)
end
unless @@state_animations.include?(animation)
@@state_animations.push(animation)
end
end
end
if @state_animation.position == 3
if viewport == nil
@state_animation_ox = Graphics.width / 2
@state_animation_oy = Graphics.width / 2
else
@state_animation_ox = viewport.rect.width / 2
@state_animation_oy = viewport.rect.height / 2
end
else
@state_animation_ox = x - ox + width / 2
@state_animation_oy = y - oy + height / 2
if @state_animation.position == 0
@state_animation_oy -= height / 2
elsif @state_animation.position == 2
@state_animation_oy += height / 2
end
end
end

#--------------------------------------------------------------------------
# new method: load_state_animation_bitmap
#--------------------------------------------------------------------------
def load_state_animation_bitmap
animation1_name = @state_animation.animation1_name
animation1_hue = @state_animation.animation1_hue
animation2_name = @state_animation.animation2_name
animation2_hue = @state_animation.animation2_hue
@state_animation_bitmap1 = Cache.animation(animation1_name, animation1_hue)
@state_animation_bitmap2 = Cache.animation(animation2_name, animation2_hue)
if @@_reference_count.include?(@state_animation_bitmap1)
@@_reference_count[@state_animation_bitmap1] += 1
else
@@_reference_count[@state_animation_bitmap1] = 1
end
if @@_reference_count.include?(@state_animation_bitmap2)
@@_reference_count[@state_animation_bitmap2] += 1
else
@@_reference_count[@state_animation_bitmap2] = 1
end
Graphics.frame_reset
end

#--------------------------------------------------------------------------
# new method: dispose_state_animation
#--------------------------------------------------------------------------
def dispose_state_animation
if @state_animation_bitmap1 != nil
@@_reference_count[@state_animation_bitmap1] -= 1
if @@_reference_count[@state_animation_bitmap1] == 0
@state_animation_bitmap1.dispose
end
end
if @state_animation_bitmap2 != nil
@@_reference_count[@state_animation_bitmap2] -= 1
if @@_reference_count[@state_animation_bitmap2] == 0
@state_animation_bitmap2.dispose
end
end
if @state_animation_sprites != nil
for sprite in @state_animation_sprites
sprite.dispose
end
@state_animation_sprites = nil
@state_animation = nil
end
@state_animation_bitmap1 = nil
@state_animation_bitmap2 = nil
end

#--------------------------------------------------------------------------
# new method: update_state_animation
#--------------------------------------------------------------------------
def update_state_animation
return if @state_animation == nil
update_state_animation_position
@state_animation_duration -= 1
unless @state_animation_duration % RATE == 0
if @state_animation_duration >= 0
@state_frame_index = @state_animation.frame_max
@state_frame_index -= (@state_animation_duration + RATE - 1) / RATE
for timing in @state_animation.timings
next unless timing.frame == @state_frame_index
state_animation_process_timing(timing)
end
else
@state_frame_index = 0
@state_animation_duration = @state_animation.frame_max * RATE
end
end
return if @state_frame_index == nil
state_animation_set_sprites(@state_animation.frames[@state_frame_index])
end

#--------------------------------------------------------------------------
# new method: update_state_animation_position
#--------------------------------------------------------------------------
def update_state_animation_position
if @state_animation.position == 3
if viewport == nil
@state_animation_ox = Graphics.width / 2
@state_animation_oy = Graphics.width / 2
else
@state_animation_ox = viewport.rect.width / 2
@state_animation_oy = viewport.rect.height / 2
end
else
@state_animation_ox = x - ox + width / 2
@state_animation_oy = y - oy + height / 2
if @state_animation.position == 0
@state_animation_oy -= height / 2
elsif @state_animation.position == 2
@state_animation_oy += height / 2
end
end
end

#--------------------------------------------------------------------------
# new method: state_animation_set_sprites
#--------------------------------------------------------------------------
def state_animation_set_sprites(frame)
return if @state_animation == nil
return if frame == nil
cell_data = frame.cell_data
for i in 0..15
sprite = @state_animation_sprites[i]
next if sprite == nil
pattern = cell_data[i, 0]
if pattern == nil or pattern == -1
sprite.visible = false
next
end
if pattern < 100
sprite.bitmap = @state_animation_bitmap1
else
sprite.bitmap = @state_animation_bitmap2
end
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192,
#---
pattern % 100 / 5 * 192, 192, 192)
sprite.x = @state_animation_ox + cell_data[i, 1]
sprite.y = @state_animation_oy + cell_data[i, 2]
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
#---
sprite.z = self.z + 200 + i
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
sprite.zoom_x *= @battler.state_animation_zoom
sprite.zoom_x /= 100
sprite.zoom_y *= @battler.state_animation_zoom
sprite.zoom_y /= 100
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
sprite.blend_type = cell_data[i, 7]
end
end

#--------------------------------------------------------------------------
# new method: state_animation_process_timing
#--------------------------------------------------------------------------
def state_animation_process_timing(timing)
timing.se.play
case timing.flash_scope
when 1
if @battler_animation == nil
self.flash(timing.flash_color, timing.flash_duration * RATE)
end
return if @character_sprite == nil
@character_sprite.flash(timing.flash_color, timing.flash_duration*RATE)
when 2
return if viewport == nil
viewport.flash(timing.flash_color, timing.flash_duration * RATE)
when 3
self.flash(nil, timing.flash_duration * RATE)
return if @character_sprite == nil
@character_sprite.flash(nil, timing.flash_duration * RATE)
end
end

#--------------------------------------------------------------------------
# new method: start_battler_animation
#--------------------------------------------------------------------------
def start_battler_animation(animation)
if $scene.is_a?(Scene_Battle) and $scene.emptyview? and @battler.actor?
dispose_battler_animation
return
end
return if @battler_animation != nil and
@battler_animation.id == animation.id
dispose_battler_animation
@battler_animation = animation
return if @battler_animation == nil
@battler_ani_hash = YEM::BATTLE_ENGINE::ANIMATION_BATTLER_SETTINGS
@battler_ani_max_cell = YEM::BATTLE_ENGINE::ANIMATION_BATTLER_MAX_CELLS
#---
if @battler.actor?
@battler_animation_mirror = @battler_ani_hash[:mirror_actor]
else
@battler_animation_mirror = @battler_ani_hash[:mirror_enemy]
end
#---
@battler_animation_duration = @battler_animation.frame_max * RATE + 1
load_battler_animation_bitmap
@battler_animation_sprites = []
if @battler_animation.position != 3 or
!@@battler_animations.include?(animation)
if @use_sprite
for i in 0..@battler_ani_max_cell
sprite = ::Sprite.new(self.viewport)
sprite.visible = false
@battler_animation_sprites.push(sprite)
end
unless @@battler_animations.include?(animation)
@@battler_animations.push(animation)
end
end
end
if @battler_animation.position == 3
if viewport == nil
@battler_animation_ox = Graphics.width / 2
@battler_animation_oy = Graphics.height / 2
else
@battler_animation_ox = viewport.rect.width / 2
@battler_animation_oy = viewport.rect.height / 2
end
else
@battler_animation_ox = x - ox + width/2
@battler_animation_oy = y - oy + height/2
if @battler_animation.position == 0
@battler_animation_oy -= height / 2
elsif @battler_animation.position == 2
@battler_animation_oy += height / 2
end
end
@battler_frame_index = 0
end

#--------------------------------------------------------------------------
# new method: load_battler_animation_bitmap
#--------------------------------------------------------------------------
def load_battler_animation_bitmap
animation1_name = @battler_animation.animation1_name
animation1_hue = @battler_animation.animation1_hue
animation1_hue += @battler.enemy.animation_hue if @battler.enemy?
animation2_name = @battler_animation.animation2_name
animation2_hue = @battler_animation.animation2_hue
animation2_hue += @battler.enemy.animation_hue if @battler.enemy?
@battler_animation_bitmap1 = Cache.animation(animation1_name,animation1_hue)
@battler_animation_bitmap2 = Cache.animation(animation2_name,animation2_hue)
if @@_reference_count.include?(@battler_animation_bitmap1)
@@_reference_count[@battler_animation_bitmap1] += 1
else
@@_reference_count[@battler_animation_bitmap1] = 1
end
if @@_reference_count.include?(@battler_animation_bitmap2)
@@_reference_count[@battler_animation_bitmap2] += 1
else
@@_reference_count[@battler_animation_bitmap2] = 1
end
Graphics.frame_reset
end

#--------------------------------------------------------------------------
# new method: dispose_battler_animation
#--------------------------------------------------------------------------
def dispose_battler_animation
if @battler_animation_bitmap1 != nil
@@_reference_count[@battler_animation_bitmap1] -= 1
if @@_reference_count[@battler_animation_bitmap1] == 0
@battler_animation_bitmap1.dispose
end
end
if @battler_animation_bitmap2 != nil
@@_reference_count[@battler_animation_bitmap2] -= 1
if @@_reference_count[@battler_animation_bitmap2] == 0
@battler_animation_bitmap2.dispose
end
end
if @battler_animation_sprites != nil
for sprite in @battler_animation_sprites
sprite.dispose
end
@battler_animation_sprites = nil
@battler_animation = nil
end
@battler_animation_bitmap1 = nil
@battler_animation_bitmap2 = nil
end

#--------------------------------------------------------------------------
# new method: update_battler_animation
#--------------------------------------------------------------------------
def update_battler_animation
return if @battler_animation == nil
update_battler_animation_position
@battler_animation_duration -= 1
unless @battler_animation_duration % RATE == 0
if @battler_animation_duration >= 0
@battler_frame_index = @battler_animation.frame_max
@battler_frame_index -= (@battler_animation_duration + RATE - 1) / RATE
for timing in @battler_animation.timings
next unless timing.frame == @battler_frame_index
battler_animation_process_timing(timing)
end
elsif @battler_animation.battler_looping
@battler_frame_index = 0
@battler_animation_duration = @battler_animation.frame_max * RATE
end
end
return if @battler_frame_index == nil
frame = @battler_animation.frames[@battler_frame_index]
battler_animation_set_sprites(frame)
end

#--------------------------------------------------------------------------
# new method: update_battler_animation_position
#--------------------------------------------------------------------------
def update_battler_animation_position
if @battler_animation.position == 3
if viewport == nil
@battler_animation_ox = Graphics.width / 2
@battler_animation_oy = Graphics.width / 2
else
@battler_animation_ox = viewport.rect.width / 2
@battler_animation_oy = viewport.rect.height / 2
end
else
@battler_animation_ox = x - ox + width/2
@battler_animation_oy = y - oy + height/2
if @battler_animation.position == 0
@battler_animation_oy -= height / 2
elsif @battler_animation.position == 2
@battler_animation_oy += height / 2
end
end
end

#--------------------------------------------------------------------------
# new method: battler_animation_set_sprites
#--------------------------------------------------------------------------
def battler_animation_set_sprites(frame)
return if @battler_animation == nil
return if frame == nil
cell_data = frame.cell_data
for i in 0..@battler_ani_max_cell
sprite = @battler_animation_sprites[i]
next if sprite == nil
pattern = cell_data[i, 0]
if pattern == nil or pattern == -1
sprite.visible = false
next
end
if pattern < 100
sprite.bitmap = @battler_animation_bitmap1
else
sprite.bitmap = @battler_animation_bitmap2
end
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192,
pattern % 100 / 5 * 192, 192, 192)
if @battler_animation_mirror
sprite.x = @battler_animation_ox - cell_data[i, 1]
sprite.y = @battler_animation_oy + cell_data[i, 2]
sprite.angle = (360 - cell_data[i, 4])
sprite.mirror = (cell_data[i, 5] == 0)
else
sprite.x = @battler_animation_ox + cell_data[i, 1]
sprite.y = @battler_animation_oy + cell_data[i, 2]
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
end
sprite.z = self.z + 50 + i
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
sprite.blend_type = cell_data[i, 7]
#---
sprite.color = self.color
sprite.visible = self.visible
sprite.update
end
self.flash(nil, 60 * RATE)
return if @character_sprite == nil
@character_sprite.flash(nil, 60 * RATE)
end

#--------------------------------------------------------------------------
# new method: battler_animation_process_timing
#--------------------------------------------------------------------------
def battler_animation_process_timing(timing)
timing.se.play if @battler_ani_hash[:allow_sound]
case timing.flash_scope
when 1
if @battler_animation == nil
self.flash(timing.flash_color, timing.flash_duration * RATE)
end
battler_animation_flash(timing)
when 2
return if viewport == nil
return unless @battler_ani_hash[:allow_flash]
viewport.flash(timing.flash_color, timing.flash_duration * RATE)
end
end

#--------------------------------------------------------------------------
# new method: battler_animation_flash
#--------------------------------------------------------------------------
def battler_animation_flash(timing)
frame = @battler_animation.frames[@battler_frame_index]
return if @battler_animation == nil
return if frame == nil
cell_data = frame.cell_data
colour = (timing.flash_scope == 1) ? timing.flash_color : nil
for i in 0..@battler_ani_max_cell
sprite = @battler_animation_sprites[i]
next if sprite == nil
sprite.flash(colour, timing.flash_duration * RATE)
end
end

#--------------------------------------------------------------------------
# new method: create_popup
#--------------------------------------------------------------------------
def create_popup(value, rules, flags)
return if @battler == nil
return if flags & @popup_flags != []
array = YEM::BATTLE_ENGINE::POPUP_RULES[rules]
for popup in @popups
popup.y -= array[2]*9/11
end
#---
view = $scene.spriteset.viewportB
new_popup = Sprite_Popup.new(view, @battler, value, rules, flags)
@popups.push(new_popup)
@popup_flags.push("weakness") if flags.include?("weakness")
@popup_flags.push("resistant") if flags.include?("resistant")
@popup_flags.push("immune") if flags.include?("immune")
@popup_flags.push("absorbed") if flags.include?("absorbed")
end

#--------------------------------------------------------------------------
# new method: dispose_popups
#--------------------------------------------------------------------------
def dispose_popups
for popup in @popups
@popups.delete(popup)
popup.dispose
popup = nil
end
end

#--------------------------------------------------------------------------
# new method: update_popups
#--------------------------------------------------------------------------
def update_popups
@popups = [] if @popups == nil
for popup in @popups
popup.update
next unless popup.opacity <= 0
popup.bitmap.dispose
popup.dispose
@popups.delete(popup)
popup = nil
end
@popup_flags = [] if @popups == [] and @popup_flags != []
return unless $scene.is_a?(Scene_Battle)
if @current_active_battler != $scene.active_battler
@current_active_battler = $scene.active_battler
@popup_flags = []
end
end

#--------------------------------------------------------------------------
# new method: create_character_dimensions
#--------------------------------------------------------------------------
def create_character_dimensions
return if @character_sprite == nil
@width = YEM::BATTLE_ENGINE::ACTOR_ASPECTS[:width]
@height = YEM::BATTLE_ENGINE::ACTOR_ASPECTS[:height]
self.ox = @width/2
self.oy = @height
end

#--------------------------------------------------------------------------
# new method: update_character_sprite
#--------------------------------------------------------------------------
def update_character_sprite
return if @character_sprite == nil
if @battler.character.character_name != @battler.character_name or
@battler.character.character_index != @battler.character_index
char_name = @battler.character_name
char_index = @battler.character_index
@battler.character.set_graphic(char_name, char_index)
end
@character_sprite.update
@character_sprite.z = self.z
end

#--------------------------------------------------------------------------
# new method: create_move_to
#--------------------------------------------------------------------------
def create_move_to(destination_x, destination_y, total_frames = 60)
return unless @battler.sprite_movable?
den = [total_frames, 1].max
if destination_x != nil
@move_to_x = Integer(destination_x)
@move_rate_x = [(@battler.screen_x - @move_to_x).abs/den, 2].max
end
if destination_y != nil
@move_to_y = Integer(destination_y)
@move_rate_y = [(@battler.screen_y - @move_to_y).abs/den, 2].max
end
return if @character_sprite == nil
end

#--------------------------------------------------------------------------
# new method: update_move_to
#--------------------------------------------------------------------------
def update_move_to
if @move_to_x != nil
value = [(@battler.screen_x - @move_to_x).abs, @move_rate_x].min
@battler.screen_x += (@move_to_x > @battler.screen_x) ? value : -value
@move_to_x = nil if @battler.screen_x == @move_to_x
end
if @move_to_y != nil
value = [(@battler.screen_y - @move_to_y).abs, @move_rate_y].min
@battler.screen_y += (@move_to_y > @battler.screen_y) ? value : -value
@move_to_y = nil if @battler.screen_y == @move_to_y
end
end

#--------------------------------------------------------------------------
# new method: face_coordinate
#--------------------------------------------------------------------------
def face_coordinate(destination_x, destination_y)
if @character_sprite != nil
@battler.character.break_pose if $imported["ExtendedMovement"]
@battler.character.step_anime = true
@battler.character.mirror = false
end
x1 = Integer(@battler.screen_x)
x2 = Integer(destination_x)
y1 = Graphics.height - Integer(@battler.screen_y)
y2 = Graphics.height - Integer(destination_y)
return if x1 == x2 and y1 == y2
#---
angle = Integer(Math.atan2((y2-y1),(x2-x1)) * 1800 / Math:tongue.gifI)
if (0..225) === angle or (-225..0) === angle
direction = 6
elsif (226..675) === angle
direction = 9
elsif (676..1125) === angle
direction = 8
elsif (1126..1575) === angle
direction = 7
elsif (1576..1800) === angle or (-1800..-1576) === angle
direction = 4
elsif (-1575..-1126) === angle
direction = 1
elsif (-1125..-676) === angle
direction = 2
elsif (-675..-226) === angle
direction = 3
end
#---
@battler.direction = direction if @battler.enemy?
if @character_sprite != nil
direction = $scene.spriteset.correct_direction(direction)
@battler.character.set_direction(direction)
end
end

#--------------------------------------------------------------------------
# new method: turn_direction
#--------------------------------------------------------------------------
def turn_direction(direction, backward = false)
return if @character_sprite == nil
return unless [1,2,3,4,6,7,8,9].include?(direction)
back_hash = {1=>9,2=>8,3=>7,4=>6,6=>4,7=>3,8=>2,9=>1}
direction = back_hash[direction] if backward
direction = back_hash[direction] if @battler.enemy?
direction = $scene.spriteset.correct_direction(direction)
@battler.character.break_pose if $imported["ExtendedMovement"]
@battler.character.set_direction(direction)
end

#--------------------------------------------------------------------------
# new method: start_character_death
#--------------------------------------------------------------------------
def start_character_death
return if @character_sprite == nil
return if @character_death_duration != nil
@character_death_duration = 9
@battler.character.step_anime = false
@battler.character.mirror = @battler.enemy?
@battler.character.set_direction(4)
if @battler.use_battler_animations?
@battler.battler_animation_stance("DEAD")
return
end
if $imported["ExtendedMovement"] and @character_sprite.appropiate_filename?
@battler.character.pose = "fallen"
@character_sprite.ox *= @battler.actor? ? 2 : 0
@character_sprite.angle = @battler.actor? ? -90 : 90
@character_sprite.mirror = @battler.enemy?
@character_sprite.update
end
end

#--------------------------------------------------------------------------
# new method: update_character_death
#--------------------------------------------------------------------------
def update_character_death
return if @character_death_duration == nil
return if @character_sprite == nil
return if @character_death_duration == 0
@character_sprite.angle += @battler.actor? ? 10 : -10
@character_death_duration -= 1
return unless @character_death_duration == 0
if $imported["ExtendedMovement"] and @character_sprite.appropiate_filename?
@character_sprite.angle = 0
else
@battler.character.set_direction(8)
@character_sprite.angle = @battler.actor? ? 90 : -90
end
end

#--------------------------------------------------------------------------
# new method: revive_character_death
#--------------------------------------------------------------------------
def revive_character_death
return if @character_sprite == nil
@character_death_duration = nil
@character_sprite.angle = 0
@character_sprite.ox = @character_sprite.width/2
@battler.character.break_pose if $imported["ExtendedMovement"]
@battler.character.step_anime = true
case $scene.view_type
when 1; type = :front
when 2; type = :side
when 3; type = :angle
else; return
end
direction = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[type][0]
turn_direction(direction)
create_move_to(@battler.origin_x, @battler.origin_y, 20)
$scene.update_battler_poses
end

#--------------------------------------------------------------------------
# new method: create_icon
#--------------------------------------------------------------------------
def create_icon(icon, attachment)
return if @character_sprite == nil
@icon_sprites = [] if @icon_sprites == nil
#---
case icon
when :weapon1
return if @battler.weapons.compact.size <= 0
dispose_icon(@icon_weapon1, icon)
icon_index = @battler.weapon1_icon
when :weapon2
return if @battler.weapons.compact.size <= 1
dispose_icon(@icon_weapon2, icon)
icon_index = @battler.weapon2_icon
when :shield
return if @battler.armor1_id == 0
dispose_icon(@icon_shield, icon)
icon_index = @battler.guard_icon
when :item
return unless @battler.action.item?
dispose_icon(@icon_item, icon)
icon_index = @battler.action.item.icon_index
else
return if icon.to_i == 0
icon_index = icon.to_i
icon = :last
end
#---
icon_sprite = Sprite_Icon.new(viewport, icon_index, @battler)
@icon_sprites.push(icon_sprite)
icon_sprite.set_origin(attachment)
#---
case icon
when :weapon1
@icon_weapon1 = icon_sprite
when :weapon2
@icon_weapon2 = icon_sprite
when :shield
@icon_shield = icon_sprite
when :item
@icon_item = icon_sprite
end
@icon_last = @icon_sprites[-1]
end

#--------------------------------------------------------------------------
# new method: dispose_icon
#--------------------------------------------------------------------------
def dispose_icon(icon_sprite, type = nil)
return if icon_sprite == nil
icon_sprite.dispose
case type
when :weapon1; @icon_weapon1 = nil
when :weapon2; @icon_weapon2 = nil
when :shield; @icon_armour = nil
when :item; @icon_item = nil
end
@icon_sprites.delete(icon_sprite)
icon_sprite = nil
@icon_last = @icon_sprites[-1]
end

#--------------------------------------------------------------------------
# new method: update_icon_sprites
#--------------------------------------------------------------------------
def update_icon_sprites
return if @icon_sprites == nil
return unless @icon_sprites != []
for icon_sprite in @icon_sprites; icon_sprite.update; end
end

#--------------------------------------------------------------------------
# new method: clear_jump
#--------------------------------------------------------------------------
def clear_jump
@jump_count = nil
@jump_duration = nil
@jump_peak = nil
@jump_height = nil
end

#--------------------------------------------------------------------------
# new method: create_jump
#--------------------------------------------------------------------------
def create_jump(height, duration)
@jump_count = duration
@jump_duration = duration
@jump_peak = height
@jump_height = 0
end

#--------------------------------------------------------------------------
# new method: update_jump
#--------------------------------------------------------------------------
def update_jump
return if @jump_count == nil
@jump_duration -= 1
if @jump_duration < 0
clear_jump
return
end
#---
@battler.screen_y += @jump_height
if @move_to_y != nil
value = [(@battler.screen_y - @move_to_y).abs, @move_rate_y].min
difference = (@move_to_y > @battler.screen_y) ? value : -value
@battler.screen_y += difference
end
#---
if @jump_duration > @jump_count*7/8
n = @jump_height + [@jump_peak/@jump_count, 1].max * 1.50
elsif @jump_duration > @jump_count*6/8
n = @jump_height + [@jump_peak/@jump_count, 1].max * 1.45
elsif @jump_duration > @jump_count*5/8
n = @jump_height + [@jump_peak/@jump_count, 1].max * 1.30
elsif @jump_duration > @jump_count*4/8
n = @jump_height + [@jump_peak/@jump_count, 1].max * 1.00
elsif @jump_duration > @jump_count*3/8
n = @jump_height - [@jump_peak/@jump_count, 1].max * 1.00
elsif @jump_duration > @jump_count*2/8
n = @jump_height - [@jump_peak/@jump_count, 1].max * 1.30
elsif @jump_duration > @jump_count*1/8
n = @jump_height - [@jump_peak/@jump_count, 1].max * 1.45
else
n = @jump_height - [@jump_peak/@jump_count, 1].max * 1.50
end
@jump_height = [Integer(n), 0].max
@battler.screen_y = @battler.screen_y - @jump_height
end

end # Sprite_Battler

#===============================================================================
# Sprite_Popup
#===============================================================================

class Sprite_Popup < Sprite_Base

#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :flags

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(viewport, battler, value, rules, flags)
super(viewport)
@value = value
@rules = rules
@rules = "DEFAULT" unless YEM::BATTLE_ENGINE::POPUP_RULES.include?(@rules)
@fade = YEM::BATTLE_ENGINE::POPUP_SETTINGS[:fade]
@full = YEM::BATTLE_ENGINE::POPUP_SETTINGS[:full]
@flags = flags
@battler = battler
create_popup_bitmap
end

#--------------------------------------------------------------------------
# create_popup_bitmap
#--------------------------------------------------------------------------
def create_popup_bitmap
array = YEM::BATTLE_ENGINE::POPUP_RULES[@rules]
bw = YEM::BATTLE_ENGINE::POPUP_SETTINGS[:width]
bw += 48 if @flags.include?("state")
size = array[2]
size = Integer(size * 1.2) if @flags.include?("critical")
bh = size * 2
bitmap = Bitmap.new(bw, bh)
bitmap.font.name = array[8]
bitmap.font.size = size
bitmap.font.bold = array[3]
bitmap.font.italic = array[4]
bitmap.font.shadow = false
if flags.include?("critical")
crit_rules = YEM::BATTLE_ENGINE::POPUP_RULES["CRITICAL"]
bitmap.font.color.set(crit_rules[5], crit_rules[6], crit_rules[7])
else
bitmap.font.color.set(0, 0, 0)
end
self.bitmap = bitmap
dx = 0; dy = 0; dw = 0
dx += 24 if @flags.include?("state")
dw += 24 if @flags.include?("state")
bitmap.draw_text(dx+1, dy+1, bw-dw, bh, @value, 1)
bitmap.draw_text(dx+1, dy-1, bw-dw, bh, @value, 1)
bitmap.draw_text(dx-1, dy+1, bw-dw, bh, @value, 1)
bitmap.draw_text(dx-1, dy-1, bw-dw, bh, @value, 1)
bitmap.font.color.set(array[5], array[6], array[7])
bitmap.draw_text(dx, dy, bw-dw, bh, @value, 1)
if @flags.include?("state")
c_width = bitmap.text_size(@value).width
icon_bitmap = $game_temp.iconset
icon_index = flag_state_icon
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
bitmap.blt(dx+(bw-c_width)/2-36, (bh/2-dy)/2-2, icon_bitmap, rect, 255)
end
self.bitmap = bitmap
self.x = @battler.screen_x
self.x += rand(4) - rand(4) if @battler.spriteset.popups.size >= 1
self.x -= $scene.spriteset.viewport1.ox
self.y = @battler.screen_y - @battler.spriteset.oy/2
self.y += YEM::BATTLE_ENGINE::POPUP_SETTINGS[:offset] if !$scene.emptyview?
self.y -= $scene.spriteset.viewport1.oy
self.ox = bw/2; self.oy = bh/2
self.zoom_x = self.zoom_y = array[0]
if @flags.include?("no zoom")
self.zoom_x = self.zoom_y = array[1]
end
@target_zoom = array[1]
@zoom_direction = (self.zoom_x > @target_zoom) ? "down" : "up"
self.z = 500
end

#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
#---
if @flags.include?("critical") and
YEM::BATTLE_ENGINE::POPUP_SETTINGS[:flash]
@hue_duration = 2 if @hue_duration == nil or @hue_duration == 0
@hue_duration -= 1
self.bitmap.hue_change(15) if @hue_duration <= 0
end
#---
if @zoom_direction == "up"
self.zoom_x = [self.zoom_x + 0.075, @target_zoom].min
self.zoom_y = [self.zoom_y + 0.075, @target_zoom].min
else
self.zoom_x = [self.zoom_x - 0.075, @target_zoom].max
self.zoom_y = [self.zoom_y - 0.075, @target_zoom].max
end
#---
@full -= 1
return if @full > 0
self.y -= 1
self.opacity -= @fade
end

#--------------------------------------------------------------------------
# flag_state_icon
#--------------------------------------------------------------------------
def flag_state_icon
for item in @flags; return item if item.is_a?(Integer); end
return 0
end

end # Sprite_Popup

#===============================================================================
# Sprite_OrderBattler
#===============================================================================

class Sprite_OrderBattler < Sprite_Base

#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :first_time

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(viewport, battler, battle_type = 0)
super(viewport)
@battler = battler
@battle_type = battle_type
@destination = 24
@move_rate_x = 1
@move_rate_y = 1
@update_wait = 0
@hash = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS
@show_dead = YEM::BATTLE_ENGINE::TURNS_DEAD_BATTLERS
@charge_icon_id = YEM::BATTLE_ENGINE::CTB_RULES[:chargeicon]
@charge_size = Integer(YEM::BATTLE_ENGINE::CTB_RULES[:chargesize] * 24)
create_battler_bitmap
end

#--------------------------------------------------------------------------
# dispose
#--------------------------------------------------------------------------
def dispose
self.bitmap.dispose if self.bitmap != nil
super
end

#--------------------------------------------------------------------------
# create_battler_bitmap
#--------------------------------------------------------------------------
def create_battler_bitmap
case @battle_type
when 0 # Default Turn Battle
create_dtb_style
when 1 # Press Turn Battle
# Unused
when 2 # Active Turn Battle
create_atb_style
when 3 # Press Turn Battle
create_dtb_style
end
end

#--------------------------------------------------------------------------
# create_dtb_style
#--------------------------------------------------------------------------
def create_dtb_style
bitmap = Bitmap.new(24, 24)
icon_bitmap = Cache.system("Iconset")
#--- Create Battler Background ---
icon_index = @battler.actor? ? @hash[:actor][0] : @hash[:enemy][0]
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
bitmap.blt(0, 0, icon_bitmap, rect)
#--- Create Battler Icon ---
icon_index = @battler.battler_icon
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
temp_bitmap = Bitmap.new(24, 24)
temp_bitmap.blt(0, 0, icon_bitmap, rect)
temp_bitmap.hue_change(@battler.enemy.enemy_icon_hue) if @battler.enemy?
bitmap.blt(0, 0, temp_bitmap, Rect.new(0, 0, 24, 24))
temp_bitmap.dispose
#--- Create Battler Border ---
icon_index = @battler.actor? ? @hash[:actor][1] : @hash[:enemy][1]
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
bitmap.blt(0, 0, icon_bitmap, rect)
#--- Create Battler Letter ---
@draw_letter = draw_letter?
@charge_icon = charge_icon?
if @draw_letter
bitmap.font.name = ["UmePlus Gothic", "Courier New"]
bitmap.font.color.set(255, 255, 255)
bitmap.font.size = 12
bitmap.draw_text(-3, 10, 12, 12, @battler.letter.to_s, 0)
end
if @charge_icon
icon_index = @charge_icon_id
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
dest_rect = Rect.new(0, 0, @charge_size, @charge_size)
bitmap.stretch_blt(dest_rect, icon_bitmap, rect)
end
#---
self.bitmap.dispose if self.bitmap != nil
self.bitmap = bitmap
return if @created_icon
@created_icon = true
self.ox = 12; self.oy = 12
self.x = 24
self.y = 24
self.z = 8000
end

#--------------------------------------------------------------------------
# create_atb_style
#--------------------------------------------------------------------------
def create_atb_style
bitmap = Bitmap.new(24, 48)
icon_bitmap = Cache.system("Iconset")
#--- Create Battler Background ---
icon_index = @battler.actor? ? @hash[:actor][0] : @hash[:enemy][0]
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
bitmap.blt(0, 24, icon_bitmap, rect)
#--- Create Battler Icon ---
icon_index = @battler.battler_icon
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
temp_bitmap = Bitmap.new(24, 24)
temp_bitmap.blt(0, 0, icon_bitmap, rect)
temp_bitmap.hue_change(@battler.enemy.enemy_icon_hue) if @battler.enemy?
bitmap.blt(0, 24, temp_bitmap, Rect.new(0, 0, 24, 24))
temp_bitmap.dispose
#--- Create Battler Border ---
icon_index = @battler.actor? ? @hash[:actor][1] : @hash[:enemy][1]
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
bitmap.blt(0, 24, icon_bitmap, rect)
#--- Create Battler Letter ---
@draw_letter = draw_letter?
@charge_icon = charge_icon?
if @draw_letter
bitmap.font.name = ["UmePlus Gothic", "Courier New"]
bitmap.font.color.set(255, 255, 255)
bitmap.font.size = 12
bitmap.draw_text(-3, 34, 12, 12, @battler.letter.to_s, 0)
end
#--- Create Battler Arrow ---
icon_index = @battler.actor? ? @hash[:actor][5] : @hash[:enemy][5]
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
bitmap.blt(0, 0, icon_bitmap, rect)
#---
self.bitmap.dispose if self.bitmap != nil
self.bitmap = bitmap
return if @created_icon
@created_icon = true
self.ox = 12; self.oy = 18
self.x = 6
self.y = 12
self.z = 8000 + self.x
end

#--------------------------------------------------------------------------
# draw_letter?
#--------------------------------------------------------------------------
def draw_letter?
return false unless @battler.enemy?
return @battler.plural
end

#--------------------------------------------------------------------------
# charge_icon?
#--------------------------------------------------------------------------
def charge_icon?
return false unless $scene.is_a?(Scene_Battle)
return false unless $scene.ctb?
return @battler.ctb_speed_bonus < 0
end

#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
return unless $scene.is_a?(Scene_Battle)
if (@draw_letter != draw_letter?) or (@charge_icon != charge_icon?)
create_battler_bitmap
end
#---
case @battle_type
when 0 # Default Turn Battle
update_dtb_style
when 1 # Press Turn Battle
# No update
when 2 # Active Turn Battle
update_atb_style
when 3 # Charge Turn Battle
update_dtb_style
end
end

#--------------------------------------------------------------------------
# update_dtb_style
#--------------------------------------------------------------------------
def update_dtb_style
return if @move_to_x == nil
if @battler.hidden or (!@show_dead and @battler.dead? and
self.opacity <= 64)
@move_to_x = -48
self.x = -48
return
end
self.z = (@battler.dead?) ? 6000 : 8000
@move_to_y = 24
if self.x != @move_to_x
self.z = (@move_to_x < self.x) ? 7500 : 8500
@move_to_y = (@move_to_x < self.x) ? 18 : 30 if @first_time
value = [[(@move_to_x-self.x).abs, @move_rate_x].min, 1].max
self.x += (@move_to_x > self.x) ? value : -value
@first_time = true if self.x == @move_to_x
end
#---
if $scene.target_actor_window != nil
@move_to_y = 12 if $scene.highlighted_targets.include?(@battler)
@move_to_y = 12 if $scene.target_actor_window.actor == @battler
end
if $scene.target_enemy_window != nil
@move_to_y = 12 if $scene.highlighted_targets.include?(@battler)
@move_to_y = 12 if $scene.target_enemy_window.enemy == @battler
end
#---
if self.y != @move_to_y
@update_wait -= 1
if @update_wait <= 0
value = [[(@move_to_y-self.y).abs, @move_rate_y].min, 1].max
self.y += (@move_to_y > self.y) ? value : -value
end
end
if self.y == @move_to_y and $scene.target_enemy_window != nil
@update_wait = 4
end
self.opacity += (@battler.exist?) ? 8 : -4
self.opacity = [[self.opacity, 255].min, 0].max
end

#--------------------------------------------------------------------------
# make_dtb_destination
#--------------------------------------------------------------------------
def make_dtb_destination
if @battler.hidden
self.opacity = 0
return
end
array = $scene.performed_actors.reverse
action = $scene.action_battlers.reverse - $scene.performed_actors.reverse
array += action
result = []
#---
if @show_dead
for member in array
next if member.hidden
result.push(member) if member.dead?
end
end
for member in array
next if member.hidden
result.push(member) unless member.dead?
action.delete(member) if member.dead? and !@show_dead
end
#---
index = result.index(@battler).to_i
@move_to_x = 24 + index * 24
if dtb_spacing?
@move_to_x += 6 if action.include?(@battler)
@move_to_x += 6 if (index + 1 == result.size) and action.size > 1
end
den = @first_time ? 12 : 24
@move_rate_x = [(self.x - @move_to_x).abs/den, 1].max
end

#--------------------------------------------------------------------------
# dtb_spacing?
#--------------------------------------------------------------------------
def dtb_spacing?
return false if $scene.party_input_flag
return true
end

#--------------------------------------------------------------------------
# update_atb_style
#--------------------------------------------------------------------------
def update_atb_style
if self.x >= 6 + @battler.atb_position
self.x = [self.x-16, 6 + @battler.atb_position].max
else
difference = (6 + @battler.atb_position) - self.x
value = [difference / $scene.atb_speed, 1].max
self.x = [self.x+value, 6 + @battler.atb_position].min
end
self.z = 8000 + self.x
self.opacity += @battler.exist? ? 8 : -8
end

#--------------------------------------------------------------------------
# new method: make_ctb_destination
#--------------------------------------------------------------------------
def make_ctb_destination
if @battler.hidden
self.opacity = 0
return
end
array = $scene.action_battlers.reverse
result = []
#---
if @show_dead
for member in array
next if member.hidden
next unless member.dead?
result.push(member)
end
end
for member in array
next if member.hidden
next if member.dead?
next if member.movable?
result.push(member)
end
for member in array
next if member.hidden
next if member.dead?
next unless member.movable?
result.push(member)
end
#---
index = result.index(@battler).to_i
@move_to_x = 24 + index * 24
den = @first_time ? 12 : 24
@move_rate_x = [(self.x - @move_to_x).abs/den, 1].max
end

end # Sprite_OrderBattler

#===============================================================================
# Sprite_Icon
#===============================================================================

class Sprite_Icon < Sprite_Base

#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :battler
attr_accessor :icon
attr_accessor :offset_x
attr_accessor :offset_y
attr_accessor :offset_z

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(viewport, icon, battler = nil)
super(viewport)
@battler = battler
@icon = icon
@attach_x = 0
@attach_y = 0
@offset_x = 0
@offset_y = 0
@offset_z = 0
create_icon_bitmap
end

#--------------------------------------------------------------------------
# dispose
#--------------------------------------------------------------------------
def dispose
self.bitmap.dispose if self.bitmap != nil
super
end

#--------------------------------------------------------------------------
# create_icon_bitmap
#--------------------------------------------------------------------------
def create_icon_bitmap
return if @icon == nil
self.bitmap = Cache.system("Iconset")
self.src_rect.set(@icon % 16 * 24, @icon / 16 * 24, 24, 24)
end

#--------------------------------------------------------------------------
# set_origin
#--------------------------------------------------------------------------
def set_origin(type)
@offset_z = 2
@attachment = type
case type
when :item
self.ox = 12
self.oy = 12
@offset_y = -@battler.bitmap_height
@offset_x = -@battler.bitmap_width / 2
when :hand1
self.ox = 24
self.oy = 24
@attach_y = -@battler.bitmap_height/3
@attach_x = -@battler.bitmap_width/5
when :hand2
self.ox = 24
self.oy = 24
@attach_y = -@battler.bitmap_height/3
@attach_x = @battler.bitmap_width/5
when :middle
self.ox = 12
self.oy = 12
@offset_y = -@battler.bitmap_height/2
when :top
self.ox = 12
self.oy = 24
@offset_y = -@battler.bitmap_height
when :base
self.ox = 12
self.oy = 24
end
end

#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
update_rotate
update_opacity
update_move
update_position
end

#--------------------------------------------------------------------------
# update_position
#--------------------------------------------------------------------------
def update_position
if @battler != nil
self.mirror = mirror_battler?
update_attachment(self.mirror)
attach_x = self.mirror ? -@attach_x : @attach_x
self.x = @battler.screen_x + attach_x + @offset_x
self.y = @battler.screen_y + @attach_y + @offset_y
self.z = @battler.screen_z + @offset_z - 1
else
self.x = @offset_x
self.y = @offset_y
self.z = @offset_z
end
end

#--------------------------------------------------------------------------
# update_attachment
#--------------------------------------------------------------------------
def update_attachment(mirror = false)
case @attachment
when :hand1
self.ox = mirror ? 0 : 24
self.oy = 24
@attach_y = -@battler.bitmap_height/3
@attach_x = -@battler.bitmap_width/5
when :hand2
self.ox = mirror ? 0 : 24
self.oy = 24
@attach_y = -@battler.bitmap_height/3
@attach_x = @battler.bitmap_width/5
else
@attach_x = 0
@attach_y = 0
end
end

#--------------------------------------------------------------------------
# mirror_battler?
#--------------------------------------------------------------------------
def mirror_battler?
return false if @battler.spriteset.character_sprite == nil
return true if @battler.character.direction == 8
return @battler.character.mirror
end

#--------------------------------------------------------------------------
# change_angle
#--------------------------------------------------------------------------
def change_angle(value); self.angle = value; end

#--------------------------------------------------------------------------
# rotate
#--------------------------------------------------------------------------
def rotate(set_angle, set_speed, clockwise = false)
@rotate_angle = set_angle
@turn_angle = 0
@rotate_speed = set_speed
@clockwise = clockwise
end

#--------------------------------------------------------------------------
# update_rotate
#--------------------------------------------------------------------------
def update_rotate
return if @rotate_angle == nil
clockwise = @clockwise
clockwise = !clockwise if self.mirror
self.angle += clockwise ? -@rotate_speed : @rotate_speed
@turn_angle += @rotate_speed
if @rotate_angle.is_a?(Integer) and @turn_angle >= @rotate_angle
@rotate_angle = nil
end
end

#--------------------------------------------------------------------------
# opacity_rate
#--------------------------------------------------------------------------
def opacity_rate(rate); @opacity_rate = rate; end

#--------------------------------------------------------------------------
# update_opacity
#--------------------------------------------------------------------------
def update_opacity
return if @opacity_rate == nil or @opacity_rate == 0
self.opacity += @opacity_rate
end

#--------------------------------------------------------------------------
# move_direction
#--------------------------------------------------------------------------
def move_direction(direction, speed, frames)
case direction
when 1 # Down Left
@move_2 = @move_4 = speed
@move_2_count = @move_4_count = 0
@move_2_frames = @move_4_frames = frames
when 2 # Down
@move_2 = speed
@move_2_count = 0
@move_2_frames = frames
when 3 # Down Right
@move_2 = @move_6 = speed
@move_2_count = @move_6_count = 0
@move_2_frames = @move_6_frames = frames
when 4 # Left
@move_4 = speed
@move_4_count = 0
@move_4_frames = frames
when 6 # Right
@move_6 = speed
@move_6_count = 0
@move_6_frames = frames
when 7 # Up Left
@move_8 = @move_4 = speed
@move_8_count = @move_4_count = 0
@move_8_frames = @move_4_frames = frames
when 8 # Up
@move_8 = speed
@move_8_count = 0
@move_8_frames = frames
when 9 # Up Right
@move_8 = @move_6 = speed
@move_8_count = @move_6_count = 0
@move_8_frames = @move_6_frames = frames
else; return
end
end

#--------------------------------------------------------------------------
# update_move
#--------------------------------------------------------------------------
def update_move
if @move_2 != nil # Down Move
@offset_y += @move_2
@move_2_count += 1
if @move_2_count >= @move_2_frames
@move_2 = @move_2_count = @move_2_frames = nil
end
end
if @move_4 != nil # Left Move
@offset_x -= @move_4
@move_4_count += 1
if @move_4_count >= @move_4_frames
@move_4 = @move_4_count = @move_4_frames = nil
end
end
if @move_6 != nil # Right Move
@offset_x += @move_6
@move_6_count += 1
if @move_6_count >= @move_6_frames
@move_6 = @move_6_count = @move_6_frames = nil
end
end
if @move_8 != nil # Up Move
@offset_y -= @move_8
@move_8_count += 1
if @move_8_count >= @move_8_frames
@move_8 = @move_8_count = @move_8_frames = nil
end
end
end

end # Sprite_Icon

#===============================================================================
# Sprite_PTB
#===============================================================================

class Sprite_PTB < Sprite_Base

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(viewport, dx, dy, group, index)
super(viewport)
self.x = dx
self.y = dy
self.z = 100
@group = group
@index = index
create_bitmap
end

#--------------------------------------------------------------------------
# create_bitmap
#--------------------------------------------------------------------------
def create_bitmap
return unless @index > @group.ptb_total_turns - @group.ptb_bonus_turns
return unless @index <= @group.ptb_total_turns
hash = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS
icon_index = (@group == $game_party) ? hash[:actor][4] : hash[:enemy][4]
bitmap = Bitmap.new(24, 24)
icon_bitmap = Cache.system("Iconset")
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
bitmap.blt(0, 0, icon_bitmap, rect)
self.bitmap = bitmap
self.blend_type = 1
self.ox = 12; self.oy = 12
self.x += 12; self.y += 12
@allow_update = true
@up_glow = false
end

#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
return unless @allow_update
self.opacity += @up_glow ? 8 : -8
if self.opacity <= 0
@up_glow = true
elsif self.opacity >= 255
@up_glow = false
end
end

end # Sprite_PTB

#===============================================================================
# Sprite_BattleCursor
#===============================================================================

class Sprite_BattleCursor < Sprite

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(viewport)
super(viewport)
create_cursor
self.x = Graphics.width/2
self.y = Graphics.height/2
self.z = 200
self.opacity = 0
end

#--------------------------------------------------------------------------
# create_cursor
#--------------------------------------------------------------------------
def create_cursor
self.bitmap = Cache.system(YEM::BATTLE_ENGINE::BATTLE_CURSOR[:filename])
self.ox = self.width / 2
self.ox += YEM::BATTLE_ENGINE::BATTLE_CURSOR[:x_offset]
self.oy = self.height
self.oy += YEM::BATTLE_ENGINE::BATTLE_CURSOR[:y_offset]
end

#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
#---
return unless $scene.is_a?(Scene_Battle)
update_opacity
update_move_to
update_follow
end

#--------------------------------------------------------------------------
# update_opacity
#--------------------------------------------------------------------------
def update_opacity
value = opaque? ? 16 : -16
self.opacity += value
end

#--------------------------------------------------------------------------
# opaque?
#--------------------------------------------------------------------------
def opaque?
return false unless $scene.is_a?(Scene_Battle)
return false if $scene.hide_battlecursor
return false if @battler != nil and @battler.actor? and $scene.emptyview?
if $scene.actor_command_window != nil
return true if $scene.actor_command_window.active
end
return true if $scene.target_actor_window != nil
return true if $scene.target_enemy_window != nil
return false
end

#--------------------------------------------------------------------------
# create_move_to
#--------------------------------------------------------------------------
def create_move_to
return unless $scene.is_a?(Scene_Battle)
if $scene.target_actor_window != nil
@battler = $scene.target_actor_window.actor
elsif $scene.target_enemy_window != nil
@battler = $scene.target_enemy_window.enemy
elsif $scene.actor_command_window.active
@battler = $scene.actor_command_window.actor
else
return
end
return if @battler == nil
return if @battler.actor? and $scene.emptyview?
@move_to_x = @battler.screen_x
@move_to_x += YEM::BATTLE_ENGINE::BATTLE_CURSOR[:actor_x] if @battler.actor?
@move_to_x -= $scene.spriteset.viewport1.ox
@move_to_y = @battler.screen_y - @battler.bitmap_height
@move_to_y -= YEM::BATTLE_ENGINE::BATTLE_CURSOR[:actor_y] if @battler.actor?
@move_to_y -= $scene.spriteset.viewport1.oy
#---
if @first_time
distance_x = (@move_to_x - self.x).abs
distance_y = (@move_to_y - self.y).abs
@move_rate_x = [distance_x/10, 1].max
@move_rate_y = [distance_y/10, 1].max
else
@first_time = true
self.x = @move_to_x
self.y = @move_to_y
end
end

#--------------------------------------------------------------------------
# update_move_to
#--------------------------------------------------------------------------
def update_move_to
return unless $scene.is_a?(Scene_Battle)
return if @battler == nil
if @move_to_x != nil and @move_rate_x != nil
value = [(self.x - @move_to_x).abs, @move_rate_x].min
self.x += (@move_to_x > self.x) ? value : -value
@move_to_x = nil if self.x == @move_to_x
end
if @move_to_y != nil and @move_rate_y != nil
value = [(self.y - @move_to_y).abs, @move_rate_y].min
self.y += (@move_to_y > self.y) ? value : -value
@move_to_y = nil if self.y == @move_to_y
end
end

#--------------------------------------------------------------------------
# update_follow
#--------------------------------------------------------------------------
def update_follow
return unless $scene.is_a?(Scene_Battle)
return unless $scene.atb?
return if @battler == nil
require_update = false
if @battler_x != @battler.screen_x - $scene.spriteset.viewport1.ox
require_update = true
elsif @battler_y != @battler.screen_y - $scene.spriteset.viewport1.oy
require_update = true
end
if require_update
@battler_x = @battler.screen_x - $scene.spriteset.viewport1.ox
@battler_y = @battler.screen_y - $scene.spriteset.viewport1.oy
create_move_to
end
end

end # Sprite_BattleCursor

#===============================================================================
# Spriteset_Battle
#===============================================================================

class Spriteset_Battle

#--------------------------------------------------------------------------
# public instance variable
#--------------------------------------------------------------------------
attr_accessor :actor_sprites
attr_accessor :enemy_sprites
attr_accessor :battle_cursor
attr_accessor :battleback_sprite
attr_accessor :camera_x
attr_accessor :camera_y
attr_accessor :order_sprites
attr_accessor :ptb_update
attr_accessor :viewport1
attr_accessor :viewportA
attr_accessor :viewportB
attr_accessor :viewportC

#--------------------------------------------------------------------------
# overwrite method: create_viewports
#--------------------------------------------------------------------------
def create_viewports
create_camera
#---
@viewport1 = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport2 = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport3 = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewportA = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewportB = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewportC = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport2.z = 50
@viewport3.z = 100
@viewportA.z = 250
@viewportB.z = 200
@viewportC.z = 500
#---
create_order_sprites
create_battle_cursor
end

#--------------------------------------------------------------------------
# alias method: dispose_viewports
#--------------------------------------------------------------------------
alias dispose_viewports_spriteset_battle_bem dispose_viewports unless $@
def dispose_viewports
dispose_viewports_spriteset_battle_bem
dispose_order_sprites
dispose_battle_cursor
@viewportA.dispose
@viewportB.dispose
end

#--------------------------------------------------------------------------
# overwrite method: update_viewports
#--------------------------------------------------------------------------
def update_viewports
update_camera
update_order_sprites
update_ptb_call
#---
@viewport1.tone = $game_troop.screen.tone
@viewport1.ox = @camera_x + $game_troop.screen.shake
@viewport1.oy = @camera_y
@viewport2.color = $game_troop.screen.flash_color
@viewport3.color.set(0, 0, 0, 255 - $game_troop.screen.brightness)
@viewport1.update
@viewport2.update
@viewport3.update
#---
if $scene.is_a?(Scene_Battle) and $scene.target_help_window != nil
if $scene.target_help_window.active and !$scene.win_loss_flag
@viewportA.rect.y = [@viewportA.rect.y+4, 56].min
else
@viewportA.rect.y = [@viewportA.rect.y-4, 0].max
end
end
@viewportA.update
@viewportB.update
#---
update_battle_cursor
update_magic_circle
update_magic_square
update_battleback_lighting
end

#--------------------------------------------------------------------------
# overwrite method: create_enemies
#--------------------------------------------------------------------------
def create_enemies
dispose_enemies if @enemy_sprites != nil
$scene.enemychars = {}
@enemy_sprites = []
for enemy in $game_troop.members.reverse
if $scene.view_type == 0 or enemy.character_name == ""
@enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
else
character = Game_Character.new
character.set_graphic(enemy.character_name, enemy.character_index)
character.opacity = 0 if enemy.hidden
character.step_anime = true
character_sprite = Sprite_Character.new(@viewport1, character)
create_enemy_coordinates(character, enemy)
battler_sprite = Sprite_Battler.new(@viewport1, enemy)
battler_sprite.character_sprite = character_sprite
@enemy_sprites.push(battler_sprite)
@enemy_sprites[@enemy_sprites.size-1].create_character_dimensions
$scene.enemychars[enemy] = character
if enemy.dead?
battler_sprite.start_character_death
battler_sprite.character_death_duration = 1
battler_sprite.update_character_death
end
end
end
end

#--------------------------------------------------------------------------
# new method: create_enemy_coordinates
#--------------------------------------------------------------------------
def create_enemy_coordinates(character, enemy)
character.origin_x = enemy.origin_x
character.origin_y = enemy.origin_y
case $scene.view_type
when 1; array = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[:front]
when 2; array = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[:side]
when 3; array = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[:angle]
end
back_hash = {1=>9,2=>8,3=>7,4=>6,6=>4,7=>3,8=>2,9=>1}
backdir = back_hash[array[0]]
direction = correct_direction(backdir)
character.set_direction(direction)
character.screen_x = character.origin_x
character.screen_y = character.origin_y
character.screen_z = 200
end

#--------------------------------------------------------------------------
# overwrite method: create_actors
#--------------------------------------------------------------------------
def create_actors
dispose_actors if @actor_sprites != nil
$scene.characters = {}
@actor_sprites = []
unless [1, 2, 3].include?($scene.view_type)
for member in $game_party.members
@actor_sprites.push(Sprite_Battler.new(@viewport1, member))
end
return
end
for actor in $game_party.members
character = Game_Character.new
character.set_graphic(actor.character_name, actor.character_index)
character.step_anime = true
character_sprite = Sprite_Character.new(@viewport1, character)
create_actor_coordinates(character, actor)
battler_sprite = Sprite_Battler.new(@viewport1, actor)
battler_sprite.character_sprite = character_sprite
@actor_sprites.push(battler_sprite)
@actor_sprites[@actor_sprites.size-1].create_character_dimensions
$scene.characters[actor.index] = character
if actor.dead?
battler_sprite.start_character_death
battler_sprite.character_death_duration = 1
battler_sprite.update_character_death
end
end
end

#--------------------------------------------------------------------------
# new method: create_actor_coordinates
#--------------------------------------------------------------------------
def create_actor_coordinates(character, actor)
index = actor.index
index = 0 unless YEM::BATTLE_ENGINE::ACTOR_COORDINATES.include?(index)
array = YEM::BATTLE_ENGINE::ACTOR_COORDINATES[index][$scene.view_type]
character.origin_x = array[0]
character.origin_y = array[1]
case $scene.view_type
when 1; array = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[:front]
when 2; array = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[:side]
when 3; array = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[:angle]
end
direction = correct_direction(array[0])
character.set_direction(direction)
case actor.class.position
when 0
character.origin_x += array[1]
character.origin_y += array[2]
when 1
character.origin_x += array[3]
character.origin_y += array[4]
when 2
character.origin_x += array[5]
character.origin_y += array[6]
end
character.screen_x = character.origin_x
character.screen_y = character.origin_y
character.screen_z = 200
end

#--------------------------------------------------------------------------
# new method: correct_direction
#--------------------------------------------------------------------------
def correct_direction(direction)
return direction if $imported["ExtendedMovement"]
correction ={ 1=>2, 2=>2, 3=>6, 4=>4, 6=>6, 7=>4, 8=>8, 9=>8 }
return correction[direction]
end

#--------------------------------------------------------------------------
# alias method: update_enemies
#--------------------------------------------------------------------------
alias update_enemies_bem update_enemies unless $@
def update_enemies
return unless $scene.is_a?(Scene_Battle)
update_enemies_bem
for key in $scene.enemychars
character = key[1]
character.update
end
end

#--------------------------------------------------------------------------
# overwrite method: update_actors
#--------------------------------------------------------------------------
def update_actors
return unless $scene.is_a?(Scene_Battle)
for sprite in @actor_sprites
sprite.update
end
for key in $scene.characters
character = key[1]
character.update
end
end

#--------------------------------------------------------------------------
# overwrite method: animation?
#--------------------------------------------------------------------------
def animation?
for sprite in @enemy_sprites + @actor_sprites
return true if sprite.animation?
next if sprite.character_sprite == nil
return true if sprite.character_sprite.animation?
end
return false
end

#--------------------------------------------------------------------------
# new method: create_camera
#--------------------------------------------------------------------------
def create_camera
@camera_x = 0
@camera_y = 0
@camera_to_x = 0
@camera_to_y = 0
@camera_to_x_rate = 4
@camera_to_y_rate = 4
end

#--------------------------------------------------------------------------
# new method: update_camera
#--------------------------------------------------------------------------
def update_camera
if @camera_x != @camera_to_x
value = [[(@camera_to_x-@camera_x).abs, @camera_to_x_rate].min, 1].max
@camera_x += (@camera_to_x > @camera_x) ? value : -value
end
if @camera_y != @camera_to_y
value = [[(@camera_to_y-@camera_y).abs, @camera_to_y_rate].min, 1].max
@camera_y += (@camera_to_y > @camera_y) ? value : -value
end
end

#--------------------------------------------------------------------------
# new method: set_camera_desintation
#--------------------------------------------------------------------------
def set_camera_destination(to_x, to_y, frames = 60)
@camera_to_x = to_x
@camera_to_y = to_y
@camera_to_x_rate = [(@camera_to_x-@camera_x).abs/[frames, 1].max, 1].max
@camera_to_y_rate = [(@camera_to_y-@camera_y).abs/[frames, 1].max, 1].max
end

#--------------------------------------------------------------------------
# new method: scroll_camera
#--------------------------------------------------------------------------
def scroll_camera(direction, distance, frames = 60)
to_x = @camera_to_x
to_y = @camera_to_y
case direction
when 1 # Down Left
to_x += distance
to_y -= distance
when 2 # Down
to_y -= distance
when 3 # Down Right
to_x -= distance
to_y -= distance
when 4 # Left
to_x -= distance
when 6 # Right
to_x += distance
when 7 # Up Left
to_x -= distance
to_y += distance
when 8 # Up
to_y += distance
when 9 # Up Right
to_x += distance
to_y += distance
end
set_camera_destination(to_x, to_y, frames)
end

#--------------------------------------------------------------------------
# new method: create_order_sprites
#--------------------------------------------------------------------------
def create_order_sprites
case $scene.battle_type
when 0 # Default Turn Battle
create_dtb_sprites
when 1 # Press Turn Battle
# none, reset in battle
when 2 # Active Turn Battle
create_atb_sprites
when 3 # Charge Turn Battle
create_ctb_sprites
end
end

#--------------------------------------------------------------------------
# new method: update_order_sprites
#--------------------------------------------------------------------------
def update_order_sprites
return if @order_sprites == nil
for sprite in @order_sprites
sprite.update
end
end

#--------------------------------------------------------------------------
# new method: dispose_order_sprites
#--------------------------------------------------------------------------
def dispose_order_sprites
return if @order_sprites == nil
for sprite in @order_sprites
sprite.dispose
sprite = nil
end
@order_sprites = nil
end

#--------------------------------------------------------------------------
# new method: create_dtb_sprites
#--------------------------------------------------------------------------
def create_dtb_sprites
dispose_order_sprites
@order_sprites = []
array = $game_party.members + $game_troop.members
for member in array.reverse
sprite = Sprite_OrderBattler.new(@viewportA, member, 0)
@order_sprites.push(sprite)
end
end

#--------------------------------------------------------------------------
# new method: update_dtb_order
#--------------------------------------------------------------------------
def update_dtb_order
return unless $scene.is_a?(Scene_Battle)
return unless $scene.dtb?
return if @order_sprites == nil
for sprite in @order_sprites
sprite.make_dtb_destination
end
end

#--------------------------------------------------------------------------
# new method: update_ptb_call
#--------------------------------------------------------------------------
def update_ptb_call
return if @ptb_update == nil
refresh_ptb_counters(@ptb_update)
end

#--------------------------------------------------------------------------
# new method: refresh_ptb_counters
#--------------------------------------------------------------------------
def refresh_ptb_counters(group)
@ptb_update = nil
dispose_order_sprites
@order_sprites = []
amount = group.ptb_total_turns
index = 1; dx = 12; dy = 6
amount.times do
sprite = Sprite_PTB.new(@viewportA, dx, dy, group, index)
@order_sprites.push(sprite)
index += 1
dx += 24
dy = (dy == 6) ? 18 : 6
end
end

#--------------------------------------------------------------------------
# create_atb_sprites
#--------------------------------------------------------------------------
def create_atb_sprites
dispose_order_sprites
@order_sprites = []
create_atb_gauge
array = $game_party.members + $game_troop.members
for member in array.reverse
sprite = Sprite_OrderBattler.new(@viewportA, member, 2)
@order_sprites.push(sprite)
end
end

#--------------------------------------------------------------------------
# create_atb_gauge
#--------------------------------------------------------------------------
def create_atb_gauge
sprite = Sprite_Base.new(@viewportA)
bitmap = Cache.system(YEM::BATTLE_ENGINE::ATB_GAUGE)
sprite.bitmap = bitmap
sprite.x = 5
sprite.y = 5
@order_sprites.push(sprite)
end

#--------------------------------------------------------------------------
# new method: create_ctb_sprites
#--------------------------------------------------------------------------
def create_ctb_sprites
dispose_order_sprites
@order_sprites = []
array = $game_party.members + $game_troop.members
for member in array.reverse
sprite = Sprite_OrderBattler.new(@viewportA, member, 3)
@order_sprites.push(sprite)
end
end

#--------------------------------------------------------------------------
# new method: update_ctb_order
#--------------------------------------------------------------------------
def update_ctb_order
return unless $scene.is_a?(Scene_Battle)
return unless $scene.ctb?
return if @order_sprites == nil
for sprite in @order_sprites
sprite.make_ctb_destination
end
end

#--------------------------------------------------------------------------
# new method: mark_first_time_order
#--------------------------------------------------------------------------
def mark_first_time_order
return unless $scene.is_a?(Scene_Battle)
return if @marked_first_time
@marked_first_time = true
return if $scene.ptb?
return if @order_sprites == nil
for sprite in @order_sprites
sprite.first_time = true
end
end

#--------------------------------------------------------------------------
# new method: create_battle_cursor
#--------------------------------------------------------------------------
def create_battle_cursor
return unless YEM::BATTLE_ENGINE::BATTLE_CURSOR[:enable]
@battle_cursor = Sprite_BattleCursor.new(@viewportB)
end

#--------------------------------------------------------------------------
# new method: update_battle_cursor
#--------------------------------------------------------------------------
def update_battle_cursor
return if @battle_cursor == nil
@battle_cursor.update
end

#--------------------------------------------------------------------------
# new method: dispose_battle_cursor
#--------------------------------------------------------------------------
def dispose_battle_cursor
return if @battle_cursor == nil
@battle_cursor.dispose
end

#--------------------------------------------------------------------------
# new method: create_magic_circle
#--------------------------------------------------------------------------
def create_magic_circle(window, obj)
if obj.is_a?(RPG::Skill) or obj.is_a?(RPG::Item)
return if obj.aoe_radius <= 0
else; return
end
#---
@aoe_window = window
@magic_circle_sprite = Sprite.new(@viewport1)
@magic_circle_sprite.bitmap = Cache.picture(obj.aoe_image)
diameter = obj.aoe_radius * 2 + 1
@magic_circle_sprite.blend_type = obj.aoe_blend
@magic_circle_sprite.zoom_x = diameter * 1.125 /
@magic_circle_sprite.width
@magic_circle_sprite.zoom_y = @magic_circle_sprite.zoom_x *
(obj.aoe_height + 0.01)
@magic_circle_sprite.ox = @magic_circle_sprite.width/2
@magic_circle_sprite.oy = @magic_circle_sprite.height/2
@magic_circle_sprite.z = 2
end

#--------------------------------------------------------------------------
# new method: dispose_magic_circle
#--------------------------------------------------------------------------
def dispose_magic_circle
@magic_circle_sprite.dispose if @magic_circle_sprite != nil
@magic_circle_sprite = nil
@aoe_window = nil
end

#--------------------------------------------------------------------------
# new method: update_magic_circle
#--------------------------------------------------------------------------
def update_magic_circle
return if @magic_circle_sprite == nil
if @aoe_window != nil
if @aoe_window.is_a?(Window_TargetEnemy)
target = @aoe_window.enemy
group = $game_troop
value_x = target.screen_x + target.enemy.target_offset_x
value_y = target.screen_y + target.enemy.target_offset_y
elsif @aoe_window.is_a?(Window_BattleStatus)
target = @aoe_window.actor
group = $game_party
value_x = target.screen_x
value_y = target.screen_y
end
#---
update_highlight = false
if @magic_circle_sprite.x != value_x
update_highlight = true
@magic_circle_sprite.x = value_x
end
if @magic_circle_sprite.y != value_y
update_highlight = true
@magic_circle_sprite.y = value_y
end
$scene.create_highlighted_targets(group) if update_highlight
#---
end
@magic_circle_sprite.opacity += @magic_circle_sprite_upward ? 8 : -8
if @magic_circle_sprite.opacity <= 0
@magic_circle_sprite_upward = true
elsif @magic_circle_sprite.opacity >= 255
@magic_circle_sprite_upward = false
end
end

#--------------------------------------------------------------------------
# new method: create_magic_square
#--------------------------------------------------------------------------
def create_magic_square(window, obj)
if obj.is_a?(RPG::Skill) or obj.is_a?(RPG::Item)
return if obj.rect_type <= 0
else; return
end
@aoe_window = window
@magic_square_sprite = Sprite.new(@viewport1)
@magic_square_sprite.bitmap = Cache.picture(obj.rect_image)
@magic_square_sprite.blend_type = obj.rect_blend
@magic_square_type = obj.rect_type
rect_value = obj.rect_value * 2 + 1
case @magic_square_type
when 1 # Column
@magic_square_sprite.zoom_x = rect_value * 1.0 /
@magic_square_sprite.width
@magic_square_sprite.zoom_y = Graphics.height * 1.0 /
@magic_square_sprite.height
@magic_square_sprite.ox = @magic_square_sprite.width/2
when 2 # Row
@magic_square_sprite.zoom_x = Graphics.width * 1.0 /
@magic_square_sprite.width
@magic_square_sprite.zoom_y = rect_value * 1.0 /
@magic_square_sprite.height
@magic_square_sprite.oy = @magic_square_sprite.height/2
when 3 # Map
@magic_square_sprite.zoom_x = Graphics.width * 1.0 /
@magic_square_sprite.width
@magic_square_sprite.zoom_y = Graphics.height * 1.0 /
@magic_square_sprite.height
end
@magic_square_sprite.z = 3
end

#--------------------------------------------------------------------------
# new method: dispose_magic_square
#--------------------------------------------------------------------------
def dispose_magic_square
@magic_square_sprite.dispose if @magic_square_sprite != nil
@magic_square_sprite = nil
@aoe_window = nil
end

#--------------------------------------------------------------------------
# new method: update_magic_square
#--------------------------------------------------------------------------
def update_magic_square
return if @magic_square_sprite == nil
if @aoe_window != nil
if @aoe_window.is_a?(Window_TargetEnemy)
group = $game_troop
target = @aoe_window.enemy
case @magic_square_type
when 1 # Column
value_x = target.screen_x
value_x += target.enemy.target_offset_x
value_y = 0
when 2 # Row
value_x = 0
value_y = target.screen_y
value_y += target.enemy.target_offset_y
when 3 # Map
value_x = 0
value_y = 0
end
elsif @aoe_window.is_a?(Window_BattleStatus)
group = $game_party
target = @aoe_window.actor
case @magic_square_type
when 1 # Column
value_x = target.screen_x
value_y = 0
when 2 # Row
value_x = 0
value_y = target.screen_y
when 3 # Map
value_x = 0
value_y = 0
end
end
#---
update_highlight = false
if @magic_square_sprite.x != value_x
update_highlight = true
@magic_square_sprite.x = value_x
end
if @magic_square_sprite.y != value_y
update_highlight = true
@magic_square_sprite.y = value_y
end
$scene.create_highlighted_targets(group) if update_highlight
#---
end
@magic_square_sprite.opacity += @magic_square_sprite_upward ? 8 : -8
if @magic_square_sprite.opacity <= 0
@magic_square_sprite_upward = true
elsif @magic_square_sprite.opacity >= 255
@magic_square_sprite_upward = false
end
end

#--------------------------------------------------------------------------
# new method: start_battleback_darken
#--------------------------------------------------------------------------
def start_battleback_darken
@battleback_darken_duration = 32
@battleback_sprite.color.set(0,0,0,0)
end

#--------------------------------------------------------------------------
# new method: start_battleback_lighten
#--------------------------------------------------------------------------
def start_battleback_lighten
@battleback_lighten_duration = 16
@battleback_sprite.color.set(0,0,0,128)
end

#--------------------------------------------------------------------------
# new method: update_battleback_lighting
#--------------------------------------------------------------------------
def update_battleback_lighting
if @battleback_darken_duration != nil
@battleback_darken_duration -= 1
duration = @battleback_darken_duration
@battleback_sprite.color.alpha += 4
@battleback_darken_duration = nil if @battleback_darken_duration <= 0
return
end
if @battleback_lighten_duration != nil
@battleback_lighten_duration -= 1
@battleback_sprite.color.alpha -= 8
@battleback_lighten_duration = nil if @battleback_lighten_duration <= 0
end
end

end # Spriteset_Battle

#==============================================================================
# Window_Base
#==============================================================================

class Window_Base < Window

#--------------------------------------------------------------------------
# alias method: initialize
#--------------------------------------------------------------------------
alias initialize_window_base_bem initialize unless $@
def initialize(x, y, width, height)
initialize_window_base_bem(x, y, width, height)
if $game_temp.in_battle
$disposable_melody_windows = [] if $disposable_melody_windows == nil
$disposable_melody_windows.push(self)
end
end

#--------------------------------------------------------------------------
# alias method: dispose
#--------------------------------------------------------------------------
alias dispose_window_base_bem dispose unless $@
def dispose
if $game_temp.in_battle
$disposable_melody_windows = [] if $disposable_melody_windows == nil
$disposable_melody_windows.delete(self)
end
dispose_window_base_bem
end

#--------------------------------------------------------------------------
# rage_gauge_color1
#--------------------------------------------------------------------------
def rage_gauge_color1
return text_color(YEM::BATTLE_ENGINE::SKILL_SETTINGS[:rage_gauge1])
end

#--------------------------------------------------------------------------
# rage_gauge_color2
#--------------------------------------------------------------------------
def rage_gauge_color2
return text_color(YEM::BATTLE_ENGINE::SKILL_SETTINGS[:rage_gauge2])
end

#--------------------------------------------------------------------------
# new method: draw_actor_rage_gauge
#--------------------------------------------------------------------------
unless $imported["CoreFixesUpgradesMelody"]
def draw_actor_rage_gauge(actor, x, y, width = 120, height = nil)
gc0 = gauge_back_color
gc1 = text_color(YEM::BATTLE_ENGINE::RAGE[:rage_gauge1])
gc2 = text_color(YEM::BATTLE_ENGINE::RAGE[:rage_gauge2])
gh = 6
gy = y + WLH - 8 - (gh - 6)
gb = width
self.contents.fill_rect(x, gy, gb, gh, gc0)
gw = [[gb * actor.rage / actor.max_rage, width].min, 0].max
self.contents.gradient_fill_rect(x, gy, gw, gh, gc1, gc2)
end
end

#--------------------------------------------------------------------------
# new method: draw_enemy_hp_gauge
#--------------------------------------------------------------------------
def draw_enemy_hp_gauge(battler, x, y, width = 120)
battler.hp = [battler.hp, battler.maxhp].min
gc0 = gauge_back_color
gc1 = text_color(battler.enemy.quick_gauge[:hp_gauge1])
gc2 = text_color(battler.enemy.quick_gauge[:hp_gauge2])
gh = 6
gy = y + WLH - 8 - (gh - 6)
if battler.maxhp < battler.base_maxhp and battler.base_maxhp > 0 and
!(battler.base_maxhp > battler.maxhp_limit)
gb = width * battler.maxhp / battler.base_maxhp
self.contents.fill_rect(x, gy, width, gh, text_color(7))
else
gb = width
end
self.contents.fill_rect(x, gy, gb, gh, gc0)
gw = gb * battler.hp / battler.maxhp
self.contents.gradient_fill_rect(x, gy, gw, gh, gc1, gc2)
end

#--------------------------------------------------------------------------
# new method: draw_enemy_mp_gauge
#--------------------------------------------------------------------------
def draw_enemy_mp_gauge(battler, x, y, width = 120, height = nil)
battler.mp = [battler.mp, battler.maxmp].min
gc0 = gauge_back_color
gc1 = text_color(battler.enemy.quick_gauge[:mp_gauge1])
gc2 = text_color(battler.enemy.quick_gauge[:mp_gauge2])
gh = 6
gy = y + WLH - 8 - (gh - 6)
if battler.maxmp < battler.base_maxmp and battler.base_maxmp > 0 and
!(battler.base_maxmp > battler.maxmp_limit)
gb = width * battler.maxmp / battler.base_maxmp
self.contents.fill_rect(x, gy, width, gh, text_color(7))
else
gb = width
end
self.contents.fill_rect(x, gy, gb, gh, gc0)
if battler.maxmp <= 0
if battler.base_maxmp <= 0
gw = width
else
gw = 0
end
else
gw = gb * battler.mp / battler.maxmp
end
self.contents.gradient_fill_rect(x, gy, gw, gh, gc1, gc2)
end

#--------------------------------------------------------------------------
# new method: draw_enemy_rage_gauge
#--------------------------------------------------------------------------
def draw_enemy_rage_gauge(actor, x, y, width = 120, height = nil)
gc0 = gauge_back_color
gc1 = text_color(YEM::BATTLE_ENGINE::SKILL_SETTINGS[:rage_gauge1])
gc2 = text_color(YEM::BATTLE_ENGINE::SKILL_SETTINGS[:rage_gauge2])
gh = $imported["CoreFixesUpgradesMelody"] ? YEM::UPGRADE::GAUGE_HEIGHT : 6
gy = y + WLH - 8 - (gh - 6)
gb = width
self.contents.fill_rect(x, gy, gb, gh, gc0)
gw = [[gb * actor.rage / actor.max_rage, width].min, 0].max
self.contents.gradient_fill_rect(x, gy, gw, gh, gc1, gc2)
end

end # Window_Base

#==============================================================================
# Window_Command_Centered
#==============================================================================

class Window_Command_Centered < Window_Command

#--------------------------------------------------------------------------
# new method: draw_item
#--------------------------------------------------------------------------
def draw_item(index, enabled = true)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(rect, @commands[index],1)
end

end # Window_Command_Centered

#===============================================================================
# Window_BattleDebug
#===============================================================================

class Window_BattleDebug < Window_Base

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
super(0, 16, Graphics.width, 56)
self.back_opacity = 0
self.opacity = 0
end

#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
call_enable
return unless @enabled
return unless $scene.is_a?(Scene_Battle)
refresh if @current_selected != $scene.selected_battler
refresh if @current_active != $scene.active_battler
refresh if @current_turn != $game_troop.turn_count
end

#--------------------------------------------------------------------------
# call_enable
#--------------------------------------------------------------------------
def call_enable
return if @enabled
if Input.press?(Input::CTRL) and Input.press?(Input::ALT)
@enabled = true
Sound.play_decision
end
end

#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.size = 16
dw = contents.width/4
@current_selected = $scene.selected_battler
@current_active = $scene.active_battler
@current_turn = $game_troop.turn_count
if @current_turn != nil
turn = @current_turn
text = sprintf("Turn: %s", turn)
self.contents.draw_text(dw*0, 0, dw, WLH, text, 0)
end
if @current_selected != nil
name = @current_selected.name
text = sprintf("Sel: %s", name)
self.contents.draw_text(dw*2, 0, dw, WLH, text, 0)
end
if @current_active != nil
name = @current_active.name
text = sprintf("Act: %s", name)
self.contents.draw_text(dw*3, 0, dw, WLH, text, 0)
end
end

end # Window_BattleDebug

#==============================================================================
# Window_TargetEnemy
#==============================================================================

class Window_TargetEnemy < Window_Command

#--------------------------------------------------------------------------
# overwrite method: initialize
#--------------------------------------------------------------------------
def initialize
commands = []
super(416, commands, 8, 1)
end

#--------------------------------------------------------------------------
# overwrite method: refresh
#--------------------------------------------------------------------------
def refresh
@commands = []
@enemies = []
for enemy in $game_troop.members
next unless enemy.exist?
@commands.push(enemy.name)
@enemies.push(enemy)
end
@enemies.sort! { |a,b| a.screen_x <=> b.screen_x }
self.contents.clear
@item_max = @commands.size
for i in 0...@item_max; draw_item(i); end
end

end # Window_TargetEnemy

#===============================================================================
# Window_TargetHelp
#===============================================================================

class Window_TargetHelp < Window_Base

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
super(0, 0, Graphics.width, 56)
refresh
end

#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh(target = nil, battler = nil)
self.contents.clear
return if target == nil
if draw_unique_name?(battler)
draw_obj_selection(battler)
return
end
name = target.name
if $imported["EnemyLevels"] and target.enemy?
name = sprintf(YEM::ENEMY_LEVEL::LEVEL_TEXT, target.level, name)
end
self.contents.draw_text(0, 0, contents.width, WLH, name, 1)
end

#--------------------------------------------------------------------------
# draw_unique_name?
#--------------------------------------------------------------------------
def draw_unique_name?(battler)
return false if battler == nil
return false if battler.action == nil
return false if battler.action.attack?
obj = battler.action.skill if battler.action.skill?
obj = battler.action.item if battler.action.item?
if $scene.atb?
case battler.action.atb_queue_kind
when 0; return false
when 1; obj = $data_skills[battler.action.atb_queue_basic]
when 2; obj = $data_items[battler.action.atb_queue_basic]
end
end
return false if obj == nil
return true if obj.target_text != nil
return true if !obj.need_selection?
return false
end

#--------------------------------------------------------------------------
# draw_obj_selection
#--------------------------------------------------------------------------
def draw_obj_selection(battler)
obj = battler.action.skill if battler.action.skill?
obj = battler.action.item if battler.action.item?
if $scene.atb?
case battler.action.atb_queue_kind
when 1; obj = $data_skills[battler.action.atb_queue_basic]
when 2; obj = $data_items[battler.action.atb_queue_basic]
end
end
if obj.for_user?
text = YEM::BATTLE_ENGINE::TARGET_WINDOW[:user]
elsif obj.for_friend?
if obj.for_one?
text = YEM::BATTLE_ENGINE::TARGET_WINDOW[:actor]
else
text = YEM::BATTLE_ENGINE::TARGET_WINDOW[:actors]
end
if obj.for_dead_friend?
text = sprintf(YEM::BATTLE_ENGINE::TARGET_WINDOW[:dead], text)
end
elsif obj.for_opponent?
if obj.for_one?
text = YEM::BATTLE_ENGINE::TARGET_WINDOW[:enemy]
else
text = YEM::BATTLE_ENGINE::TARGET_WINDOW[:enemies]
end
else
text = YEM::BATTLE_ENGINE::TARGET_WINDOW[:none]
self.contents.draw_text(0, 0, contents.width, WLH, text, 1)
return
end
if obj.for_random?
n = obj.random_targets
text = sprintf(YEM::BATTLE_ENGINE::TARGET_WINDOW[:random], n, text)
end
if obj.for_all?
text = sprintf(YEM::BATTLE_ENGINE::TARGET_WINDOW[:all], text)
end
if obj.target_text != nil
name = ""
if $scene.target_enemy_window != nil
name = $scene.target_enemy_window.enemy.name
if $imported["EnemyLevels"] and $scene.target_enemy_window.enemy.enemy?
level = $scene.target_enemy_window.enemy.level
name = sprintf(YEM::ENEMY_LEVEL::LEVEL_TEXT, level, name)
end
elsif $scene.target_actor_window != nil
name = $scene.target_enemy_window.actor.name
end
text = sprintf(obj.target_text, name)
end
self.contents.draw_text(0, 0, contents.width, WLH, text, 1)
end

end # Window_TargetHelp

#===============================================================================
# Window_BattleMessageMelody
#===============================================================================

class Window_BattleMessageMelody < Window_BattleMessage

#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :align
attr_accessor :icon

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
super
self.x = 0
self.y = 32
self.z = 300
self.back_opacity = 0
self.opacity = 0
self.windowskin = Cache.system("Window")
@align = YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:alignment]
create_background_sprite
change_viewport($scene.spriteset.viewportB)
end

#--------------------------------------------------------------------------
# dispose
#--------------------------------------------------------------------------
def dispose
super
@leftsprite.bitmap.dispose
@leftsprite.dispose
@centersprite.bitmap.dispose
@centersprite.dispose
@rightsprite.bitmap.dispose
@rightsprite.dispose
end

#--------------------------------------------------------------------------
# create_background_sprite
#--------------------------------------------------------------------------
def create_background_sprite
gw = Graphics.width
g1 = YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:gradient1]
g2 = YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:gradient2]
#--- Create Left Aligned Sprite ---
bitmap = Bitmap.new(gw, 112)
bitmap.gradient_fill_rect(0, 16, gw, 96, g1, g2)
@leftsprite = Sprite.new(self.viewport)
@leftsprite.bitmap = bitmap
@leftsprite.x = self.x
@leftsprite.y = self.y
@leftsprite.z = self.z - 1
@leftsprite.src_rect.height = 16
#--- Create Center Aligned Sprite ---
bitmap = Bitmap.new(gw, 112)
bitmap.gradient_fill_rect(0, 16, gw/2, 96, g2, g1)
bitmap.gradient_fill_rect(gw/2, 16, gw/2, 96, g1, g2)
@centersprite = Sprite.new(self.viewport)
@centersprite.bitmap = bitmap
@centersprite.x = self.x
@centersprite.y = self.y
@centersprite.z = self.z - 1
@centersprite.src_rect.height = 16
#--- Create Right Aligned Sprite ---
bitmap = Bitmap.new(gw, 112)
bitmap.gradient_fill_rect(0, 16, gw, 96, g2, g1)
@rightsprite = Sprite.new(self.viewport)
@rightsprite.bitmap = bitmap
@rightsprite.x = self.x
@rightsprite.y = self.y
@rightsprite.z = self.z - 1
@rightsprite.src_rect.height = 16
#--- Hide Sprites ---
@leftsprite.opacity = 0
@centersprite.opacity = 0
@rightsprite.opacity = 0
end

#--------------------------------------------------------------------------
# change_viewport
#--------------------------------------------------------------------------
def change_viewport(viewport)
return if self.viewport == viewport
self.viewport = viewport
@leftsprite.viewport = self.viewport
@centersprite.viewport = self.viewport
@rightsprite.viewport = self.viewport
end

#--------------------------------------------------------------------------
# new_page
#--------------------------------------------------------------------------
def new_page
super
self.windowskin = Cache.system("Window")
self.contents.font.shadow = true
self.contents.font.color = normal_color
end

#--------------------------------------------------------------------------
# clear
#--------------------------------------------------------------------------
def clear
super
@icon = nil
end

#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
update
super
end

#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
return if @anti_update
if self.viewport != nil
#---
self.x = self.viewport.ox
@leftsprite.x = @centersprite.x = @rightsprite.x = self.x
#---
self.y = self.viewport.oy + 32
@leftsprite.y = @centersprite.y = @rightsprite.y = self.y
#---
end
if self.visible and (@lines.size > 0) or
(@text != nil or self.pause or @index > -1)
if @text != nil
lines = 4
else
lines = (!self.pause or @index > -1) ? @lines.size : 4
end
case @align
when 1
@centersprite.opacity += YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:opacity]
@centersprite.src_rect.height = 16 + (lines * 24)
when 2
@rightsprite.opacity += YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:opacity]
@rightsprite.src_rect.height = 16 + (lines * 24)
else
@leftsprite.opacity += YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:opacity]
@leftsprite.src_rect.height = 16 + (lines * 24)
end
@countdown = 8
elsif @countdown != nil and @countdown > 0
@countdown -= 1
elsif @countdown != nil
@centersprite.opacity -= YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:opacity]
@leftsprite.opacity -= YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:opacity]
@rightsprite.opacity -= YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:opacity]
end
super
end

#--------------------------------------------------------------------------
# draw_line
#--------------------------------------------------------------------------
def draw_line(index)
rect = Rect.new(0, 0, 0, 0)
rect.x += 4
rect.y += index * WLH
rect.width = contents.width - 8
rect.height = WLH
dx = rect.x; dy = rect.y; dw = rect.width; dh = rect.height
self.contents.clear_rect(rect)
if $imported["CustomMessageMelody"] and $game_message.busy
self.contents.font.name = YEM::MESSAGE::MESSAGE_WINDOW_FONT
else
self.contents.font.name = Font.default_name
end
self.contents.font.color = normal_color
if index == 0 and (@icon != nil and @icon != 0)
fx = contents.text_size(@lines[index]).width
case @align
when 0 # Left Aligned
draw_icon(@icon, dx, dy)
dx += 24
when 1 # Center Aligned
draw_icon(@icon, (dw-fx)/2-12, dy)
dx += 12
when 2 # Right Aligned
draw_icon(@icon, dw-fx-24, dy)
end
end
self.contents.draw_text(dx, dy, dw, dh, @lines[index], @align)
end

end # Window_BattleMessageMelody

#===============================================================================
# Window_BattleStatus
#===============================================================================

class Window_BattleStatus < Window_Selectable

#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :battle_refresh_call
attr_accessor :frozen_cursor
attr_accessor :highlight_all
attr_accessor :highlight_user
attr_accessor :highlight_none
attr_accessor :highlight_dead
attr_accessor :target_highlight

#--------------------------------------------------------------------------
# overwrite method: initialize
#--------------------------------------------------------------------------
def initialize(minimum = false)
super(0, 0, Graphics.width - 128, 128)
max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
@item_max = [$game_party.members.size, max_members].max
@column_max = @item_max
@minimum = minimum
@current_party = $game_party.members
recreate unless @miniature
self.active = false
end

#--------------------------------------------------------------------------
# actor
#--------------------------------------------------------------------------
def actor; return $game_party.members[self.index]; end

#--------------------------------------------------------------------------
# recreate
#--------------------------------------------------------------------------
def recreate
max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
@item_max = [$game_party.members.size, max_members].max
@item_max = 1 if @minitature
@updating = -1
@current_party = $game_party.members
@current_hp = {}; @current_hp_gauge = {}; @maxhp = {}
@current_mp = {}; @current_mp_gauge = {}; @maxmp = {}
@current_rage = {}; @current_rage_gauge = {}; @max_rage = {}
temp_rect = item_rect(0)
@hp_gauge_width = temp_rect.width-4
@mp_gauge_width = temp_rect.width-4
@rg_gauge_width = temp_rect.width-4
for i in 0...@current_party.size
actor = $game_party.members[i]
#--
@current_hp[i] = actor.hp
maxhp = [[actor.maxhp, actor.base_maxhp, 1].max, actor.maxhp_limit].min
@current_hp_gauge[i] = (actor.hp * @hp_gauge_width / maxhp)
@maxhp[i] = maxhp
#--
maxmp = [[actor.maxmp, actor.base_maxmp, 1].max, actor.maxmp_limit].min
@current_mp[i] = actor.mp
@current_mp_gauge[i] = (actor.mp * @mp_gauge_width / [actor.maxmp,1].max)
@maxmp[i] = maxmp
#---
actor.rage = 0 if actor.rage == nil
@current_rage[i] = actor.rage
@current_rage_gauge[i] = actor.rage * @rg_gauge_width / actor.max_rage
@max_rage[i] = actor.max_rage
end
refresh
end

#--------------------------------------------------------------------------
# new method: update
#--------------------------------------------------------------------------
def update
super unless prevent_left_right?
redraw if @last_index != self.index
redraw if @battle_refresh_call
return unless @minimum
recreate if @current_party != $game_party.members
return unless $scene.is_a?(Scene_Battle)
for member in $game_party.members; redraw if member.update_states; end
redraw if @last_active_battler != $scene.active_battler
end

#--------------------------------------------------------------------------
# new method: prevent_left_right
#--------------------------------------------------------------------------
def prevent_left_right?
return true if (@frozen_cursor and (Input.repeat?(Input::LEFT) or
Input.repeat?(Input::RIGHT)))
if Input.repeat?(Input::LEFT) and $game_party.members[self.index-1] == nil
return true
end
if Input.repeat?(Input::RIGHT) and $game_party.members[self.index+1] == nil
return true
end
return false
end

#--------------------------------------------------------------------------
# new method: redraw
#--------------------------------------------------------------------------
def redraw
return unless $scene.is_a?(Scene_Battle)
@last_index = self.index
@last_active_battler = $scene.active_battler
@battle_refresh_call = false
refresh
end

#--------------------------------------------------------------------------
# overwrite method: refresh
#--------------------------------------------------------------------------
def refresh
return if @miniature
max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
@item_max = [$game_party.members.size, max_members].max
@column_max = @item_max
for i in 0...@item_max; draw_item(i); end
end

#--------------------------------------------------------------------------
# overwrite method: draw_item
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
actor = $game_party.members[index]
return if actor == nil
draw_member_face(actor, rect.clone)
draw_member_action(actor, rect.clone)
return if @minimum
draw_member_name(actor, rect.clone)
draw_member_states(actor, rect.clone)
draw_member_hp(actor, rect.clone)
draw_member_mp(actor, rect.clone)
draw_member_rage(actor, rect.clone)
end

#--------------------------------------------------------------------------
# new method: item_rect
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new(0, 0, 0, 0)
rect.width = contents.width / @item_max
rect.height = contents.height
rect.x = index * rect.width
rect.y = 0
return rect
end

#--------------------------------------------------------------------------
# new method: draw_member_face
#--------------------------------------------------------------------------
def draw_member_face(actor, content_rect)
lower_opacity = YEM::BATTLE_ENGINE::PARTY_WINDOW[:face_opacity]
opacity = opacity?(actor) ? 255 : lower_opacity
face_name = actor.face_name
face_index = actor.face_index
bitmap = Cache.face(face_name)
rect = Rect.new(0, 0, 0, 0)
rect.width = [content_rect.width-4, 92].min
rect.height = [contents.height-4, 92].min
rect.x = face_index % 4 * 96 + (96-rect.width) / 2
rect.y = face_index / 4 * 96 + (96-rect.height) / 2
self.contents.blt(content_rect.x+2, content_rect.y+2, bitmap, rect, opacity)
end

#--------------------------------------------------------------------------
# new method: draw_member_action
#--------------------------------------------------------------------------
def draw_member_action(actor, rect)
return unless YEM::BATTLE_ENGINE::PARTY_WINDOW[:action_icons]
icon = YEM::BATTLE_ENGINE::ICON_MESSAGE[:wait_icon]
case actor.action.kind
when 0 # Basic
case actor.action.basic
when 0 # Attack
icon = actor.attack_icon
when 1 # Guard
icon = actor.guard_icon
when 2 # Escape
icon = YEM::BATTLE_ENGINE::ICON_MESSAGE[:flee_icon]
end
when 1 # Skill
icon = actor.action.skill.icon_index
when 2 # Item
icon = actor.action.item.icon_index
end
enabled = actor.action.valid?
enabled = false if actor.action.kind == 0 and actor.action.basic == 3
if $scene.is_a?(Scene_Battle) and $scene.ctb? and actor.action.guard?
icon = actor.guard_icon
enabled = true
end
draw_icon(icon, rect.x, rect.y, enabled)
end

#--------------------------------------------------------------------------
# new method: opacity?
#--------------------------------------------------------------------------
def opacity?(actor)
return false if actor == nil
if $scene.is_a?(Scene_Battle) and $scene.ctb?
return true if actor.ctb_active? and !@minimum
end
return true if self.is_a?(Window_BattleStatus_Mini)
return false if actor == nil
return false if @highlight_none
return true if @highlight_all
if @highlight_dead
return true if self.index == actor.index and actor.dead?
return false
end
return false if actor.dead?
if !@target_highlight and $scene.is_a?(Scene_Battle)
return true if actor.active_battler?
end
if @highlight_user and $scene.is_a?(Scene_Battle)
return true if actor == $scene.selected_battler
end
return false if @highlight_user
return true if self.index == actor.index
return false if !@minimum
return false
end

#--------------------------------------------------------------------------
# new method: draw_member_name
#--------------------------------------------------------------------------
def draw_member_name(actor, rect)
name = actor.name
self.contents.font.size = YEM::BATTLE_ENGINE::PARTY_WINDOW[:name_size]
dy = rect.y
if YEM::BATTLE_ENGINE::PARTY_WINDOW[:action_icons]
dx = rect.x+24
dw = rect.width-28
else
dx = rect.x+4
dw = rect.width-8
end
self.contents.font.color = hp_color(actor)
self.contents.draw_text(dx, dy, dw, WLH, name)
end

#--------------------------------------------------------------------------
# new method: draw_member_states
#--------------------------------------------------------------------------
def draw_member_states(actor, rect)
dw = [YEM::BATTLE_ENGINE::PARTY_WINDOW[:max_states] * 24, rect.width].min
draw_actor_state(actor, rect.x, rect.y + WLH, dw)
actor.update_states = false
end

#--------------------------------------------------------------------------
# new method: draw_member_hp
#--------------------------------------------------------------------------
def draw_member_hp(actor, rect)
@updating = -1
i = actor.index
maxhp = @maxhp[i]
dy = WLH * 3 - YEM::BATTLE_ENGINE::PARTY_WINDOW[:stat_size]
dx = rect.x + 2
self.contents.fill_rect(dx, dy+WLH-8, @hp_gauge_width, 8, gauge_back_color)
#---
target_gauge = (actor.hp * @hp_gauge_width / maxhp)
if @current_hp_gauge[i] > target_gauge
@updating = i
@current_hp_gauge[i] -= [2, (@current_hp_gauge[i]-target_gauge).abs].min
@current_hp_gauge[i] = [@current_hp_gauge[i], 0].max
gw = @current_hp_gauge[i]
gw = [gw, 3].max if actor.hp > 0
gc1 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:hp_dmg_gauge])
gc2 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:hp_dmg_gauge])
self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
gw = @hp_gauge_width * actor.hp / maxhp
gw = [gw, 3].max if actor.hp > 0
gc1 = hp_gauge_color1
gc2 = hp_gauge_color2
self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
elsif @current_hp_gauge[i] < target_gauge
@updating = i
@current_hp_gauge[i] += [2, (@current_hp_gauge[i]-target_gauge).abs].min
@current_hp_gauge[i] = [@current_hp_gauge[i], @hp_gauge_width].min
gw = @hp_gauge_width * actor.hp / maxhp
gw = [gw, 3].max if actor.hp > 0
gc1 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:hp_heal_gauge])
gc2 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:hp_heal_gauge])
self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
gw = @current_hp_gauge[i]
gw = [gw, 3].max if actor.hp > 0
gc1 = hp_gauge_color1
gc2 = hp_gauge_color2
self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
else
gw = @current_hp_gauge[i]
gw = [gw, 3].max if actor.hp > 0
gc1 = hp_gauge_color1
gc2 = hp_gauge_color2
self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
end
#---
if maxhp > actor.maxhp
gce = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:exhaust_gauge])
gbw = @hp_gauge_width * (actor.base_maxhp - actor.maxhp) / maxhp + 1
gbc = gauge_back_color
self.contents.fill_rect(dx+@hp_gauge_width-gbw-2, dy+WLH-8, gbw, 8, gbc)
self.contents.fill_rect(dx+@hp_gauge_width-gbw-1, dy+WLH-7, gbw, 6, gce)
end
#---
if @current_hp[i] != actor.hp
@updating = i
den = [@hp_gauge_width/3 + rand(@hp_gauge_width/2), 1].max
value = [[maxhp/den, (@current_hp[i]-actor.hp).abs].min, 1].max
@current_hp[i] += (@current_hp[i] > actor.hp) ? -value : value
@current_hp[i] = actor.hp if @current_hp_gauge[i] == target_gauge
end
#---
dy += 4
self.contents.font.size = YEM::BATTLE_ENGINE::PARTY_WINDOW[:stat_size]
self.contents.font.color = system_color
self.contents.draw_text(dx, dy, rect.width-4, WLH, Vocab::hp_a, 0)
self.contents.font.color = hp_color(actor)
text = @current_hp[i]
self.contents.draw_text(dx, dy, rect.width-4, WLH, text, 2)
#---
end

#--------------------------------------------------------------------------
# new method: draw_member_mp
#--------------------------------------------------------------------------
def draw_member_mp(actor, rect)
@updating = -1
i = actor.index
maxmp = @maxmp[i]
dy = WLH * 3 - 2
dx = rect.x + 2
mp_gw = @mp_gauge_width
if actor.use_rage?
dx += rect.width/2
dx -= 3
mp_gw = mp_gw/2+1
end
self.contents.fill_rect(dx, dy+WLH-8, mp_gw, 8, gauge_back_color)
#---
target_gauge = (actor.mp * @mp_gauge_width / maxmp)
if @current_mp_gauge[i] > target_gauge and !@miniature
@updating = i
@current_mp_gauge[i] -= [2, (@current_mp_gauge[i]-target_gauge).abs].min
@current_mp_gauge[i] = [@current_mp_gauge[i], 0].max
gw = @current_mp_gauge[i]
gw = gw/2+1 if actor.use_rage?
gw = [gw, 3].max if actor.mp > 0
gc1 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:mp_dmg_gauge])
gc2 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:mp_dmg_gauge])
self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
gw = mp_gw * actor.mp / maxmp
gw = [gw, 3].max if actor.mp > 0
gc1 = mp_gauge_color1
gc2 = mp_gauge_color2
self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
elsif @current_mp_gauge[i] < target_gauge and !@miniature
@updating = i
@current_mp_gauge[i] += [2, (@current_mp_gauge[i]-target_gauge).abs].min
@current_mp_gauge[i] = [@current_mp_gauge[i], @mp_gauge_width].min
gw = mp_gw * actor.mp / maxmp
gw = [gw, 3].max if actor.mp > 0
gc1 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:mp_heal_gauge])
gc2 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:mp_heal_gauge])
self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
gw = @current_mp_gauge[i]
gw = gw/2+1 if actor.use_rage?
gw = [gw, 3].max if actor.mp > 0
gc1 = mp_gauge_color1
gc2 = mp_gauge_color2
self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
else
gw = mp_gw * actor.mp / maxmp
gw = [gw, 3].max if actor.mp > 0
gc1 = mp_gauge_color1
gc2 = mp_gauge_color2
self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
end
#---
if actor.base_maxmp > actor.maxmp
gce = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:exhaust_gauge])
gbw = mp_gw
gbw *= (actor.base_maxmp - actor.maxmp) / [actor.base_maxmp, 1].max + 1
gbc = gauge_back_color
self.contents.fill_rect(dx+mp_gw-gbw-2, dy+WLH-8, gbw, 8, gbc)
self.contents.fill_rect(dx+mp_gw-gbw-1, dy+WLH-7, gbw, 6, gce)
end
#---
if @current_mp[i] != actor.mp
@updating = i
den = [mp_gw/3 + rand(mp_gw/2), 1].max
value = [[maxmp/den, (@current_mp[i]-actor.mp).abs].min, 1].max
@current_mp[i] += (@current_mp[i] > actor.mp) ? -value : value
@current_mp[i] = actor.mp if @current_mp_gauge[i] == target_gauge
end
#---
dy += 4
self.contents.font.size = YEM::BATTLE_ENGINE::PARTY_WINDOW[:stat_size]
self.contents.font.color = system_color
self.contents.draw_text(dx, dy, rect.width-4, WLH, Vocab::mp_a, 0)
self.contents.font.color = mp_color(actor)
text = @current_mp[i]
dw = rect.width-4
dw /= 2 if actor.use_rage?
self.contents.draw_text(dx, dy, dw, WLH, text, 2)
#---
end

#--------------------------------------------------------------------------
# new method: draw_member_rage
#--------------------------------------------------------------------------
def draw_member_rage(actor, rect)
return unless actor.use_rage?
@updating = -1
i = actor.index
max_rage = @max_rage[i]
dy = WLH * 3 - 2
dx = rect.x + 2
rg_gw = @rg_gauge_width / 2
self.contents.fill_rect(dx, dy+WLH-8, rg_gw, 8, gauge_back_color)
#---
target_gauge = (actor.rage * @rg_gauge_width / max_rage)
target_gauge += 2 if actor.rage > 0
if @current_rage_gauge[i] > target_gauge
@updating = i
value = [2,(@current_rage_gauge[i]-target_gauge).abs].min
@current_rage_gauge[i] -= value
@current_rage_gauge[i] = [@current_rage_gauge[i], 0].max
gw = @current_rage_gauge[i] / 2
gw = [gw, 3].max if actor.rage > 0
gc1 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:rg_dmg_gauge])
gc2 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:rg_dmg_gauge])
self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
gw = rg_gw * actor.rage / max_rage
gw = [gw, 3].max if actor.rage > 0
gc1 = rage_gauge_color1
gc2 = rage_gauge_color2
self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
elsif @current_rage_gauge[i] < target_gauge
@updating = i
value = [2,(@current_rage_gauge[i]-target_gauge).abs].min
@current_rage_gauge[i] += value
@current_rage_gauge[i] = [@current_rage_gauge[i], rg_gw*2].min
gw = rg_gw * actor.rage / max_rage
gw = [gw, 3].max if actor.rage > 0
gc1 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:rg_heal_gauge])
gc2 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:rg_heal_gauge])
self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
gw = @current_rage_gauge[i] / 2
gw = [gw, 3].max if actor.rage > 0
gc1 = rage_gauge_color1
gc2 = rage_gauge_color2
self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
else
gw = @current_rage_gauge[i] / 2
gw = [gw, 3].max if actor.rage > 0
gc1 = rage_gauge_color1
gc2 = rage_gauge_color2
self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
end
#---
if @current_rage[i] != actor.rage
@updating = i
@current_rage[i] += (@current_rage[i] > actor.rage) ? -1 : 1
@current_rage[i] = actor.rage if @current_rage_gauge[i] == target_gauge
end
#---
dy += 4
self.contents.font.size = YEM::BATTLE_ENGINE::PARTY_WINDOW[:stat_size]
self.contents.font.color = system_color
self.contents.draw_text(dx, dy, rect.width/2-2, WLH, Vocab::rage_a, 0)
self.contents.font.color = normal_color
text = @current_rage[i]
self.contents.draw_text(dx, dy, rect.width/2-4, WLH, text, 2)
#---
end

end # Window_BattleStatus

#===============================================================================
# Window_BattleStatus_Mini
#===============================================================================

class Window_BattleStatus_Mini < Window_BattleStatus

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
@miniature = true
super
self.x = Graphics.width - 128
self.y = Graphics.height - 128
self.width = 128
self.height = 128
create_contents
recreate
end

#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_item($scene.selected_battler.index)
end

#--------------------------------------------------------------------------
# new method: item_rect
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new(0, 0, 96, 96)
return rect
end

end # Window_BattleStatus_Mini

#===============================================================================
# Window_BattleStatusHP
#===============================================================================

class Window_BattleStatusHP < Window_BattleStatus

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
super
self.active = false
self.back_opacity = 0
self.opacity = 0
end

#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
recreate if @current_party != $game_party.members
if @updating >= 0
draw_item(@updating)
return
end
for member in $game_party.members
draw_item(member.index) if redraw?(member)
break if redraw?(member)
end
end

#--------------------------------------------------------------------------
# redraw?
#--------------------------------------------------------------------------
def redraw?(member)
i = member.index
if member.update_maxhp
value = [[member.maxhp, member.base_maxhp, 1].max, member.maxhp_limit].min
@maxhp[i] = value
member.update_maxhp = nil
return true
end
return true if @current_hp_gauge[i] != (member.hp*@hp_gauge_width/@maxhp[i])
return true if @current_hp[i] != member.hp
return false
end

#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
@item_max = [$game_party.members.size, max_members].max
for i in 0...@item_max; draw_item(i); end
end

#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
actor = $game_party.members[index]
return if actor == nil
draw_member_name(actor, rect.clone)
draw_member_hp(actor, rect.clone)
end

end # Window_BattleStatusHP

#===============================================================================
# Window_BattleStatusMP
#===============================================================================

class Window_BattleStatusMP < Window_BattleStatus

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
super
self.active = false
self.back_opacity = 0
self.opacity = 0
end

#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
recreate if @current_party != $game_party.members
if @updating >= 0
draw_item(@updating)
return
end
for member in $game_party.members
draw_item(member.index) if redraw?(member)
break if redraw?(member)
end
end

#--------------------------------------------------------------------------
# redraw?
#--------------------------------------------------------------------------
def redraw?(member)
i = member.index
if member.update_maxmp
value = [[member.maxmp, member.base_maxmp, 1].max, member.maxmp_limit].min
@maxmp[i] = value
member.update_maxmp = nil
@first_test = false
return true
end
return true if @current_mp_gauge[i] != (member.mp*@mp_gauge_width/@maxmp[i])
return true if @current_mp[i] != member.mp
return false
end

#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
@item_max = [$game_party.members.size, max_members].max
for i in 0...@item_max; draw_item(i); end
end

#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
actor = $game_party.members[index]
return if actor == nil
draw_member_mp(actor, rect.clone)
end

end # Window_BattleStatusMP

#===============================================================================
# Window_BattleStatusRage
#===============================================================================

class Window_BattleStatusRage < Window_BattleStatus

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
super
self.active = false
self.back_opacity = 0
self.opacity = 0
end

#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
recreate if @current_party != $game_party.members
if @updating >= 0
draw_item(@updating)
return
end
for member in $game_party.members
draw_item(member.index) if redraw?(member)
break if redraw?(member)
end
end

#--------------------------------------------------------------------------
# redraw?
#--------------------------------------------------------------------------
def redraw?(member)
return false unless member.use_rage?
return true if @current_rage[member.index] != member.rage
return false
end

#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
@item_max = [$game_party.members.size, max_members].max
for i in 0...@item_max; draw_item(i); end
end

#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
actor = $game_party.members[index]
return if actor == nil
draw_member_rage(actor, rect.clone)
end

end # Window_BattleStatusRage

#===============================================================================
# Window_BattleStatusStates
#===============================================================================

class Window_BattleStatusStates < Window_BattleStatus

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
super
self.active = false
self.back_opacity = 0
self.opacity = 0
end

#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
recreate if @current_party != $game_party.members
for member in $game_party.members
draw_item(member.index) if redraw?(member)
break if redraw?(member)
end
end

#--------------------------------------------------------------------------
# redraw?
#--------------------------------------------------------------------------
def redraw?(member)
return true if member.update_states
return false
end

#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
@item_max = [$game_party.members.size, max_members].max
for i in 0...@item_max; draw_item(i); end
end

#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
actor = $game_party.members[index]
return if actor == nil
draw_member_states(actor, rect.clone)
end

end # Window_BattleStatusStates

#===============================================================================
# Window_ComboCounter
#===============================================================================

class Window_ComboCounter < Window_Base

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
super(0, -64, Graphics.width, 80)
self.back_opacity = 0
self.opacity = 0
@current = 0
@current_active_battler = nil
@close_counter = 0
@req = YEM::BATTLE_ENGINE::COMBO_WINDOW[:requirehit] - 1
@fade_frames = YEM::BATTLE_ENGINE::COMBO_WINDOW[:fadeframes]
@total_sprint = YEM::BATTLE_ENGINE::COMBO_WINDOW[:total_text]
@heal_sprint = YEM::BATTLE_ENGINE::COMBO_WINDOW[:total_heal]
@dmg_sprint = YEM::BATTLE_ENGINE::COMBO_WINDOW[:total_dmg]
end

#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
return unless $scene.is_a?(Scene_Battle)
return if $scene.combo_hits == nil
update_combo_damage if $scene.combo_update
self.y = [self.y + 4, -14].min if $scene.combo_hits > @req and self.y < -14
refresh if @combo_damage != @current
return if $scene.combo_hits > @req
return if @close_flag
@close_counter -= 1
return if @close_counter > 0
self.y = [self.y - 1, -64].max
return unless self.y <= -64
self.contents.clear
@current = 0
@close_flag = true
end

#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
if @current_active_battler != $scene.active_battler# and !@updating
@current_active_battler = $scene.active_battler
@combo = $scene.combo_hits
@current = 0
end
return unless $scene.combo_hits > @req# or @updating
#---
if @combo_damage != @current
#maxdmg = @combo_damage
#value = [maxdmg/32 + rand(maxdmg/32), 1].max
#value = [[value, (@combo_damage-@current).abs].min, 1].max
#@current = [@current + value, @combo_damage].min
@current = @combo_damage
end
#@updating = @combo_damage != @current
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.bold = true
@combo = [@combo, $scene.combo_hits].max
text = sprintf(YEM::BATTLE_ENGINE::COMBO_WINDOW[:combo_text], @combo)
self.contents.draw_text(4,WLH*0, contents.width-8, WLH, text, 2)
#---
update_combo_damage if @combo_direction == nil
text = sprintf(@dmg_sprint, @current) if @combo_direction > 0
text = sprintf(@heal_sprint, @current) if @combo_direction < 0
text = sprintf(@total_sprint, @current) if @combo_direction == 0
self.contents.draw_text(4,WLH*1-4, contents.width-8, WLH, text, 2)
#---
#return unless @updating
@close_flag = false
@close_counter = @fade_frames
end

#--------------------------------------------------------------------------
# update_combo_damage
#--------------------------------------------------------------------------
def update_combo_damage
$scene.combo_update = false
@combo_direction = -1 if $scene.combo_damage < 0
@combo_direction = 0 if $scene.combo_damage == 0
@combo_direction = 1 if $scene.combo_damage > 0
@combo_damage = $scene.combo_damage.abs
end

end # Window_ComboCounter

#===============================================================================
# Window_Skill
#===============================================================================

class Window_Skill < Window_Selectable

#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :battle_refresh_call

#--------------------------------------------------------------------------
# new method: update
#--------------------------------------------------------------------------
def update
if @battle_refresh_call
$game_temp.less_spacing = true
refresh
@battle_refresh_call = false
$game_temp.less_spacing = nil
end
super
end

#--------------------------------------------------------------------------
# overwrite method: refresh
#--------------------------------------------------------------------------
def refresh
@spacing = 4 if $game_temp.less_spacing
@data = []
for skill in @actor.skills
next unless include?(skill)
@data.push(skill)
if skill.id == @actor.last_skill_id
self.index = @data.size - 1 unless @first_time
end
end
@item_max = @data.size
self.index = [self.index, @data.size - 1].min
create_contents
@first_time = true
for i in 0...@item_max; draw_item(i); end
end

#--------------------------------------------------------------------------
# new method: include?
#--------------------------------------------------------------------------
def include?(skill)
if skill != nil
return false if skill.name == ""
return false if $game_temp.in_battle and skill.hide_in_battle
end
return true
end

#--------------------------------------------------------------------------
# overwrite method: draw_item
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
skill = @data[index]
return if skill == nil
enabled = @actor.skill_can_use?(skill)
draw_obj_name(skill, rect.clone, enabled)
draw_obj_cost(skill, rect.clone, enabled)
end

#--------------------------------------------------------------------------
# new method: draw_obj_name
#--------------------------------------------------------------------------
def draw_obj_name(obj, rect, enabled)
draw_icon(obj.icon_index, rect.x, rect.y, enabled)
self.contents.font.size = Font.default_size
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
rect.width -= 48
self.contents.draw_text(rect.x+24, rect.y, rect.width-24, WLH, obj.name)
end

#--------------------------------------------------------------------------
# new method: draw_obj_cost
#--------------------------------------------------------------------------
def draw_obj_cost(obj, rect, enabled)
return unless obj.is_a?(RPG::Skill)
return draw_obj_cooldown(obj, rect) if @actor.cooldown(obj) > 0
return draw_obj_limited(obj, rect) if @actor.skill_limited?(obj)
return if @actor.custom_skill_costs(obj, :calc_cost) <= 0
dx = rect.x + rect.width - 48; dy = rect.y
if @actor.custom_skill_costs(obj, :use_icon) != 0
icon = @actor.custom_skill_costs(obj, :use_icon)
draw_icon(icon, rect.x+rect.width-24, rect.y, enabled)
text = @actor.custom_skill_costs(obj, :text_cost)
dw = 24
else
cost = @actor.custom_skill_costs(obj, :text_cost)
text = @actor.custom_skill_costs(obj, :suffix)
text = sprintf(text, cost)
dw = 44
end
self.contents.font.size = @actor.custom_skill_costs(obj, :font_size)
colour_id = @actor.custom_skill_costs(obj, :colour)
self.contents.font.color = text_color(colour_id)
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(dx, dy, dw, WLH, text, 2)
end

#--------------------------------------------------------------------------
# new method: draw_obj_cooldown
#--------------------------------------------------------------------------
def draw_obj_cooldown(obj, rect, enabled = false)
hash = YEM::BATTLE_ENGINE::SKILL_SETTINGS
dx = rect.x + rect.width - 48; dy = rect.y
if Icon.cooldown != 0
draw_icon(Icon.cooldown, rect.x+rect.width-24, rect.y, enabled)
text = @actor.cooldown(obj)
dw = 24
else
cost = @actor.cooldown(obj)
text = hash[:cooldown_suffix]
text = sprintf(text, cost)
dw = 44
end
self.contents.font.size = hash[:cooldown_size]
colour_id = hash[:cooldown_colour]
self.contents.font.color = text_color(colour_id)
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(dx, dy, dw, WLH, text, 2)
end

#--------------------------------------------------------------------------
# new method: draw_obj_limited
#--------------------------------------------------------------------------
def draw_obj_limited(obj, rect, enabled = false)
hash = YEM::BATTLE_ENGINE::SKILL_SETTINGS
dx = rect.x + rect.width - 48; dy = rect.y
text = hash[:limited_text]
if Icon.cooldown != 0
draw_icon(Icon.limited_use, rect.x+rect.width-24, rect.y, enabled)
dw = 24
else
dw = 24
end
self.contents.font.size = hash[:limited_size]
colour_id = hash[:limited_colour]
self.contents.font.color = text_color(colour_id)
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(dx, dy, dw, WLH, text, 2)
end

end # Window_Skill

#===============================================================================
# Window_Item
#===============================================================================

class Window_Item < Window_Selectable

#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :battle_refresh_call

#--------------------------------------------------------------------------
# new method: update
#--------------------------------------------------------------------------
def update
if @battle_refresh_call
$game_temp.less_spacing = true
refresh
@battle_refresh_call = false
$game_temp.less_spacing = nil
end
super
end

#--------------------------------------------------------------------------
# overwrite method: include
#--------------------------------------------------------------------------
def include?(item)
return false if item == nil
return false if $game_temp.in_battle and !$game_party.item_can_use?(item)
return false if item.name == ""
return true
end

#--------------------------------------------------------------------------
# overwrite method: refresh
#--------------------------------------------------------------------------
def refresh
@spacing = 4 if $game_temp.less_spacing
@data = []
for item in $game_party.items
next unless include?(item)
@data.push(item)
if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
self.index = @data.size - 1 unless @first_time
end
end
@data.push(nil) if include?(nil)
@item_max = @data.size
create_contents
@first_time = true
for i in 0...@item_max; draw_item(i); end
end

#--------------------------------------------------------------------------
# alias method: enable?
#--------------------------------------------------------------------------
alias enable_window_item_bem enable? unless $@
def enable?(item)
if $scene.is_a?(Scene_Battle) and $scene.selected_battler != nil
return $scene.selected_battler.item_can_use?(item)
end
return enable_window_item_bem(item)
end

#--------------------------------------------------------------------------
# overwrite method: draw_item
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
return if item == nil
enabled = enable?(item)
draw_obj_name(item, rect.clone, enabled)
draw_obj_charges(item, rect.clone, enabled)
draw_obj_total(item, rect.clone, enabled)
end

#--------------------------------------------------------------------------
# new method: draw_obj_name
#--------------------------------------------------------------------------
def draw_obj_name(obj, rect, enabled)
draw_icon(obj.icon_index, rect.x, rect.y, enabled)
self.contents.font.size = Font.default_size
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
rect.width -= 48
self.contents.draw_text(rect.x+24, rect.y, rect.width-24, WLH, obj.name)
end

#--------------------------------------------------------------------------
# new method: draw_obj_charges
#--------------------------------------------------------------------------
def draw_obj_charges(obj, rect, enabled)
return unless obj.is_a?(RPG::Item)
return unless obj.consumable
return if obj.charges <= 1
$game_party.item_charges = {} if $game_party.item_charges == nil
$game_party.item_charges[obj.id] = obj.charges if
$game_party.item_charges[obj.id] == nil
charges = $game_party.item_charges[obj.id]
dx = rect.x; dy = rect.y + WLH/3
self.contents.font.size = YEM::BATTLE_ENGINE::ITEM_SETTINGS[:charge]
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(dx, dy, 24, WLH * 2/3, charges, 2)
self.contents.font.size = Font.default_size
end

#--------------------------------------------------------------------------
# new method: draw_obj_total
#--------------------------------------------------------------------------
def draw_obj_total(obj, rect, enabled)
hash = YEM::BATTLE_ENGINE::ITEM_SETTINGS
number = $game_party.item_number(obj)
dx = rect.x + rect.width - 36; dy = rect.y; dw = 32
text = sprintf(hash[:text], number)
self.contents.font.size = hash[:size]
self.contents.font.color = text_color(hash[:colour])
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(dx, dy, dw, WLH, text, 2)
end

end # Window_Item

#===============================================================================
# Window_PartyCommand
#===============================================================================

class Window_PartyCommand < Window_Command

#--------------------------------------------------------------------------
# overwrite method: initialize
#--------------------------------------------------------------------------
def initialize
array = create_command_list
super(128, array)
self.height = 128
self.active = false
end

#--------------------------------------------------------------------------
# item
#--------------------------------------------------------------------------
def item; return @data[self.index]; end

#--------------------------------------------------------------------------
# new method: create_command_list
#--------------------------------------------------------------------------
def create_command_list
@data = []; array = []
for command in YEM::BATTLE_ENGINE::PARTY_COMMANDS
case command
when :fight
array.push(Vocab.fight)
when :execute
next unless $scene.dtb?
vocab = YEM::BATTLE_ENGINE::PARTY_VOCAB[command]
array.push(vocab)
when :status, :option
vocab = YEM::BATTLE_ENGINE::PARTY_VOCAB[command]
array.push(vocab)
when :escape
next unless $scene.dtb? or $scene.ptb?
array.push(Vocab.escape)
when :turnskip
next unless $scene.ptb?
vocab = YEM::BATTLE_ENGINE::PARTY_VOCAB[command]
array.push(vocab)
when :atb_type
next unless $scene.atb?
array.push("ATB_COMMAND_TYPE")
when :atb_speed
next unless $scene.atb?
array.push("ATB_COMMAND_SPEED")
else; next
end
@data.push(command)
end
return array
end

#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index, enabled = true)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
enabled = enabled?(@data[index])
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
text = @commands[index]
#---
case text
when "ATB_COMMAND_TYPE"
case $game_variables[YEM::BATTLE_ENGINE::OPTIONS[:atb_avariable]]
when 0; key = :atb_t0
when 1; key = :atb_t1
when 2; key = :atb_t2
when 3; key = :atb_t3
else; return
end
text = YEM::BATTLE_ENGINE::PARTY_VOCAB[key]
when "ATB_COMMAND_SPEED"
text = YEM::BATTLE_ENGINE::PARTY_VOCAB[:atb_spd]
variable = YEM::BATTLE_ENGINE::OPTIONS[:atb_svariable]
text = sprintf(text, $game_variables[variable])
end
#---
self.contents.draw_text(rect, text, 1)
end

#--------------------------------------------------------------------------
# enabled?
#--------------------------------------------------------------------------
def enabled?(obj)
return $game_troop.can_escape if obj == :escape
return true
end

end # Window_PartyCommand

#===============================================================================
# Window_ActorCommand
#===============================================================================

class Window_ActorCommand < Window_Command

#--------------------------------------------------------------------------
# public instance variable
#--------------------------------------------------------------------------
attr_accessor :actor

#--------------------------------------------------------------------------
# alias method: initialize
#--------------------------------------------------------------------------
alias initialize_window_actorcommand_bem initialize unless $@
def initialize
@disable_empty_commands = YEM::BATTLE_ENGINE::DISABLE_EMPTY_COMMANDS
initialize_window_actorcommand_bem
end

#--------------------------------------------------------------------------
# new method: item
#--------------------------------------------------------------------------
def item; return @data[self.index]; end

#--------------------------------------------------------------------------
# new method: skill
#--------------------------------------------------------------------------
def skill; return $data_skills[@skills[item]]; end

#--------------------------------------------------------------------------
# overwrite method: setup
#--------------------------------------------------------------------------
def setup(actor)
@actor = actor
@data = []; @commands = []; @skills = {}
data_set = actor.class.id
data_set = 0 if !YEM::BATTLE_ENGINE::CLASS_COMMANDS.include?(actor.class.id)
#---
for item in YEM::BATTLE_ENGINE::CLASS_COMMANDS[data_set]
case item
when :attack; @commands.push(actor.attack_vocab)
when :skill; @commands.push(actor.skill_vocab)
when :guard; @commands.push(actor.guard_vocab)
when :item; @commands.push(Vocab.item)
when :equip; @commands.push(YEM::BATTLE_ENGINE::EQUIP_VOCAB)
when :escape
next unless $game_troop.can_escape
@commands.push(Vocab.escape)
else
valid = false
if YEM::BATTLE_ENGINE::SKILL_COMMANDS.include?(item)
@skills[item] = YEM::BATTLE_ENGINE::SKILL_COMMANDS[item][0]
@commands.push(YEM::BATTLE_ENGINE::SKILL_COMMANDS[item][1])
valid = true
end
next unless valid
end
@data.push(item)
end
#---
@item_max = @commands.size
refresh
self.index = 0
end

#--------------------------------------------------------------------------
# new method: update
#--------------------------------------------------------------------------
def update
return unless $scene.is_a?(Scene_Battle)
super unless Input.trigger?(Input::L) or Input.trigger?(Input::R)
return unless @actor == $scene.status_window.actor
refresh if @actor != nil and @actor.update_commands
end

#--------------------------------------------------------------------------
# new method: refresh
#--------------------------------------------------------------------------
def refresh
create_contents
@actor.update_commands = false if @actor != nil
for i in 0...@item_max
draw_item(i)
end
end

#--------------------------------------------------------------------------
# new method: draw_item
#--------------------------------------------------------------------------
def draw_item(index, enabled = true)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
obj = @data[index]
enabled = enabled?(obj)
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(rect, @commands[index], 1)
end

#--------------------------------------------------------------------------
# new method: enabled?
#--------------------------------------------------------------------------
def enabled?(obj = nil)
return false unless @actor.actor?
if @actor.auto_battle
return true if obj == :equip and @actor.equip_cooldown.to_i <= 0
return true if obj == :escape and $game_troop.can_escape
return false
end
return false unless @actor.inputable?
return false if obj == nil
return false if obj == :equip and @actor.equip_cooldown.to_i > 0
if @disable_empty_commands
return false if obj == :skill and @actor.skills.size <= 0
return false if obj == :item and $game_party.battle_item_size <= 0
end
if @skills.include?(obj)
skill = $data_skills[@skills[obj]]
return @actor.skill_can_use?(skill)
end
return true
end

end # Window_ActorCommand

#===============================================================================
# Window_ConfirmCommand
#===============================================================================

class Window_ConfirmCommand < Window_Command

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
array = create_command_list
super(128, array)
self.openness = 0
self.height = 128
self.active = false
end

#--------------------------------------------------------------------------
# item
#--------------------------------------------------------------------------
def item; return @data[self.index]; end

#--------------------------------------------------------------------------
# create_command_list
#--------------------------------------------------------------------------
def create_command_list
@data = []; array = []
for command in YEM::BATTLE_ENGINE::CONFIRM_COMMANDS
case command
when :confirm
next unless $scene.dtb?
vocab = YEM::BATTLE_ENGINE::CONFIRM_VOCAB[command]
array.push(vocab)
when :status, :option
vocab = YEM::BATTLE_ENGINE::CONFIRM_VOCAB[command]
array.push(vocab)
when :escape
next unless $scene.dtb? or $scene.ptb?
array.push(Vocab.escape)
when :turnskip
next unless $scene.ptb?
vocab = YEM::BATTLE_ENGINE::CONFIRM_VOCAB[command]
array.push(vocab)
when :atb_type
next unless $scene.atb?
array.push("ATB_COMMAND_TYPE")
when :atb_speed
next unless $scene.atb?
array.push("ATB_COMMAND_SPEED")
else; next
end
@data.push(command)
end
return array
end

#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index, enabled = true)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
enabled = enabled?(@data[index])
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
text = @commands[index]
#---
case text
when "ATB_COMMAND_TYPE"
case $game_variables[YEM::BATTLE_ENGINE::OPTIONS[:atb_avariable]]
when 0; key = :atb_t0
when 1; key = :atb_t1
when 2; key = :atb_t2
when 3; key = :atb_t3
else; return
end
text = YEM::BATTLE_ENGINE::CONFIRM_VOCAB[key]
when "ATB_COMMAND_SPEED"
text = YEM::BATTLE_ENGINE::CONFIRM_VOCAB[:atb_spd]
variable = YEM::BATTLE_ENGINE::OPTIONS[:atb_svariable]
text = sprintf(text, $game_variables[variable])
end
#---
self.contents.draw_text(rect, text, 1)
end

#--------------------------------------------------------------------------
# enabled?
#--------------------------------------------------------------------------
def enabled?(obj)
return $game_troop.can_escape if obj == :escape
return true
end

end # Window_ConfirmCommand

#===============================================================================
# Window_BattleActor
#===============================================================================

class Window_BattleActor < Window_Base

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
super(0, 0, Graphics.width, Graphics.height - 128)
@letter_ranks = YEM::BATTLE_ENGINE::TEXT_RANKS[:enable]
refresh
end

#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh(index = 0)
self.contents.clear
@actor = $game_party.members[index]
return if @actor == nil
self.contents.font.size = Font.default_size
self.contents.font.color = normal_color
dx = 8; dy = 0
#--- Left Half ---
draw_actor_face(@actor, dx, dy)
draw_actor_name(@actor, dx+112, dy); dy += WLH
draw_actor_class(@actor, dx+112, dy); dy += WLH
draw_actor_level(@actor, dx+112, dy); dy += WLH*2
dw = contents.width/2 - dx - 24
draw_actor_hp(@actor, dx, dy, dw); dy += WLH
draw_actor_mp(@actor, dx, dy, dw); dy += WLH
#--- Right Half ---
dx = contents.width/2; dy = WLH/2
draw_actor_elements(@actor, dx, dy); dy += WLH*3
draw_actor_states(@actor, dx, dy); dy = WLH*6 + 8
draw_actor_parameters(@actor, dx, dy)
end

#--------------------------------------------------------------------------
# draw_actor_elements
#--------------------------------------------------------------------------
def draw_actor_elements(actor, dx, dy)
self.contents.font.size = YEM::BATTLE_ENGINE::TEXT_RANK_SIZE
dw = contents.width - dx
spacing = YEM::BATTLE_ENGINE::ELEMENT_SPACING
array = YEM::BATTLE_ENGINE::ALLY_ELEMENTS
dx = dx + dw - (array.size*(spacing+24)) - spacing*3/2
for element_id in array
next if element_id > $data_system.elements.size
icon = Icon.element(element_id)
draw_icon(icon, dx, dy)
rate = actor.element_rate(element_id)
text = sprintf("%d%%", rate)
if rate > 200; colour = :rank_s
elsif rate > 150; colour = :rank_a
elsif rate > 100; colour = :rank_b
elsif rate > 50; colour = :rank_c
elsif rate > 0; colour = :rank_d
elsif rate == 0; colour = :rank_e
else; colour = :rank_f
end
text = YEM::BATTLE_ENGINE::TEXT_RANKS[colour] if @letter_ranks
colour = YEM::BATTLE_ENGINE::RANK_COLOURS[colour]
self.contents.font.color = text_color(colour)
self.contents.draw_text(dx-spacing/2, dy+WLH, spacing+24, WLH, text, 1)
dx += spacing+24
end
end

#--------------------------------------------------------------------------
# draw_actor_states
#--------------------------------------------------------------------------
def draw_actor_states(actor, dx, dy)
self.contents.font.size = YEM::BATTLE_ENGINE::TEXT_RANK_SIZE
dw = contents.width - dx
spacing = YEM::BATTLE_ENGINE::STATE_SPACING
array = YEM::BATTLE_ENGINE::ALLY_STATES
dx = dx + dw - (array.size*(spacing+24)) - spacing*3/2
for state_id in array
state = $data_states[state_id]
next if state == nil
icon = state.icon_index
draw_icon(icon, dx, dy)
rate = actor.state_probability(state_id)
text = sprintf("%d%%", rate)
if rate > 100; colour = :rank_s
elsif rate > 80; colour = :rank_a
elsif rate > 60; colour = :rank_b
elsif rate > 40; colour = :rank_c
elsif rate > 20; colour = :rank_d
elsif rate > 0; colour = :rank_e
else; colour = :rank_f
end
text = YEM::BATTLE_ENGINE::TEXT_RANKS[colour] if @letter_ranks
colour = YEM::BATTLE_ENGINE::RANK_COLOURS[colour]
self.contents.font.color = text_color(colour)
self.contents.draw_text(dx-spacing/2, dy+WLH, spacing+24, WLH, text, 1)
dx += spacing+24
end
end

#--------------------------------------------------------------------------
# draw_actor_parameters
#--------------------------------------------------------------------------
def draw_actor_parameters(actor, dx, dy)
self.contents.font.size = YEM::BATTLE_ENGINE::TEXT_STAT_SIZE
fx = dx; fy = dy
dw = (contents.width - dx)/2 - 4
for stat in YEM::BATTLE_ENGINE::ALLY_STATS
case stat
when :atk
name = Vocab.atk
value = actor.atk
when :def
name = Vocab.def
value = actor.def
when :spi
name = Vocab.spi
value = actor.spi
when :res
next unless $imported["RES Stat"]
name = Vocab.res
value = actor.res
when :dex
next unless $imported["DEX Stat"]
name = Vocab.dex
value = actor.dex
when :agi
name = Vocab.agi
value = actor.agi
when :hit
name = Vocab.hit
value = sprintf("%d%%", [[actor.hit, 1].max, 99].min)
when :eva
name = Vocab.eva
value = sprintf("%d%%", [[actor.eva, 1].max, 99].min)
when :cri
name = Vocab.cri
value = sprintf("%d%%", [[actor.cri, 1].max, 99].min)
when :odds
name = Vocab.odds
value = actor.odds * 100 / total_party_odds
value = sprintf("%d%%", [[value, 1].max, 99].min)
else; next
end
draw_icon(Icon.stat(actor, stat), dx, dy)
self.contents.font.color = system_color
self.contents.draw_text(dx+24, dy, 40, WLH, name)
self.contents.font.color = normal_color
self.contents.draw_text(dx+64, dy, dw-72, WLH, value, 2)
dx += dw + 4
if dx + dw + 4 > contents.width
dx = fx
dy += WLH
break if dy + WLH > contents.height
end
end
end

#--------------------------------------------------------------------------
# total_party_odds
#--------------------------------------------------------------------------
def total_party_odds
return @total_odds if @total_odds != nil
@total_odds = 0
for member in $game_party.members
@total_odds += member.odds
end
return @total_odds
end

end # Window_BattleActor

#===============================================================================
# Window_BattleActorStates
#===============================================================================

class Window_BattleActorStates < Window_Selectable

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
dx = 8; dy = WLH*7 - 16
super(dx, dy, Graphics.width/2 - dx*2, Graphics.height - 128 - dy)
@draw_state_turns = $imported["CoreFixesUpgradesMelody"]
self.back_opacity = 0
self.opacity = 0
end

#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh(actor = nil)
@data = []
@actor = actor
if @actor == nil
self.index = -1
@item_max = 0
create_contents
return
end
for state in actor.states
next if state == nil
@data.push(state)
end
@data = [:normal] if @data == []
@item_max = @data.size
create_contents
self.index = (@item_max > 0) ? 0 : -1
for i in 0...@item_max; draw_item(i); end
end

#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
state = @data[index]
return if state == nil
if state == :normal
draw_icon(Icon.normal_state, rect.x, rect.y)
text = YEM::BATTLE_ENGINE::TEXT_NORMAL_STATE
else
draw_icon(state.icon_index, rect.x, rect.y)
draw_state_turns(rect.x, rect.y, state, @actor) if @draw_state_turns
text = state.name
if @actor.stack(state) > 1
display = YEM::BATTLE_ENGINE::STATE_SETTINGS[:stack_display]
text = sprintf(display, text, @actor.stack(state).to_s)
end
end
self.contents.font.color = normal_color
self.contents.font.bold = Font.default_bold
self.contents.font.size = Font.default_size
self.contents.draw_text(rect.x+24, rect.y, rect.width-28, WLH, text)
end

end # Window_BattleActorStates

#===============================================================================
# Window_BattleOptions
#===============================================================================

class Window_BattleOptions < Window_Selectable

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(dx, dy)
super(dx, dy, Graphics.width-dx, Graphics.height-dy-128)
self.index = 0
refresh
end

#--------------------------------------------------------------------------
# item
#--------------------------------------------------------------------------
def item; return @data[self.index]; end

#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
@data = []
for command in YEM::BATTLE_ENGINE::OPTION_COMMANDS
case command
when :bgm_volume, :bgs_volume, :sfx_volume
when :animations, :autocursor, :next_actor, :skill_help
when :atb_active, :atb_speeds; next unless $scene.atb?
when :cinematics; next
else; next
end
@data.push(command)
end
@item_max = @data.size
create_contents
for i in 0...@item_max; draw_item(i); end
end

#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
obj = @data[index]
return if obj == nil
case obj
when :bgm_volume, :bgs_volume, :sfx_volume
draw_volume_item(obj, rect.clone)
when :animations, :autocursor, :next_actor, :skill_help, :cinematics
draw_switch_item(obj, rect.clone)
when :atb_active, :atb_speeds
draw_atb_item(obj, rect.clone)
end
end

#--------------------------------------------------------------------------
# draw_volume_item
#--------------------------------------------------------------------------
def draw_volume_item(obj, rect)
options = YEM::BATTLE_ENGINE::OPTIONS
case obj
when :bgm_volume
title = options[:bgm_volume]
value = $game_variables[options[:bgm_variable]]
mute = $game_switches[options[:bgm_mute_sw]]
when :bgs_volume
title = options[:bgs_volume]
value = $game_variables[options[:bgs_variable]]
mute = $game_switches[options[:bgs_mute_sw]]
when :sfx_volume
title = options[:sfx_volume]
value = $game_variables[options[:sfx_variable]]
mute = $game_switches[options[:sfx_mute_sw]]
else; return
end
value = sprintf(options[:audio], value)
self.contents.font.color = normal_color
self.contents.draw_text(rect.x, rect.y, rect.width/2, WLH, title, 1)
self.contents.font.color.alpha = mute ? 128 : 255
dx = rect.x + rect.width/2
self.contents.draw_text(dx, rect.y, rect.width/4, WLH, value, 1)
self.contents.font.color.alpha = mute ? 255 : 128
dx = rect.x + rect.width*3/4
self.contents.draw_text(dx, rect.y, rect.width/4, WLH, options[:mute], 1)
end

#--------------------------------------------------------------------------
# draw_switch_item
#--------------------------------------------------------------------------
def draw_switch_item(obj, rect)
options = YEM::BATTLE_ENGINE::OPTIONS
title = options[obj]
case obj
when :animations
name1 = options[:ani_show]
name2 = options[:ani_hide]
toggle = $game_switches[options[:animation_sw]]
when :autocursor
name1 = options[:curmem_on]
name2 = options[:curmem_off]
toggle = $game_switches[options[:autocursor_sw]]
when :next_actor
name1 = options[:next_on]
name2 = options[:next_off]
toggle = $game_switches[options[:next_actor_sw]]
when :skill_help
name1 = options[:help_on]
name2 = options[:help_off]
toggle = $game_switches[options[:skill_help_sw]]
when :cinematics
name1 = options[:cinem_on]
name2 = options[:cinem_off]
toggle = $game_switches[options[:cinematics_sw]]
else; return
end
self.contents.font.color = normal_color
self.contents.draw_text(rect.x, rect.y, rect.width/2, WLH, title, 1)
self.contents.font.color.alpha = toggle ? 255 : 128
dx = rect.x + rect.width/2
self.contents.draw_text(dx, rect.y, rect.width/4, WLH, name1, 1)
self.contents.font.color.alpha = toggle ? 128 : 255
dx = rect.x + rect.width*3/4
self.contents.draw_text(dx, rect.y, rect.width/4, WLH, name2, 1)
end

#--------------------------------------------------------------------------
# draw_atb_item
#--------------------------------------------------------------------------
def draw_atb_item(obj, rect)
options = YEM::BATTLE_ENGINE::OPTIONS
case obj
when :atb_active
title = options[:atb_aname]
value = $game_variables[options[:atb_avariable]]
#---
self.contents.font.color = normal_color
name1 = options[:wait_0]
dx = rect.x + rect.width/2
self.contents.font.color.alpha = (value == 0) ? 255 : 128
self.contents.draw_text(dx, rect.y, rect.width/8, WLH, name1, 1)
name2 = options[:wait_1]
dx = rect.x + rect.width*5/8
self.contents.font.color.alpha = (value == 1) ? 255 : 128
self.contents.draw_text(dx, rect.y, rect.width/8, WLH, name2, 1)
name3 = options[:wait_2]
dx = rect.x + rect.width*6/8
self.contents.font.color.alpha = (value == 2) ? 255 : 128
self.contents.draw_text(dx, rect.y, rect.width/8, WLH, name3, 1)
name4 = options[:wait_3]
dx = rect.x + rect.width*7/8
self.contents.font.color.alpha = (value == 3) ? 255 : 128
self.contents.draw_text(dx, rect.y, rect.width/8, WLH, name4, 1)
#---
when :atb_speeds
title = options[:atb_sname]
value = $game_variables[options[:atb_svariable]] - 1
#---
for i in 0...10
self.contents.font.color = normal_color
name = (i + 1).to_s
dx = rect.x + rect.width * (10 + i)/20
self.contents.font.color.alpha = (value == i) ? 255 : 128
self.contents.draw_text(dx, rect.y, rect.width/20, WLH, name, 1)
end
#---
else; return
end
self.contents.font.color = normal_color
self.contents.draw_text(rect.x, rect.y, rect.width/2, WLH, title, 1)
end

#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
if Input.trigger?(Input::C)
input_case_c
elsif Input.repeat?(Input::LEFT)
input_case_left
elsif Input.repeat?(Input::RIGHT)
input_case_right
end
end

#--------------------------------------------------------------------------
# input_case_c
#--------------------------------------------------------------------------
def input_case_c
options = YEM::BATTLE_ENGINE::OPTIONS
case item
when :bgm_volume; switch = options[:bgm_mute_sw]
when :bgs_volume; switch = options[:bgs_mute_sw]
when :sfx_volume; switch = options[:sfx_mute_sw]
when :animations; switch = options[:animation_sw]
when :autocursor; switch = options[:autocursor_sw]
when :next_actor; switch = options[:next_actor_sw]
when :skill_help; switch = options[:skill_help_sw]
when :cinematics; switch = options[:cinematics_sw]
else; return
end
$game_switches[switch] = !$game_switches[switch]
Sound.play_decision
RPG::BGM::last.play if item == :bgm_volume
RPG::BGS::last.play if item == :bgs_volume
draw_item(self.index)
end

#--------------------------------------------------------------------------
# input_case_left
#--------------------------------------------------------------------------
def input_case_left
options = YEM::BATTLE_ENGINE::OPTIONS
ignore = false
case item
when :bgm_volume, :bgs_volume, :sfx_volume
value = Input.press?(Input::SHIFT) ? 10 : 1
case item
when :bgm_volume; variable = options[:bgm_variable]
when :bgs_volume; variable = options[:bgs_variable]
when :sfx_volume; variable = options[:sfx_variable]
end
return if $game_variables[variable] == 0
$game_variables[variable] -= value
$game_variables[variable] = [$game_variables[variable], 0].max
ignore = true
when :atb_active
variable = options[:atb_avariable]
return if $game_variables[variable] == 0
$game_variables[variable] -= 1
$game_variables[variable] = [$game_variables[variable], 0].max
ignore = true
if $scene.is_a?(Scene_Battle) and $scene.atb?
$scene.party_command_window.refresh
$scene.confirm_command_window.refresh
end
when :atb_speeds
variable = options[:atb_svariable]
return if $game_variables[variable] == 1
$game_variables[variable] -= 1
$game_variables[variable] = [$game_variables[variable], 1].max
ignore = true
if $scene.is_a?(Scene_Battle) and $scene.atb?
$scene.party_command_window.refresh
$scene.confirm_command_window.refresh
end
when :animations; switch = options[:animation_sw]
when :autocursor; switch = options[:autocursor_sw]
when :next_actor; switch = options[:next_actor_sw]
when :skill_help; switch = options[:skill_help_sw]
when :cinematics; switch = options[:cinematics_sw]
else; return
end
unless ignore
return if $game_switches[switch]
$game_switches[switch] = true
end
Sound.play_cursor
RPG::BGM::last.play if item == :bgm_volume
RPG::BGS::last.play if item == :bgs_volume
draw_item(self.index)
end

#--------------------------------------------------------------------------
# input_case_right
#--------------------------------------------------------------------------
def input_case_right
options = YEM::BATTLE_ENGINE::OPTIONS
ignore = false
case item
when :bgm_volume, :bgs_volume, :sfx_volume
value = Input.press?(Input::SHIFT) ? 10 : 1
case item
when :bgm_volume; variable = options[:bgm_variable]
when :bgs_volume; variable = options[:bgs_variable]
when :sfx_volume; variable = options[:sfx_variable]
end
return if $game_variables[variable] == 100
$game_variables[variable] += value
$game_variables[variable] = [$game_variables[variable], 100].min
ignore = true
when :atb_active
variable = options[:atb_avariable]
return if $game_variables[variable] == 3
$game_variables[variable] += 1
$game_variables[variable] = [$game_variables[variable], 3].min
ignore = true
if $scene.is_a?(Scene_Battle) and $scene.atb?
$scene.party_command_window.refresh
$scene.confirm_command_window.refresh
end
when :atb_speeds
variable = options[:atb_svariable]
return if $game_variables[variable] == 10
$game_variables[variable] += 1
$game_variables[variable] = [$game_variables[variable], 10].min
ignore = true
if $scene.is_a?(Scene_Battle) and $scene.atb?
$scene.party_command_window.refresh
$scene.confirm_command_window.refresh
end
when :animations; switch = options[:animation_sw]
when :autocursor; switch = options[:autocursor_sw]
when :next_actor; switch = options[:next_actor_sw]
when :skill_help; switch = options[:skill_help_sw]
when :cinematics; switch = options[:cinematics_sw]
else; return
end
unless ignore
return if !$game_switches[switch]
$game_switches[switch] = false
end
Sound.play_cursor
RPG::BGM::last.play if item == :bgm_volume
RPG::BGS::last.play if item == :bgs_volume
draw_item(self.index)
end

#--------------------------------------------------------------------------
# update_help
#--------------------------------------------------------------------------
def update_help
case item
when :bgm_volume; type = :bgm_des
when :bgs_volume; type = :bgs_des
when :sfx_volume; type = :sfx_des
when :animations; type = :ani_des
when :autocursor; type = :curmem_des
when :next_actor; type = :next_des
when :skill_help; type = :help_des
when :cinematics; type = :cinem_des
when :atb_active
case $game_variables[YEM::BATTLE_ENGINE::OPTIONS[:atb_avariable]]
when 0; type = :wait_0_des
when 1; type = :wait_1_des
when 2; type = :wait_2_des
when 3: type = :wait_3_des
end
when :atb_speeds; type = :atb_s_des
else; type = nil
end
text = YEM::BATTLE_ENGINE::OPTIONS[type].to_s
@help_window.set_text(text, 1)
end

end # Window_BattleOptions

#===============================================================================
# Window_PressTurns
#===============================================================================

class Window_PressTurns < Window_Base

#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :update_call

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(group)
@group = group
super(-16, -64, Graphics.width + 16, 80)
self.z = 10
self.back_opacity = 0
self.opacity = 0
set_icons
@appear = false
@disappear = false
end

#--------------------------------------------------------------------------
# set_icons
#--------------------------------------------------------------------------
def set_icons
if @group.is_a?(Game_Party)
@turn_icon = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS[:actor][2]
@used_icon = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS[:actor][3]
@bonus_icon = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS[:actor][4]
else
@turn_icon = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS[:enemy][2]
@used_icon = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS[:enemy][3]
@bonus_icon = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS[:enemy][4]
end
end

#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
if @appear
self.y = [self.y + 4, -16].min
@appear = false if self.y >= -16
elsif @disappear
self.y = [self.y - 4, -64].max
@disappear = false if self.y <= -64
end
refresh if @update_call
end

#--------------------------------------------------------------------------
# appear
#--------------------------------------------------------------------------
def appear
@appear = true
@disappear = false
self.z = 11
refresh
end

#--------------------------------------------------------------------------
# disappear
#--------------------------------------------------------------------------
def disappear
@disappear = true
@appear = false
self.z = 10
end

#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@update_call = false
dx = draw_turn_icons
dx = draw_bonus_icons(dx)
draw_used_icons(dx)
end

#--------------------------------------------------------------------------
# draw_turn_icons
#--------------------------------------------------------------------------
def draw_turn_icons(dx = 12)
@dy = 6
amount = @group.ptb_total_turns
amount -= @group.ptb_bonus_turns
amount.times do
draw_icon(@turn_icon, dx, @dy)
@dy = (@dy == 6) ? 18 : 6
dx += 24
end
return dx
end

#--------------------------------------------------------------------------
# draw_bonus_icons
#--------------------------------------------------------------------------
def draw_bonus_icons(dx)
return dx if @group.ptb_total_turns <= 0
amount = @group.ptb_bonus_turns
amount.times do
draw_icon(@turn_icon, dx, @dy)
@dy = (@dy == 6) ? 18 : 6
dx += 24
end
return dx
end

#--------------------------------------------------------------------------
# draw_used_icons
#--------------------------------------------------------------------------
def draw_used_icons(dx)
amount = @group.ptb_member_turns
amount -= @group.ptb_total_turns
return if amount <= 0
amount.times do
draw_icon(@used_icon, dx, @dy)
@dy = (@dy == 6) ? 18 : 6
dx += 24
end
end

end # Window_PressTurns

#===============================================================================
# Window_EnemyGauge
#===============================================================================

class Window_EnemyGauge < Window_Base

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
super(0, 0, 120, WLH*3+32)
self.visible = false
self.opacity = 0
self.back_opacity = 0
self.z = 16000
end

#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
return unless $scene.is_a?(Scene_Battle)
return unless $scene.atb?
if @battler == nil
self.visible = false
return
end
refresh_call = false
#---
refresh_call = true if @current_hp != @battler.hp
refresh_call = true if @current_maxhp != @battler.maxhp
refresh_call = true if @current_mp != @battler.mp
refresh_call = true if @current_maxmp != @battler.maxmp
refresh_call = true if @current_states != @battler.states
#---
if @current_x != @battler.screen_x or @current_y != @battler.screen_y
@current_x = @battler.screen_x
@current_y = @battler.screen_y
self.x = @battler.screen_x - self.width/2
self.x -= $scene.spriteset.viewport1.ox
self.y = @battler.screen_y - self.height/2 - WLH + 12
self.y -= $scene.spriteset.viewport1.oy
end
#---
refresh if refresh_call
end

#--------------------------------------------------------------------------
# battler=
#--------------------------------------------------------------------------
def battler=(battler)
@battler = battler
if @battler == nil
self.visible = false
return
end
self.visible = true
self.width = @battler.enemy.quick_gauge[:width]
@current_x = @battler.screen_x
@current_y = @battler.screen_y
self.x = @battler.screen_x - self.width/2
self.x -= $scene.spriteset.viewport1.ox
self.y = @battler.screen_y - self.height/2 - WLH + 12
self.y -= $scene.spriteset.viewport1.oy
create_contents
refresh
end

#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
dy = 0
sw = contents.width
#---
if $scene.atb?
@current_hp = @battler.hp
@current_maxhp = @battler.maxhp
@current_mp = @battler.mp
@current_maxmp = @battler.maxmp
@current_states = @battler.states.clone
end
#---
draw_actor_state(@battler,0,WLH,sw) if @battler.enemy.quick_gauge[:states]
dy += WLH+8
if @battler.enemy.quick_gauge[:show_hp]
draw_back_gauge(0, dy, sw)
draw_enemy_hp_gauge(@battler,1,dy+1,sw-2)
dy += 7
end
if @battler.enemy.quick_gauge[:show_mp]
draw_back_gauge(0, dy, contents.width)
if @battler.use_rage?
draw_enemy_rage_gauge(@battler,1,dy+1,sw/2-1)
draw_enemy_mp_gauge(@battler,sw/2+1,dy+1,sw/2-2)
else
draw_enemy_mp_gauge(@battler,1,dy+1,sw-2)
end
dy += 7
end
end

#--------------------------------------------------------------------------
# new method: draw_back_gauge
#--------------------------------------------------------------------------
def draw_back_gauge(x, y, width = 120)
self.contents.fill_rect(x, y + WLH - 8, width, 8, gauge_back_color)
end

end # Window_EnemyGauge

#===============================================================================
# Scene_Battle
#===============================================================================

class Scene_Battle < Scene_Base

#--------------------------------------------------------------------------
# overwrite method: wait_for_animation
#--------------------------------------------------------------------------
def wait_for_animation
update_basic
update_basic while @spriteset.animation?
end

#--------------------------------------------------------------------------
# overwrite method: display_attack_animation
#--------------------------------------------------------------------------
def display_attack_animation(targets)
if @active_battler.is_a?(Game_Enemy)
aid1 = @active_battler.atk_animation_id
display_normal_animation(targets, aid1)
else
aid1 = @active_battler.atk_animation_id
aid2 = @active_battler.atk_animation_id2
display_normal_animation(targets, aid1, false)
wait_for_animation if aid2 != 0
display_normal_animation(targets, aid2, true)
end
end

#--------------------------------------------------------------------------
# overwrite method: display_animation
#--------------------------------------------------------------------------
def display_animation(targets, animation_id)
if animation_id < 0
display_attack_animation(targets)
else
display_normal_animation(targets, animation_id)
end
end

#--------------------------------------------------------------------------
# overwrite method: display_normal_animation
#--------------------------------------------------------------------------
def display_normal_animation(targets, animation_id, mirror = false)
return unless show_animation?
animation = $data_animations[animation_id]
return if animation == nil
mirror = !mirror if @action_values.include?("MIRROR")
to_screen = (animation.position == 3)
ani_check = false
for target in targets.uniq
if ani_check
target.pseudo_ani_id = animation_id
else
target.animation_id = animation_id
target.animation_mirror = target_mirror?(mirror, target)
target.animation_mirror = false if animation.anti_mirror
end
ani_check = true if to_screen
end
end

#--------------------------------------------------------------------------
# overwrite method: display_pseudo_animation
#--------------------------------------------------------------------------
def display_pseudo_animation(targets, animation_id)
return unless show_animation?
animation = $data_animations[animation_id]
return if animation == nil
for target in targets.uniq
target.pseudo_ani_id = animation_id
end
end

#--------------------------------------------------------------------------
# new method: wait_for_movement
#--------------------------------------------------------------------------
def wait_for_movement
return if emptyview?
members = $game_party.members + $game_troop.members
movers = []; requirement = 0
for member in members
next unless member.sprite_movable?
movers.push(member)
requirement += 1
end
return if requirement == 0
loop do
check = 0
for mover in movers
next unless mover.sprite_movable?
next if mover.spriteset.move_to_x != nil
next if mover.spriteset.move_to_y != nil
check += 1
end
break if check == requirement
update_basic
end
end

#--------------------------------------------------------------------------
# new method: wait_for_jump
#--------------------------------------------------------------------------
def wait_for_jump
return if emptyview?
members = $game_party.members + $game_troop.members
movers = []; requirement = 0
for member in members
next unless member.sprite_movable?
movers.push(member)
requirement += 1
end
return if requirement == 0
loop do
check = 0
for mover in movers
next unless mover.sprite_movable?
next if mover.spriteset.jump_duration != nil
check += 1
end
break if check == requirement
update_basic
end
end

#--------------------------------------------------------------------------
# new method: start_victory_poses
#--------------------------------------------------------------------------
def start_victory_poses
for member in $game_party.existing_members
next unless member.use_battler_animations?
member.battler_animation_stance("VICTORY")
end
return unless $imported["ExtendedMovement"]
return unless YEM::BATTLE_ENGINE::AUTO_POSES[:victory]
for member in $game_party.existing_members
next if member.character == nil
member.character.break_pose
member.character.mirror = false
member.character.pose = "VICTORY"
end
end

#--------------------------------------------------------------------------
# new method: update_battler_poses
#--------------------------------------------------------------------------
def update_battler_poses
return unless $scene.is_a?(Scene_Battle)
return if @action_occuring
for member in @all_members
update_stances_individual(member)
end
#---
return unless $imported["ExtendedMovement"]
for member in $game_party.existing_members
update_pose_individual(member)
end
for member in $game_troop.existing_members
update_pose_individual(member)
end
end

#--------------------------------------------------------------------------
# new method: update_stances_individual
#--------------------------------------------------------------------------
def update_stances_individual(member, ignore_active_battler = false)
return unless member.use_battler_animations?
return if member == @active_battler and !ignore_active_battler
stance = ""
if member.dead?
stance = "DEAD"
elsif !member.movable?
stance = "STASIS"
elsif member.hp < member.maxhp / 4
stance = "PIYORI"
else
stance = "IDLE"
end
return if stance == ""
member.battler_animation_stance(stance)
end

#--------------------------------------------------------------------------
# new method: update_pose_individual
#--------------------------------------------------------------------------
def update_pose_individual(member, ignore_active_battler = false)
return unless $scene.is_a?(Scene_Battle)
return unless $imported["ExtendedMovement"]
return if member == @active_battler and !ignore_active_battler
return if member.dead?
return if member.character == nil
if member.spriteset.character_sprite != nil
return unless member.spriteset.character_sprite.appropiate_filename?
end
return if member.use_battler_animations?
auto_poses = YEM::BATTLE_ENGINE::AUTO_POSES
settings = YEM::BATTLE_ENGINE::POSE_SETTINGS
if member.hp < member.maxhp / 4
pose = :piyori
name = "PIYORI"
stance = "PIYORI"
else
pose = :ready
name = "READY"
stance = "IDLE"
end
return if member.character.pose == name.upcase
member.character.break_pose
member.character.step_anime = true
return unless auto_poses[pose]
direction = member.character.direction
member.character.step_anime = false unless member.movable?
return if settings[pose][1].include?(direction)
member.character.mirror = settings[pose][0].include?(direction)
member.character.pose = name
member.character.step_anime = false unless member.movable?
end

#--------------------------------------------------------------------------
# new method: refresh_ptb_windows
#--------------------------------------------------------------------------
def refresh_battle_windows
@skill_window.battle_refresh_call = true if @skill_window != nil
@item_window.battle_refresh_call = true if @item_window != nil
@mini_window.battle_refresh_call = true if @mini_window != nil
end

#--------------------------------------------------------------------------
# new method: refresh_ptb_windows
#--------------------------------------------------------------------------
def refresh_ptb_windows
return unless ptb?
return if @active_battler == nil
if @active_battler.actor?
@ptb_party_window.update_call = true
@spriteset.ptb_update = $game_party
else
@ptb_troop_window.update_call = true
@spriteset.ptb_update = $game_troop
end
end

#--------------------------------------------------------------------------
# new method: update_battle_cursor
#--------------------------------------------------------------------------
def update_battle_cursor
return unless $scene.is_a?(Scene_Battle)
return if @spriteset.battle_cursor == nil
@spriteset.battle_cursor.create_move_to
end

#--------------------------------------------------------------------------
# new method: create_aoe_indicator
#--------------------------------------------------------------------------
def create_aoe_indicator(window)
if atb?
case @selected_battler.action.atb_queue_kind
when 1 # Skill
obj = $data_skills[@selected_battler.action.atb_queue_basic]
when 2 # Item
obj = $data_items[@selected_battler.action.atb_queue_basic]
else; return
end
else
if @selected_battler.action.skill?
obj = @selected_battler.action.skill
elsif @selected_battler.action.item?
obj = @selected_battler.action.item
else; return
end
end
#---
@spriteset.create_magic_circle(window, obj)
@spriteset.create_magic_square(window, obj)
end

#--------------------------------------------------------------------------
# new method: dispose_aoe_indicator
#--------------------------------------------------------------------------
def dispose_aoe_indicator
@spriteset.dispose_magic_circle
@spriteset.dispose_magic_square
end

end # Scene_Battle

#===============================================================================
#
# END OF FILE
#
#===============================================================================
[/spoiler]
Go to the top of the page
 
+Quote Post
   
Pillanious
post Feb 28 2012, 10:07 PM
Post #8


Level 8
Group Icon

Group: Revolutionary
Posts: 125
Type: Musician
RM Skill: Beginner




Boards aren't allowing scripts to be inserted for some reason...Dunno what's up - but I'll post it whenever the bug is fixed.

This post has been edited by Pillanious: Feb 28 2012, 10:09 PM
Go to the top of the page
 
+Quote Post
   
Ashalinia
post Feb 29 2012, 08:10 PM
Post #9


Level 12
Group Icon

Group: Revolutionary
Posts: 204
Type: Writer
RM Skill: Intermediate




Try downloading this one to see if the error still occurs (or a different one):

Melody IV Script

Edit: You might want to put that script in a spoiler...


This post has been edited by Ashalinia: Feb 29 2012, 08:13 PM


__________________________
Do you hate me? Good, I hate you too.

Rob_Riv is my idol. :)



Support



-----------------------------------------------------------------------------------------------------------------

Sorcerer's Night
Go to the top of the page
 
+Quote Post
   
FenrirWolf123
post Mar 1 2012, 11:06 AM
Post #10


Level 1
Group Icon

Group: Member
Posts: 6
Type: Developer
RM Skill: Beginner




No... won' t work, still the same error...
have some special things to do, like put in the animation in the script, or a right place in the animation tab?
I sorry about the script, but i don't know put in spoiler, and if you see in the beginning and the end, there a [spoiler]!
And i think i figure up what is wrong, using all 5 scripts with a SBS script its ok?
If won't, that the problem.

This post has been edited by FenrirWolf123: Mar 1 2012, 11:13 AM
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th June 2013 - 07:53 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker