Advertisement
FlipelyFlip

Hide MP Battle Engine Melody IV

Feb 8th, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 260.43 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Yanfly Engine Melody - Battle Engine Melody - Part IV - Visuals
  4. # Last Date Updated: 2010.05.01
  5. # Level: Phantasm
  6. #
  7. # This section contains most of the visual aspects of Battle Engine Melody.
  8. # Therefore, this section will include mostly sprite information, window data,
  9. # and minor Game_Battler info and data that is used for visuals. This section
  10. # is excluded from the core coding to allow easier access.
  11. #
  12. #===============================================================================
  13. # Updates
  14. # -----------------------------------------------------------------------------
  15. # o 2010.02.12 to 2010.05.01 - Started and Finished Script.
  16. #===============================================================================
  17.  
  18. module YEM
  19.   module DEFAULT_ACTIONS
  20.    
  21.     #===========================================================================
  22.     # Default Attack Actions
  23.     # -------------------------------------------------------------------------
  24.     # These are the default attack actions for your enemies and weapons if they
  25.     # don't have any tags to overwrite their programming.
  26.     #===========================================================================
  27.     ATTACK_SETUP =[
  28.       ["MESSAGE", ["COMMAND ATTACK"]],
  29.       ["MOVE USER", ["FORWARD", "WAIT"]],
  30.       ["EFFECT", ["USER", "WHITE FLASH"]],
  31.     ] # Do not remove this.
  32.     ATTACK_WHOLE =[
  33.       ["IMMORTAL", ["TARGETS", "TRUE"]],
  34.     ] # Do not remove this.
  35.     ATTACK_TARGET =[
  36.       ["MOVE USER", ["TARGET", "MIDDLE", "WAIT"]],
  37.       ["AUTOMELODY", ["SINGLE SWING"]],
  38.       ["AUTOMELODY", ["ATTACK FULL"]],
  39.     ] # Do not remove this.
  40.     ATTACK_FOLLOW =[
  41.       ["WAIT FOR MOVE"],
  42.       ["IMMORTAL", ["TARGETS", "FALSE"]],
  43.     ] # Do not remove this.
  44.     ATTACK_FINISH =[
  45.       ["ICON DELETE", ["USER", "WEAPON"]],
  46.       ["AUTOMELODY", ["RETURN ORIGIN"]],
  47.       ["WAIT", [45, "SKIP"]],
  48.     ] # Do not remove this.
  49.    
  50.     #===========================================================================
  51.     # Default Magical Skill Actions
  52.     # -------------------------------------------------------------------------
  53.     # The following is the default setup for magical skills. This is applied to
  54.     # any skill that doesn't have Physical Attack checked in the database. If
  55.     # Physical Attack is checked, it will use a different action list setup.
  56.     #===========================================================================
  57.     MAGIC_SETUP =[
  58.       ["MESSAGE", ["COMMAND SKILL"]],
  59.       ["MOVE USER", ["FORWARD", "WAIT"]],
  60.       ["AUTOMELODY", ["CAST ANIMATION"]],
  61.     ] # Do not remove this.
  62.     MAGIC_WHOLE =[
  63.       ["IMMORTAL", ["TARGETS", "TRUE"]],
  64.       ["AUTOMELODY", ["SKILL FULL"]],
  65.     ] # Do not remove this.
  66.     MAGIC_TARGET =[
  67.     ] # Do not remove this.
  68.     MAGIC_FOLLOW =[
  69.       ["WAIT FOR MOVE"],
  70.       ["IMMORTAL", ["TARGETS", "FALSE"]],
  71.     ] # Do not remove this.
  72.     MAGIC_FINISH =[
  73.       ["COMMON EVENT", ["SKILL"]],
  74.       ["AUTOMELODY", ["RETURN ORIGIN"]],
  75.       ["WAIT", [45, "SKIP"]],
  76.     ] # Do not remove this.
  77.    
  78.     #===========================================================================
  79.     # Default Physical Skill Actions
  80.     # -------------------------------------------------------------------------
  81.     # The following is the default setup for physical skills. This is applied
  82.     # to any skill that has Physical Attack checked in the database. If Physical
  83.     # Attack is not checked, it will use a different action list setup.
  84.     #===========================================================================
  85.     PHYSICAL_SETUP =[
  86.       ["MESSAGE", ["COMMAND SKILL"]],
  87.       ["MOVE USER", ["FORWARD", "WAIT"]],
  88.       ["CAST ANIMATION", ["WAIT"]],
  89.     ] # Do not remove this.
  90.     PHYSICAL_WHOLE =[
  91.     ] # Do not remove this.
  92.     PHYSICAL_TARGET =[
  93.       ["IMMORTAL", ["TARGETS", "TRUE"]],
  94.       ["ICON DELETE", ["USER", "WEAPON"]],
  95.       ["MOVE USER", ["TARGET", "BODY", "WAIT"]],
  96.       ["AUTOMELODY", ["SINGLE SWING"]],
  97.       ["AUTOMELODY", ["SKILL FULL"]],
  98.       ["IMMORTAL", ["TARGETS", "FALSE"]],
  99.     ] # Do not remove this.
  100.     PHYSICAL_FOLLOW =[
  101.       ["WAIT FOR MOVE"],
  102.     ] # Do not remove this.
  103.     PHYSICAL_FINISH =[
  104.       ["COMMON EVENT", ["SKILL"]],
  105.       ["ICON DELETE", ["USER", "WEAPON"]],
  106.       ["AUTOMELODY", ["RETURN ORIGIN"]],
  107.       ["WAIT", [45, "SKIP"]],
  108.     ] # Do not remove this.
  109.    
  110.     #===========================================================================
  111.     # Default Item Actions
  112.     # -------------------------------------------------------------------------
  113.     # The following is the default setup for using items. This is applied to
  114.     # both physical and non-physical items.
  115.     #===========================================================================
  116.     ITEM_SETUP =[
  117.       ["MESSAGE", ["COMMAND ITEM"]],
  118.       ["MOVE USER", ["FORWARD", "WAIT"]],
  119.       ["AUTOMELODY", ["ITEM FLOAT"]],
  120.     ] # Do not remove this.
  121.     ITEM_WHOLE =[
  122.       ["IMMORTAL", ["TARGETS", "TRUE"]],
  123.       ["AUTOMELODY", ["ITEM FULL"]],
  124.     ] # Do not remove this.
  125.     ITEM_TARGET =[
  126.     ] # Do not remove this.
  127.     ITEM_FOLLOW =[
  128.       ["WAIT FOR MOVE"],
  129.       ["IMMORTAL", ["TARGETS", "FALSE"]],
  130.     ] # Do not remove this.
  131.     ITEM_FINISH =[
  132.       ["COMMON EVENT", ["ITEM"]],
  133.       ["AUTOMELODY", ["RETURN ORIGIN"]],
  134.       ["WAIT", [45, "SKIP"]],
  135.     ] # Do not remove this.
  136.    
  137.     #===========================================================================
  138.     # Guard Mini-Actions
  139.     # -------------------------------------------------------------------------
  140.     # This is the action command list for guarding. These are applied to every
  141.     # enemy and every shield's selection.
  142.     #===========================================================================
  143.     GUARD_ACTIONS =[
  144.       ["MESSAGE", ["COMMAND GUARD"]],
  145.       ["POSE", ["GUARDING"]],
  146.       ["EFFECT", ["USER", "WHITE FLASH"]],
  147.       ["WAIT", [45, "SKIP"]],
  148.     ] # Do not remove this.
  149.    
  150.     #===========================================================================
  151.     # Wait Mini-Actions
  152.     # -------------------------------------------------------------------------
  153.     # This is the action command when for waiting battlers. These aren't unique
  154.     # for each weapon or item or enemy. This is universal amongst all waits.
  155.     #===========================================================================
  156.     WAIT_ACTIONS =[
  157.       ["MESSAGE", ["COMMAND WAIT"]],
  158.       ["EFFECT", ["USER", "WHITE FLASH"]],
  159.       ["WAIT", [45, "SKIP"]],
  160.     ] # Do not remove this.
  161.    
  162.     #===========================================================================
  163.     # Enemy Escape Mini-Actions
  164.     # -------------------------------------------------------------------------
  165.     # This is only applied to enemies who can escape. These aren't unique for
  166.     # each enemy. All escaping enemies will draw from the same action list.
  167.     #===========================================================================
  168.     ENEMY_ESCAPE_ACTIONS =[
  169.       ["MESSAGE", ["COMMAND ESCAPE"]],
  170.       ["SE", ["PLAY ESCAPE"]],
  171.       ["TURN USER", ["BACKWARD"]],
  172.       ["STANCE", ["USER", "RETURN"]],
  173.       ["MOVE USER", ["BACKWARD", 32, 30]],
  174.       ["WAIT", [30, "SKIP"]],
  175.       ["ESCAPE EFFECT", ["USER"]],
  176.       ["WAIT", [60, "SKIP"]],
  177.     ] # Do not remove this.
  178.    
  179.     #===========================================================================
  180.     # Actor Escape Mini-Actions
  181.     # -------------------------------------------------------------------------
  182.     # This is only applied to the party when an escape is successful. This will
  183.     # be applied to the whole party at once, but only non-dead members will
  184.     # visually run away.
  185.     #===========================================================================
  186.     ACTOR_ESCAPE_ACTIONS =[
  187.       ["TURN PARTY", ["BACKWARD"]],
  188.       ["STANCE", ["PARTY", "RETURN"]],
  189.       ["MOVE PARTY", ["BACKWARD", 256, 60, "WAIT"]],
  190.     ] # Do not remove this.
  191.    
  192.     #===========================================================================
  193.     # Critical Mini-Actions
  194.     # -------------------------------------------------------------------------
  195.     # This is what will occur when a critical hit occurs. These actions aren't
  196.     # unique per character. All critical hits will play the same action.
  197.     #===========================================================================
  198.     CRITICAL_ACTIONS =[
  199.     # ["POPUP", ["TARGET", "POP_CRITICAL"]],
  200.       ["MESSAGE", ["COMMAND CRITICAL"]],
  201.     ] # Do not remove this.
  202.    
  203.     #===========================================================================
  204.     # Miss Mini-Actions
  205.     # -------------------------------------------------------------------------
  206.     # This is what will occur when a miss event occurs. These actions aren't
  207.     # unique per character. All miss cases will play the same action.
  208.     #===========================================================================
  209.     MISS_ACTIONS =[
  210.       ["STANCE", ["TARGET", "EVADE"]],
  211.       ["POSE", ["TARGET", "EVADE"]],
  212.       ["POPUP", ["TARGET", "POP_MISS"]],
  213.       ["MESSAGE", ["COMMAND MISS"]],
  214.       ["SE", ["PLAY MISS"]],
  215.     ] # Do not remove this.
  216.    
  217.     #===========================================================================
  218.     # Evade Mini-Actions
  219.     # -------------------------------------------------------------------------
  220.     # This is what will occur when a evasion occurs. These actions aren't
  221.     # unique per character. All evasion cases will play the same action.
  222.     #===========================================================================
  223.     EVADE_ACTIONS =[
  224.       ["STANCE", ["TARGET", "EVADE"]],
  225.       ["POSE", ["TARGET", "EVADE"]],
  226.       ["POPUP", ["TARGET", "POP_EVADE"]],
  227.       ["MESSAGE", ["COMMAND EVADE"]],
  228.       ["SE", ["PLAY EVADE"]],
  229.     ] # Do not remove this.
  230.    
  231.     #===========================================================================
  232.     # Fail Mini-Actions
  233.     # -------------------------------------------------------------------------
  234.     # When skills fail or items fail, the fail actions will be called upon to
  235.     # produce a series of actions. All fail cases will play the same action.
  236.     #===========================================================================
  237.     FAIL_ACTIONS =[
  238.       ["POPUP", ["TARGET", "POP_FAIL"]],
  239.       ["MESSAGE", ["COMMAND FAIL"]],
  240.     ] # Do not remove this.
  241.    
  242.     #===========================================================================
  243.     # HP Damage Mini-Actions
  244.     # -------------------------------------------------------------------------
  245.     # The following sets the HP damage series. These are the actions played
  246.     # when a target takes 0 HP damage, receives healing, or the takes damage.
  247.     # Absorption is taken into consideration for healing and damage.
  248.     #===========================================================================
  249.     HP_DAMAGE_NONE =[
  250.       ["POPUP", ["TARGET", "HP_NONE"]],
  251.       ["MESSAGE", ["COMMAND HP DAMAGE", "NONE"]],
  252.     ] # Do not remove this.
  253.     HP_DAMAGE_HEAL =[
  254.       ["POPUP", ["TARGET", "HP_HEAL"]],
  255.       ["MESSAGE", ["COMMAND HP DAMAGE", "HEAL"]],
  256.       ["SE", ["PLAY RECOVERY"]],
  257.     ] # Do not remove this.
  258.     HP_DAMAGE_DMG =[
  259.       ["STANCE", ["TARGET", "DAMAGE"]],
  260.       ["POSE", ["TARGET", "DAMAGE"]],
  261.       ["POPUP", ["TARGET", "HP_DMG"]],
  262.       ["MESSAGE", ["COMMAND HP DAMAGE", "DAMAGE"]],
  263.       ["SE", ["PLAY ACTOR DAMAGE", "if target.actor?"]],
  264.       ["SE", ["PLAY ENEMY DAMAGE", "if target.enemy?"]],
  265.     ] # Do not remove this.
  266.    
  267.     #===========================================================================
  268.     # MP Damage Mini-Actions
  269.     # -------------------------------------------------------------------------
  270.     # The following sets the MP damage series. These are the actions played
  271.     # when a target takes 0 MP damage, receives healing, or the takes damage.
  272.     # Absorption is taken into consideration for healing and damage.
  273.     #===========================================================================
  274.     MP_DAMAGE_HEAL =[
  275.       ["POPUP", ["TARGET", "MP_HEAL"]],
  276.       ["MESSAGE", ["COMMAND MP DAMAGE", "HEAL"]],
  277.       ["SE", ["PLAY RECOVERY"]],
  278.     ] # Do not remove this.
  279.     MP_DAMAGE_DMG =[
  280.       ["POPUP", ["TARGET", "MP_DMG"]],
  281.       ["MESSAGE", ["COMMAND MP DAMAGE", "DAMAGE"]],
  282.       ["SE", ["PLAY ACTOR DAMAGE", "if target.actor?"]],
  283.       ["SE", ["PLAY ENEMY DAMAGE", "if target.enemy?"]],
  284.     ] # Do not remove this.
  285.    
  286.     #===========================================================================
  287.     # State Change Mini-Actions
  288.     # -------------------------------------------------------------------------
  289.     # The following sets the state change series. These actions are played
  290.     # whenever a target receives a state change through an executed action.
  291.     #===========================================================================
  292.     ADD_STATE =[
  293.       ["POPUP", ["TARGET", "POP_ADDSTATE"]],
  294.       ["MESSAGE", ["COMMAND STATES", "ADDED"]],
  295.     ] # Do not remove this.
  296.     REM_STATE =[
  297.       ["POPUP", ["TARGET", "POP_REMSTATE"]],
  298.       ["MESSAGE", ["COMMAND STATES", "REMOVE"]],
  299.     ] # Do not remove this.
  300.     DUR_STATE =[
  301.       ["POPUP", ["TARGET", "POP_DURSTATE"]],
  302.       ["MESSAGE", ["COMMAND STATES", "REMAINED"]],
  303.     ] # Do not remove this.
  304.    
  305.   end # DEFAULT_ACTIONS
  306. end # YEM
  307.  
  308. #===============================================================================
  309. # Editting anything past this point may potentially result in causing computer
  310. # damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
  311. # Therefore, edit at your own risk.
  312. #===============================================================================
  313.  
  314. #===============================================================================
  315. # module Icon
  316. #===============================================================================
  317.  
  318. module Icon
  319.  
  320.   #--------------------------------------------------------------------------
  321.   # self.element
  322.   #--------------------------------------------------------------------------
  323.   def self.element(element_id)
  324.     icon = YEM::BATTLE_ENGINE::ELEMENT_ICONS[element_id]
  325.     return (icon == nil) ? 0 : icon
  326.   end
  327.  
  328.   #--------------------------------------------------------------------------
  329.   # self.stat
  330.   #--------------------------------------------------------------------------
  331.   def self.stat(actor, item)
  332.     limit = actor.parameter_limit
  333.     icon = 0
  334.     case item
  335.     when :atk
  336.       if actor.atk > actor.base_atk
  337.         icon = Icon.stat_up(item)
  338.       elsif actor.atk < actor.base_atk and actor.atk != limit
  339.         icon = Icon.stat_dn(item)
  340.       end
  341.      
  342.     when :def
  343.       if actor.def > actor.base_def
  344.         icon = Icon.stat_up(item)
  345.       elsif actor.def < actor.base_def and actor.def != limit
  346.         icon = Icon.stat_dn(item)
  347.       end
  348.      
  349.     when :spi
  350.       if actor.spi > actor.base_spi
  351.         icon = Icon.stat_up(item)
  352.       elsif actor.spi < actor.base_spi and actor.spi != limit
  353.         icon = Icon.stat_dn(item)
  354.       end
  355.      
  356.     when :res
  357.       return icon unless $imported["RES Stat"]
  358.       if actor.res > actor.base_res
  359.         icon = Icon.stat_up(item)
  360.       elsif actor.res < actor.base_res and actor.res != limit
  361.         icon = Icon.stat_dn(item)
  362.       end
  363.      
  364.     when :dex
  365.       return icon unless $imported["DEX Stat"]
  366.       if actor.dex > actor.base_dex
  367.         icon = Icon.stat_up(item)
  368.       elsif actor.dex < actor.base_dex and actor.dex != limit
  369.         icon = Icon.stat_dn(item)
  370.       end
  371.      
  372.     when :agi
  373.       if actor.agi > actor.base_agi
  374.         icon = Icon.stat_up(item)
  375.       elsif actor.agi < actor.base_agi and actor.agi != limit
  376.         icon = Icon.stat_dn(item)
  377.       end
  378.     end
  379.     return icon
  380.   end
  381.  
  382.   #--------------------------------------------------------------------------
  383.   # self.stat_up
  384.   #--------------------------------------------------------------------------
  385.   def self.stat_up(item = nil)
  386.     return YEM::BATTLE_ENGINE::STAT_ICONS[:stat_up]
  387.   end
  388.  
  389.   #--------------------------------------------------------------------------
  390.   # self.stat_dn
  391.   #--------------------------------------------------------------------------
  392.   def self.stat_dn(item = nil)
  393.     return YEM::BATTLE_ENGINE::STAT_ICONS[:stat_dn]
  394.   end
  395.  
  396.   #--------------------------------------------------------------------------
  397.   # self.normal_state
  398.   #--------------------------------------------------------------------------
  399.   def self.normal_state
  400.     return YEM::BATTLE_ENGINE::STAT_ICONS[:normal]
  401.   end
  402.  
  403.   #--------------------------------------------------------------------------
  404.   # self.mp_cost
  405.   #--------------------------------------------------------------------------
  406.   def self.mp_cost
  407.     return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:mp_icon]
  408.   end
  409.  
  410.   #--------------------------------------------------------------------------
  411.   # self.hp_cost
  412.   #--------------------------------------------------------------------------
  413.   def self.hp_cost
  414.     return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:hp_icon]
  415.   end
  416.  
  417.   #--------------------------------------------------------------------------
  418.   # self.gold_cost
  419.   #--------------------------------------------------------------------------
  420.   def self.gold_cost
  421.     return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:gold_icon]
  422.   end
  423.  
  424.   #--------------------------------------------------------------------------
  425.   # self.rage_cost
  426.   #--------------------------------------------------------------------------
  427.   def self.rage_cost
  428.     return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:rage_icon]
  429.   end
  430.  
  431.   #--------------------------------------------------------------------------
  432.   # self.cooldown
  433.   #--------------------------------------------------------------------------
  434.   def self.cooldown
  435.     return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:cooldown_icon]
  436.   end
  437.  
  438.   #--------------------------------------------------------------------------
  439.   # self.limited_use
  440.   #--------------------------------------------------------------------------
  441.   def self.limited_use
  442.     return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:limited_icon]
  443.   end
  444.  
  445. end # Icon
  446.  
  447. #===============================================================================
  448. # Game_Battler
  449. #===============================================================================
  450.  
  451. class Game_Battler
  452.  
  453.   #--------------------------------------------------------------------------
  454.   # public instance variables
  455.   #--------------------------------------------------------------------------
  456.   attr_accessor :battler_animation_id
  457.   attr_accessor :battler_icon
  458.   attr_accessor :pseudo_ani_id
  459.   attr_accessor :popup_array
  460.   attr_accessor :sub_animation_id
  461.   attr_accessor :vanish_case
  462.  
  463.   #--------------------------------------------------------------------------
  464.   # alias method: clear_sprite_effects
  465.   #--------------------------------------------------------------------------
  466.   alias clear_sprite_effects_bem clear_sprite_effects unless $@
  467.   def clear_sprite_effects
  468.     clear_sprite_effects_bem
  469.     @pseudo_ani_id = 0
  470.   end
  471.  
  472.   #--------------------------------------------------------------------------
  473.   # new method: state_animation_zoom
  474.   #--------------------------------------------------------------------------
  475.   def state_animation_zoom; return 100; end
  476.  
  477.   #--------------------------------------------------------------------------
  478.   # new method: reload_state_animation
  479.   #--------------------------------------------------------------------------
  480.   def reload_state_animation
  481.     return unless $scene.is_a?(Scene_Battle)
  482.     @state_animation_id = 0
  483.     for state in states
  484.       next unless state.state_ani > 0
  485.       @state_animation_id = state.state_ani
  486.       break
  487.     end
  488.   end
  489.  
  490.   #--------------------------------------------------------------------------
  491.   # new method: create_popup
  492.   #--------------------------------------------------------------------------
  493.   def create_popup(value, rules = "DEFAULT", flags = [])
  494.     return unless $scene.is_a?(Scene_Battle)
  495.     if flags.include?("critical") and $scene.ptb?
  496.       bonus = YEM::BATTLE_ENGINE::PTB_RULES[:regain_critical]
  497.       action.opponents_unit.gain_bonus($scene.active_battler, bonus)
  498.     end
  499.     array = [value, rules, flags]
  500.     @popup_array = [] if @popup_array == nil
  501.     @popup_array.push(array)
  502.   end
  503.  
  504.   #--------------------------------------------------------------------------
  505.   # new method: white_flash=
  506.   #--------------------------------------------------------------------------
  507.   def white_flash=(value)
  508.     return unless exist?
  509.     @white_flash = value
  510.   end
  511.  
  512.   #--------------------------------------------------------------------------
  513.   # new methods: bitmap_height and bitmap_width
  514.   #--------------------------------------------------------------------------
  515.   def bitmap_height; return Integer(spriteset.height * zoom); end
  516.   def bitmap_width; return Integer(spriteset.width * zoom); end
  517.    
  518.   #--------------------------------------------------------------------------
  519.   # new method: spriteset
  520.   #--------------------------------------------------------------------------
  521.   def spriteset
  522.     return $scene.spriteset.enemy_sprites.reverse[self.index]
  523.   end
  524.  
  525.   #--------------------------------------------------------------------------
  526.   # new method: attack_icon
  527.   #--------------------------------------------------------------------------
  528.   def attack_icon
  529.     return YEM::BATTLE_ENGINE::ICON_MESSAGE[:atk_icon]
  530.   end
  531.  
  532.   #--------------------------------------------------------------------------
  533.   # new method: guard_icon
  534.   #--------------------------------------------------------------------------
  535.   def guard_icon
  536.     return YEM::BATTLE_ENGINE::ICON_MESSAGE[:grd_icon]
  537.   end
  538.  
  539.   #--------------------------------------------------------------------------
  540.   # new method: sprite_movable?
  541.   #--------------------------------------------------------------------------
  542.   def sprite_movable?
  543.     return false if !exist?
  544.     return true
  545.   end
  546.  
  547.   #--------------------------------------------------------------------------
  548.   # new method: mirror?
  549.   #--------------------------------------------------------------------------
  550.   def mirror?; return false; end
  551.    
  552.   #--------------------------------------------------------------------------
  553.   # new method: zoom
  554.   #--------------------------------------------------------------------------
  555.   def zoom; return 1.0; end
  556.  
  557.   #--------------------------------------------------------------------------
  558.   # use_battler_animations?
  559.   #--------------------------------------------------------------------------
  560.   def use_battler_animations?; return false; end
  561.    
  562.   #--------------------------------------------------------------------------
  563.   # battler_animation_stance
  564.   #--------------------------------------------------------------------------
  565.   def battler_animation_stance(string); return; end
  566.  
  567. end # Game_Battler
  568.  
  569. #===============================================================================
  570. # Game_Actor
  571. #===============================================================================
  572.  
  573. class Game_Actor < Game_Battler
  574.  
  575.   #--------------------------------------------------------------------------
  576.   # quick methods: use_sprite? screen_z battler_name battler_hue
  577.   #--------------------------------------------------------------------------
  578.   def use_sprite?; return true; end
  579.   def battler_name; return ""; end
  580.   def battler_hue; return 0; end
  581.  
  582.   #--------------------------------------------------------------------------
  583.   # alias method: atk_animation_id
  584.   #--------------------------------------------------------------------------
  585.   alias atk_animation_id_bem atk_animation_id unless $@
  586.   def atk_animation_id
  587.     return @cache_atk_animation[1] if @cache_atk_animation[1] != nil
  588.     @cache_atk_animation[1] = atk_animation_id_bem
  589.     for state in states
  590.       next unless state.attack_animation > 0
  591.       @cache_atk_animation[1] = state.attack_animation
  592.       break
  593.     end
  594.     return @cache_atk_animation[1]
  595.   end
  596.  
  597.   #--------------------------------------------------------------------------
  598.   # alias method: atk_animation_id2
  599.   #--------------------------------------------------------------------------
  600.   alias atk_animation_id2_bem atk_animation_id2 unless $@
  601.   def atk_animation_id2
  602.     return @cache_atk_animation[2] if @cache_atk_animation[2] != nil
  603.     @cache_atk_animation[2] = atk_animation_id2_bem
  604.     return @cache_atk_animation[2] if @cache_atk_animation[2] == 0
  605.     for state in states
  606.       next unless state.attack_animation > 0
  607.       @cache_atk_animation[2] = state.attack_animation
  608.       break
  609.     end
  610.     return @cache_atk_animation[2]
  611.   end
  612.  
  613.   #--------------------------------------------------------------------------
  614.   # new method: state_animation_zoom
  615.   #--------------------------------------------------------------------------
  616.   def state_animation_zoom
  617.     return YEM::BATTLE_ENGINE::STATE_SETTINGS[:actor_ani_zoom]
  618.   end
  619.  
  620.   #--------------------------------------------------------------------------
  621.   # new method: screen_x
  622.   #--------------------------------------------------------------------------
  623.   def screen_x
  624.     return 0 unless $scene.is_a?(Scene_Battle)
  625.     if $scene.emptyview? or character == nil
  626.       calc = Graphics.width - 128 - 32
  627.       max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
  628.       maximum = [$game_party.members.size, max_members].max
  629.       calc /= maximum
  630.       width = calc
  631.       n = index * width + width/2 + 16
  632.       n += 128
  633.       n -= $scene.info_viewport.ox if $scene.info_viewport != nil
  634.       return n
  635.     end
  636.     return character.screen_x
  637.   end
  638.  
  639.   #--------------------------------------------------------------------------
  640.   # new method: screen_x=
  641.   #--------------------------------------------------------------------------
  642.   def screen_x=(value); character.screen_x = value; end
  643.  
  644.   #--------------------------------------------------------------------------
  645.   # new method: origin_x
  646.   #--------------------------------------------------------------------------
  647.   def origin_x
  648.     return 0 unless $scene.is_a?(Scene_Battle)
  649.     return screen_x if $scene.emptyview?
  650.     return character.origin_x
  651.   end
  652.  
  653.   #--------------------------------------------------------------------------
  654.   # new method: screen_y
  655.   #--------------------------------------------------------------------------
  656.   def screen_y
  657.     return 0 unless $scene.is_a?(Scene_Battle)
  658.     if $scene.emptyview? or character == nil
  659.       n = Graphics.height - 128
  660.       return n
  661.     end
  662.     return character.screen_y
  663.   end
  664.  
  665.   #--------------------------------------------------------------------------
  666.   # new method: screen_y=
  667.   #--------------------------------------------------------------------------
  668.   def screen_y=(value); character.screen_y = value; end
  669.  
  670.   #--------------------------------------------------------------------------
  671.   # new method: origin_y
  672.   #--------------------------------------------------------------------------
  673.   def origin_y
  674.     return 0 unless $scene.is_a?(Scene_Battle)
  675.     return screen_y if $scene.emptyview?
  676.     return character.origin_y
  677.   end
  678.  
  679.   #--------------------------------------------------------------------------
  680.   # new method: screen_z
  681.   #--------------------------------------------------------------------------
  682.   def screen_z
  683.     return 100 unless $scene.is_a?(Scene_Battle)
  684.     return 100 if $scene.emptyview? or character == nil
  685.     return character.screen_z + character.screen_y
  686.   end
  687.  
  688.   #--------------------------------------------------------------------------
  689.   # new method: screen_z=
  690.   #--------------------------------------------------------------------------
  691.   def screen_z=(value); character.screen_z = value; end
  692.    
  693.   #--------------------------------------------------------------------------
  694.   # new method: spriteset
  695.   #--------------------------------------------------------------------------
  696.   def spriteset
  697.     return $scene.spriteset.actor_sprites[self.index]
  698.   end
  699.  
  700.   #--------------------------------------------------------------------------
  701.   # new method: character
  702.   #--------------------------------------------------------------------------
  703.   def character
  704.     return nil unless $scene.is_a?(Scene_Battle)
  705.     return $scene.characters[self.index]
  706.   end
  707.  
  708.   #--------------------------------------------------------------------------
  709.   # new method: attack_icon
  710.   #--------------------------------------------------------------------------
  711.   def attack_icon
  712.     return super if weapons.compact == []
  713.     return weapon1_icon
  714.   end
  715.  
  716.   #--------------------------------------------------------------------------
  717.   # new method: guard_icon
  718.   #--------------------------------------------------------------------------
  719.   def guard_icon
  720.     for armor in armors.compact
  721.       next unless armor.kind == 0
  722.       return armor.icon_index
  723.     end
  724.     return super
  725.   end
  726.  
  727.   #--------------------------------------------------------------------------
  728.   # new method: battler_icon
  729.   #--------------------------------------------------------------------------
  730.   def battler_icon
  731.     if YEM::BATTLE_ENGINE::BATTLER_ACTOR_ICONS.include?(@actor_id)
  732.       return YEM::BATTLE_ENGINE::BATTLER_ACTOR_ICONS[@actor_id]
  733.     elsif YEM::BATTLE_ENGINE::BATTLER_CLASS_ICONS.include?(@class_id)
  734.       return YEM::BATTLE_ENGINE::BATTLER_CLASS_ICONS[@class_id]
  735.     end
  736.     return YEM::BATTLE_ENGINE::DEFAULT_ACTOR_ICON
  737.   end
  738.  
  739.   #--------------------------------------------------------------------------
  740.   # new method: weapon1_icon
  741.   #--------------------------------------------------------------------------
  742.   def weapon1_icon
  743.     return @cache_weapon_icon[1] if @cache_weapon_icon[1] != nil
  744.     icon = 0
  745.     icon = weapons[0].icon_index if weapons.compact.size > 0
  746.     for state in states
  747.       next unless state.weapon_icon > 0
  748.       icon = state.weapon_icon
  749.       break
  750.     end
  751.     @cache_weapon_icon[1] = icon
  752.     return @cache_weapon_icon[1]
  753.   end
  754.  
  755.   #--------------------------------------------------------------------------
  756.   # new method: weapon2_icon
  757.   #--------------------------------------------------------------------------
  758.   def weapon2_icon
  759.     return @cache_weapon_icon[2] if @cache_weapon_icon[2] != nil
  760.     icon = 0
  761.     icon = weapons[1].icon_index if weapons.compact.size > 1
  762.     for state in states
  763.       next unless state.weapon_icon > 0
  764.       icon = state.weapon_icon
  765.       break
  766.     end
  767.     @cache_weapon_icon[2] = icon
  768.     return @cache_weapon_icon[2]
  769.   end
  770.  
  771.   #--------------------------------------------------------------------------
  772.   # use_battler_animations?
  773.   #--------------------------------------------------------------------------
  774.   def use_battler_animations?
  775.     array = [@character_name, @character_index]
  776.     return YEM::BATTLE_ENGINE::ANIMATION_BATTLER_ACTORS.include?(array)
  777.   end
  778.  
  779.   #--------------------------------------------------------------------------
  780.   # battler_animation_stance
  781.   #--------------------------------------------------------------------------
  782.   def battler_animation_stance(string)
  783.     array = [@character_name, @character_index]
  784.     hash = YEM::BATTLE_ENGINE::ANIMATION_BATTLER_ACTORS[array]
  785.     return unless hash.include?(string)
  786.     @battler_animation_id = hash[string]
  787.   end
  788.  
  789. end # Game_Actor
  790.  
  791. #===============================================================================
  792. # Game_Enemy
  793. #===============================================================================
  794.  
  795. class Game_Enemy < Game_Battler
  796.  
  797.   #--------------------------------------------------------------------------
  798.   # public instance variables
  799.   #--------------------------------------------------------------------------
  800.   attr_accessor :direction
  801.   attr_accessor :origin_x
  802.   attr_accessor :origin_y
  803.  
  804.   #--------------------------------------------------------------------------
  805.   # new method: screen_x
  806.   #--------------------------------------------------------------------------
  807.   def screen_x
  808.     return character == nil ? @screen_x : character.screen_x
  809.   end
  810.  
  811.   #--------------------------------------------------------------------------
  812.   # new method: screen_x=
  813.   #--------------------------------------------------------------------------
  814.   def screen_x=(value)
  815.     @screen_x = value if character == nil
  816.     character.screen_x = value if character != nil
  817.   end
  818.  
  819.   #--------------------------------------------------------------------------
  820.   # new method: screen_y
  821.   #--------------------------------------------------------------------------
  822.   def screen_y
  823.     return character == nil ? @screen_y : character.screen_y
  824.   end
  825.  
  826.   #--------------------------------------------------------------------------
  827.   # new method: screen_y=
  828.   #--------------------------------------------------------------------------
  829.   def screen_y=(value)
  830.     @screen_y = value if character == nil
  831.     character.screen_y = value if character != nil
  832.   end
  833.  
  834.   #--------------------------------------------------------------------------
  835.   # alias method: screen_z
  836.   #--------------------------------------------------------------------------
  837.   alias screen_z_enemy screen_z unless $@
  838.   def screen_z
  839.     return @battle_screen_z if @battle_screen_z != nil
  840.     return screen_z_enemy + self.screen_y
  841.   end
  842.  
  843.   #--------------------------------------------------------------------------
  844.   # new method: screen_z=
  845.   #--------------------------------------------------------------------------
  846.   def screen_z=(value)
  847.     @battle_screen_z = value if character == nil
  848.     character.screen_z = value if character != nil
  849.   end
  850.  
  851.   #--------------------------------------------------------------------------
  852.   # new method: character
  853.   #--------------------------------------------------------------------------
  854.   def character
  855.     if enemy.character_name == "" or !$scene.is_a?(Scene_Battle)
  856.       return nil
  857.     else
  858.       return $scene.enemychars[self]
  859.     end
  860.   end
  861.  
  862.   #--------------------------------------------------------------------------
  863.   # new method: character_name
  864.   #--------------------------------------------------------------------------
  865.   def character_name; return enemy.character_name; end
  866.  
  867.   #--------------------------------------------------------------------------
  868.   # new method: character_index
  869.   #--------------------------------------------------------------------------
  870.   def character_index; return enemy.character_index; end
  871.  
  872.   #--------------------------------------------------------------------------
  873.   # new method: screen_z=
  874.   #--------------------------------------------------------------------------
  875.   def screen_z=(value); @battle_screen_z = value; end
  876.  
  877.   #--------------------------------------------------------------------------
  878.   # new method: state_animation_zoom
  879.   #--------------------------------------------------------------------------
  880.   def state_animation_zoom; return enemy.state_zoom; end
  881.  
  882.   #--------------------------------------------------------------------------
  883.   # new method: atk_animation_id
  884.   #--------------------------------------------------------------------------
  885.   def atk_animation_id
  886.     return @cache_atk_animation[1] if @cache_atk_animation[1] != nil
  887.     @cache_atk_animation[1] = enemy.attack_animation
  888.     for state in states
  889.       next unless state.attack_animation > 0
  890.       @cache_atk_animation[1] = state.attack_animation
  891.       break
  892.     end
  893.     return @cache_atk_animation[1]
  894.   end
  895.  
  896.   #--------------------------------------------------------------------------
  897.   # new method: attack_icon
  898.   #--------------------------------------------------------------------------
  899.   def attack_icon
  900.     return enemy.weapons[0].icon_index if enemy.weapons.compact.size > 0
  901.     return super
  902.   end
  903.  
  904.   #--------------------------------------------------------------------------
  905.   # new method: weapon1_icon
  906.   #--------------------------------------------------------------------------
  907.   def weapon1_icon
  908.     return enemy.weapons[0].icon_index if enemy.weapons.compact.size > 0
  909.     return 0
  910.   end
  911.  
  912.   #--------------------------------------------------------------------------
  913.   # new method: weapon2_icon
  914.   #--------------------------------------------------------------------------
  915.   def weapon2_icon
  916.     return enemy.weapons[1].icon_index if enemy.weapons.compact.size > 1
  917.     return 0
  918.   end
  919.  
  920.   #--------------------------------------------------------------------------
  921.   # new method: guard_icon
  922.   #--------------------------------------------------------------------------
  923.   def guard_icon
  924.     return enemy.shield.icon_index if enemy.shield.icon_index != 0
  925.     return super
  926.   end
  927.  
  928.   #--------------------------------------------------------------------------
  929.   # new method: battler_icon
  930.   #--------------------------------------------------------------------------
  931.   def battler_icon; return enemy.enemy_icon; end
  932.  
  933.   #--------------------------------------------------------------------------
  934.   # new method: mirror?
  935.   #--------------------------------------------------------------------------
  936.   def mirror?
  937.     return false unless $scene.is_a?(Scene_Battle)
  938.     case $scene.view_type
  939.     when 0; return enemy.view_mirror[:empty]
  940.     when 1; return enemy.view_mirror[:front]
  941.     when 2; return enemy.view_mirror[:side]
  942.     when 3; return enemy.view_mirror[:angle]
  943.     end
  944.     return false
  945.   end
  946.  
  947.   #--------------------------------------------------------------------------
  948.   # new method: zoom
  949.   #--------------------------------------------------------------------------
  950.   def zoom
  951.     return false unless $scene.is_a?(Scene_Battle)
  952.     case $scene.view_type
  953.     when 0; return enemy.view_zoom[:empty]
  954.     when 1; return enemy.view_zoom[:front]
  955.     when 2; return enemy.view_zoom[:side]
  956.     when 3; return enemy.view_zoom[:angle]
  957.     end
  958.     return false
  959.   end
  960.  
  961.   #--------------------------------------------------------------------------
  962.   # use_battler_animations?
  963.   #--------------------------------------------------------------------------
  964.   def use_battler_animations?
  965.     return enemy.animation_stance.include?("IDLE")
  966.   end
  967.  
  968.   #--------------------------------------------------------------------------
  969.   # battler_animation_stance
  970.   #--------------------------------------------------------------------------
  971.   def battler_animation_stance(string)
  972.     return unless enemy.animation_stance.include?(string)
  973.     @battler_animation_id = enemy.animation_stance[string]
  974.   end
  975.  
  976.   #--------------------------------------------------------------------------
  977.   # new method: sprite_movable?
  978.   #--------------------------------------------------------------------------
  979.   def sprite_movable?
  980.     return false if enemy.unmoving
  981.     return super
  982.   end
  983.  
  984.   #--------------------------------------------------------------------------
  985.   # new method: weapons
  986.   #--------------------------------------------------------------------------
  987.   def weapons; return enemy.weapons; end
  988.  
  989.   #--------------------------------------------------------------------------
  990.   # new method: armor1_id
  991.   #--------------------------------------------------------------------------
  992.   def armor1_id; return enemy.shield == nil ? 0 : enemy.shield.id; end
  993.  
  994. end # Game_Enemy
  995.  
  996. #===============================================================================
  997. # Game_Troop
  998. #===============================================================================
  999.  
  1000. class Game_Troop < Game_Unit
  1001.  
  1002.   #--------------------------------------------------------------------------
  1003.   # overwrite method: setup
  1004.   #--------------------------------------------------------------------------
  1005.   def setup(troop_id)
  1006.     clear
  1007.     @troop_id = troop_id
  1008.     @enemies = []
  1009.     case $game_variables[YEM::BATTLE_ENGINE::VIEW_TYPE_VARIABLE]
  1010.     when 1; type = :front
  1011.     when 2; type = :side
  1012.     when 3; type = :angle
  1013.     else    type = :empty
  1014.     end
  1015.     offsets = YEM::BATTLE_ENGINE::AUTO_POSITION_ADJUSTMENTS[type]
  1016.     offsets = [0,0,1.0,0.0,0.0,1.0] if !YEM::BATTLE_ENGINE::AUTO_ENEMY_POSITIONS
  1017.     for member in troop.members
  1018.       next if $data_enemies[member.enemy_id] == nil
  1019.       enemy = Game_Enemy.new(@enemies.size, member.enemy_id)
  1020.       enemy.hidden = member.hidden
  1021.       enemy.immortal = member.immortal
  1022.       #---
  1023.       result_x = (member.x * offsets[2]) + (member.y * offsets[4])
  1024.       result_x += offsets[0] # Offset X
  1025.       #---
  1026.       result_y = (member.x * offsets[3]) + (member.y * offsets[5])
  1027.       result_y += offsets[1] # Offset Y
  1028.       #---
  1029.       enemy.screen_x = Integer(result_x)
  1030.       enemy.screen_y = Integer(result_y)
  1031.       enemy.origin_x = enemy.screen_x
  1032.       enemy.origin_y = enemy.screen_y
  1033.       @enemies.push(enemy)
  1034.     end
  1035.     make_unique_names
  1036.   end
  1037.  
  1038. end # Game_Troop
  1039.  
  1040. #===============================================================================
  1041. # Game_Map
  1042. #===============================================================================
  1043.  
  1044. class Game_Map
  1045.  
  1046.   #--------------------------------------------------------------------------
  1047.   # alias method: loop_horizontal?
  1048.   #--------------------------------------------------------------------------
  1049.   alias loop_horizontal_bem loop_horizontal? unless $@
  1050.   def loop_horizontal?
  1051.     return false if $game_temp.in_battle
  1052.     return loop_horizontal_bem
  1053.   end
  1054.  
  1055.   #--------------------------------------------------------------------------
  1056.   # alias method: loop_vertical?
  1057.   #--------------------------------------------------------------------------
  1058.   alias loop_vertical_bem loop_vertical? unless $@
  1059.   def loop_vertical?
  1060.     return false if $game_temp.in_battle
  1061.     return loop_vertical_bem
  1062.   end
  1063.  
  1064. end # Game_Map
  1065.  
  1066. #===============================================================================
  1067. # Game_Character
  1068. #===============================================================================
  1069.  
  1070. class Game_Character
  1071.  
  1072.   #--------------------------------------------------------------------------
  1073.   # public instance variables
  1074.   #--------------------------------------------------------------------------
  1075.   attr_accessor :mirror
  1076.   attr_accessor :opacity
  1077.   attr_accessor :origin_x
  1078.   attr_accessor :origin_y
  1079.   attr_accessor :step_anime
  1080.  
  1081.   #--------------------------------------------------------------------------
  1082.   # alias method: screen_x
  1083.   #--------------------------------------------------------------------------
  1084.   alias screen_x_character_bem screen_x unless $@
  1085.   def screen_x
  1086.     return @battle_screen_x if @battle_screen_x != nil
  1087.     return screen_x_character_bem
  1088.   end
  1089.  
  1090.   #--------------------------------------------------------------------------
  1091.   # new method: screen_x=
  1092.   #--------------------------------------------------------------------------
  1093.   def screen_x=(value); @battle_screen_x = value; end
  1094.  
  1095.   #--------------------------------------------------------------------------
  1096.   # alias method: screen_y
  1097.   #--------------------------------------------------------------------------
  1098.   alias screen_y_character_bem screen_y unless $@
  1099.   def screen_y
  1100.     return @battle_screen_y if @battle_screen_y != nil
  1101.     return screen_y_character_bem
  1102.   end
  1103.  
  1104.   #--------------------------------------------------------------------------
  1105.   # new method: screen_y=
  1106.   #--------------------------------------------------------------------------
  1107.   def screen_y=(value); @battle_screen_y = value; end
  1108.  
  1109.   #--------------------------------------------------------------------------
  1110.   # alias method: screen_z
  1111.   #--------------------------------------------------------------------------
  1112.   alias screen_z_character_bem screen_z unless $@
  1113.   def screen_z
  1114.     return @battle_screen_z if @battle_screen_z != nil
  1115.     return screen_z_character_bem
  1116.   end
  1117.  
  1118.   #--------------------------------------------------------------------------
  1119.   # new method: screen_z=
  1120.   #--------------------------------------------------------------------------
  1121.   def screen_z=(value); @battle_screen_z = value; end
  1122.  
  1123. end # Game_Character
  1124.  
  1125. #===============================================================================
  1126. # Sprite_Base
  1127. #===============================================================================
  1128.  
  1129. class Sprite_Base < Sprite
  1130.  
  1131.   #--------------------------------------------------------------------------
  1132.   # constants
  1133.   #--------------------------------------------------------------------------
  1134.   RATE = $imported["CoreFixesUpgradesMelody"] ? YEM::FIXES::ANIMATION_RATE : 4
  1135.   @@sub_animations = []
  1136.  
  1137.   #--------------------------------------------------------------------------
  1138.   # alias method: initialize
  1139.   #--------------------------------------------------------------------------
  1140.   alias initialize_sprite_base_bem initialize unless $@
  1141.   def initialize(viewport = nil)
  1142.     initialize_sprite_base_bem(viewport)
  1143.     @no_effect = false
  1144.     @banimation_duration = 0
  1145.     @sub_animation_duration = 0
  1146.   end
  1147.  
  1148.   #--------------------------------------------------------------------------
  1149.   # alias method: dispose
  1150.   #--------------------------------------------------------------------------
  1151.   alias dispose_sprite_base_bem dispose unless $@
  1152.   def dispose
  1153.     dispose_sprite_base_bem
  1154.     dispose_sub_animation
  1155.   end
  1156.  
  1157.   #--------------------------------------------------------------------------
  1158.   # alias method: update
  1159.   #--------------------------------------------------------------------------
  1160.   alias update_sprite_base_bem update unless $@
  1161.   def update
  1162.     update_sprite_base_bem
  1163.     update_sub_animation if @sub_animation != nil
  1164.     @@sub_animations.clear
  1165.   end
  1166.  
  1167.   #--------------------------------------------------------------------------
  1168.   # alias method: start_animation
  1169.   #--------------------------------------------------------------------------
  1170.   alias start_animation_bem start_animation unless $@
  1171.   def start_animation(animation, mirror = false)
  1172.     @no_effect = false
  1173.     start_animation_bem(animation, mirror)
  1174.   end
  1175.  
  1176.   #--------------------------------------------------------------------------
  1177.   # new method: start_pseudo_ani
  1178.   #--------------------------------------------------------------------------
  1179.   def start_pseudo_ani(animation, mirror = false)
  1180.     dispose_animation
  1181.     @animation = animation
  1182.     return if @animation == nil
  1183.     @no_effect = true
  1184.     @animation_mirror = mirror
  1185.     @animation_duration = @animation.frame_max * RATE + 1
  1186.     @animation_sprites = []
  1187.   end
  1188.  
  1189.   #--------------------------------------------------------------------------
  1190.   # overwrite method: animation_process_timing
  1191.   #--------------------------------------------------------------------------
  1192.   def animation_process_timing(timing)
  1193.     timing.se.play unless @no_effect
  1194.     case timing.flash_scope
  1195.     when 1
  1196.       if @battler_animation == nil
  1197.         self.flash(timing.flash_color, timing.flash_duration * RATE)
  1198.       end
  1199.       battler_animation_flash(timing) if @battler_animation != nil
  1200.     when 2
  1201.       return if @no_effect
  1202.       if viewport != nil
  1203.         viewport.flash(timing.flash_color, timing.flash_duration * RATE)
  1204.       end
  1205.     when 3
  1206.       self.flash(nil, timing.flash_duration * RATE)
  1207.       battler_animation_flash(timing) if @battler_animation != nil
  1208.     end
  1209.   end
  1210.  
  1211.   #--------------------------------------------------------------------------
  1212.   # new method: start_sub_animation
  1213.   #--------------------------------------------------------------------------
  1214.   def start_sub_animation(animation, mirror = false)
  1215.     dispose_sub_animation
  1216.     @sub_animation = animation
  1217.     return if @sub_animation == nil
  1218.     @sub_animation_mirror = mirror
  1219.     @sub_animation_duration = @sub_animation.frame_max * RATE + 1
  1220.     load_sub_animation_bitmap
  1221.     @sub_animation_sprites = []
  1222.     if @sub_animation.position != 3 or not @@sub_animations.include?(animation)
  1223.       if @use_sprite
  1224.         for i in 0..15
  1225.           sprite = ::Sprite.new(self.viewport)
  1226.           sprite.visible = false
  1227.           @sub_animation_sprites.push(sprite)
  1228.         end
  1229.         unless @@sub_animations.include?(animation)
  1230.           @@sub_animations.push(animation)
  1231.         end
  1232.       end
  1233.     end
  1234.     if @sub_animation.position == 3
  1235.       if viewport == nil
  1236.         @sub_animation_ox = Graphics.width / 2
  1237.         @sub_animation_oy = Graphics.height / 2
  1238.       else
  1239.         @sub_animation_ox = viewport.rect.width / 2
  1240.         @sub_animation_oy = viewport.rect.height / 2
  1241.       end
  1242.     else
  1243.       @sub_animation_ox = x - ox + width / 2
  1244.       @sub_animation_oy = y - oy + height / 2
  1245.       if @sub_animation.position == 0
  1246.         @sub_animation_oy -= height / 2
  1247.       elsif @sub_animation.position == 2
  1248.         @sub_animation_oy += height / 2
  1249.       end
  1250.     end
  1251.   end
  1252.  
  1253.   #--------------------------------------------------------------------------
  1254.   # new method: load_sub_animation_bitmap
  1255.   #--------------------------------------------------------------------------
  1256.   def load_sub_animation_bitmap
  1257.     animation1_name = @sub_animation.animation1_name
  1258.     animation1_hue = @sub_animation.animation1_hue
  1259.     animation2_name = @sub_animation.animation2_name
  1260.     animation2_hue = @sub_animation.animation2_hue
  1261.     @sub_animation_bitmap1 = Cache.animation(animation1_name, animation1_hue)
  1262.     @sub_animation_bitmap2 = Cache.animation(animation2_name, animation2_hue)
  1263.     if @@_reference_count.include?(@sub_animation_bitmap1)
  1264.       @@_reference_count[@sub_animation_bitmap1] += 1
  1265.     else
  1266.       @@_reference_count[@sub_animation_bitmap1] = 1
  1267.     end
  1268.     if @@_reference_count.include?(@sub_animation_bitmap2)
  1269.       @@_reference_count[@sub_animation_bitmap2] += 1
  1270.     else
  1271.       @@_reference_count[@sub_animation_bitmap2] = 1
  1272.     end
  1273.     Graphics.frame_reset
  1274.   end
  1275.  
  1276.   #--------------------------------------------------------------------------
  1277.   # new method: dispose_sub_animation
  1278.   #--------------------------------------------------------------------------
  1279.   def dispose_sub_animation
  1280.     if @sub_animation_bitmap1 != nil
  1281.       @@_reference_count[@sub_animation_bitmap1] -= 1
  1282.       if @@_reference_count[@sub_animation_bitmap1] == 0
  1283.         @sub_animation_bitmap1.dispose
  1284.       end
  1285.     end
  1286.     if @sub_animation_bitmap2 != nil
  1287.       @@_reference_count[@sub_animation_bitmap2] -= 1
  1288.       if @@_reference_count[@sub_animation_bitmap2] == 0
  1289.         @sub_animation_bitmap2.dispose
  1290.       end
  1291.     end
  1292.     if @sub_animation_sprites != nil
  1293.       for sprite in @sub_animation_sprites
  1294.         sprite.dispose
  1295.       end
  1296.       @sub_animation_sprites = nil
  1297.       @sub_animation = nil
  1298.     end
  1299.     @sub_animation_bitmap1 = nil
  1300.     @sub_animation_bitmap2 = nil
  1301.   end
  1302.  
  1303.   #--------------------------------------------------------------------------
  1304.   # new method: update_sub_animation
  1305.   #--------------------------------------------------------------------------
  1306.   def update_sub_animation
  1307.     @sub_animation_duration -= 1
  1308.     return unless @sub_animation_duration % RATE == 0
  1309.     if @sub_animation_duration > 0
  1310.       frame_index = @sub_animation.frame_max
  1311.       frame_index -= (@sub_animation_duration+RATE-1)/RATE
  1312.       sub_animation_set_sprites(@sub_animation.frames[frame_index])
  1313.       for timing in @sub_animation.timings
  1314.         next unless timing.frame == frame_index
  1315.         animation_process_timing(timing)
  1316.       end
  1317.       return
  1318.     end
  1319.     dispose_sub_animation
  1320.   end
  1321.  
  1322.   #--------------------------------------------------------------------------
  1323.   # new method: sub_animation_set_sprites
  1324.   #--------------------------------------------------------------------------
  1325.   def sub_animation_set_sprites(frame)
  1326.     cell_data = frame.cell_data
  1327.     for i in 0..15
  1328.       sprite = @sub_animation_sprites[i]
  1329.       next if sprite == nil
  1330.       pattern = cell_data[i, 0]
  1331.       if pattern == nil or pattern == -1
  1332.         sprite.visible = false
  1333.         next
  1334.       end
  1335.       if pattern < 100
  1336.         sprite.bitmap = @sub_animation_bitmap1
  1337.       else
  1338.         sprite.bitmap = @sub_animation_bitmap2
  1339.       end
  1340.       sprite.visible = true
  1341.       sprite.src_rect.set(pattern % 5 * 192,
  1342.         pattern % 100 / 5 * 192, 192, 192)
  1343.       if @sub_animation_mirror
  1344.         sprite.x = @sub_animation_ox - cell_data[i, 1]
  1345.         sprite.y = @sub_animation_oy + cell_data[i, 2]
  1346.         sprite.angle = (360 - cell_data[i, 4])
  1347.         sprite.mirror = (cell_data[i, 5] == 0)
  1348.       else
  1349.         sprite.x = @sub_animation_ox + cell_data[i, 1]
  1350.         sprite.y = @sub_animation_oy + cell_data[i, 2]
  1351.         sprite.angle = cell_data[i, 4]
  1352.         sprite.mirror = (cell_data[i, 5] == 1)
  1353.       end
  1354.       sprite.z = self.z + 250 + i
  1355.       sprite.ox = 96
  1356.       sprite.oy = 96
  1357.       sprite.zoom_x = cell_data[i, 3] / 100.0
  1358.       sprite.zoom_y = cell_data[i, 3] / 100.0
  1359.       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  1360.       sprite.blend_type = cell_data[i, 7]
  1361.     end
  1362.   end
  1363.  
  1364. end # Sprite_Base
  1365.  
  1366. #===============================================================================
  1367. # Sprite_Battler
  1368. #===============================================================================
  1369.  
  1370. class Sprite_Battler < Sprite_Base
  1371.  
  1372.   #--------------------------------------------------------------------------
  1373.   # constants
  1374.   #--------------------------------------------------------------------------
  1375.   RATE = $imported["CoreFixesUpgradesMelody"] ? YEM::FIXES::ANIMATION_RATE : 4
  1376.   @@battler_animations = []
  1377.   @@state_animations = []
  1378.  
  1379.   #--------------------------------------------------------------------------
  1380.   # public instance variables
  1381.   #--------------------------------------------------------------------------
  1382.   attr_accessor :character_death_duration
  1383.   attr_accessor :character_sprite
  1384.   attr_accessor :icon_weapon1
  1385.   attr_accessor :icon_weapon2
  1386.   attr_accessor :icon_sprites
  1387.   attr_accessor :icon_shield
  1388.   attr_accessor :icon_item
  1389.   attr_accessor :icon_last
  1390.   attr_accessor :jump_duration
  1391.   attr_accessor :move_to_x
  1392.   attr_accessor :move_to_y
  1393.   attr_accessor :popups
  1394.  
  1395.   #--------------------------------------------------------------------------
  1396.   # alias method: initialize
  1397.   #--------------------------------------------------------------------------
  1398.   alias initialize_sprite_battler_bem initialize unless $@
  1399.   def initialize(viewport, battler = nil)
  1400.     initialize_sprite_battler_bem(viewport, battler)
  1401.     @popups = []
  1402.     @popup_flags = []
  1403.     @state_animation_duration = 0
  1404.     return if @battler == nil
  1405.     self.mirror = @battler.mirror?
  1406.     self.zoom_x = @battler.zoom
  1407.     self.zoom_y = @battler.zoom
  1408.   end
  1409.  
  1410.   #--------------------------------------------------------------------------
  1411.   # alias method: dispose
  1412.   #--------------------------------------------------------------------------
  1413.   alias dispose_sprite_battler_bem dispose
  1414.   def dispose
  1415.     @character_sprite.dispose if @character_sprite != nil
  1416.     dispose_popups
  1417.     dispose_sprite_battler_bem
  1418.     dispose_state_animation
  1419.     dispose_battler_animation
  1420.     return if @icon_sprites == nil
  1421.     for icon_sprite in @icon_sprites; icon_sprite.dispose; end
  1422.   end
  1423.  
  1424.   #--------------------------------------------------------------------------
  1425.   # alias method: update
  1426.   #--------------------------------------------------------------------------
  1427.   alias update_sprite_battler_bem update unless $@
  1428.   def update
  1429.     update_sprite_battler_bem
  1430.     update_battler_animation
  1431.     update_state_animation
  1432.     return if @battler == nil
  1433.     update_popups
  1434.     update_jump
  1435.     update_move_to
  1436.     update_character_sprite
  1437.     update_character_death
  1438.     update_icon_sprites
  1439.   end
  1440.  
  1441.   #--------------------------------------------------------------------------
  1442.   # alias method: setup_new_effect
  1443.   #--------------------------------------------------------------------------
  1444.   alias setup_new_effect_bem setup_new_effect unless $@
  1445.   def setup_new_effect
  1446.     start_character_death if @battler.collapse
  1447.     setup_new_effect_bem unless anti_whiten
  1448.     #---
  1449.     if @battler.vanish_case == 1
  1450.       @battler.vanish_case = nil
  1451.       @effect_type = DISAPPEAR
  1452.       @effect_duration = 32
  1453.     elsif @battler.vanish_case == 2
  1454.       @battler.vanish_case = nil
  1455.       @effect_type = APPEAR
  1456.       @effect_duration = 16
  1457.     elsif @battler.vanish_case == 3
  1458.       @battler.vanish_case = nil
  1459.       self.opacity = 0
  1460.       @battler.character.opacity = 0 if @character_sprite != nil
  1461.     elsif @battler.vanish_case == 4
  1462.       @battler.vanish_case = nil
  1463.       self.opacity = 255
  1464.       @battler.character.opacity = 255 if @character_sprite != nil
  1465.     end
  1466.     #---
  1467.     if @battler.popup_array != [] and @battler.popup_array != nil
  1468.       array = @battler.popup_array.shift
  1469.       create_popup(array[0], array[1], array[2])
  1470.     end
  1471.     #---
  1472.     if @battler.pseudo_ani_id != 0 and @battler.pseudo_ani_id != nil
  1473.       animation = $data_animations[@battler.pseudo_ani_id]
  1474.       start_pseudo_ani(animation)
  1475.       @battler.pseudo_ani_id = 0
  1476.     end
  1477.     #---
  1478.     if @battler.state_animation_id != nil
  1479.       if @battler.state_animation_id == 0
  1480.         dispose_state_animation
  1481.       else
  1482.         start_state_animation($data_animations[@battler.state_animation_id])
  1483.       end
  1484.     end
  1485.     #---
  1486.     if @battler.battler_animation_id != nil
  1487.       start_battler_animation($data_animations[@battler.battler_animation_id])
  1488.     end
  1489.     #---
  1490.     if @battler.sub_animation_id != nil
  1491.       start_sub_animation($data_animations[@battler.sub_animation_id])
  1492.       @battler.sub_animation_id = nil
  1493.     end
  1494.   end
  1495.  
  1496.   #--------------------------------------------------------------------------
  1497.   # alias method: update_appear
  1498.   #--------------------------------------------------------------------------
  1499.   alias update_appear_bem update_appear unless $@
  1500.   def update_appear
  1501.     update_appear_bem
  1502.     return if @character_sprite == nil
  1503.     @battler.character.opacity = (16 - @effect_duration) * 16
  1504.   end
  1505.  
  1506.   #--------------------------------------------------------------------------
  1507.   # alias method: update_disappear
  1508.   #--------------------------------------------------------------------------
  1509.   alias update_disappear_bem update_disappear unless $@
  1510.   def update_disappear
  1511.     update_disappear_bem
  1512.     return if @character_sprite == nil
  1513.     @battler.character.opacity = 256 - (32 - @effect_duration) * 10
  1514.   end
  1515.  
  1516.   #--------------------------------------------------------------------------
  1517.   # alias method: update_collapse
  1518.   #--------------------------------------------------------------------------
  1519.   alias update_collapse_bem update_collapse unless $@
  1520.   def update_collapse
  1521.     if @battler.actor?
  1522.       @effect_duration = 0
  1523.       return
  1524.     end
  1525.     update_collapse_bem
  1526.   end
  1527.  
  1528.   #--------------------------------------------------------------------------
  1529.   # new method: anti_whiten
  1530.   #--------------------------------------------------------------------------
  1531.   def anti_whiten
  1532.     if @battler.white_flash and @battler.state?(1)
  1533.       if @battler.collapse
  1534.         @effect_type = COLLAPSE
  1535.         @effect_duration = 48
  1536.         @battler.collapse = false
  1537.         @battler_visible = false
  1538.       end
  1539.       return true
  1540.     end
  1541.     return false
  1542.   end
  1543.  
  1544.   #--------------------------------------------------------------------------
  1545.   # new method: start_animation
  1546.   #--------------------------------------------------------------------------
  1547.   def start_animation(animation, mirror = false)
  1548.     if @character_sprite != nil
  1549.       @character_sprite.start_animation(animation, mirror)
  1550.       return
  1551.     end
  1552.     super(animation, mirror)
  1553.   end
  1554.  
  1555.   #--------------------------------------------------------------------------
  1556.   # new method: start_pseudo_ani
  1557.   #--------------------------------------------------------------------------
  1558.   def start_pseudo_ani(animation, mirror = false)
  1559.     if @character_sprite != nil
  1560.       @character_sprite.start_pseudo_ani(animation, mirror)
  1561.       return
  1562.     end
  1563.     super(animation, mirror)
  1564.   end
  1565.  
  1566.   #--------------------------------------------------------------------------
  1567.   # new method: start_state_animation
  1568.   #--------------------------------------------------------------------------
  1569.   def start_state_animation(animation)
  1570.     return if @state_animation != nil and @state_animation.id == animation.id
  1571.     dispose_state_animation
  1572.     @state_animation = animation
  1573.     return if @state_animation == nil
  1574.     @state_frame_index = 0
  1575.     @state_animation_mirror = false
  1576.     @state_animation_duration = @state_animation.frame_max * RATE + 1
  1577.     load_state_animation_bitmap
  1578.     @state_animation_sprites = []
  1579.     if @state_animation.position != 3 or !@@state_animations.include?(animation)
  1580.       if @use_sprite
  1581.         for i in 0..15
  1582.           sprite = ::Sprite.new(self.viewport)
  1583.           sprite.visible = false
  1584.           @state_animation_sprites.push(sprite)
  1585.         end
  1586.         unless @@state_animations.include?(animation)
  1587.           @@state_animations.push(animation)
  1588.         end
  1589.       end
  1590.     end
  1591.     if @state_animation.position == 3
  1592.       if viewport == nil
  1593.         @state_animation_ox = Graphics.width / 2
  1594.         @state_animation_oy = Graphics.width / 2
  1595.       else
  1596.         @state_animation_ox = viewport.rect.width / 2
  1597.         @state_animation_oy = viewport.rect.height / 2
  1598.       end
  1599.     else
  1600.       @state_animation_ox = x - ox + width / 2
  1601.       @state_animation_oy = y - oy + height / 2
  1602.       if @state_animation.position == 0
  1603.         @state_animation_oy -= height / 2
  1604.       elsif @state_animation.position == 2
  1605.         @state_animation_oy += height / 2
  1606.       end
  1607.     end
  1608.   end
  1609.  
  1610.   #--------------------------------------------------------------------------
  1611.   # new method: load_state_animation_bitmap
  1612.   #--------------------------------------------------------------------------
  1613.   def load_state_animation_bitmap
  1614.     animation1_name = @state_animation.animation1_name
  1615.     animation1_hue = @state_animation.animation1_hue
  1616.     animation2_name = @state_animation.animation2_name
  1617.     animation2_hue = @state_animation.animation2_hue
  1618.     @state_animation_bitmap1 = Cache.animation(animation1_name, animation1_hue)
  1619.     @state_animation_bitmap2 = Cache.animation(animation2_name, animation2_hue)
  1620.     if @@_reference_count.include?(@state_animation_bitmap1)
  1621.       @@_reference_count[@state_animation_bitmap1] += 1
  1622.     else
  1623.       @@_reference_count[@state_animation_bitmap1] = 1
  1624.     end
  1625.     if @@_reference_count.include?(@state_animation_bitmap2)
  1626.       @@_reference_count[@state_animation_bitmap2] += 1
  1627.     else
  1628.       @@_reference_count[@state_animation_bitmap2] = 1
  1629.     end
  1630.     Graphics.frame_reset
  1631.   end
  1632.  
  1633.   #--------------------------------------------------------------------------
  1634.   # new method: dispose_state_animation
  1635.   #--------------------------------------------------------------------------
  1636.   def dispose_state_animation
  1637.     if @state_animation_bitmap1 != nil
  1638.       @@_reference_count[@state_animation_bitmap1] -= 1
  1639.       if @@_reference_count[@state_animation_bitmap1] == 0
  1640.         @state_animation_bitmap1.dispose
  1641.       end
  1642.     end
  1643.     if @state_animation_bitmap2 != nil
  1644.       @@_reference_count[@state_animation_bitmap2] -= 1
  1645.       if @@_reference_count[@state_animation_bitmap2] == 0
  1646.         @state_animation_bitmap2.dispose
  1647.       end
  1648.     end
  1649.     if @state_animation_sprites != nil
  1650.       for sprite in @state_animation_sprites
  1651.         sprite.dispose
  1652.       end
  1653.       @state_animation_sprites = nil
  1654.       @state_animation = nil
  1655.     end
  1656.     @state_animation_bitmap1 = nil
  1657.     @state_animation_bitmap2 = nil
  1658.   end
  1659.  
  1660.   #--------------------------------------------------------------------------
  1661.   # new method: update_state_animation
  1662.   #--------------------------------------------------------------------------
  1663.   def update_state_animation
  1664.     return if @state_animation == nil
  1665.     update_state_animation_position
  1666.     @state_animation_duration -= 1
  1667.     unless @state_animation_duration % RATE == 0
  1668.       if @state_animation_duration >= 0
  1669.         @state_frame_index = @state_animation.frame_max
  1670.         @state_frame_index -= (@state_animation_duration + RATE - 1) / RATE
  1671.         for timing in @state_animation.timings
  1672.           next unless timing.frame == @state_frame_index
  1673.           state_animation_process_timing(timing)
  1674.         end
  1675.       else
  1676.         @state_frame_index = 0
  1677.         @state_animation_duration = @state_animation.frame_max * RATE
  1678.       end
  1679.     end
  1680.     return if @state_frame_index == nil
  1681.     state_animation_set_sprites(@state_animation.frames[@state_frame_index])
  1682.   end
  1683.  
  1684.   #--------------------------------------------------------------------------
  1685.   # new method: update_state_animation_position
  1686.   #--------------------------------------------------------------------------
  1687.   def update_state_animation_position
  1688.     if @state_animation.position == 3
  1689.       if viewport == nil
  1690.         @state_animation_ox = Graphics.width / 2
  1691.         @state_animation_oy = Graphics.width / 2
  1692.       else
  1693.         @state_animation_ox = viewport.rect.width / 2
  1694.         @state_animation_oy = viewport.rect.height / 2
  1695.       end
  1696.     else
  1697.       @state_animation_ox = x - ox + width / 2
  1698.       @state_animation_oy = y - oy + height / 2
  1699.       if @state_animation.position == 0
  1700.         @state_animation_oy -= height / 2
  1701.       elsif @state_animation.position == 2
  1702.         @state_animation_oy += height / 2
  1703.       end
  1704.     end
  1705.   end
  1706.  
  1707.   #--------------------------------------------------------------------------
  1708.   # new method: state_animation_set_sprites
  1709.   #--------------------------------------------------------------------------
  1710.   def state_animation_set_sprites(frame)
  1711.     return if @state_animation == nil
  1712.     return if frame == nil
  1713.     cell_data = frame.cell_data
  1714.     for i in 0..15
  1715.       sprite = @state_animation_sprites[i]
  1716.       next if sprite == nil
  1717.       pattern = cell_data[i, 0]
  1718.       if pattern == nil or pattern == -1
  1719.         sprite.visible = false
  1720.         next
  1721.       end
  1722.       if pattern < 100
  1723.         sprite.bitmap = @state_animation_bitmap1
  1724.       else
  1725.         sprite.bitmap = @state_animation_bitmap2
  1726.       end
  1727.       sprite.visible = true
  1728.       sprite.src_rect.set(pattern % 5 * 192,
  1729.       #---
  1730.       pattern % 100 / 5 * 192, 192, 192)
  1731.       sprite.x = @state_animation_ox + cell_data[i, 1]
  1732.       sprite.y = @state_animation_oy + cell_data[i, 2]
  1733.       sprite.angle = cell_data[i, 4]
  1734.       sprite.mirror = (cell_data[i, 5] == 1)
  1735.       #---
  1736.       sprite.z = self.z + 200 + i
  1737.       sprite.ox = 96
  1738.       sprite.oy = 96
  1739.       sprite.zoom_x = cell_data[i, 3] / 100.0
  1740.       sprite.zoom_y = cell_data[i, 3] / 100.0
  1741.       sprite.zoom_x *= @battler.state_animation_zoom
  1742.       sprite.zoom_x /= 100
  1743.       sprite.zoom_y *= @battler.state_animation_zoom
  1744.       sprite.zoom_y /= 100
  1745.       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  1746.       sprite.blend_type = cell_data[i, 7]
  1747.     end
  1748.   end
  1749.  
  1750.   #--------------------------------------------------------------------------
  1751.   # new method: state_animation_process_timing
  1752.   #--------------------------------------------------------------------------
  1753.   def state_animation_process_timing(timing)
  1754.     timing.se.play
  1755.     case timing.flash_scope
  1756.     when 1
  1757.       if @battler_animation == nil
  1758.         self.flash(timing.flash_color, timing.flash_duration * RATE)
  1759.       end
  1760.       return if @character_sprite == nil
  1761.       @character_sprite.flash(timing.flash_color, timing.flash_duration*RATE)
  1762.     when 2
  1763.       return if viewport == nil
  1764.       viewport.flash(timing.flash_color, timing.flash_duration * RATE)
  1765.     when 3
  1766.       self.flash(nil, timing.flash_duration * RATE)
  1767.       return if @character_sprite == nil
  1768.       @character_sprite.flash(nil, timing.flash_duration * RATE)
  1769.     end
  1770.   end
  1771.  
  1772.   #--------------------------------------------------------------------------
  1773.   # new method: start_battler_animation
  1774.   #--------------------------------------------------------------------------
  1775.   def start_battler_animation(animation)
  1776.     if $scene.is_a?(Scene_Battle) and $scene.emptyview? and @battler.actor?
  1777.       dispose_battler_animation
  1778.       return
  1779.     end
  1780.     return if @battler_animation != nil and
  1781.       @battler_animation.id == animation.id
  1782.     dispose_battler_animation
  1783.     @battler_animation = animation
  1784.     return if @battler_animation == nil
  1785.     @battler_ani_hash = YEM::BATTLE_ENGINE::ANIMATION_BATTLER_SETTINGS
  1786.     @battler_ani_max_cell = YEM::BATTLE_ENGINE::ANIMATION_BATTLER_MAX_CELLS
  1787.     #---
  1788.     if @battler.actor?
  1789.       @battler_animation_mirror = @battler_ani_hash[:mirror_actor]
  1790.     else
  1791.       @battler_animation_mirror = @battler_ani_hash[:mirror_enemy]
  1792.     end
  1793.     #---
  1794.     @battler_animation_duration = @battler_animation.frame_max * RATE + 1
  1795.     load_battler_animation_bitmap
  1796.     @battler_animation_sprites = []
  1797.     if @battler_animation.position != 3 or
  1798.     !@@battler_animations.include?(animation)
  1799.       if @use_sprite
  1800.         for i in 0..@battler_ani_max_cell
  1801.           sprite = ::Sprite.new(self.viewport)
  1802.           sprite.visible = false
  1803.           @battler_animation_sprites.push(sprite)
  1804.         end
  1805.         unless @@battler_animations.include?(animation)
  1806.           @@battler_animations.push(animation)
  1807.         end
  1808.       end
  1809.     end
  1810.     if @battler_animation.position == 3
  1811.       if viewport == nil
  1812.         @battler_animation_ox = Graphics.width / 2
  1813.         @battler_animation_oy = Graphics.height / 2
  1814.       else
  1815.         @battler_animation_ox = viewport.rect.width / 2
  1816.         @battler_animation_oy = viewport.rect.height / 2
  1817.       end
  1818.     else
  1819.       @battler_animation_ox = x - ox + width/2
  1820.       @battler_animation_oy = y - oy + height/2
  1821.       if @battler_animation.position == 0
  1822.         @battler_animation_oy -= height / 2
  1823.       elsif @battler_animation.position == 2
  1824.         @battler_animation_oy += height / 2
  1825.       end
  1826.     end
  1827.     @battler_frame_index = 0
  1828.   end
  1829.  
  1830.   #--------------------------------------------------------------------------
  1831.   # new method: load_battler_animation_bitmap
  1832.   #--------------------------------------------------------------------------
  1833.   def load_battler_animation_bitmap
  1834.     animation1_name = @battler_animation.animation1_name
  1835.     animation1_hue = @battler_animation.animation1_hue
  1836.     animation1_hue += @battler.enemy.animation_hue if @battler.enemy?
  1837.     animation2_name = @battler_animation.animation2_name
  1838.     animation2_hue = @battler_animation.animation2_hue
  1839.     animation2_hue += @battler.enemy.animation_hue if @battler.enemy?
  1840.     @battler_animation_bitmap1 = Cache.animation(animation1_name,animation1_hue)
  1841.     @battler_animation_bitmap2 = Cache.animation(animation2_name,animation2_hue)
  1842.     if @@_reference_count.include?(@battler_animation_bitmap1)
  1843.       @@_reference_count[@battler_animation_bitmap1] += 1
  1844.     else
  1845.       @@_reference_count[@battler_animation_bitmap1] = 1
  1846.     end
  1847.     if @@_reference_count.include?(@battler_animation_bitmap2)
  1848.       @@_reference_count[@battler_animation_bitmap2] += 1
  1849.     else
  1850.       @@_reference_count[@battler_animation_bitmap2] = 1
  1851.     end
  1852.     Graphics.frame_reset
  1853.   end
  1854.  
  1855.   #--------------------------------------------------------------------------
  1856.   # new method: dispose_battler_animation
  1857.   #--------------------------------------------------------------------------
  1858.   def dispose_battler_animation
  1859.     if @battler_animation_bitmap1 != nil
  1860.       @@_reference_count[@battler_animation_bitmap1] -= 1
  1861.       if @@_reference_count[@battler_animation_bitmap1] == 0
  1862.         @battler_animation_bitmap1.dispose
  1863.       end
  1864.     end
  1865.     if @battler_animation_bitmap2 != nil
  1866.       @@_reference_count[@battler_animation_bitmap2] -= 1
  1867.       if @@_reference_count[@battler_animation_bitmap2] == 0
  1868.         @battler_animation_bitmap2.dispose
  1869.       end
  1870.     end
  1871.     if @battler_animation_sprites != nil
  1872.       for sprite in @battler_animation_sprites
  1873.         sprite.dispose
  1874.       end
  1875.       @battler_animation_sprites = nil
  1876.       @battler_animation = nil
  1877.     end
  1878.     @battler_animation_bitmap1 = nil
  1879.     @battler_animation_bitmap2 = nil
  1880.   end
  1881.  
  1882.   #--------------------------------------------------------------------------
  1883.   # new method: update_battler_animation
  1884.   #--------------------------------------------------------------------------
  1885.   def update_battler_animation
  1886.     return if @battler_animation == nil
  1887.     update_battler_animation_position
  1888.     @battler_animation_duration -= 1
  1889.     unless @battler_animation_duration % RATE == 0
  1890.       if @battler_animation_duration >= 0
  1891.         @battler_frame_index = @battler_animation.frame_max
  1892.         @battler_frame_index -= (@battler_animation_duration + RATE - 1) / RATE
  1893.         for timing in @battler_animation.timings
  1894.           next unless timing.frame == @battler_frame_index
  1895.           battler_animation_process_timing(timing)
  1896.         end
  1897.       elsif @battler_animation.battler_looping
  1898.         @battler_frame_index = 0
  1899.         @battler_animation_duration = @battler_animation.frame_max * RATE
  1900.       end
  1901.     end
  1902.     return if @battler_frame_index == nil
  1903.     frame = @battler_animation.frames[@battler_frame_index]
  1904.     battler_animation_set_sprites(frame)
  1905.   end
  1906.  
  1907.   #--------------------------------------------------------------------------
  1908.   # new method: update_battler_animation_position
  1909.   #--------------------------------------------------------------------------
  1910.   def update_battler_animation_position
  1911.     if @battler_animation.position == 3
  1912.       if viewport == nil
  1913.         @battler_animation_ox = Graphics.width / 2
  1914.         @battler_animation_oy = Graphics.width / 2
  1915.       else
  1916.         @battler_animation_ox = viewport.rect.width / 2
  1917.         @battler_animation_oy = viewport.rect.height / 2
  1918.       end
  1919.     else
  1920.       @battler_animation_ox = x - ox + width/2
  1921.       @battler_animation_oy = y - oy + height/2
  1922.       if @battler_animation.position == 0
  1923.         @battler_animation_oy -= height / 2
  1924.       elsif @battler_animation.position == 2
  1925.         @battler_animation_oy += height / 2
  1926.       end
  1927.     end
  1928.   end
  1929.  
  1930.   #--------------------------------------------------------------------------
  1931.   # new method: battler_animation_set_sprites
  1932.   #--------------------------------------------------------------------------
  1933.   def battler_animation_set_sprites(frame)
  1934.     return if @battler_animation == nil
  1935.     return if frame == nil
  1936.     cell_data = frame.cell_data
  1937.     for i in 0..@battler_ani_max_cell
  1938.       sprite = @battler_animation_sprites[i]
  1939.       next if sprite == nil
  1940.       pattern = cell_data[i, 0]
  1941.       if pattern == nil or pattern == -1
  1942.         sprite.visible = false
  1943.         next
  1944.       end
  1945.       if pattern < 100
  1946.         sprite.bitmap = @battler_animation_bitmap1
  1947.       else
  1948.         sprite.bitmap = @battler_animation_bitmap2
  1949.       end
  1950.       sprite.visible = true
  1951.       sprite.src_rect.set(pattern % 5 * 192,
  1952.         pattern % 100 / 5 * 192, 192, 192)
  1953.       if @battler_animation_mirror
  1954.         sprite.x = @battler_animation_ox - cell_data[i, 1]
  1955.         sprite.y = @battler_animation_oy + cell_data[i, 2]
  1956.         sprite.angle = (360 - cell_data[i, 4])
  1957.         sprite.mirror = (cell_data[i, 5] == 0)
  1958.       else
  1959.         sprite.x = @battler_animation_ox + cell_data[i, 1]
  1960.         sprite.y = @battler_animation_oy + cell_data[i, 2]
  1961.         sprite.angle = cell_data[i, 4]
  1962.         sprite.mirror = (cell_data[i, 5] == 1)
  1963.       end
  1964.       sprite.z = self.z + 50 + i
  1965.       sprite.ox = 96
  1966.       sprite.oy = 96
  1967.       sprite.zoom_x = cell_data[i, 3] / 100.0
  1968.       sprite.zoom_y = cell_data[i, 3] / 100.0
  1969.       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  1970.       sprite.blend_type = cell_data[i, 7]
  1971.       #---
  1972.       sprite.color = self.color
  1973.       sprite.visible = self.visible
  1974.       sprite.update
  1975.     end
  1976.     self.flash(nil, 60 * RATE)
  1977.     return if @character_sprite == nil
  1978.     @character_sprite.flash(nil, 60 * RATE)
  1979.   end
  1980.  
  1981.   #--------------------------------------------------------------------------
  1982.   # new method: battler_animation_process_timing
  1983.   #--------------------------------------------------------------------------
  1984.   def battler_animation_process_timing(timing)
  1985.     timing.se.play if @battler_ani_hash[:allow_sound]
  1986.     case timing.flash_scope
  1987.     when 1
  1988.       if @battler_animation == nil
  1989.         self.flash(timing.flash_color, timing.flash_duration * RATE)
  1990.       end
  1991.       battler_animation_flash(timing)
  1992.     when 2
  1993.       return if viewport == nil
  1994.       return unless @battler_ani_hash[:allow_flash]
  1995.       viewport.flash(timing.flash_color, timing.flash_duration * RATE)
  1996.     end
  1997.   end
  1998.  
  1999.   #--------------------------------------------------------------------------
  2000.   # new method: battler_animation_flash
  2001.   #--------------------------------------------------------------------------
  2002.   def battler_animation_flash(timing)
  2003.     frame = @battler_animation.frames[@battler_frame_index]
  2004.     return if @battler_animation == nil
  2005.     return if frame == nil
  2006.     cell_data = frame.cell_data
  2007.     colour = (timing.flash_scope == 1) ? timing.flash_color : nil
  2008.     for i in 0..@battler_ani_max_cell
  2009.       sprite = @battler_animation_sprites[i]
  2010.       next if sprite == nil
  2011.       sprite.flash(colour, timing.flash_duration * RATE)
  2012.     end
  2013.   end
  2014.  
  2015.   #--------------------------------------------------------------------------
  2016.   # new method: create_popup
  2017.   #--------------------------------------------------------------------------
  2018.   def create_popup(value, rules, flags)
  2019.     return if @battler == nil
  2020.     return if flags & @popup_flags != []
  2021.     array = YEM::BATTLE_ENGINE::POPUP_RULES[rules]
  2022.     for popup in @popups
  2023.       popup.y -= array[2]*9/11
  2024.     end
  2025.     #---
  2026.     view = $scene.spriteset.viewportB
  2027.     new_popup = Sprite_Popup.new(view, @battler, value, rules, flags)
  2028.     @popups.push(new_popup)
  2029.     @popup_flags.push("weakness") if flags.include?("weakness")
  2030.     @popup_flags.push("resistant") if flags.include?("resistant")
  2031.     @popup_flags.push("immune") if flags.include?("immune")
  2032.     @popup_flags.push("absorbed") if flags.include?("absorbed")
  2033.   end
  2034.  
  2035.   #--------------------------------------------------------------------------
  2036.   # new method: dispose_popups
  2037.   #--------------------------------------------------------------------------
  2038.   def dispose_popups
  2039.     for popup in @popups
  2040.       @popups.delete(popup)
  2041.       popup.dispose
  2042.       popup = nil
  2043.     end
  2044.   end
  2045.  
  2046.   #--------------------------------------------------------------------------
  2047.   # new method: update_popups
  2048.   #--------------------------------------------------------------------------
  2049.   def update_popups
  2050.     @popups = [] if @popups == nil
  2051.     for popup in @popups
  2052.       popup.update
  2053.       next unless popup.opacity <= 0
  2054.       popup.bitmap.dispose
  2055.       popup.dispose
  2056.       @popups.delete(popup)
  2057.       popup = nil
  2058.     end
  2059.     @popup_flags = [] if @popups == [] and @popup_flags != []
  2060.     return unless $scene.is_a?(Scene_Battle)
  2061.     if @current_active_battler != $scene.active_battler
  2062.       @current_active_battler = $scene.active_battler
  2063.       @popup_flags = []
  2064.     end
  2065.   end
  2066.  
  2067.   #--------------------------------------------------------------------------
  2068.   # new method: create_character_dimensions
  2069.   #--------------------------------------------------------------------------
  2070.   def create_character_dimensions
  2071.     return if @character_sprite == nil
  2072.     @width  = YEM::BATTLE_ENGINE::ACTOR_ASPECTS[:width]
  2073.     @height = YEM::BATTLE_ENGINE::ACTOR_ASPECTS[:height]
  2074.     self.ox = @width/2
  2075.     self.oy = @height
  2076.   end
  2077.  
  2078.   #--------------------------------------------------------------------------
  2079.   # new method: update_character_sprite
  2080.   #--------------------------------------------------------------------------
  2081.   def update_character_sprite
  2082.     return if @character_sprite == nil
  2083.     if @battler.character.character_name != @battler.character_name or
  2084.     @battler.character.character_index != @battler.character_index
  2085.       char_name = @battler.character_name
  2086.       char_index = @battler.character_index
  2087.       @battler.character.set_graphic(char_name, char_index)
  2088.     end
  2089.     @character_sprite.update
  2090.     @character_sprite.z = self.z
  2091.   end
  2092.  
  2093.   #--------------------------------------------------------------------------
  2094.   # new method: create_move_to
  2095.   #--------------------------------------------------------------------------
  2096.   def create_move_to(destination_x, destination_y, total_frames = 60)
  2097.     return unless @battler.sprite_movable?
  2098.     den = [total_frames, 1].max
  2099.     if destination_x != nil
  2100.       @move_to_x = Integer(destination_x)
  2101.       @move_rate_x = [(@battler.screen_x - @move_to_x).abs/den, 2].max
  2102.     end
  2103.     if destination_y != nil
  2104.       @move_to_y = Integer(destination_y)
  2105.       @move_rate_y = [(@battler.screen_y - @move_to_y).abs/den, 2].max
  2106.     end
  2107.     return if @character_sprite == nil
  2108.   end
  2109.  
  2110.   #--------------------------------------------------------------------------
  2111.   # new method: update_move_to
  2112.   #--------------------------------------------------------------------------
  2113.   def update_move_to
  2114.     if @move_to_x != nil
  2115.       value = [(@battler.screen_x - @move_to_x).abs, @move_rate_x].min
  2116.       @battler.screen_x += (@move_to_x > @battler.screen_x) ? value : -value
  2117.       @move_to_x = nil if @battler.screen_x == @move_to_x
  2118.     end
  2119.     if @move_to_y != nil
  2120.       value = [(@battler.screen_y - @move_to_y).abs, @move_rate_y].min
  2121.       @battler.screen_y += (@move_to_y > @battler.screen_y) ? value : -value
  2122.       @move_to_y = nil if @battler.screen_y == @move_to_y
  2123.     end
  2124.   end
  2125.  
  2126.   #--------------------------------------------------------------------------
  2127.   # new method: face_coordinate
  2128.   #--------------------------------------------------------------------------
  2129.   def face_coordinate(destination_x, destination_y)
  2130.     if @character_sprite != nil
  2131.       @battler.character.break_pose if $imported["ExtendedMovement"]
  2132.       @battler.character.step_anime = true
  2133.       @battler.character.mirror = false
  2134.     end
  2135.     x1 = Integer(@battler.screen_x)
  2136.     x2 = Integer(destination_x)
  2137.     y1 = Graphics.height - Integer(@battler.screen_y)
  2138.     y2 = Graphics.height - Integer(destination_y)
  2139.     return if x1 == x2 and y1 == y2
  2140.     #---
  2141.     angle = Integer(Math.atan2((y2-y1),(x2-x1)) * 1800 / Math::PI)
  2142.     if (0..225) === angle or (-225..0) === angle
  2143.       direction = 6
  2144.     elsif (226..675) === angle
  2145.       direction = 9
  2146.     elsif (676..1125) === angle
  2147.       direction = 8
  2148.     elsif (1126..1575) === angle
  2149.       direction = 7
  2150.     elsif (1576..1800) === angle or (-1800..-1576) === angle
  2151.       direction = 4
  2152.     elsif (-1575..-1126) === angle
  2153.       direction = 1
  2154.     elsif (-1125..-676) === angle
  2155.       direction = 2
  2156.     elsif (-675..-226) === angle
  2157.       direction = 3
  2158.     end
  2159.     #---
  2160.     @battler.direction = direction if @battler.enemy?
  2161.     if @character_sprite != nil
  2162.       direction = $scene.spriteset.correct_direction(direction)
  2163.       @battler.character.set_direction(direction)
  2164.     end
  2165.   end
  2166.  
  2167.   #--------------------------------------------------------------------------
  2168.   # new method: turn_direction
  2169.   #--------------------------------------------------------------------------
  2170.   def turn_direction(direction, backward = false)
  2171.     return if @character_sprite == nil
  2172.     return unless [1,2,3,4,6,7,8,9].include?(direction)
  2173.     back_hash = {1=>9,2=>8,3=>7,4=>6,6=>4,7=>3,8=>2,9=>1}
  2174.     direction = back_hash[direction] if backward
  2175.     direction = back_hash[direction] if @battler.enemy?
  2176.     direction = $scene.spriteset.correct_direction(direction)
  2177.     @battler.character.break_pose if $imported["ExtendedMovement"]
  2178.     @battler.character.set_direction(direction)
  2179.   end
  2180.  
  2181.   #--------------------------------------------------------------------------
  2182.   # new method: start_character_death
  2183.   #--------------------------------------------------------------------------
  2184.   def start_character_death
  2185.     return if @character_sprite == nil
  2186.     return if @character_death_duration != nil
  2187.     @character_death_duration = 9
  2188.     @battler.character.step_anime = false
  2189.     @battler.character.mirror = false
  2190.     @battler.character.set_direction(4)
  2191.     if @battler.use_battler_animations?
  2192.       @battler.battler_animation_stance("DEAD")
  2193.       return
  2194.     end
  2195.     if $imported["ExtendedMovement"]
  2196.       @battler.character.pose = "fallen"
  2197.       @character_sprite.ox *= 2
  2198.       @character_sprite.angle = -90
  2199.       @character_sprite.update
  2200.     end
  2201.   end
  2202.  
  2203.   #--------------------------------------------------------------------------
  2204.   # new method: update_character_death
  2205.   #--------------------------------------------------------------------------
  2206.   def update_character_death
  2207.     return if @character_death_duration == nil
  2208.     return if @character_sprite == nil
  2209.     return if @character_death_duration == 0
  2210.     @character_sprite.angle += 10
  2211.     @character_death_duration -= 1
  2212.     return unless @character_death_duration == 0
  2213.     if $imported["ExtendedMovement"]
  2214.       @character_sprite.angle = 0
  2215.     else
  2216.       @battler.character.set_direction(8)
  2217.       @character_sprite.angle = 90
  2218.     end
  2219.   end
  2220.  
  2221.   #--------------------------------------------------------------------------
  2222.   # new method: revive_character_death
  2223.   #--------------------------------------------------------------------------
  2224.   def revive_character_death
  2225.     return if @character_sprite == nil
  2226.     @character_death_duration = nil
  2227.     @character_sprite.angle = 0
  2228.     @character_sprite.ox = @character_sprite.width/2
  2229.     @battler.character.break_pose if $imported["ExtendedMovement"]
  2230.     @battler.character.step_anime = true
  2231.     case $scene.view_type
  2232.     when 1; type = :front
  2233.     when 2; type = :side
  2234.     when 3; type = :angle
  2235.     else; return
  2236.     end
  2237.     direction = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[type][0]
  2238.     turn_direction(direction)
  2239.     create_move_to(@battler.origin_x, @battler.origin_y, 20)
  2240.     $scene.update_battler_poses
  2241.   end
  2242.  
  2243.   #--------------------------------------------------------------------------
  2244.   # new method: create_icon
  2245.   #--------------------------------------------------------------------------
  2246.   def create_icon(icon, attachment)
  2247.     return if @character_sprite == nil
  2248.     @icon_sprites = [] if @icon_sprites == nil
  2249.     #---
  2250.     case icon
  2251.     when :weapon1
  2252.       return if @battler.weapons.compact.size <= 0
  2253.       dispose_icon(@icon_weapon1, icon)
  2254.       icon_index = @battler.weapon1_icon
  2255.     when :weapon2
  2256.       return if @battler.weapons.compact.size <= 1
  2257.       dispose_icon(@icon_weapon2, icon)
  2258.       icon_index = @battler.weapon2_icon
  2259.     when :shield
  2260.       return if @battler.armor1_id == 0
  2261.       dispose_icon(@icon_shield, icon)
  2262.       icon_index = @battler.guard_icon
  2263.     when :item
  2264.       return unless @battler.action.item?
  2265.       dispose_icon(@icon_item, icon)
  2266.       icon_index = @battler.action.item.icon_index
  2267.     else
  2268.       return if icon.to_i == 0
  2269.       icon_index = icon.to_i
  2270.       icon = :last
  2271.     end
  2272.     #---
  2273.     icon_sprite = Sprite_Icon.new(viewport, icon_index, @battler)
  2274.     @icon_sprites.push(icon_sprite)
  2275.     icon_sprite.set_origin(attachment)
  2276.     #---
  2277.     case icon
  2278.     when :weapon1
  2279.       @icon_weapon1 = icon_sprite
  2280.     when :weapon2
  2281.       @icon_weapon2 = icon_sprite
  2282.     when :shield
  2283.       @icon_shield = icon_sprite
  2284.     when :item
  2285.       @icon_item = icon_sprite
  2286.     end
  2287.     @icon_last = @icon_sprites[-1]
  2288.   end
  2289.  
  2290.   #--------------------------------------------------------------------------
  2291.   # new method: dispose_icon
  2292.   #--------------------------------------------------------------------------
  2293.   def dispose_icon(icon_sprite, type = nil)
  2294.     return if icon_sprite == nil
  2295.     icon_sprite.dispose
  2296.     case type
  2297.     when :weapon1; @icon_weapon1 = nil
  2298.     when :weapon2; @icon_weapon2 = nil
  2299.     when :shield; @icon_armour = nil
  2300.     when :item; @icon_item = nil
  2301.     end
  2302.     @icon_sprites.delete(icon_sprite)
  2303.     icon_sprite = nil
  2304.     @icon_last = @icon_sprites[-1]
  2305.   end
  2306.  
  2307.   #--------------------------------------------------------------------------
  2308.   # new method: update_icon_sprites
  2309.   #--------------------------------------------------------------------------
  2310.   def update_icon_sprites
  2311.     return if @icon_sprites == nil
  2312.     return unless @icon_sprites != []
  2313.     for icon_sprite in @icon_sprites; icon_sprite.update; end
  2314.   end
  2315.  
  2316.   #--------------------------------------------------------------------------
  2317.   # new method: clear_jump
  2318.   #--------------------------------------------------------------------------
  2319.   def clear_jump
  2320.     @jump_count = nil
  2321.     @jump_duration = nil
  2322.     @jump_peak = nil
  2323.     @jump_height = nil
  2324.   end
  2325.  
  2326.   #--------------------------------------------------------------------------
  2327.   # new method: create_jump
  2328.   #--------------------------------------------------------------------------
  2329.   def create_jump(height, duration)
  2330.     @jump_count = duration
  2331.     @jump_duration = duration
  2332.     @jump_peak = height
  2333.     @jump_height = 0
  2334.   end
  2335.  
  2336.   #--------------------------------------------------------------------------
  2337.   # new method: update_jump
  2338.   #--------------------------------------------------------------------------
  2339.   def update_jump
  2340.     return if @jump_count == nil
  2341.     @jump_duration -= 1
  2342.     if @jump_duration < 0
  2343.       clear_jump
  2344.       return
  2345.     end
  2346.     #---
  2347.     @battler.screen_y += @jump_height
  2348.     if @move_to_y != nil
  2349.       value = [(@battler.screen_y - @move_to_y).abs, @move_rate_y].min
  2350.       difference = (@move_to_y > @battler.screen_y) ? value : -value
  2351.       @battler.screen_y += difference
  2352.     end
  2353.     #---
  2354.     if @jump_duration > @jump_count*7/8
  2355.       n = @jump_height + [@jump_peak/@jump_count, 1].max * 1.50
  2356.     elsif @jump_duration > @jump_count*6/8
  2357.       n = @jump_height + [@jump_peak/@jump_count, 1].max * 1.45
  2358.     elsif @jump_duration > @jump_count*5/8
  2359.       n = @jump_height + [@jump_peak/@jump_count, 1].max * 1.30
  2360.     elsif @jump_duration > @jump_count*4/8
  2361.       n = @jump_height + [@jump_peak/@jump_count, 1].max * 1.00
  2362.     elsif @jump_duration > @jump_count*3/8
  2363.       n = @jump_height - [@jump_peak/@jump_count, 1].max * 1.00
  2364.     elsif @jump_duration > @jump_count*2/8
  2365.       n = @jump_height - [@jump_peak/@jump_count, 1].max * 1.30
  2366.     elsif @jump_duration > @jump_count*1/8
  2367.       n = @jump_height - [@jump_peak/@jump_count, 1].max * 1.45
  2368.     else
  2369.       n = @jump_height - [@jump_peak/@jump_count, 1].max * 1.50
  2370.     end
  2371.     @jump_height = [Integer(n), 0].max
  2372.     @battler.screen_y = @battler.screen_y - @jump_height
  2373.   end
  2374.  
  2375. end # Sprite_Battler
  2376.  
  2377. #===============================================================================
  2378. # Sprite_Popup
  2379. #===============================================================================
  2380.  
  2381. class Sprite_Popup < Sprite_Base
  2382.  
  2383.   #--------------------------------------------------------------------------
  2384.   # public instance variables
  2385.   #--------------------------------------------------------------------------
  2386.   attr_accessor :flags
  2387.  
  2388.   #--------------------------------------------------------------------------
  2389.   # initialize
  2390.   #--------------------------------------------------------------------------
  2391.   def initialize(viewport, battler, value, rules, flags)
  2392.     super(viewport)
  2393.     @value = value
  2394.     @rules = rules
  2395.     @rules = "DEFAULT" unless YEM::BATTLE_ENGINE::POPUP_RULES.include?(@rules)
  2396.     @fade = YEM::BATTLE_ENGINE::POPUP_SETTINGS[:fade]
  2397.     @full = YEM::BATTLE_ENGINE::POPUP_SETTINGS[:full]
  2398.     @flags = flags
  2399.     @battler = battler
  2400.     create_popup_bitmap
  2401.   end
  2402.  
  2403.   #--------------------------------------------------------------------------
  2404.   # create_popup_bitmap
  2405.   #--------------------------------------------------------------------------
  2406.   def create_popup_bitmap
  2407.     array = YEM::BATTLE_ENGINE::POPUP_RULES[@rules]
  2408.     bw = YEM::BATTLE_ENGINE::POPUP_SETTINGS[:width]
  2409.     bw += 48 if @flags.include?("state")
  2410.     size = array[2]
  2411.     size = Integer(size * 1.2) if @flags.include?("critical")
  2412.     bh = size * 2
  2413.     bitmap = Bitmap.new(bw, bh)
  2414.     bitmap.font.name = array[8]
  2415.     bitmap.font.size = size
  2416.     bitmap.font.bold = array[3]
  2417.     bitmap.font.italic = array[4]
  2418.     bitmap.font.shadow = false
  2419.     if flags.include?("critical")
  2420.       crit_rules = YEM::BATTLE_ENGINE::POPUP_RULES["CRITICAL"]
  2421.       bitmap.font.color.set(crit_rules[5], crit_rules[6], crit_rules[7])
  2422.     else
  2423.       bitmap.font.color.set(0, 0, 0)
  2424.     end
  2425.     self.bitmap = bitmap
  2426.     dx = 0; dy = 0; dw = 0
  2427.     dx += 24 if @flags.include?("state")
  2428.     dw += 24 if @flags.include?("state")
  2429.     bitmap.draw_text(dx+1, dy+1, bw-dw, bh, @value, 1)
  2430.     bitmap.draw_text(dx+1, dy-1, bw-dw, bh, @value, 1)
  2431.     bitmap.draw_text(dx-1, dy+1, bw-dw, bh, @value, 1)
  2432.     bitmap.draw_text(dx-1, dy-1, bw-dw, bh, @value, 1)
  2433.     bitmap.font.color.set(array[5], array[6], array[7])
  2434.     bitmap.draw_text(dx, dy, bw-dw, bh, @value, 1)
  2435.     if @flags.include?("state")
  2436.       c_width = bitmap.text_size(@value).width
  2437.       icon_bitmap = $game_temp.iconset
  2438.       icon_index = flag_state_icon
  2439.       rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  2440.       bitmap.blt(dx+(bw-c_width)/2-36, (bh/2-dy)/2-2, icon_bitmap, rect, 255)
  2441.     end
  2442.     self.bitmap = bitmap
  2443.     self.x = @battler.screen_x
  2444.     self.x += rand(4) - rand(4) if @battler.spriteset.popups.size >= 1
  2445.     self.x -= $scene.spriteset.viewport1.ox
  2446.     self.y = @battler.screen_y - @battler.spriteset.oy/2
  2447.     self.y += YEM::BATTLE_ENGINE::POPUP_SETTINGS[:offset] if !$scene.emptyview?
  2448.     self.y -= $scene.spriteset.viewport1.oy
  2449.     self.ox = bw/2; self.oy = bh/2
  2450.     self.zoom_x = self.zoom_y = array[0]
  2451.     if @flags.include?("no zoom")
  2452.       self.zoom_x = self.zoom_y = array[1]
  2453.     end
  2454.     @target_zoom = array[1]
  2455.     @zoom_direction = (self.zoom_x > @target_zoom) ? "down" : "up"
  2456.     self.z = 500
  2457.   end
  2458.  
  2459.   #--------------------------------------------------------------------------
  2460.   # update
  2461.   #--------------------------------------------------------------------------
  2462.   def update
  2463.     super
  2464.     #---
  2465.     if @flags.include?("critical") and
  2466.     YEM::BATTLE_ENGINE::POPUP_SETTINGS[:flash]
  2467.       @hue_duration = 2 if @hue_duration == nil or @hue_duration == 0
  2468.       @hue_duration -= 1
  2469.       self.bitmap.hue_change(15) if @hue_duration <= 0
  2470.     end
  2471.     #---
  2472.     if @zoom_direction == "up"
  2473.       self.zoom_x = [self.zoom_x + 0.075, @target_zoom].min
  2474.       self.zoom_y = [self.zoom_y + 0.075, @target_zoom].min
  2475.     else
  2476.       self.zoom_x = [self.zoom_x - 0.075, @target_zoom].max
  2477.       self.zoom_y = [self.zoom_y - 0.075, @target_zoom].max
  2478.     end
  2479.     #---
  2480.     @full -= 1
  2481.     return if @full > 0
  2482.     self.y -= 1
  2483.     self.opacity -= @fade
  2484.   end
  2485.  
  2486.   #--------------------------------------------------------------------------
  2487.   # flag_state_icon
  2488.   #--------------------------------------------------------------------------
  2489.   def flag_state_icon
  2490.     for item in @flags; return item if item.is_a?(Integer); end
  2491.     return 0
  2492.   end
  2493.  
  2494. end # Sprite_Popup
  2495.  
  2496. #===============================================================================
  2497. # Sprite_OrderBattler
  2498. #===============================================================================
  2499.  
  2500. class Sprite_OrderBattler < Sprite_Base
  2501.  
  2502.   #--------------------------------------------------------------------------
  2503.   # public instance variables
  2504.   #--------------------------------------------------------------------------
  2505.   attr_accessor :first_time
  2506.  
  2507.   #--------------------------------------------------------------------------
  2508.   # initialize
  2509.   #--------------------------------------------------------------------------
  2510.   def initialize(viewport, battler, battle_type = 0)
  2511.     super(viewport)
  2512.     @battler = battler
  2513.     @battle_type = battle_type
  2514.     @destination = 24
  2515.     @move_rate_x = 1
  2516.     @move_rate_y = 1
  2517.     @update_wait = 0
  2518.     @hash = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS
  2519.     @show_dead = YEM::BATTLE_ENGINE::TURNS_DEAD_BATTLERS
  2520.     @charge_icon_id = YEM::BATTLE_ENGINE::CTB_RULES[:chargeicon]
  2521.     @charge_size = Integer(YEM::BATTLE_ENGINE::CTB_RULES[:chargesize] * 24)
  2522.     create_battler_bitmap
  2523.   end
  2524.  
  2525.   #--------------------------------------------------------------------------
  2526.   # dispose
  2527.   #--------------------------------------------------------------------------
  2528.   def dispose
  2529.     self.bitmap.dispose if self.bitmap != nil
  2530.     super
  2531.   end
  2532.  
  2533.   #--------------------------------------------------------------------------
  2534.   # create_battler_bitmap
  2535.   #--------------------------------------------------------------------------
  2536.   def create_battler_bitmap
  2537.     case @battle_type
  2538.     when 0 # Default Turn Battle
  2539.       create_dtb_style
  2540.     when 1 # Press Turn Battle
  2541.       # Unused
  2542.     when 2 # Active Turn Battle
  2543.       create_atb_style
  2544.     when 3 # Press Turn Battle
  2545.       create_dtb_style
  2546.     end
  2547.   end
  2548.  
  2549.   #--------------------------------------------------------------------------
  2550.   # create_dtb_style
  2551.   #--------------------------------------------------------------------------
  2552.   def create_dtb_style
  2553.     bitmap = Bitmap.new(24, 24)
  2554.     icon_bitmap = Cache.system("Iconset")
  2555.     #--- Create Battler Background ---
  2556.     icon_index = @battler.actor? ? @hash[:actor][0] : @hash[:enemy][0]
  2557.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  2558.     bitmap.blt(0, 0, icon_bitmap, rect)
  2559.     #--- Create Battler Icon ---
  2560.     icon_index = @battler.battler_icon
  2561.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  2562.     temp_bitmap = Bitmap.new(24, 24)
  2563.     temp_bitmap.blt(0, 0, icon_bitmap, rect)
  2564.     temp_bitmap.hue_change(@battler.enemy.enemy_icon_hue) if @battler.enemy?
  2565.     bitmap.blt(0, 0, temp_bitmap, Rect.new(0, 0, 24, 24))
  2566.     temp_bitmap.dispose
  2567.     #--- Create Battler Border ---
  2568.     icon_index = @battler.actor? ? @hash[:actor][1] : @hash[:enemy][1]
  2569.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  2570.     bitmap.blt(0, 0, icon_bitmap, rect)
  2571.     #--- Create Battler Letter ---
  2572.     @draw_letter = draw_letter?
  2573.     @charge_icon = charge_icon?
  2574.     if @draw_letter
  2575.       bitmap.font.name = ["UmePlus Gothic", "Courier New"]
  2576.       bitmap.font.color.set(255, 255, 255)
  2577.       bitmap.font.size = 12
  2578.       bitmap.draw_text(-3, 10, 12, 12, @battler.letter.to_s, 0)
  2579.     end
  2580.     if @charge_icon
  2581.       icon_index = @charge_icon_id
  2582.       rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  2583.       dest_rect = Rect.new(0, 0, @charge_size, @charge_size)
  2584.       bitmap.stretch_blt(dest_rect, icon_bitmap, rect)
  2585.     end
  2586.     #---
  2587.     self.bitmap.dispose if self.bitmap != nil
  2588.     self.bitmap = bitmap
  2589.     return if @created_icon
  2590.     @created_icon = true
  2591.     self.ox = 12; self.oy = 12
  2592.     self.x = 24
  2593.     self.y = 24
  2594.     self.z = 8000
  2595.   end
  2596.  
  2597.   #--------------------------------------------------------------------------
  2598.   # create_atb_style
  2599.   #--------------------------------------------------------------------------
  2600.   def create_atb_style
  2601.     bitmap = Bitmap.new(24, 48)
  2602.     icon_bitmap = Cache.system("Iconset")
  2603.     #--- Create Battler Background ---
  2604.     icon_index = @battler.actor? ? @hash[:actor][0] : @hash[:enemy][0]
  2605.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  2606.     bitmap.blt(0, 24, icon_bitmap, rect)
  2607.     #--- Create Battler Icon ---
  2608.     icon_index = @battler.battler_icon
  2609.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  2610.     temp_bitmap = Bitmap.new(24, 24)
  2611.     temp_bitmap.blt(0, 0, icon_bitmap, rect)
  2612.     temp_bitmap.hue_change(@battler.enemy.enemy_icon_hue) if @battler.enemy?
  2613.     bitmap.blt(0, 24, temp_bitmap, Rect.new(0, 0, 24, 24))
  2614.     temp_bitmap.dispose
  2615.     #--- Create Battler Border ---
  2616.     icon_index = @battler.actor? ? @hash[:actor][1] : @hash[:enemy][1]
  2617.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  2618.     bitmap.blt(0, 24, icon_bitmap, rect)
  2619.     #--- Create Battler Letter ---
  2620.     @draw_letter = draw_letter?
  2621.     @charge_icon = charge_icon?
  2622.     if @draw_letter
  2623.       bitmap.font.name = ["UmePlus Gothic", "Courier New"]
  2624.       bitmap.font.color.set(255, 255, 255)
  2625.       bitmap.font.size = 12
  2626.       bitmap.draw_text(-3, 34, 12, 12, @battler.letter.to_s, 0)
  2627.     end
  2628.     #--- Create Battler Arrow ---
  2629.     icon_index = @battler.actor? ? @hash[:actor][5] : @hash[:enemy][5]
  2630.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  2631.     bitmap.blt(0, 0, icon_bitmap, rect)
  2632.     #---
  2633.     self.bitmap.dispose if self.bitmap != nil
  2634.     self.bitmap = bitmap
  2635.     return if @created_icon
  2636.     @created_icon = true
  2637.     self.ox = 12; self.oy = 18
  2638.     self.x = 6
  2639.     self.y = 12
  2640.     self.z = 8000 + self.x
  2641.   end
  2642.  
  2643.   #--------------------------------------------------------------------------
  2644.   # draw_letter?
  2645.   #--------------------------------------------------------------------------
  2646.   def draw_letter?
  2647.     return false unless @battler.enemy?
  2648.     return @battler.plural
  2649.   end
  2650.  
  2651.   #--------------------------------------------------------------------------
  2652.   # charge_icon?
  2653.   #--------------------------------------------------------------------------
  2654.   def charge_icon?
  2655.     return false unless $scene.is_a?(Scene_Battle)
  2656.     return false unless $scene.ctb?
  2657.     return @battler.ctb_speed_bonus < 0
  2658.   end
  2659.  
  2660.   #--------------------------------------------------------------------------
  2661.   # update
  2662.   #--------------------------------------------------------------------------
  2663.   def update
  2664.     super
  2665.     return unless $scene.is_a?(Scene_Battle)
  2666.     if (@draw_letter != draw_letter?) or (@charge_icon != charge_icon?)
  2667.       create_battler_bitmap
  2668.     end
  2669.     #---
  2670.     case @battle_type
  2671.     when 0 # Default Turn Battle
  2672.       update_dtb_style
  2673.     when 1 # Press Turn Battle
  2674.       # No update
  2675.     when 2 # Active Turn Battle
  2676.       update_atb_style
  2677.     when 3 # Charge Turn Battle
  2678.       update_dtb_style
  2679.     end
  2680.   end
  2681.  
  2682.   #--------------------------------------------------------------------------
  2683.   # update_dtb_style
  2684.   #--------------------------------------------------------------------------
  2685.   def update_dtb_style
  2686.     return if @move_to_x == nil
  2687.     if @battler.hidden or (!@show_dead and @battler.dead? and
  2688.     self.opacity <= 64)
  2689.       @move_to_x = -48
  2690.       self.x = -48
  2691.       return
  2692.     end
  2693.     self.z = (@battler.dead?) ? 6000 : 8000
  2694.     @move_to_y = 24
  2695.     if self.x != @move_to_x
  2696.       self.z = (@move_to_x < self.x) ? 7500 : 8500
  2697.       @move_to_y = (@move_to_x < self.x) ? 18 : 30 if @first_time
  2698.       value = [[(@move_to_x-self.x).abs, @move_rate_x].min, 1].max
  2699.       self.x += (@move_to_x > self.x) ? value : -value
  2700.       @first_time = true if self.x == @move_to_x
  2701.     end
  2702.     #---
  2703.     if $scene.target_actor_window != nil
  2704.       @move_to_y = 12 if $scene.highlighted_targets.include?(@battler)
  2705.       @move_to_y = 12 if $scene.target_actor_window.actor == @battler
  2706.     end
  2707.     if $scene.target_enemy_window != nil
  2708.       @move_to_y = 12 if $scene.highlighted_targets.include?(@battler)
  2709.       @move_to_y = 12 if $scene.target_enemy_window.enemy == @battler
  2710.     end
  2711.     #---
  2712.     if self.y != @move_to_y
  2713.       @update_wait -= 1
  2714.       if @update_wait <= 0
  2715.         value = [[(@move_to_y-self.y).abs, @move_rate_y].min, 1].max
  2716.         self.y += (@move_to_y > self.y) ? value : -value
  2717.       end
  2718.     end
  2719.     if self.y == @move_to_y and $scene.target_enemy_window != nil
  2720.       @update_wait = 4
  2721.     end
  2722.     self.opacity += (@battler.exist?) ? 8 : -4
  2723.     self.opacity = [[self.opacity, 255].min, 0].max
  2724.   end
  2725.  
  2726.   #--------------------------------------------------------------------------
  2727.   # make_dtb_destination
  2728.   #--------------------------------------------------------------------------
  2729.   def make_dtb_destination
  2730.     if @battler.hidden
  2731.       self.opacity = 0
  2732.       return
  2733.     end
  2734.     array = $scene.performed_actors.reverse
  2735.     action = $scene.action_battlers.reverse - $scene.performed_actors.reverse
  2736.     array += action
  2737.     result = []
  2738.     #---
  2739.     if @show_dead
  2740.       for member in array
  2741.         next if member.hidden
  2742.         result.push(member) if member.dead?
  2743.       end
  2744.     end
  2745.     for member in array
  2746.       next if member.hidden
  2747.       result.push(member) unless member.dead?
  2748.       action.delete(member) if member.dead? and !@show_dead
  2749.     end
  2750.     #---
  2751.     index = result.index(@battler).to_i
  2752.     @move_to_x = 24 + index * 24
  2753.     if dtb_spacing?
  2754.       @move_to_x += 6 if action.include?(@battler)
  2755.       @move_to_x += 6 if (index + 1 == result.size) and action.size > 1
  2756.     end
  2757.     den = @first_time ? 12 : 24
  2758.     @move_rate_x = [(self.x - @move_to_x).abs/den, 1].max
  2759.   end
  2760.  
  2761.   #--------------------------------------------------------------------------
  2762.   # dtb_spacing?
  2763.   #--------------------------------------------------------------------------
  2764.   def dtb_spacing?
  2765.     return false if $scene.party_input_flag
  2766.     return true
  2767.   end
  2768.  
  2769.   #--------------------------------------------------------------------------
  2770.   # update_atb_style
  2771.   #--------------------------------------------------------------------------
  2772.   def update_atb_style
  2773.     if self.x >= 6 + @battler.atb_position
  2774.       self.x = [self.x-16, 6 + @battler.atb_position].max
  2775.     else
  2776.       difference = (6 + @battler.atb_position) - self.x
  2777.       value = [difference / $scene.atb_speed, 1].max
  2778.       self.x = [self.x+value, 6 + @battler.atb_position].min
  2779.     end
  2780.     self.z = 8000 + self.x
  2781.     self.opacity += @battler.exist? ? 8 : -8
  2782.   end
  2783.  
  2784.   #--------------------------------------------------------------------------
  2785.   # new method: make_ctb_destination
  2786.   #--------------------------------------------------------------------------
  2787.   def make_ctb_destination
  2788.     if @battler.hidden
  2789.       self.opacity = 0
  2790.       return
  2791.     end
  2792.     array = $scene.action_battlers.reverse
  2793.     result = []
  2794.     #---
  2795.     if @show_dead
  2796.       for member in array
  2797.         next if member.hidden
  2798.         next unless member.dead?
  2799.         result.push(member)
  2800.       end
  2801.     end
  2802.     for member in array
  2803.       next if member.hidden
  2804.       next if member.dead?
  2805.       next if member.movable?
  2806.       result.push(member)
  2807.     end
  2808.     for member in array
  2809.       next if member.hidden
  2810.       next if member.dead?
  2811.       next unless member.movable?
  2812.       result.push(member)
  2813.     end
  2814.     #---
  2815.     index = result.index(@battler).to_i
  2816.     @move_to_x = 24 + index * 24
  2817.     den = @first_time ? 12 : 24
  2818.     @move_rate_x = [(self.x - @move_to_x).abs/den, 1].max
  2819.   end
  2820.  
  2821. end # Sprite_OrderBattler
  2822.  
  2823. #===============================================================================
  2824. # Sprite_Icon
  2825. #===============================================================================
  2826.  
  2827. class Sprite_Icon < Sprite_Base
  2828.  
  2829.   #--------------------------------------------------------------------------
  2830.   # public instance variables
  2831.   #--------------------------------------------------------------------------
  2832.   attr_accessor :battler
  2833.   attr_accessor :icon
  2834.   attr_accessor :offset_x
  2835.   attr_accessor :offset_y
  2836.   attr_accessor :offset_z
  2837.  
  2838.   #--------------------------------------------------------------------------
  2839.   # initialize
  2840.   #--------------------------------------------------------------------------
  2841.   def initialize(viewport, icon, battler = nil)
  2842.     super(viewport)
  2843.     @battler = battler
  2844.     @icon = icon
  2845.     @attach_x = 0
  2846.     @attach_y = 0
  2847.     @offset_x = 0
  2848.     @offset_y = 0
  2849.     @offset_z = 0
  2850.     create_icon_bitmap
  2851.   end
  2852.  
  2853.   #--------------------------------------------------------------------------
  2854.   # dispose
  2855.   #--------------------------------------------------------------------------
  2856.   def dispose
  2857.     self.bitmap.dispose if self.bitmap != nil
  2858.     super
  2859.   end
  2860.  
  2861.   #--------------------------------------------------------------------------
  2862.   # create_icon_bitmap
  2863.   #--------------------------------------------------------------------------
  2864.   def create_icon_bitmap
  2865.     return if @icon == nil
  2866.     self.bitmap = Cache.system("Iconset")
  2867.     self.src_rect.set(@icon % 16 * 24, @icon / 16 * 24, 24, 24)
  2868.   end
  2869.  
  2870.   #--------------------------------------------------------------------------
  2871.   # set_origin
  2872.   #--------------------------------------------------------------------------
  2873.   def set_origin(type)
  2874.     @offset_z = 2
  2875.     @attachment = type
  2876.     case type
  2877.     when :item
  2878.       self.ox = 12
  2879.       self.oy = 12
  2880.       @offset_y = -@battler.bitmap_height
  2881.       @offset_x = -@battler.bitmap_width / 2
  2882.     when :hand1
  2883.       self.ox = 24
  2884.       self.oy = 24
  2885.       @attach_y = -@battler.bitmap_height/3
  2886.       @attach_x = -@battler.bitmap_width/5
  2887.     when :hand2
  2888.       self.ox = 24
  2889.       self.oy = 24
  2890.       @attach_y = -@battler.bitmap_height/3
  2891.       @attach_x = @battler.bitmap_width/5
  2892.     when :middle
  2893.       self.ox = 12
  2894.       self.oy = 12
  2895.       @offset_y = -@battler.bitmap_height/2
  2896.     when :top
  2897.       self.ox = 12
  2898.       self.oy = 24
  2899.       @offset_y = -@battler.bitmap_height
  2900.     when :base
  2901.       self.ox = 12
  2902.       self.oy = 24
  2903.     end
  2904.   end
  2905.  
  2906.   #--------------------------------------------------------------------------
  2907.   # update
  2908.   #--------------------------------------------------------------------------
  2909.   def update
  2910.     super
  2911.     update_rotate
  2912.     update_opacity
  2913.     update_move
  2914.     update_position
  2915.   end
  2916.  
  2917.   #--------------------------------------------------------------------------
  2918.   # update_position
  2919.   #--------------------------------------------------------------------------
  2920.   def update_position
  2921.     if @battler != nil
  2922.       self.mirror = mirror_battler?
  2923.       update_attachment(self.mirror)
  2924.       attach_x = self.mirror ? -@attach_x : @attach_x
  2925.       self.x = @battler.screen_x + attach_x + @offset_x
  2926.       self.y = @battler.screen_y + @attach_y + @offset_y
  2927.       self.z = @battler.screen_z + @offset_z - 1
  2928.     else
  2929.       self.x = @offset_x
  2930.       self.y = @offset_y
  2931.       self.z = @offset_z
  2932.     end
  2933.   end
  2934.  
  2935.   #--------------------------------------------------------------------------
  2936.   # update_attachment
  2937.   #--------------------------------------------------------------------------
  2938.   def update_attachment(mirror = false)
  2939.     case @attachment
  2940.     when :hand1
  2941.       self.ox = mirror ? 0 : 24
  2942.       self.oy = 24
  2943.       @attach_y = -@battler.bitmap_height/3
  2944.       @attach_x = -@battler.bitmap_width/5
  2945.     when :hand2
  2946.       self.ox = mirror ? 0 : 24
  2947.       self.oy = 24
  2948.       @attach_y = -@battler.bitmap_height/3
  2949.       @attach_x = @battler.bitmap_width/5
  2950.     else
  2951.       @attach_x = 0
  2952.       @attach_y = 0
  2953.     end
  2954.   end
  2955.  
  2956.   #--------------------------------------------------------------------------
  2957.   # mirror_battler?
  2958.   #--------------------------------------------------------------------------
  2959.   def mirror_battler?
  2960.     return false if @battler.spriteset.character_sprite == nil
  2961.     return true if @battler.character.direction == 8
  2962.     return @battler.character.mirror
  2963.   end
  2964.  
  2965.   #--------------------------------------------------------------------------
  2966.   # change_angle
  2967.   #--------------------------------------------------------------------------
  2968.   def change_angle(value); self.angle = value; end
  2969.    
  2970.   #--------------------------------------------------------------------------
  2971.   # rotate
  2972.   #--------------------------------------------------------------------------
  2973.   def rotate(set_angle, set_speed, clockwise = false)
  2974.     @rotate_angle = set_angle
  2975.     @turn_angle = 0
  2976.     @rotate_speed = set_speed
  2977.     @clockwise = clockwise
  2978.   end
  2979.  
  2980.   #--------------------------------------------------------------------------
  2981.   # update_rotate
  2982.   #--------------------------------------------------------------------------
  2983.   def update_rotate
  2984.     return if @rotate_angle == nil
  2985.     clockwise = @clockwise
  2986.     clockwise = !clockwise if self.mirror
  2987.     self.angle += clockwise ? -@rotate_speed : @rotate_speed
  2988.     @turn_angle += @rotate_speed
  2989.     if @rotate_angle.is_a?(Integer) and @turn_angle >= @rotate_angle
  2990.       @rotate_angle = nil
  2991.     end
  2992.   end
  2993.  
  2994.   #--------------------------------------------------------------------------
  2995.   # opacity_rate
  2996.   #--------------------------------------------------------------------------
  2997.   def opacity_rate(rate); @opacity_rate = rate; end
  2998.  
  2999.   #--------------------------------------------------------------------------
  3000.   # update_opacity
  3001.   #--------------------------------------------------------------------------
  3002.   def update_opacity
  3003.     return if @opacity_rate == nil or @opacity_rate == 0
  3004.     self.opacity += @opacity_rate
  3005.   end
  3006.  
  3007.   #--------------------------------------------------------------------------
  3008.   # move_direction
  3009.   #--------------------------------------------------------------------------
  3010.   def move_direction(direction, speed, frames)
  3011.     case direction
  3012.     when 1 # Down Left
  3013.       @move_2 = @move_4 = speed
  3014.       @move_2_count  = @move_4_count  = 0
  3015.       @move_2_frames = @move_4_frames = frames
  3016.     when 2 # Down
  3017.       @move_2 = speed
  3018.       @move_2_count  = 0
  3019.       @move_2_frames = frames
  3020.     when 3 # Down Right
  3021.       @move_2 = @move_6 = speed
  3022.       @move_2_count  = @move_6_count  = 0
  3023.       @move_2_frames = @move_6_frames = frames
  3024.     when 4 # Left
  3025.       @move_4 = speed
  3026.       @move_4_count  = 0
  3027.       @move_4_frames = frames
  3028.     when 6 # Right
  3029.       @move_6 = speed
  3030.       @move_6_count  = 0
  3031.       @move_6_frames = frames
  3032.     when 7 # Up Left
  3033.       @move_8 = @move_4 = speed
  3034.       @move_8_count  = @move_4_count  = 0
  3035.       @move_8_frames = @move_4_frames = frames
  3036.     when 8 # Up
  3037.       @move_8 = speed
  3038.       @move_8_count  = 0
  3039.       @move_8_frames = frames
  3040.     when 9 # Up Right
  3041.       @move_8 = @move_6 = speed
  3042.       @move_8_count  = @move_6_count  = 0
  3043.       @move_8_frames = @move_6_frames = frames
  3044.     else; return
  3045.     end
  3046.   end
  3047.  
  3048.   #--------------------------------------------------------------------------
  3049.   # update_move
  3050.   #--------------------------------------------------------------------------
  3051.   def update_move
  3052.     if @move_2 != nil # Down Move
  3053.       @offset_y += @move_2
  3054.       @move_2_count += 1
  3055.       if @move_2_count >= @move_2_frames
  3056.         @move_2 = @move_2_count = @move_2_frames = nil
  3057.       end
  3058.     end
  3059.     if @move_4 != nil # Left Move
  3060.       @offset_x -= @move_4
  3061.       @move_4_count += 1
  3062.       if @move_4_count >= @move_4_frames
  3063.         @move_4 = @move_4_count = @move_4_frames = nil
  3064.       end
  3065.     end
  3066.     if @move_6 != nil # Right Move
  3067.       @offset_x += @move_6
  3068.       @move_6_count += 1
  3069.       if @move_6_count >= @move_6_frames
  3070.         @move_6 = @move_6_count = @move_6_frames = nil
  3071.       end
  3072.     end
  3073.     if @move_8 != nil # Up Move
  3074.       @offset_y -= @move_8
  3075.       @move_8_count += 1
  3076.       if @move_8_count >= @move_8_frames
  3077.         @move_8 = @move_8_count = @move_8_frames = nil
  3078.       end
  3079.     end
  3080.   end
  3081.  
  3082. end # Sprite_Icon
  3083.  
  3084. #===============================================================================
  3085. # Sprite_PTB
  3086. #===============================================================================
  3087.  
  3088. class Sprite_PTB < Sprite_Base
  3089.  
  3090.   #--------------------------------------------------------------------------
  3091.   # initialize
  3092.   #--------------------------------------------------------------------------
  3093.   def initialize(viewport, dx, dy, group, index)
  3094.     super(viewport)
  3095.     self.x = dx
  3096.     self.y = dy
  3097.     self.z = 100
  3098.     @group = group
  3099.     @index = index
  3100.     create_bitmap
  3101.   end
  3102.  
  3103.   #--------------------------------------------------------------------------
  3104.   # create_bitmap
  3105.   #--------------------------------------------------------------------------
  3106.   def create_bitmap
  3107.     return unless @index > @group.ptb_total_turns - @group.ptb_bonus_turns
  3108.     return unless @index <= @group.ptb_total_turns
  3109.     hash = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS
  3110.     icon_index = (@group == $game_party) ? hash[:actor][4] : hash[:enemy][4]
  3111.     bitmap = Bitmap.new(24, 24)
  3112.     icon_bitmap = Cache.system("Iconset")
  3113.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  3114.     bitmap.blt(0, 0, icon_bitmap, rect)
  3115.     self.bitmap = bitmap
  3116.     self.blend_type = 1
  3117.     self.ox = 12; self.oy = 12
  3118.     self.x += 12; self.y += 12
  3119.     @allow_update = true
  3120.     @up_glow = false
  3121.   end
  3122.  
  3123.   #--------------------------------------------------------------------------
  3124.   # update
  3125.   #--------------------------------------------------------------------------
  3126.   def update
  3127.     super
  3128.     return unless @allow_update
  3129.     self.opacity += @up_glow ? 8 : -8
  3130.     if self.opacity <= 0
  3131.       @up_glow = true
  3132.     elsif self.opacity >= 255
  3133.       @up_glow = false
  3134.     end
  3135.   end
  3136.  
  3137. end # Sprite_PTB
  3138.  
  3139. #===============================================================================
  3140. # Sprite_BattleCursor
  3141. #===============================================================================
  3142.  
  3143. class Sprite_BattleCursor < Sprite
  3144.  
  3145.   #--------------------------------------------------------------------------
  3146.   # initialize
  3147.   #--------------------------------------------------------------------------
  3148.   def initialize(viewport)
  3149.     super(viewport)
  3150.     create_cursor
  3151.     self.x = Graphics.width/2
  3152.     self.y = Graphics.height/2
  3153.     self.z = 200
  3154.     self.opacity = 0
  3155.   end
  3156.  
  3157.   #--------------------------------------------------------------------------
  3158.   # create_cursor
  3159.   #--------------------------------------------------------------------------
  3160.   def create_cursor
  3161.     self.bitmap = Cache.system(YEM::BATTLE_ENGINE::BATTLE_CURSOR[:filename])
  3162.     self.ox = self.width / 2
  3163.     self.ox += YEM::BATTLE_ENGINE::BATTLE_CURSOR[:x_offset]
  3164.     self.oy = self.height
  3165.     self.oy += YEM::BATTLE_ENGINE::BATTLE_CURSOR[:y_offset]
  3166.   end
  3167.  
  3168.   #--------------------------------------------------------------------------
  3169.   # update
  3170.   #--------------------------------------------------------------------------
  3171.   def update
  3172.     super
  3173.     #---
  3174.     return unless $scene.is_a?(Scene_Battle)
  3175.     update_opacity
  3176.     update_move_to
  3177.     update_follow
  3178.   end
  3179.  
  3180.   #--------------------------------------------------------------------------
  3181.   # update_opacity
  3182.   #--------------------------------------------------------------------------
  3183.   def update_opacity
  3184.     value = opaque? ? 16 : -16
  3185.     self.opacity += value
  3186.   end
  3187.  
  3188.   #--------------------------------------------------------------------------
  3189.   # opaque?
  3190.   #--------------------------------------------------------------------------
  3191.   def opaque?
  3192.     return false unless $scene.is_a?(Scene_Battle)
  3193.     return false if $scene.hide_battlecursor
  3194.     return false if @battler != nil and @battler.actor? and $scene.emptyview?
  3195.     if $scene.actor_command_window != nil
  3196.       return true if $scene.actor_command_window.active
  3197.     end
  3198.     return true if $scene.target_actor_window != nil
  3199.     return true if $scene.target_enemy_window != nil
  3200.     return false
  3201.   end
  3202.  
  3203.   #--------------------------------------------------------------------------
  3204.   # create_move_to
  3205.   #--------------------------------------------------------------------------
  3206.   def create_move_to
  3207.     return unless $scene.is_a?(Scene_Battle)
  3208.     if $scene.target_actor_window != nil
  3209.       @battler = $scene.target_actor_window.actor
  3210.     elsif $scene.target_enemy_window != nil
  3211.       @battler = $scene.target_enemy_window.enemy
  3212.     elsif $scene.actor_command_window.active
  3213.       @battler = $scene.actor_command_window.actor
  3214.     else
  3215.       return
  3216.     end
  3217.     return if @battler == nil
  3218.     return if @battler.actor? and $scene.emptyview?
  3219.     @move_to_x = @battler.screen_x
  3220.     @move_to_x += YEM::BATTLE_ENGINE::BATTLE_CURSOR[:actor_x] if @battler.actor?
  3221.     @move_to_x -= $scene.spriteset.viewport1.ox
  3222.     @move_to_y = @battler.screen_y - @battler.bitmap_height
  3223.     @move_to_y -= YEM::BATTLE_ENGINE::BATTLE_CURSOR[:actor_y] if @battler.actor?
  3224.     @move_to_y -= $scene.spriteset.viewport1.oy
  3225.     #---
  3226.     if @first_time
  3227.       distance_x = (@move_to_x - self.x).abs
  3228.       distance_y = (@move_to_y - self.y).abs
  3229.       @move_rate_x = [distance_x/10, 1].max
  3230.       @move_rate_y = [distance_y/10, 1].max
  3231.     else
  3232.       @first_time = true
  3233.       self.x = @move_to_x
  3234.       self.y = @move_to_y
  3235.     end
  3236.   end
  3237.  
  3238.   #--------------------------------------------------------------------------
  3239.   # update_move_to
  3240.   #--------------------------------------------------------------------------
  3241.   def update_move_to
  3242.     return unless $scene.is_a?(Scene_Battle)
  3243.     return if @battler == nil
  3244.     if @move_to_x != nil and @move_rate_x != nil
  3245.       value = [(self.x - @move_to_x).abs, @move_rate_x].min
  3246.       self.x += (@move_to_x > self.x) ? value : -value
  3247.       @move_to_x = nil if self.x == @move_to_x
  3248.     end
  3249.     if @move_to_y != nil and @move_rate_y != nil
  3250.       value = [(self.y - @move_to_y).abs, @move_rate_y].min
  3251.       self.y += (@move_to_y > self.y) ? value : -value
  3252.       @move_to_y = nil if self.y == @move_to_y
  3253.     end
  3254.   end
  3255.  
  3256.   #--------------------------------------------------------------------------
  3257.   # update_follow
  3258.   #--------------------------------------------------------------------------
  3259.   def update_follow
  3260.     return unless $scene.is_a?(Scene_Battle)
  3261.     return unless $scene.atb?
  3262.     return if @battler == nil
  3263.     require_update = false
  3264.     if @battler_x != @battler.screen_x - $scene.spriteset.viewport1.ox
  3265.       require_update = true
  3266.     elsif @battler_y != @battler.screen_y - $scene.spriteset.viewport1.oy
  3267.       require_update = true
  3268.     end
  3269.     if require_update
  3270.       @battler_x = @battler.screen_x - $scene.spriteset.viewport1.ox
  3271.       @battler_y = @battler.screen_y - $scene.spriteset.viewport1.oy
  3272.       create_move_to
  3273.     end
  3274.   end
  3275.  
  3276. end # Sprite_BattleCursor
  3277.  
  3278. #===============================================================================
  3279. # Spriteset_Battle
  3280. #===============================================================================
  3281.  
  3282. class Spriteset_Battle
  3283.  
  3284.   #--------------------------------------------------------------------------
  3285.   # public instance variable
  3286.   #--------------------------------------------------------------------------
  3287.   attr_accessor :actor_sprites
  3288.   attr_accessor :enemy_sprites
  3289.   attr_accessor :battle_cursor
  3290.   attr_accessor :battleback_sprite
  3291.   attr_accessor :camera_x
  3292.   attr_accessor :camera_y
  3293.   attr_accessor :order_sprites
  3294.   attr_accessor :ptb_update
  3295.   attr_accessor :viewport1
  3296.   attr_accessor :viewportA
  3297.   attr_accessor :viewportB
  3298.   attr_accessor :viewportC
  3299.  
  3300.   #--------------------------------------------------------------------------
  3301.   # overwrite method: create_viewports
  3302.   #--------------------------------------------------------------------------
  3303.   def create_viewports
  3304.     create_camera
  3305.     #---
  3306.     @viewport1 = Viewport.new(0, 0, Graphics.width, Graphics.height)
  3307.     @viewport2 = Viewport.new(0, 0, Graphics.width, Graphics.height)
  3308.     @viewport3 = Viewport.new(0, 0, Graphics.width, Graphics.height)
  3309.     @viewportA = Viewport.new(0, 0, Graphics.width, Graphics.height)
  3310.     @viewportB = Viewport.new(0, 0, Graphics.width, Graphics.height)
  3311.     @viewportC = Viewport.new(0, 0, Graphics.width, Graphics.height)
  3312.     @viewport2.z = 50
  3313.     @viewport3.z = 100
  3314.     @viewportA.z = 250
  3315.     @viewportB.z = 200
  3316.     @viewportC.z = 500
  3317.     #---
  3318.     create_order_sprites
  3319.     create_battle_cursor
  3320.   end
  3321.  
  3322.   #--------------------------------------------------------------------------
  3323.   # alias method: dispose_viewports
  3324.   #--------------------------------------------------------------------------
  3325.   alias dispose_viewports_spriteset_battle_bem dispose_viewports unless $@
  3326.   def dispose_viewports
  3327.     dispose_viewports_spriteset_battle_bem
  3328.     dispose_order_sprites
  3329.     dispose_battle_cursor
  3330.     @viewportA.dispose
  3331.     @viewportB.dispose
  3332.   end
  3333.  
  3334.   #--------------------------------------------------------------------------
  3335.   # overwrite method: update_viewports
  3336.   #--------------------------------------------------------------------------
  3337.   def update_viewports
  3338.     update_camera
  3339.     update_order_sprites
  3340.     update_ptb_call
  3341.     #---
  3342.     @viewport1.tone = $game_troop.screen.tone
  3343.     @viewport1.ox = @camera_x + $game_troop.screen.shake
  3344.     @viewport1.oy = @camera_y
  3345.     @viewport2.color = $game_troop.screen.flash_color
  3346.     @viewport3.color.set(0, 0, 0, 255 - $game_troop.screen.brightness)
  3347.     @viewport1.update
  3348.     @viewport2.update
  3349.     @viewport3.update
  3350.     #---
  3351.     if $scene.is_a?(Scene_Battle) and $scene.target_help_window != nil
  3352.       if $scene.target_help_window.active and !$scene.win_loss_flag
  3353.         @viewportA.rect.y = [@viewportA.rect.y+4, 56].min
  3354.       else
  3355.         @viewportA.rect.y = [@viewportA.rect.y-4, 0].max
  3356.       end
  3357.     end
  3358.     @viewportA.update
  3359.     @viewportB.update
  3360.     #---
  3361.     update_battle_cursor
  3362.     update_magic_circle
  3363.     update_magic_square
  3364.     update_battleback_lighting
  3365.   end
  3366.  
  3367.   #--------------------------------------------------------------------------
  3368.   # overwrite method: create_enemies
  3369.   #--------------------------------------------------------------------------
  3370.   def create_enemies
  3371.     dispose_enemies if @enemy_sprites != nil
  3372.     $scene.enemychars = {}
  3373.     @enemy_sprites = []
  3374.     for enemy in $game_troop.members.reverse
  3375.       if $scene.view_type == 0 or enemy.character_name == ""
  3376.         @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
  3377.       else
  3378.         character = Game_Character.new
  3379.         character.set_graphic(enemy.character_name, enemy.character_index)
  3380.         character.step_anime = true
  3381.         character_sprite = Sprite_Character.new(@viewport1, character)
  3382.         create_enemy_coordinates(character, enemy)
  3383.         battler_sprite = Sprite_Battler.new(@viewport1, enemy)
  3384.         battler_sprite.character_sprite = character_sprite
  3385.         @enemy_sprites.push(battler_sprite)
  3386.         @enemy_sprites[@enemy_sprites.size-1].create_character_dimensions
  3387.         $scene.enemychars[enemy] = character
  3388.         if enemy.dead?
  3389.           battler_sprite.start_character_death
  3390.           battler_sprite.character_death_duration = 1
  3391.           battler_sprite.update_character_death
  3392.         end
  3393.       end
  3394.     end
  3395.   end
  3396.  
  3397.   #--------------------------------------------------------------------------
  3398.   # new method: create_enemy_coordinates
  3399.   #--------------------------------------------------------------------------
  3400.   def create_enemy_coordinates(character, enemy)
  3401.     character.origin_x = enemy.origin_x
  3402.     character.origin_y = enemy.origin_y
  3403.     case $scene.view_type
  3404.     when 1; array = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[:front]
  3405.     when 2; array = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[:side]
  3406.     when 3; array = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[:angle]
  3407.     end
  3408.     back_hash = {1=>9,2=>8,3=>7,4=>6,6=>4,7=>3,8=>2,9=>1}
  3409.     backdir = back_hash[array[0]]
  3410.     direction = correct_direction(backdir)
  3411.     character.set_direction(direction)
  3412.     character.screen_x = character.origin_x
  3413.     character.screen_y = character.origin_y
  3414.     character.screen_z = 200
  3415.   end
  3416.  
  3417.   #--------------------------------------------------------------------------
  3418.   # overwrite method: create_actors
  3419.   #--------------------------------------------------------------------------
  3420.   def create_actors
  3421.     dispose_actors if @actor_sprites != nil
  3422.     $scene.characters = {}
  3423.     @actor_sprites = []
  3424.     unless [1, 2, 3].include?($scene.view_type)
  3425.       for member in $game_party.members
  3426.         @actor_sprites.push(Sprite_Battler.new(@viewport1, member))
  3427.       end
  3428.       return
  3429.     end
  3430.     for actor in $game_party.members
  3431.       character = Game_Character.new
  3432.       character.set_graphic(actor.character_name, actor.character_index)
  3433.       character.step_anime = true
  3434.       character_sprite = Sprite_Character.new(@viewport1, character)
  3435.       create_actor_coordinates(character, actor)
  3436.       battler_sprite = Sprite_Battler.new(@viewport1, actor)
  3437.       battler_sprite.character_sprite = character_sprite
  3438.       @actor_sprites.push(battler_sprite)
  3439.       @actor_sprites[@actor_sprites.size-1].create_character_dimensions
  3440.       $scene.characters[actor.index] = character
  3441.       if actor.dead?
  3442.         battler_sprite.start_character_death
  3443.         battler_sprite.character_death_duration = 1
  3444.         battler_sprite.update_character_death
  3445.       end
  3446.     end
  3447.   end
  3448.  
  3449.   #--------------------------------------------------------------------------
  3450.   # new method: create_actor_coordinates
  3451.   #--------------------------------------------------------------------------
  3452.   def create_actor_coordinates(character, actor)
  3453.     index = actor.index
  3454.     index = 0 unless YEM::BATTLE_ENGINE::ACTOR_COORDINATES.include?(index)
  3455.     array = YEM::BATTLE_ENGINE::ACTOR_COORDINATES[index][$scene.view_type]
  3456.     character.origin_x = array[0]
  3457.     character.origin_y = array[1]
  3458.     case $scene.view_type
  3459.     when 1; array = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[:front]
  3460.     when 2; array = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[:side]
  3461.     when 3; array = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[:angle]
  3462.     end
  3463.     direction = correct_direction(array[0])
  3464.     character.set_direction(direction)
  3465.     case actor.class.position
  3466.     when 0
  3467.       character.origin_x += array[1]
  3468.       character.origin_y += array[2]
  3469.     when 1
  3470.       character.origin_x += array[3]
  3471.       character.origin_y += array[4]
  3472.     when 2
  3473.       character.origin_x += array[5]
  3474.       character.origin_y += array[6]
  3475.     end
  3476.     character.screen_x = character.origin_x
  3477.     character.screen_y = character.origin_y
  3478.     character.screen_z = 200
  3479.   end
  3480.  
  3481.   #--------------------------------------------------------------------------
  3482.   # new method: correct_direction
  3483.   #--------------------------------------------------------------------------
  3484.   def correct_direction(direction)
  3485.     return direction if $imported["ExtendedMovement"]
  3486.     correction ={ 1=>2, 2=>2, 3=>6, 4=>4, 6=>6, 7=>4, 8=>8, 9=>8 }
  3487.     return correction[direction]
  3488.   end
  3489.  
  3490.   #--------------------------------------------------------------------------
  3491.   # alias method: update_enemies
  3492.   #--------------------------------------------------------------------------
  3493.   alias update_enemies_bem update_enemies unless $@
  3494.   def update_enemies
  3495.     return unless $scene.is_a?(Scene_Battle)
  3496.     update_enemies_bem
  3497.     for key in $scene.enemychars
  3498.       character = key[1]
  3499.       character.update
  3500.     end
  3501.   end
  3502.  
  3503.   #--------------------------------------------------------------------------
  3504.   # overwrite method: update_actors
  3505.   #--------------------------------------------------------------------------
  3506.   def update_actors
  3507.     return unless $scene.is_a?(Scene_Battle)
  3508.     for sprite in @actor_sprites
  3509.       sprite.update
  3510.     end
  3511.     for key in $scene.characters
  3512.       character = key[1]
  3513.       character.update
  3514.     end
  3515.   end
  3516.  
  3517.   #--------------------------------------------------------------------------
  3518.   # overwrite method: animation?
  3519.   #--------------------------------------------------------------------------
  3520.   def animation?
  3521.     for sprite in @enemy_sprites + @actor_sprites
  3522.       return true if sprite.animation?
  3523.       next if sprite.character_sprite == nil
  3524.       return true if sprite.character_sprite.animation?
  3525.     end
  3526.     return false
  3527.   end
  3528.  
  3529.   #--------------------------------------------------------------------------
  3530.   # new method: create_camera
  3531.   #--------------------------------------------------------------------------
  3532.   def create_camera
  3533.     @camera_x = 0
  3534.     @camera_y = 0
  3535.     @camera_to_x = 0
  3536.     @camera_to_y = 0
  3537.     @camera_to_x_rate = 4
  3538.     @camera_to_y_rate = 4
  3539.   end
  3540.  
  3541.   #--------------------------------------------------------------------------
  3542.   # new method: update_camera
  3543.   #--------------------------------------------------------------------------
  3544.   def update_camera
  3545.     if @camera_x != @camera_to_x
  3546.       value = [[(@camera_to_x-@camera_x).abs, @camera_to_x_rate].min, 1].max
  3547.       @camera_x += (@camera_to_x > @camera_x) ? value : -value
  3548.     end
  3549.     if @camera_y != @camera_to_y
  3550.       value = [[(@camera_to_y-@camera_y).abs, @camera_to_y_rate].min, 1].max
  3551.       @camera_y += (@camera_to_y > @camera_y) ? value : -value
  3552.     end
  3553.   end
  3554.  
  3555.   #--------------------------------------------------------------------------
  3556.   # new method: set_camera_desintation
  3557.   #--------------------------------------------------------------------------
  3558.   def set_camera_destination(to_x, to_y, frames = 60)
  3559.     @camera_to_x = to_x
  3560.     @camera_to_y = to_y
  3561.     @camera_to_x_rate = [(@camera_to_x-@camera_x).abs/[frames, 1].max, 1].max
  3562.     @camera_to_y_rate = [(@camera_to_y-@camera_y).abs/[frames, 1].max, 1].max
  3563.   end
  3564.  
  3565.   #--------------------------------------------------------------------------
  3566.   # new method: scroll_camera
  3567.   #--------------------------------------------------------------------------
  3568.   def scroll_camera(direction, distance, frames = 60)
  3569.     to_x = @camera_to_x
  3570.     to_y = @camera_to_y
  3571.     case direction
  3572.     when 1 # Down Left
  3573.       to_x += distance
  3574.       to_y -= distance
  3575.     when 2 # Down
  3576.       to_y -= distance
  3577.     when 3 # Down Right
  3578.       to_x -= distance
  3579.       to_y -= distance
  3580.     when 4 # Left
  3581.       to_x -= distance
  3582.     when 6 # Right
  3583.       to_x += distance
  3584.     when 7 # Up Left
  3585.       to_x -= distance
  3586.       to_y += distance
  3587.     when 8 # Up
  3588.       to_y += distance
  3589.     when 9 # Up Right
  3590.       to_x += distance
  3591.       to_y += distance
  3592.     end
  3593.     set_camera_destination(to_x, to_y, frames)
  3594.   end
  3595.  
  3596.   #--------------------------------------------------------------------------
  3597.   # new method: create_order_sprites
  3598.   #--------------------------------------------------------------------------
  3599.   def create_order_sprites
  3600.     case $scene.battle_type
  3601.     when 0 # Default Turn Battle
  3602.       create_dtb_sprites
  3603.     when 1 # Press Turn Battle
  3604.       # none, reset in battle
  3605.     when 2 # Active Turn Battle
  3606.       create_atb_sprites
  3607.     when 3 # Charge Turn Battle
  3608.       create_ctb_sprites
  3609.     end
  3610.   end
  3611.  
  3612.   #--------------------------------------------------------------------------
  3613.   # new method: update_order_sprites
  3614.   #--------------------------------------------------------------------------
  3615.   def update_order_sprites
  3616.     return if @order_sprites == nil
  3617.     for sprite in @order_sprites
  3618.       sprite.update
  3619.     end
  3620.   end
  3621.  
  3622.   #--------------------------------------------------------------------------
  3623.   # new method: dispose_order_sprites
  3624.   #--------------------------------------------------------------------------
  3625.   def dispose_order_sprites
  3626.     return if @order_sprites == nil
  3627.     for sprite in @order_sprites
  3628.       sprite.dispose
  3629.       sprite = nil
  3630.     end
  3631.     @order_sprites = nil
  3632.   end
  3633.  
  3634.   #--------------------------------------------------------------------------
  3635.   # new method: create_dtb_sprites
  3636.   #--------------------------------------------------------------------------
  3637.   def create_dtb_sprites
  3638.     dispose_order_sprites
  3639.     @order_sprites = []
  3640.     array = $game_party.members + $game_troop.members
  3641.     for member in array.reverse
  3642.       sprite = Sprite_OrderBattler.new(@viewportA, member, 0)
  3643.       @order_sprites.push(sprite)
  3644.     end
  3645.   end
  3646.  
  3647.   #--------------------------------------------------------------------------
  3648.   # new method: update_dtb_order
  3649.   #--------------------------------------------------------------------------
  3650.   def update_dtb_order
  3651.     return unless $scene.dtb?
  3652.     return if @order_sprites == nil
  3653.     for sprite in @order_sprites
  3654.       sprite.make_dtb_destination
  3655.     end
  3656.   end
  3657.  
  3658.   #--------------------------------------------------------------------------
  3659.   # new method: update_ptb_call
  3660.   #--------------------------------------------------------------------------
  3661.   def update_ptb_call
  3662.     return if @ptb_update == nil
  3663.     refresh_ptb_counters(@ptb_update)
  3664.   end
  3665.  
  3666.   #--------------------------------------------------------------------------
  3667.   # new method: refresh_ptb_counters
  3668.   #--------------------------------------------------------------------------
  3669.   def refresh_ptb_counters(group)
  3670.     @ptb_update = nil
  3671.     dispose_order_sprites
  3672.     @order_sprites = []
  3673.     amount = group.ptb_total_turns
  3674.     index = 1; dx = 12; dy = 6
  3675.     amount.times do
  3676.       sprite = Sprite_PTB.new(@viewportA, dx, dy, group, index)
  3677.       @order_sprites.push(sprite)
  3678.       index += 1
  3679.       dx += 24
  3680.       dy = (dy == 6) ? 18 : 6
  3681.     end
  3682.   end
  3683.  
  3684.   #--------------------------------------------------------------------------
  3685.   # create_atb_sprites
  3686.   #--------------------------------------------------------------------------
  3687.   def create_atb_sprites
  3688.     dispose_order_sprites
  3689.     @order_sprites = []
  3690.     create_atb_gauge
  3691.     array = $game_party.members + $game_troop.members
  3692.     for member in array.reverse
  3693.       sprite = Sprite_OrderBattler.new(@viewportA, member, 2)
  3694.       @order_sprites.push(sprite)
  3695.     end
  3696.   end
  3697.  
  3698.   #--------------------------------------------------------------------------
  3699.   # create_atb_gauge
  3700.   #--------------------------------------------------------------------------
  3701.   def create_atb_gauge
  3702.     sprite = Sprite_Base.new(@viewportA)
  3703.     bitmap = Cache.system(YEM::BATTLE_ENGINE::ATB_GAUGE)
  3704.     sprite.bitmap = bitmap
  3705.     sprite.x = 5
  3706.     sprite.y = 5
  3707.     @order_sprites.push(sprite)
  3708.   end
  3709.  
  3710.   #--------------------------------------------------------------------------
  3711.   # new method: create_ctb_sprites
  3712.   #--------------------------------------------------------------------------
  3713.   def create_ctb_sprites
  3714.     dispose_order_sprites
  3715.     @order_sprites = []
  3716.     array = $game_party.members + $game_troop.members
  3717.     for member in array.reverse
  3718.       sprite = Sprite_OrderBattler.new(@viewportA, member, 3)
  3719.       @order_sprites.push(sprite)
  3720.     end
  3721.   end
  3722.  
  3723.   #--------------------------------------------------------------------------
  3724.   # new method: update_ctb_order
  3725.   #--------------------------------------------------------------------------
  3726.   def update_ctb_order
  3727.     return unless $scene.is_a?(Scene_Battle)
  3728.     return unless $scene.ctb?
  3729.     return if @order_sprites == nil
  3730.     for sprite in @order_sprites
  3731.       sprite.make_ctb_destination
  3732.     end
  3733.   end
  3734.  
  3735.   #--------------------------------------------------------------------------
  3736.   # new method: mark_first_time_order
  3737.   #--------------------------------------------------------------------------
  3738.   def mark_first_time_order
  3739.     return unless $scene.is_a?(Scene_Battle)
  3740.     return if @marked_first_time
  3741.     @marked_first_time = true
  3742.     return if $scene.ptb?
  3743.     return if @order_sprites == nil
  3744.     for sprite in @order_sprites
  3745.       sprite.first_time = true
  3746.     end
  3747.   end
  3748.  
  3749.   #--------------------------------------------------------------------------
  3750.   # new method: create_battle_cursor
  3751.   #--------------------------------------------------------------------------
  3752.   def create_battle_cursor
  3753.     return unless YEM::BATTLE_ENGINE::BATTLE_CURSOR[:enable]
  3754.     @battle_cursor = Sprite_BattleCursor.new(@viewportB)
  3755.   end
  3756.  
  3757.   #--------------------------------------------------------------------------
  3758.   # new method: update_battle_cursor
  3759.   #--------------------------------------------------------------------------
  3760.   def update_battle_cursor
  3761.     return if @battle_cursor == nil
  3762.     @battle_cursor.update
  3763.   end
  3764.  
  3765.   #--------------------------------------------------------------------------
  3766.   # new method: dispose_battle_cursor
  3767.   #--------------------------------------------------------------------------
  3768.   def dispose_battle_cursor
  3769.     return if @battle_cursor == nil
  3770.     @battle_cursor.dispose
  3771.   end
  3772.  
  3773.   #--------------------------------------------------------------------------
  3774.   # new method: create_magic_circle
  3775.   #--------------------------------------------------------------------------
  3776.   def create_magic_circle(window, obj)
  3777.     if obj.is_a?(RPG::Skill) or obj.is_a?(RPG::Item)
  3778.       return if obj.aoe_radius <= 0
  3779.     else; return
  3780.     end
  3781.     #---
  3782.     @aoe_window = window
  3783.     @magic_circle_sprite = Sprite.new(@viewport1)
  3784.     @magic_circle_sprite.bitmap = Cache.picture(obj.aoe_image)
  3785.     diameter = obj.aoe_radius * 2 + 1
  3786.     @magic_circle_sprite.blend_type = obj.aoe_blend
  3787.     @magic_circle_sprite.zoom_x = diameter * 1.125 /
  3788.       @magic_circle_sprite.width
  3789.     @magic_circle_sprite.zoom_y = @magic_circle_sprite.zoom_x *
  3790.       (obj.aoe_height + 0.01)
  3791.     @magic_circle_sprite.ox = @magic_circle_sprite.width/2
  3792.     @magic_circle_sprite.oy = @magic_circle_sprite.height/2
  3793.     @magic_circle_sprite.z = 2
  3794.   end
  3795.  
  3796.   #--------------------------------------------------------------------------
  3797.   # new method: dispose_magic_circle
  3798.   #--------------------------------------------------------------------------
  3799.   def dispose_magic_circle
  3800.     @magic_circle_sprite.dispose if @magic_circle_sprite != nil
  3801.     @magic_circle_sprite = nil
  3802.     @aoe_window = nil
  3803.   end
  3804.  
  3805.   #--------------------------------------------------------------------------
  3806.   # new method: update_magic_circle
  3807.   #--------------------------------------------------------------------------
  3808.   def update_magic_circle
  3809.     return if @magic_circle_sprite == nil
  3810.     if @aoe_window != nil
  3811.       if @aoe_window.is_a?(Window_TargetEnemy)
  3812.         target = @aoe_window.enemy
  3813.         group = $game_troop
  3814.         value_x = target.screen_x + target.enemy.target_offset_x
  3815.         value_y = target.screen_y + target.enemy.target_offset_y
  3816.       elsif @aoe_window.is_a?(Window_BattleStatus)
  3817.         target = @aoe_window.actor
  3818.         group = $game_party
  3819.         value_x = target.screen_x
  3820.         value_y = target.screen_y
  3821.       end
  3822.       #---
  3823.       update_highlight = false
  3824.       if @magic_circle_sprite.x != value_x
  3825.         update_highlight = true
  3826.         @magic_circle_sprite.x = value_x
  3827.       end
  3828.       if @magic_circle_sprite.y != value_y
  3829.         update_highlight = true
  3830.         @magic_circle_sprite.y = value_y
  3831.       end
  3832.       $scene.create_highlighted_targets(group) if update_highlight
  3833.       #---
  3834.     end
  3835.     @magic_circle_sprite.opacity += @magic_circle_sprite_upward ? 8 : -8
  3836.     if @magic_circle_sprite.opacity <= 0
  3837.       @magic_circle_sprite_upward = true
  3838.     elsif @magic_circle_sprite.opacity >= 255
  3839.       @magic_circle_sprite_upward = false
  3840.     end
  3841.   end
  3842.  
  3843.   #--------------------------------------------------------------------------
  3844.   # new method: create_magic_square
  3845.   #--------------------------------------------------------------------------
  3846.   def create_magic_square(window, obj)
  3847.     if obj.is_a?(RPG::Skill) or obj.is_a?(RPG::Item)
  3848.       return if obj.rect_type <= 0
  3849.     else; return
  3850.     end
  3851.     @aoe_window = window
  3852.     @magic_square_sprite = Sprite.new(@viewport1)
  3853.     @magic_square_sprite.bitmap = Cache.picture(obj.rect_image)
  3854.     @magic_square_sprite.blend_type = obj.rect_blend
  3855.     @magic_square_type = obj.rect_type
  3856.     rect_value = obj.rect_value * 2 + 1
  3857.     case @magic_square_type
  3858.     when 1 # Column
  3859.       @magic_square_sprite.zoom_x = rect_value * 1.0 /
  3860.         @magic_square_sprite.width
  3861.       @magic_square_sprite.zoom_y = Graphics.height * 1.0 /
  3862.         @magic_square_sprite.height
  3863.       @magic_square_sprite.ox = @magic_square_sprite.width/2
  3864.     when 2 # Row
  3865.       @magic_square_sprite.zoom_x = Graphics.width * 1.0 /
  3866.         @magic_square_sprite.width
  3867.       @magic_square_sprite.zoom_y = rect_value * 1.0 /
  3868.         @magic_square_sprite.height
  3869.       @magic_square_sprite.oy = @magic_square_sprite.height/2
  3870.     when 3 # Map
  3871.       @magic_square_sprite.zoom_x = Graphics.width * 1.0 /
  3872.         @magic_square_sprite.width
  3873.       @magic_square_sprite.zoom_y = Graphics.height * 1.0 /
  3874.         @magic_square_sprite.height
  3875.     end
  3876.     @magic_square_sprite.z = 3
  3877.   end
  3878.  
  3879.   #--------------------------------------------------------------------------
  3880.   # new method: dispose_magic_square
  3881.   #--------------------------------------------------------------------------
  3882.   def dispose_magic_square
  3883.     @magic_square_sprite.dispose if @magic_square_sprite != nil
  3884.     @magic_square_sprite = nil
  3885.     @aoe_window = nil
  3886.   end
  3887.  
  3888.   #--------------------------------------------------------------------------
  3889.   # new method: update_magic_square
  3890.   #--------------------------------------------------------------------------
  3891.   def update_magic_square
  3892.     return if @magic_square_sprite == nil
  3893.     if @aoe_window != nil
  3894.       if @aoe_window.is_a?(Window_TargetEnemy)
  3895.         group = $game_troop
  3896.         target = @aoe_window.enemy
  3897.         case @magic_square_type
  3898.         when 1 # Column
  3899.           value_x = target.screen_x
  3900.           value_x += target.enemy.target_offset_x
  3901.           value_y = 0
  3902.         when 2 # Row
  3903.           value_x = 0
  3904.           value_y = target.screen_y
  3905.           value_y += target.enemy.target_offset_y
  3906.         when 3 # Map
  3907.           value_x = 0
  3908.           value_y = 0
  3909.         end
  3910.       elsif @aoe_window.is_a?(Window_BattleStatus)
  3911.         group = $game_party
  3912.         target = @aoe_window.actor
  3913.         case @magic_square_type
  3914.         when 1 # Column
  3915.           value_x = target.screen_x
  3916.           value_y = 0
  3917.         when 2 # Row
  3918.           value_x = 0
  3919.           value_y = target.screen_y
  3920.         when 3 # Map
  3921.           value_x = 0
  3922.           value_y = 0
  3923.         end
  3924.       end
  3925.       #---
  3926.       update_highlight = false
  3927.       if @magic_square_sprite.x != value_x
  3928.         update_highlight = true
  3929.         @magic_square_sprite.x = value_x
  3930.       end
  3931.       if @magic_square_sprite.y != value_y
  3932.         update_highlight = true
  3933.         @magic_square_sprite.y = value_y
  3934.       end
  3935.       $scene.create_highlighted_targets(group) if update_highlight
  3936.       #---
  3937.     end
  3938.     @magic_square_sprite.opacity += @magic_square_sprite_upward ? 8 : -8
  3939.     if @magic_square_sprite.opacity <= 0
  3940.       @magic_square_sprite_upward = true
  3941.     elsif @magic_square_sprite.opacity >= 255
  3942.       @magic_square_sprite_upward = false
  3943.     end
  3944.   end
  3945.  
  3946.   #--------------------------------------------------------------------------
  3947.   # new method: start_battleback_darken
  3948.   #--------------------------------------------------------------------------
  3949.   def start_battleback_darken
  3950.     @battleback_darken_duration = 32
  3951.     @battleback_sprite.color.set(0,0,0,0)
  3952.   end
  3953.  
  3954.   #--------------------------------------------------------------------------
  3955.   # new method: start_battleback_lighten
  3956.   #--------------------------------------------------------------------------
  3957.   def start_battleback_lighten
  3958.     @battleback_lighten_duration = 16
  3959.     @battleback_sprite.color.set(0,0,0,128)
  3960.   end
  3961.  
  3962.   #--------------------------------------------------------------------------
  3963.   # new method: update_battleback_lighting
  3964.   #--------------------------------------------------------------------------
  3965.   def update_battleback_lighting
  3966.     if @battleback_darken_duration != nil
  3967.       @battleback_darken_duration -= 1
  3968.       duration = @battleback_darken_duration
  3969.       @battleback_sprite.color.alpha += 4
  3970.       @battleback_darken_duration = nil if @battleback_darken_duration <= 0
  3971.       return
  3972.     end
  3973.     if @battleback_lighten_duration != nil
  3974.       @battleback_lighten_duration -= 1
  3975.       @battleback_sprite.color.alpha -= 8
  3976.       @battleback_lighten_duration = nil if @battleback_lighten_duration <= 0
  3977.     end
  3978.   end
  3979.  
  3980. end # Spriteset_Battle
  3981.  
  3982. #==============================================================================
  3983. # Window_Base
  3984. #==============================================================================
  3985.  
  3986. class Window_Base < Window
  3987.  
  3988.   #--------------------------------------------------------------------------
  3989.   # alias method: initialize
  3990.   #--------------------------------------------------------------------------
  3991.   alias initialize_window_base_bem initialize unless $@
  3992.   def initialize(x, y, width, height)
  3993.     initialize_window_base_bem(x, y, width, height)
  3994.     if $game_temp.in_battle
  3995.       $disposable_melody_windows = [] if $disposable_melody_windows == nil
  3996.       $disposable_melody_windows.push(self)
  3997.     end
  3998.   end
  3999.  
  4000.   #--------------------------------------------------------------------------
  4001.   # alias method: dispose
  4002.   #--------------------------------------------------------------------------
  4003.   alias dispose_window_base_bem dispose unless $@
  4004.   def dispose
  4005.     if $game_temp.in_battle
  4006.       $disposable_melody_windows = [] if $disposable_melody_windows == nil
  4007.       $disposable_melody_windows.delete(self)
  4008.     end
  4009.     dispose_window_base_bem
  4010.   end
  4011.  
  4012.   #--------------------------------------------------------------------------
  4013.   # rage_gauge_color1
  4014.   #--------------------------------------------------------------------------
  4015.   def rage_gauge_color1
  4016.     return text_color(YEM::BATTLE_ENGINE::SKILL_SETTINGS[:rage_gauge1])
  4017.   end
  4018.  
  4019.   #--------------------------------------------------------------------------
  4020.   # rage_gauge_color2
  4021.   #--------------------------------------------------------------------------
  4022.   def rage_gauge_color2
  4023.     return text_color(YEM::BATTLE_ENGINE::SKILL_SETTINGS[:rage_gauge2])
  4024.   end
  4025.  
  4026.   #--------------------------------------------------------------------------
  4027.   # new method: draw_actor_rage_gauge
  4028.   #--------------------------------------------------------------------------
  4029.   unless $imported["CoreFixesUpgradesMelody"]
  4030.   def draw_actor_rage_gauge(actor, x, y, width = 120, height = nil)
  4031.     gc0 = gauge_back_color
  4032.     gc1 = text_color(YEM::BATTLE_ENGINE::RAGE[:rage_gauge1])
  4033.     gc2 = text_color(YEM::BATTLE_ENGINE::RAGE[:rage_gauge2])
  4034.     gh = 6
  4035.     gy = y + WLH - 8 - (gh - 6)
  4036.     gb = width
  4037.     self.contents.fill_rect(x, gy, gb, gh, gc0)
  4038.     gw = [[gb * actor.rage / actor.max_rage, width].min, 0].max
  4039.     self.contents.gradient_fill_rect(x, gy, gw, gh, gc1, gc2)
  4040.   end
  4041.   end
  4042.  
  4043.   #--------------------------------------------------------------------------
  4044.   # new method: draw_enemy_hp_gauge
  4045.   #--------------------------------------------------------------------------
  4046.   def draw_enemy_hp_gauge(battler, x, y, width = 120)
  4047.     battler.hp = [battler.hp, battler.maxhp].min
  4048.     gc0 = gauge_back_color
  4049.     gc1 = text_color(battler.enemy.quick_gauge[:hp_gauge1])
  4050.     gc2 = text_color(battler.enemy.quick_gauge[:hp_gauge2])
  4051.     gh = 6
  4052.     gy = y + WLH - 8 - (gh - 6)
  4053.     if battler.maxhp < battler.base_maxhp and battler.base_maxhp > 0 and
  4054.     !(battler.base_maxhp > battler.maxhp_limit)
  4055.       gb = width * battler.maxhp / battler.base_maxhp
  4056.       self.contents.fill_rect(x, gy, width, gh, text_color(7))
  4057.     else
  4058.       gb = width
  4059.     end
  4060.     self.contents.fill_rect(x, gy, gb, gh, gc0)
  4061.     gw = gb * battler.hp / battler.maxhp
  4062.     self.contents.gradient_fill_rect(x, gy, gw, gh, gc1, gc2)
  4063.   end
  4064.  
  4065.   #--------------------------------------------------------------------------
  4066.   # new method: draw_enemy_mp_gauge
  4067.   #--------------------------------------------------------------------------
  4068.   def draw_enemy_mp_gauge(battler, x, y, width = 120, height = nil)
  4069.     battler.mp = [battler.mp, battler.maxmp].min
  4070.     gc0 = gauge_back_color
  4071.     gc1 = text_color(battler.enemy.quick_gauge[:mp_gauge1])
  4072.     gc2 = text_color(battler.enemy.quick_gauge[:mp_gauge2])
  4073.     gh = 6
  4074.     gy = y + WLH - 8 - (gh - 6)
  4075.     if battler.maxmp < battler.base_maxmp and battler.base_maxmp > 0 and
  4076.     !(battler.base_maxmp > battler.maxmp_limit)
  4077.       gb = width * battler.maxmp / battler.base_maxmp
  4078.       self.contents.fill_rect(x, gy, width, gh, text_color(7))
  4079.     else
  4080.       gb = width
  4081.     end
  4082.     self.contents.fill_rect(x, gy, gb, gh, gc0)
  4083.     if battler.maxmp <= 0
  4084.       if battler.base_maxmp <= 0
  4085.         gw = width
  4086.       else
  4087.         gw = 0
  4088.       end
  4089.     else
  4090.       gw = gb * battler.mp / battler.maxmp
  4091.     end
  4092.     self.contents.gradient_fill_rect(x, gy, gw, gh, gc1, gc2)
  4093.   end
  4094.  
  4095.   #--------------------------------------------------------------------------
  4096.   # new method: draw_enemy_rage_gauge
  4097.   #--------------------------------------------------------------------------
  4098.   def draw_enemy_rage_gauge(actor, x, y, width = 120, height = nil)
  4099.     gc0 = gauge_back_color
  4100.     gc1 = text_color(YEM::BATTLE_ENGINE::SKILL_SETTINGS[:rage_gauge1])
  4101.     gc2 = text_color(YEM::BATTLE_ENGINE::SKILL_SETTINGS[:rage_gauge2])
  4102.     gh = $imported["CoreFixesUpgradesMelody"] ? YEM::UPGRADE::GAUGE_HEIGHT : 6
  4103.     gy = y + WLH - 8 - (gh - 6)
  4104.     gb = width
  4105.     self.contents.fill_rect(x, gy, gb, gh, gc0)
  4106.     gw = [[gb * actor.rage / actor.max_rage, width].min, 0].max
  4107.     self.contents.gradient_fill_rect(x, gy, gw, gh, gc1, gc2)
  4108.   end
  4109.  
  4110. end # Window_Base
  4111.  
  4112. #==============================================================================
  4113. # Window_Command_Centered
  4114. #==============================================================================
  4115.  
  4116. class Window_Command_Centered < Window_Command
  4117.  
  4118.   #--------------------------------------------------------------------------
  4119.   # new method: draw_item
  4120.   #--------------------------------------------------------------------------
  4121.   def draw_item(index, enabled = true)
  4122.     rect = item_rect(index)
  4123.     rect.x += 4
  4124.     rect.width -= 8
  4125.     self.contents.clear_rect(rect)
  4126.     self.contents.font.color = normal_color
  4127.     self.contents.font.color.alpha = enabled ? 255 : 128
  4128.     self.contents.draw_text(rect, @commands[index],1)
  4129.   end
  4130.  
  4131. end # Window_Command_Centered
  4132.  
  4133. #===============================================================================
  4134. # Window_BattleDebug
  4135. #===============================================================================
  4136.  
  4137. class Window_BattleDebug < Window_Base
  4138.  
  4139.   #--------------------------------------------------------------------------
  4140.   # initialize
  4141.   #--------------------------------------------------------------------------
  4142.   def initialize
  4143.     super(0, 16, Graphics.width, 56)
  4144.     self.back_opacity = 0
  4145.     self.opacity = 0
  4146.   end
  4147.  
  4148.   #--------------------------------------------------------------------------
  4149.   # update
  4150.   #--------------------------------------------------------------------------
  4151.   def update
  4152.     super
  4153.     call_enable
  4154.     return unless @enabled
  4155.     return unless $scene.is_a?(Scene_Battle)
  4156.     refresh if @current_selected != $scene.selected_battler
  4157.     refresh if @current_active != $scene.active_battler
  4158.     refresh if @current_turn != $game_troop.turn_count
  4159.   end
  4160.  
  4161.   #--------------------------------------------------------------------------
  4162.   # call_enable
  4163.   #--------------------------------------------------------------------------
  4164.   def call_enable
  4165.     return if @enabled
  4166.     if Input.press?(Input::CTRL) and Input.press?(Input::ALT)
  4167.       @enabled = true
  4168.       Sound.play_decision
  4169.     end
  4170.   end
  4171.  
  4172.   #--------------------------------------------------------------------------
  4173.   # refresh
  4174.   #--------------------------------------------------------------------------
  4175.   def refresh
  4176.     self.contents.clear
  4177.     self.contents.font.size = 16
  4178.     dw = contents.width/4
  4179.     @current_selected = $scene.selected_battler
  4180.     @current_active = $scene.active_battler
  4181.     @current_turn = $game_troop.turn_count
  4182.     if @current_turn != nil
  4183.       turn = @current_turn
  4184.       text = sprintf("Turn: %s", turn)
  4185.       self.contents.draw_text(dw*0, 0, dw, WLH, text, 0)
  4186.     end
  4187.     if @current_selected != nil
  4188.       name = @current_selected.name
  4189.       text = sprintf("Sel: %s", name)
  4190.       self.contents.draw_text(dw*2, 0, dw, WLH, text, 0)
  4191.     end
  4192.     if @current_active != nil
  4193.       name = @current_active.name
  4194.       text = sprintf("Act: %s", name)
  4195.       self.contents.draw_text(dw*3, 0, dw, WLH, text, 0)
  4196.     end
  4197.   end
  4198.  
  4199. end # Window_BattleDebug
  4200.  
  4201. #==============================================================================
  4202. # Window_TargetEnemy
  4203. #==============================================================================
  4204.  
  4205. class Window_TargetEnemy < Window_Command
  4206.  
  4207.   #--------------------------------------------------------------------------
  4208.   # overwrite method: initialize
  4209.   #--------------------------------------------------------------------------
  4210.   def initialize
  4211.     commands = []
  4212.     super(416, commands, 8, 1)
  4213.   end
  4214.  
  4215.   #--------------------------------------------------------------------------
  4216.   # overwrite method: refresh
  4217.   #--------------------------------------------------------------------------
  4218.   def refresh
  4219.     @commands = []
  4220.     @enemies = []
  4221.     for enemy in $game_troop.members
  4222.       next unless enemy.exist?
  4223.       @commands.push(enemy.name)
  4224.       @enemies.push(enemy)
  4225.     end
  4226.     @enemies.sort! { |a,b| a.screen_x <=> b.screen_x }
  4227.     self.contents.clear
  4228.     @item_max = @commands.size
  4229.     for i in 0...@item_max; draw_item(i); end
  4230.   end
  4231.  
  4232. end # Window_TargetEnemy
  4233.  
  4234. #===============================================================================
  4235. # Window_TargetHelp
  4236. #===============================================================================
  4237.  
  4238. class Window_TargetHelp < Window_Base
  4239.  
  4240.   #--------------------------------------------------------------------------
  4241.   # initialize
  4242.   #--------------------------------------------------------------------------
  4243.   def initialize
  4244.     super(0, 0, Graphics.width, 56)
  4245.     refresh
  4246.   end
  4247.  
  4248.   #--------------------------------------------------------------------------
  4249.   # refresh
  4250.   #--------------------------------------------------------------------------
  4251.   def refresh(target = nil, battler = nil)
  4252.     self.contents.clear
  4253.     return if target == nil
  4254.     if draw_unique_name?(battler)
  4255.       draw_obj_selection(battler)
  4256.       return
  4257.     end
  4258.     name = target.name
  4259.     if $imported["EnemyLevels"] and target.enemy?
  4260.       name = sprintf(YEZ::ENEMY_LEVEL::LEVEL_TEXT, target.level, name) #edit
  4261.     end
  4262.     self.contents.draw_text(0, 0, contents.width, WLH, name, 1)
  4263.   end
  4264.  
  4265.   #--------------------------------------------------------------------------
  4266.   # draw_unique_name?
  4267.   #--------------------------------------------------------------------------
  4268.   def draw_unique_name?(battler)
  4269.     return false if battler == nil
  4270.     return false if battler.action == nil
  4271.     return false if battler.action.attack?
  4272.     obj = battler.action.skill if battler.action.skill?
  4273.     obj = battler.action.item if battler.action.item?
  4274.     if $scene.atb?
  4275.       case battler.action.atb_queue_kind
  4276.       when 0; return false
  4277.       when 1; obj = $data_skills[battler.action.atb_queue_basic]
  4278.       when 2; obj = $data_items[battler.action.atb_queue_basic]
  4279.       end
  4280.     end
  4281.     return false if obj == nil
  4282.     return true if obj.target_text != nil
  4283.     return true if !obj.need_selection?
  4284.     return false
  4285.   end
  4286.  
  4287.   #--------------------------------------------------------------------------
  4288.   # draw_obj_selection
  4289.   #--------------------------------------------------------------------------
  4290.   def draw_obj_selection(battler)
  4291.     obj = battler.action.skill if battler.action.skill?
  4292.     obj = battler.action.item if battler.action.item?
  4293.     if $scene.atb?
  4294.       case battler.action.atb_queue_kind
  4295.       when 1; obj = $data_skills[battler.action.atb_queue_basic]
  4296.       when 2; obj = $data_items[battler.action.atb_queue_basic]
  4297.       end
  4298.     end
  4299.     if obj.for_user?
  4300.       text = YEM::BATTLE_ENGINE::TARGET_WINDOW[:user]
  4301.     elsif obj.for_friend?
  4302.       if obj.for_one?
  4303.         text = YEM::BATTLE_ENGINE::TARGET_WINDOW[:actor]
  4304.       else
  4305.         text = YEM::BATTLE_ENGINE::TARGET_WINDOW[:actors]
  4306.       end
  4307.       if obj.for_dead_friend?
  4308.         text = sprintf(YEM::BATTLE_ENGINE::TARGET_WINDOW[:dead], text)
  4309.       end
  4310.     elsif obj.for_opponent?
  4311.       if obj.for_one?
  4312.         text = YEM::BATTLE_ENGINE::TARGET_WINDOW[:enemy]
  4313.       else
  4314.         text = YEM::BATTLE_ENGINE::TARGET_WINDOW[:enemies]
  4315.       end
  4316.     else
  4317.       text = YEM::BATTLE_ENGINE::TARGET_WINDOW[:none]
  4318.       self.contents.draw_text(0, 0, contents.width, WLH, text, 1)
  4319.       return
  4320.     end
  4321.     if obj.for_random?
  4322.       n = obj.random_targets
  4323.       text = sprintf(YEM::BATTLE_ENGINE::TARGET_WINDOW[:random], n, text)
  4324.     end
  4325.     if obj.for_all?
  4326.       text = sprintf(YEM::BATTLE_ENGINE::TARGET_WINDOW[:all], text)
  4327.     end
  4328.     if obj.target_text != nil
  4329.       name = ""
  4330.       if $scene.target_enemy_window != nil
  4331.         name = $scene.target_enemy_window.enemy.name
  4332.         if $imported["EnemyLevels"] and $scene.target_enemy_window.enemy.enemy?
  4333.           level = $scene.target_enemy_window.enemy.level
  4334.           name = sprintf(YEZ::ENEMY_LEVEL::LEVEL_TEXT, level, name) #edit
  4335.         end
  4336.       elsif $scene.target_actor_window != nil
  4337.         name = $scene.target_enemy_window.actor.name
  4338.       end
  4339.       text = sprintf(obj.target_text, name)
  4340.     end
  4341.     self.contents.draw_text(0, 0, contents.width, WLH, text, 1)
  4342.   end
  4343.  
  4344. end # Window_TargetHelp
  4345.  
  4346. #===============================================================================
  4347. # Window_BattleMessageMelody
  4348. #===============================================================================
  4349.  
  4350. class Window_BattleMessageMelody < Window_BattleMessage
  4351.  
  4352.   #--------------------------------------------------------------------------
  4353.   # public instance variables
  4354.   #--------------------------------------------------------------------------
  4355.   attr_accessor :align
  4356.   attr_accessor :icon
  4357.  
  4358.   #--------------------------------------------------------------------------
  4359.   # initialize
  4360.   #--------------------------------------------------------------------------
  4361.   def initialize
  4362.     super
  4363.     self.x = 0
  4364.     self.y = 32
  4365.     self.z = 300
  4366.     self.back_opacity = 0
  4367.     self.opacity = 0
  4368.     self.windowskin = Cache.system("Window")
  4369.     @align = YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:alignment]
  4370.     create_background_sprite
  4371.     change_viewport($scene.spriteset.viewportB)
  4372.   end
  4373.  
  4374.   #--------------------------------------------------------------------------
  4375.   # dispose
  4376.   #--------------------------------------------------------------------------
  4377.   def dispose
  4378.     super
  4379.     @leftsprite.bitmap.dispose
  4380.     @leftsprite.dispose
  4381.     @centersprite.bitmap.dispose
  4382.     @centersprite.dispose
  4383.     @rightsprite.bitmap.dispose
  4384.     @rightsprite.dispose
  4385.   end
  4386.  
  4387.   #--------------------------------------------------------------------------
  4388.   # create_background_sprite
  4389.   #--------------------------------------------------------------------------
  4390.   def create_background_sprite
  4391.     gw = Graphics.width
  4392.     g1 = YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:gradient1]
  4393.     g2 = YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:gradient2]
  4394.     #--- Create Left Aligned Sprite ---
  4395.     bitmap = Bitmap.new(gw, 112)
  4396.     bitmap.gradient_fill_rect(0, 16, gw, 96, g1, g2)
  4397.     @leftsprite = Sprite.new(self.viewport)
  4398.     @leftsprite.bitmap = bitmap
  4399.     @leftsprite.x = self.x
  4400.     @leftsprite.y = self.y
  4401.     @leftsprite.z = self.z - 1
  4402.     @leftsprite.src_rect.height = 16
  4403.     #--- Create Center Aligned Sprite ---
  4404.     bitmap = Bitmap.new(gw, 112)
  4405.     bitmap.gradient_fill_rect(0, 16, gw/2, 96, g2, g1)
  4406.     bitmap.gradient_fill_rect(gw/2, 16, gw/2, 96, g1, g2)
  4407.     @centersprite = Sprite.new(self.viewport)
  4408.     @centersprite.bitmap = bitmap
  4409.     @centersprite.x = self.x
  4410.     @centersprite.y = self.y
  4411.     @centersprite.z = self.z - 1
  4412.     @centersprite.src_rect.height = 16
  4413.     #--- Create Right Aligned Sprite ---
  4414.     bitmap = Bitmap.new(gw, 112)
  4415.     bitmap.gradient_fill_rect(0, 16, gw, 96, g2, g1)
  4416.     @rightsprite = Sprite.new(self.viewport)
  4417.     @rightsprite.bitmap = bitmap
  4418.     @rightsprite.x = self.x
  4419.     @rightsprite.y = self.y
  4420.     @rightsprite.z = self.z - 1
  4421.     @rightsprite.src_rect.height = 16
  4422.     #--- Hide Sprites ---
  4423.     @leftsprite.opacity = 0
  4424.     @centersprite.opacity = 0
  4425.     @rightsprite.opacity = 0
  4426.   end
  4427.  
  4428.   #--------------------------------------------------------------------------
  4429.   # change_viewport
  4430.   #--------------------------------------------------------------------------
  4431.   def change_viewport(viewport)
  4432.     return if self.viewport == viewport
  4433.     self.viewport = viewport
  4434.     @leftsprite.viewport = self.viewport
  4435.     @centersprite.viewport = self.viewport
  4436.     @rightsprite.viewport = self.viewport
  4437.   end
  4438.  
  4439.   #--------------------------------------------------------------------------
  4440.   # new_page
  4441.   #--------------------------------------------------------------------------
  4442.   def new_page
  4443.     super
  4444.     self.windowskin = Cache.system("Window")
  4445.     self.contents.font.shadow = true
  4446.     self.contents.font.color = normal_color
  4447.   end
  4448.  
  4449.   #--------------------------------------------------------------------------
  4450.   # clear
  4451.   #--------------------------------------------------------------------------
  4452.   def clear
  4453.     super
  4454.     @icon = nil
  4455.   end
  4456.  
  4457.   #--------------------------------------------------------------------------
  4458.   # refresh
  4459.   #--------------------------------------------------------------------------
  4460.   def refresh
  4461.     update
  4462.     super
  4463.   end
  4464.  
  4465.   #--------------------------------------------------------------------------
  4466.   # update
  4467.   #--------------------------------------------------------------------------
  4468.   def update
  4469.     return if @anti_update
  4470.     if self.viewport != nil
  4471.       #---
  4472.       self.x = self.viewport.ox
  4473.       @leftsprite.x = @centersprite.x = @rightsprite.x = self.x
  4474.       #---
  4475.       self.y = self.viewport.oy + 32
  4476.       @leftsprite.y = @centersprite.y = @rightsprite.y = self.y
  4477.       #---
  4478.     end
  4479.     if self.visible and (@lines.size > 0) or
  4480.     (@text != nil or self.pause or @index > -1)
  4481.       if @text != nil
  4482.         lines = 4
  4483.       else
  4484.         lines = (!self.pause or @index > -1) ? @lines.size : 4
  4485.       end
  4486.       case @align
  4487.       when 1
  4488.         @centersprite.opacity += YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:opacity]
  4489.         @centersprite.src_rect.height = 16 + (lines * 24)
  4490.       when 2
  4491.         @rightsprite.opacity += YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:opacity]
  4492.         @rightsprite.src_rect.height = 16 + (lines * 24)
  4493.       else
  4494.         @leftsprite.opacity += YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:opacity]
  4495.         @leftsprite.src_rect.height = 16 + (lines * 24)
  4496.       end
  4497.       @countdown = 8
  4498.     elsif @countdown != nil and @countdown > 0
  4499.       @countdown -= 1
  4500.     elsif @countdown != nil
  4501.       @centersprite.opacity -= YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:opacity]
  4502.       @leftsprite.opacity -= YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:opacity]
  4503.       @rightsprite.opacity -= YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:opacity]
  4504.     end
  4505.     super
  4506.   end
  4507.  
  4508.   #--------------------------------------------------------------------------
  4509.   # draw_line
  4510.   #--------------------------------------------------------------------------
  4511.   def draw_line(index)
  4512.     rect = Rect.new(0, 0, 0, 0)
  4513.     rect.x += 4
  4514.     rect.y += index * WLH
  4515.     rect.width = contents.width - 8
  4516.     rect.height = WLH
  4517.     dx = rect.x; dy = rect.y; dw = rect.width; dh = rect.height
  4518.     self.contents.clear_rect(rect)
  4519.     if $imported["CustomMessageMelody"] and $game_message.busy
  4520.       self.contents.font.name = YEM::MESSAGE::MESSAGE_WINDOW_FONT
  4521.     else
  4522.       self.contents.font.name = Font.default_name
  4523.     end
  4524.     self.contents.font.color = normal_color
  4525.     if index == 0 and (@icon != nil and @icon != 0)
  4526.       fx = contents.text_size(@lines[index]).width
  4527.       case @align
  4528.       when 0 # Left Aligned
  4529.         draw_icon(@icon, dx, dy)
  4530.         dx += 24
  4531.       when 1 # Center Aligned
  4532.         draw_icon(@icon, (dw-fx)/2-12, dy)
  4533.         dx += 12
  4534.       when 2 # Right Aligned
  4535.         draw_icon(@icon, dw-fx-24, dy)
  4536.       end
  4537.     end
  4538.     self.contents.draw_text(dx, dy, dw, dh, @lines[index], @align)
  4539.   end
  4540.  
  4541. end # Window_BattleMessageMelody
  4542.  
  4543. #===============================================================================
  4544. # Window_BattleStatus
  4545. #===============================================================================
  4546.  
  4547. class Window_BattleStatus < Window_Selectable
  4548.  
  4549.   #--------------------------------------------------------------------------
  4550.   # public instance variables
  4551.   #--------------------------------------------------------------------------
  4552.   attr_accessor :battle_refresh_call
  4553.   attr_accessor :frozen_cursor
  4554.   attr_accessor :highlight_all
  4555.   attr_accessor :highlight_user
  4556.   attr_accessor :highlight_none
  4557.   attr_accessor :highlight_dead
  4558.   attr_accessor :target_highlight
  4559.  
  4560.   #--------------------------------------------------------------------------
  4561.   # overwrite method: initialize
  4562.   #--------------------------------------------------------------------------
  4563.   def initialize(minimum = false)
  4564.     super(0, 0, Graphics.width - 128, 128)
  4565.     max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
  4566.     @item_max = [$game_party.members.size, max_members].max
  4567.     @column_max = @item_max
  4568.     @minimum = minimum
  4569.     @current_party = $game_party.members
  4570.     recreate unless @miniature
  4571.     self.active = false
  4572.   end
  4573.  
  4574.   #--------------------------------------------------------------------------
  4575.   # actor
  4576.   #--------------------------------------------------------------------------
  4577.   def actor; return $game_party.members[self.index]; end
  4578.  
  4579.   #--------------------------------------------------------------------------
  4580.   # recreate
  4581.   #--------------------------------------------------------------------------
  4582.   def recreate
  4583.     max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
  4584.     @item_max = [$game_party.members.size, max_members].max
  4585.     @item_max = 1 if @minitature
  4586.     @updating = -1
  4587.     @current_party = $game_party.members
  4588.     @current_hp = {}; @current_hp_gauge = {}; @maxhp = {}
  4589.     @current_mp = {}; @current_mp_gauge = {}; @maxmp = {}
  4590.     @current_rage = {}; @current_rage_gauge = {}; @max_rage = {}
  4591.     temp_rect = item_rect(0)
  4592.     @hp_gauge_width = temp_rect.width-4
  4593.     @mp_gauge_width = temp_rect.width-4
  4594.     @rg_gauge_width = temp_rect.width-4
  4595.     for i in 0...@current_party.size
  4596.       actor = $game_party.members[i]
  4597.       #--
  4598.       @current_hp[i] = actor.hp
  4599.       maxhp = [[actor.maxhp, actor.base_maxhp, 1].max, actor.maxhp_limit].min
  4600.       @current_hp_gauge[i] = (actor.hp * @hp_gauge_width / maxhp)
  4601.       @maxhp[i] = maxhp
  4602.       #--
  4603.       maxmp = [[actor.maxmp, actor.base_maxmp, 1].max, actor.maxmp_limit].min
  4604.       @current_mp[i] = actor.mp
  4605.       @current_mp_gauge[i] = (actor.mp * @mp_gauge_width / [actor.maxmp,1].max)
  4606.       @maxmp[i] = maxmp
  4607.       #---
  4608.       actor.rage = 0 if actor.rage == nil
  4609.       @current_rage[i] = actor.rage
  4610.       @current_rage_gauge[i] = actor.rage * @rg_gauge_width / actor.max_rage
  4611.       @max_rage[i] = actor.max_rage
  4612.     end
  4613.     refresh
  4614.   end
  4615.  
  4616.   #--------------------------------------------------------------------------
  4617.   # new method: update
  4618.   #--------------------------------------------------------------------------
  4619.   def update
  4620.     super unless prevent_left_right?
  4621.     redraw if @last_index != self.index
  4622.     redraw if @battle_refresh_call
  4623.     return unless @minimum
  4624.     recreate if @current_party != $game_party.members
  4625.     return unless $scene.is_a?(Scene_Battle)
  4626.     for member in $game_party.members; redraw if member.update_states; end
  4627.     redraw if @last_active_battler != $scene.active_battler
  4628.   end
  4629.  
  4630.   #--------------------------------------------------------------------------
  4631.   # new method: prevent_left_right
  4632.   #--------------------------------------------------------------------------
  4633.   def prevent_left_right?
  4634.     return true if (@frozen_cursor and (Input.repeat?(Input::LEFT) or
  4635.       Input.repeat?(Input::RIGHT)))
  4636.     if Input.repeat?(Input::LEFT) and $game_party.members[self.index-1] == nil
  4637.       return true
  4638.     end
  4639.     if Input.repeat?(Input::RIGHT) and $game_party.members[self.index+1] == nil
  4640.       return true
  4641.     end
  4642.     return false
  4643.   end
  4644.  
  4645.   #--------------------------------------------------------------------------
  4646.   # new method: redraw
  4647.   #--------------------------------------------------------------------------
  4648.   def redraw
  4649.     return unless $scene.is_a?(Scene_Battle)
  4650.     @last_index = self.index
  4651.     @last_active_battler = $scene.active_battler
  4652.     @battle_refresh_call = false
  4653.     refresh
  4654.   end
  4655.  
  4656.   #--------------------------------------------------------------------------
  4657.   # overwrite method: refresh
  4658.   #--------------------------------------------------------------------------
  4659.   def refresh
  4660.     return if @miniature
  4661.     max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
  4662.     @item_max = [$game_party.members.size, max_members].max
  4663.     @column_max = @item_max
  4664.     for i in 0...@item_max; draw_item(i); end
  4665.   end
  4666.  
  4667.   #--------------------------------------------------------------------------
  4668.   # overwrite method: draw_item
  4669.   #--------------------------------------------------------------------------
  4670.   def draw_item(index)
  4671.     rect = item_rect(index)
  4672.     self.contents.clear_rect(rect)
  4673.     actor = $game_party.members[index]
  4674.     return if actor == nil
  4675.     draw_member_face(actor, rect.clone)
  4676.     draw_member_action(actor, rect.clone)
  4677.     return if @minimum
  4678.     draw_member_name(actor, rect.clone)
  4679.     draw_member_states(actor, rect.clone)
  4680.     draw_member_hp(actor, rect.clone)
  4681.     draw_member_mp(actor, rect.clone)
  4682.     draw_member_rage(actor, rect.clone)
  4683.   end
  4684.  
  4685.   #--------------------------------------------------------------------------
  4686.   # new method: item_rect
  4687.   #--------------------------------------------------------------------------
  4688.   def item_rect(index)
  4689.     rect = Rect.new(0, 0, 0, 0)
  4690.     rect.width = contents.width / @item_max
  4691.     rect.height = contents.height
  4692.     rect.x = index * rect.width
  4693.     rect.y = 0
  4694.     return rect
  4695.   end
  4696.  
  4697.   #--------------------------------------------------------------------------
  4698.   # new method: draw_member_face
  4699.   #--------------------------------------------------------------------------
  4700.   def draw_member_face(actor, content_rect)
  4701.     lower_opacity = YEM::BATTLE_ENGINE::PARTY_WINDOW[:face_opacity]
  4702.     opacity = opacity?(actor) ? 255 : lower_opacity
  4703.     face_name = actor.face_name
  4704.     face_index = actor.face_index
  4705.     bitmap = Cache.face(face_name)
  4706.     rect = Rect.new(0, 0, 0, 0)
  4707.     rect.width = [content_rect.width-4, 92].min
  4708.     rect.height = [contents.height-4, 92].min
  4709.     rect.x = face_index % 4 * 96 + (96-rect.width) / 2
  4710.     rect.y = face_index / 4 * 96 + (96-rect.height) / 2
  4711.     self.contents.blt(content_rect.x+2, content_rect.y+2, bitmap, rect, opacity)
  4712.   end
  4713.  
  4714.   #--------------------------------------------------------------------------
  4715.   # new method: draw_member_action
  4716.   #--------------------------------------------------------------------------
  4717.   def draw_member_action(actor, rect)
  4718.     return unless YEM::BATTLE_ENGINE::PARTY_WINDOW[:action_icons]
  4719.     icon = YEM::BATTLE_ENGINE::ICON_MESSAGE[:wait_icon]
  4720.     case actor.action.kind
  4721.     when 0 # Basic
  4722.       case actor.action.basic
  4723.       when 0 # Attack
  4724.         icon = actor.attack_icon
  4725.       when 1 # Guard
  4726.         icon = actor.guard_icon
  4727.       when 2 # Escape
  4728.         icon = YEM::BATTLE_ENGINE::ICON_MESSAGE[:flee_icon]
  4729.       end
  4730.     when 1 # Skill
  4731.       icon = actor.action.skill.icon_index
  4732.     when 2 # Item
  4733.       icon = actor.action.item.icon_index
  4734.     end
  4735.     enabled = actor.action.valid?
  4736.     enabled = false if actor.action.kind == 0 and actor.action.basic == 3
  4737.     if $scene.is_a?(Scene_Battle) and $scene.ctb? and actor.action.guard?
  4738.       icon = actor.guard_icon
  4739.       enabled = true
  4740.     end
  4741.     draw_icon(icon, rect.x, rect.y, enabled)
  4742.   end
  4743.  
  4744.   #--------------------------------------------------------------------------
  4745.   # new method: opacity?
  4746.   #--------------------------------------------------------------------------
  4747.   def opacity?(actor)
  4748.     return false if actor == nil
  4749.     if $scene.is_a?(Scene_Battle) and $scene.ctb?
  4750.       return true if actor.ctb_active? and !@minimum
  4751.     end
  4752.     return true if self.is_a?(Window_BattleStatus_Mini)
  4753.     return false if actor == nil
  4754.     return false if @highlight_none
  4755.     return true if @highlight_all
  4756.     if @highlight_dead
  4757.       return true if self.index == actor.index and actor.dead?
  4758.       return false
  4759.     end
  4760.     return false if actor.dead?
  4761.     if !@target_highlight and $scene.is_a?(Scene_Battle)
  4762.       return true if actor.active_battler?
  4763.     end
  4764.     if @highlight_user and $scene.is_a?(Scene_Battle)
  4765.       return true if actor == $scene.selected_battler
  4766.     end
  4767.     return false if @highlight_user
  4768.     return true if self.index == actor.index
  4769.     return false if !@minimum
  4770.     return false
  4771.   end
  4772.  
  4773.   #--------------------------------------------------------------------------
  4774.   # new method: draw_member_name
  4775.   #--------------------------------------------------------------------------
  4776.   def draw_member_name(actor, rect)
  4777.     name = actor.name
  4778.     self.contents.font.size = YEM::BATTLE_ENGINE::PARTY_WINDOW[:name_size]
  4779.     dy = rect.y
  4780.     if YEM::BATTLE_ENGINE::PARTY_WINDOW[:action_icons]
  4781.       dx = rect.x+24
  4782.       dw = rect.width-28
  4783.     else
  4784.       dx = rect.x+4
  4785.       dw = rect.width-8
  4786.     end
  4787.     self.contents.font.color = hp_color(actor)
  4788.     self.contents.draw_text(dx, dy, dw, WLH, name)
  4789.   end
  4790.  
  4791.   #--------------------------------------------------------------------------
  4792.   # new method: draw_member_states
  4793.   #--------------------------------------------------------------------------
  4794.   def draw_member_states(actor, rect)
  4795.     dw = [YEM::BATTLE_ENGINE::PARTY_WINDOW[:max_states] * 24, rect.width].min
  4796.     draw_actor_state(actor, rect.x, rect.y + WLH, dw)
  4797.     actor.update_states = false
  4798.   end
  4799.  
  4800.   #--------------------------------------------------------------------------
  4801.   # new method: draw_member_hp
  4802.   #--------------------------------------------------------------------------
  4803.   def draw_member_hp(actor, rect)
  4804.     @updating = -1
  4805.     i = actor.index
  4806.     maxhp = @maxhp[i]
  4807.     dy = WLH * 3 - YEM::BATTLE_ENGINE::PARTY_WINDOW[:stat_size]
  4808.     dx = rect.x + 2
  4809.     self.contents.fill_rect(dx, dy+WLH-8, @hp_gauge_width, 8, gauge_back_color)
  4810.     #---
  4811.     target_gauge = (actor.hp * @hp_gauge_width / maxhp)
  4812.     if @current_hp_gauge[i] > target_gauge
  4813.       @updating = i
  4814.       @current_hp_gauge[i] -= [2, (@current_hp_gauge[i]-target_gauge).abs].min
  4815.       @current_hp_gauge[i] = [@current_hp_gauge[i], 0].max
  4816.       gw = @current_hp_gauge[i]
  4817.       gw = [gw, 3].max if actor.hp > 0
  4818.       gc1 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:hp_dmg_gauge])
  4819.       gc2 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:hp_dmg_gauge])
  4820.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
  4821.       gw = @hp_gauge_width * actor.hp / maxhp
  4822.       gw = [gw, 3].max if actor.hp > 0
  4823.       gc1 = hp_gauge_color1
  4824.       gc2 = hp_gauge_color2
  4825.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
  4826.     elsif @current_hp_gauge[i] < target_gauge
  4827.       @updating = i
  4828.       @current_hp_gauge[i] += [2, (@current_hp_gauge[i]-target_gauge).abs].min
  4829.       @current_hp_gauge[i] = [@current_hp_gauge[i], @hp_gauge_width].min
  4830.       gw = @hp_gauge_width * actor.hp / maxhp
  4831.       gw = [gw, 3].max if actor.hp > 0
  4832.       gc1 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:hp_heal_gauge])
  4833.       gc2 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:hp_heal_gauge])
  4834.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
  4835.       gw = @current_hp_gauge[i]
  4836.       gw = [gw, 3].max if actor.hp > 0
  4837.       gc1 = hp_gauge_color1
  4838.       gc2 = hp_gauge_color2
  4839.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
  4840.     else
  4841.       gw = @current_hp_gauge[i]
  4842.       gw = [gw, 3].max if actor.hp > 0
  4843.       gc1 = hp_gauge_color1
  4844.       gc2 = hp_gauge_color2
  4845.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
  4846.     end
  4847.     #---
  4848.     if maxhp > actor.maxhp
  4849.       gce = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:exhaust_gauge])
  4850.       gbw = @hp_gauge_width * (actor.base_maxhp - actor.maxhp) / maxhp + 1
  4851.       gbc = gauge_back_color
  4852.       self.contents.fill_rect(dx+@hp_gauge_width-gbw-2, dy+WLH-8, gbw, 8, gbc)
  4853.       self.contents.fill_rect(dx+@hp_gauge_width-gbw-1, dy+WLH-7, gbw, 6, gce)
  4854.     end
  4855.     #---
  4856.     if @current_hp[i] != actor.hp
  4857.       @updating = i
  4858.       den = [@hp_gauge_width/3 + rand(@hp_gauge_width/2), 1].max
  4859.       value = [[maxhp/den, (@current_hp[i]-actor.hp).abs].min, 1].max
  4860.       @current_hp[i] += (@current_hp[i] > actor.hp) ? -value : value
  4861.       @current_hp[i] = actor.hp if @current_hp_gauge[i] == target_gauge
  4862.     end
  4863.     #---
  4864.     dy += 4
  4865.     self.contents.font.size = YEM::BATTLE_ENGINE::PARTY_WINDOW[:stat_size]
  4866.     self.contents.font.color = system_color
  4867.     self.contents.draw_text(dx, dy, rect.width-4, WLH, Vocab::hp_a, 0)
  4868.     self.contents.font.color = hp_color(actor)
  4869.     text = @current_hp[i]
  4870.     self.contents.draw_text(dx, dy, rect.width-4, WLH, text, 2)
  4871.     #---
  4872.   end
  4873.  
  4874.   #--------------------------------------------------------------------------
  4875.   # new method: draw_member_mp
  4876.   #--------------------------------------------------------------------------
  4877.   def draw_member_mp(actor, rect)
  4878.     return unless actor.maxmp > 0
  4879.     @updating = -1
  4880.     i = actor.index
  4881.     maxmp = @maxmp[i]
  4882.     dy = WLH * 3 - 2
  4883.     dx = rect.x + 2
  4884.     mp_gw = @mp_gauge_width
  4885.     if actor.use_rage?
  4886.       dx += rect.width/2
  4887.       dx -= 3
  4888.       mp_gw = mp_gw/2+1
  4889.     end
  4890.     self.contents.fill_rect(dx, dy+WLH-8, mp_gw, 8, gauge_back_color)
  4891.     #---
  4892.     target_gauge = (actor.mp * @mp_gauge_width / maxmp)
  4893.     if @current_mp_gauge[i] > target_gauge and !@miniature
  4894.       @updating = i
  4895.       @current_mp_gauge[i] -= [2, (@current_mp_gauge[i]-target_gauge).abs].min
  4896.       @current_mp_gauge[i] = [@current_mp_gauge[i], 0].max
  4897.       gw = @current_mp_gauge[i]
  4898.       gw = gw/2+1 if actor.use_rage?
  4899.       gw = [gw, 3].max if actor.mp > 0
  4900.       gc1 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:mp_dmg_gauge])
  4901.       gc2 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:mp_dmg_gauge])
  4902.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
  4903.       gw = mp_gw * actor.mp / maxmp
  4904.       gw = [gw, 3].max if actor.mp > 0
  4905.       gc1 = mp_gauge_color1
  4906.       gc2 = mp_gauge_color2
  4907.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
  4908.     elsif @current_mp_gauge[i] < target_gauge and !@miniature
  4909.       @updating = i
  4910.       @current_mp_gauge[i] += [2, (@current_mp_gauge[i]-target_gauge).abs].min
  4911.       @current_mp_gauge[i] = [@current_mp_gauge[i], @mp_gauge_width].min
  4912.       gw = mp_gw * actor.mp / maxmp
  4913.       gw = [gw, 3].max if actor.mp > 0
  4914.       gc1 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:mp_heal_gauge])
  4915.       gc2 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:mp_heal_gauge])
  4916.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
  4917.       gw = @current_mp_gauge[i]
  4918.       gw = gw/2+1 if actor.use_rage?
  4919.       gw = [gw, 3].max if actor.mp > 0
  4920.       gc1 = mp_gauge_color1
  4921.       gc2 = mp_gauge_color2
  4922.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
  4923.     else
  4924.       gw = mp_gw * actor.mp / maxmp
  4925.       gw = [gw, 3].max if actor.mp > 0
  4926.       gc1 = mp_gauge_color1
  4927.       gc2 = mp_gauge_color2
  4928.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
  4929.     end
  4930.     #---
  4931.     if actor.base_maxmp > actor.maxmp
  4932.       gce = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:exhaust_gauge])
  4933.       gbw = mp_gw
  4934.       gbw *= (actor.base_maxmp - actor.maxmp) / [actor.base_maxmp, 1].max + 1
  4935.       gbc = gauge_back_color
  4936.       self.contents.fill_rect(dx+mp_gw-gbw-2, dy+WLH-8, gbw, 8, gbc)
  4937.       self.contents.fill_rect(dx+mp_gw-gbw-1, dy+WLH-7, gbw, 6, gce)
  4938.     end
  4939.     #---
  4940.     if @current_mp[i] != actor.mp
  4941.       @updating = i
  4942.       den = [mp_gw/3 + rand(mp_gw/2), 1].max
  4943.       value = [[maxmp/den, (@current_mp[i]-actor.mp).abs].min, 1].max
  4944.       @current_mp[i] += (@current_mp[i] > actor.mp) ? -value : value
  4945.       @current_mp[i] = actor.mp if @current_mp_gauge[i] == target_gauge
  4946.     end
  4947.     #---
  4948.     dy += 4
  4949.     self.contents.font.size = YEM::BATTLE_ENGINE::PARTY_WINDOW[:stat_size]
  4950.     self.contents.font.color = system_color
  4951.     self.contents.draw_text(dx, dy, rect.width-4, WLH, Vocab::mp_a, 0)
  4952.     self.contents.font.color = mp_color(actor)
  4953.     text = @current_mp[i]
  4954.     dw = rect.width-4
  4955.     dw /= 2 if actor.use_rage?
  4956.     self.contents.draw_text(dx, dy, dw, WLH, text, 2)
  4957.     #---
  4958.   end
  4959.  
  4960.   #--------------------------------------------------------------------------
  4961.   # new method: draw_member_rage
  4962.   #--------------------------------------------------------------------------
  4963.   def draw_member_rage(actor, rect)
  4964.     return unless actor.use_rage?
  4965.     @updating = -1
  4966.     i = actor.index
  4967.     max_rage = @max_rage[i]
  4968.     dy = WLH * 3 - 2
  4969.     dx = rect.x + 2
  4970.     rg_gw = @rg_gauge_width
  4971.     rg_gw /= 2 if actor.maxmp > 0
  4972.     self.contents.fill_rect(dx, dy+WLH-8, rg_gw, 8, gauge_back_color)
  4973.     #---
  4974.     target_gauge = (actor.rage * @rg_gauge_width / max_rage)
  4975.     target_gauge += 2 if actor.rage > 0
  4976.     if @current_rage_gauge[i] > target_gauge
  4977.       @updating = i
  4978.       value = [2,(@current_rage_gauge[i]-target_gauge).abs].min
  4979.       @current_rage_gauge[i] -= value
  4980.       @current_rage_gauge[i] = [@current_rage_gauge[i], 0].max
  4981.       gw = @current_rage_gauge[i]
  4982.       gw /= 2 if actor.maxmp > 0
  4983.       gw = [gw, 3].max if actor.rage > 0
  4984.       gc1 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:rg_dmg_gauge])
  4985.       gc2 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:rg_dmg_gauge])
  4986.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
  4987.       gw = rg_gw * actor.rage / max_rage
  4988.       gw = [gw, 3].max if actor.rage > 0
  4989.       gc1 = rage_gauge_color1
  4990.       gc2 = rage_gauge_color2
  4991.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
  4992.     elsif @current_rage_gauge[i] < target_gauge
  4993.       @updating = i
  4994.       value = [2,(@current_rage_gauge[i]-target_gauge).abs].min
  4995.       @current_rage_gauge[i] += value
  4996.       @current_rage_gauge[i] = [@current_rage_gauge[i], rg_gw*2].min
  4997.       gw = rg_gw * actor.rage / max_rage
  4998.       gw = [gw, 3].max if actor.rage > 0
  4999.       gc1 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:rg_heal_gauge])
  5000.       gc2 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:rg_heal_gauge])
  5001.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
  5002.       gw = @current_rage_gauge[i]
  5003.       gw /= 2 if actor.maxmp > 0
  5004.       gw = [gw, 3].max if actor.rage > 0
  5005.       gc1 = rage_gauge_color1
  5006.       gc2 = rage_gauge_color2
  5007.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
  5008.     else
  5009.       gw = @current_rage_gauge[i]
  5010.       gw /= 2 if actor.maxmp > 0
  5011.       gw = [gw, 3].max if actor.rage > 0
  5012.       gc1 = rage_gauge_color1
  5013.       gc2 = rage_gauge_color2
  5014.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, 6, gc1, gc2)
  5015.     end
  5016.     #---
  5017.     if @current_rage[i] != actor.rage
  5018.       @updating = i
  5019.       @current_rage[i] += (@current_rage[i] > actor.rage) ? -1 : 1
  5020.       @current_rage[i] = actor.rage if @current_rage_gauge[i] == target_gauge
  5021.     end
  5022.     #---
  5023.     dy += 4
  5024.     self.contents.font.size = YEM::BATTLE_ENGINE::PARTY_WINDOW[:stat_size]
  5025.     self.contents.font.color = system_color
  5026.     self.contents.draw_text(dx, dy, rect.width/2-2, WLH, Vocab::rage_a, 0)
  5027.     self.contents.font.color = normal_color
  5028.     text = @current_rage[i]
  5029.     dw = rect.width-4
  5030.     dw /= 2 if actor.maxmp > 0
  5031.     self.contents.draw_text(dx, dy, dw, WLH, text, 2)
  5032.     #---
  5033.   end
  5034.  
  5035. end # Window_BattleStatus
  5036.  
  5037. #===============================================================================
  5038. # Window_BattleStatus_Mini
  5039. #===============================================================================
  5040.  
  5041. class Window_BattleStatus_Mini < Window_BattleStatus
  5042.  
  5043.   #--------------------------------------------------------------------------
  5044.   # initialize
  5045.   #--------------------------------------------------------------------------
  5046.   def initialize
  5047.     @miniature = true
  5048.     super
  5049.     self.x = Graphics.width - 128
  5050.     self.y = Graphics.height - 128
  5051.     self.width = 128
  5052.     self.height = 128
  5053.     create_contents
  5054.     recreate
  5055.   end
  5056.  
  5057.   #--------------------------------------------------------------------------
  5058.   # refresh
  5059.   #--------------------------------------------------------------------------
  5060.   def refresh
  5061.     self.contents.clear
  5062.     draw_item($scene.selected_battler.index)
  5063.   end
  5064.  
  5065.   #--------------------------------------------------------------------------
  5066.   # new method: item_rect
  5067.   #--------------------------------------------------------------------------
  5068.   def item_rect(index)
  5069.     rect = Rect.new(0, 0, 96, 96)
  5070.     return rect
  5071.   end
  5072.  
  5073. end # Window_BattleStatus_Mini
  5074.  
  5075. #===============================================================================
  5076. # Window_BattleStatusHP
  5077. #===============================================================================
  5078.  
  5079. class Window_BattleStatusHP < Window_BattleStatus
  5080.  
  5081.   #--------------------------------------------------------------------------
  5082.   # initialize
  5083.   #--------------------------------------------------------------------------
  5084.   def initialize
  5085.     super
  5086.     self.active = false
  5087.     self.back_opacity = 0
  5088.     self.opacity = 0
  5089.   end
  5090.  
  5091.   #--------------------------------------------------------------------------
  5092.   # update
  5093.   #--------------------------------------------------------------------------
  5094.   def update
  5095.     super
  5096.     recreate if @current_party != $game_party.members
  5097.     if @updating >= 0
  5098.       draw_item(@updating)
  5099.       return
  5100.     end
  5101.     for member in $game_party.members
  5102.       draw_item(member.index) if redraw?(member)
  5103.       break if redraw?(member)
  5104.     end
  5105.   end
  5106.  
  5107.   #--------------------------------------------------------------------------
  5108.   # redraw?
  5109.   #--------------------------------------------------------------------------
  5110.   def redraw?(member)
  5111.     i = member.index
  5112.     if member.update_maxhp
  5113.       value = [[member.maxhp, member.base_maxhp, 1].max, member.maxhp_limit].min
  5114.       @maxhp[i] = value
  5115.       member.update_maxhp = nil
  5116.       return true
  5117.     end
  5118.     return true if @current_hp_gauge[i] != (member.hp*@hp_gauge_width/@maxhp[i])
  5119.     return true if @current_hp[i] != member.hp
  5120.     return false
  5121.   end
  5122.  
  5123.   #--------------------------------------------------------------------------
  5124.   # refresh
  5125.   #--------------------------------------------------------------------------
  5126.   def refresh
  5127.     max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
  5128.     @item_max = [$game_party.members.size, max_members].max
  5129.     for i in 0...@item_max; draw_item(i); end
  5130.   end
  5131.  
  5132.   #--------------------------------------------------------------------------
  5133.   # draw_item
  5134.   #--------------------------------------------------------------------------
  5135.   def draw_item(index)
  5136.     rect = item_rect(index)
  5137.     self.contents.clear_rect(rect)
  5138.     actor = $game_party.members[index]
  5139.     return if actor == nil
  5140.     draw_member_name(actor, rect.clone)
  5141.     draw_member_hp(actor, rect.clone)
  5142.   end
  5143.  
  5144. end # Window_BattleStatusHP
  5145.  
  5146. #===============================================================================
  5147. # Window_BattleStatusMP
  5148. #===============================================================================
  5149.  
  5150. class Window_BattleStatusMP < Window_BattleStatus
  5151.  
  5152.   #--------------------------------------------------------------------------
  5153.   # initialize
  5154.   #--------------------------------------------------------------------------
  5155.   def initialize
  5156.     super
  5157.     self.active = false
  5158.     self.back_opacity = 0
  5159.     self.opacity = 0
  5160.   end
  5161.  
  5162.   #--------------------------------------------------------------------------
  5163.   # update
  5164.   #--------------------------------------------------------------------------
  5165.   def update
  5166.     super
  5167.     recreate if @current_party != $game_party.members
  5168.     if @updating >= 0
  5169.       draw_item(@updating)
  5170.       return
  5171.     end
  5172.     for member in $game_party.members
  5173.       draw_item(member.index) if redraw?(member)
  5174.       break if redraw?(member)
  5175.     end
  5176.   end
  5177.  
  5178.   #--------------------------------------------------------------------------
  5179.   # redraw?
  5180.   #--------------------------------------------------------------------------
  5181.   def redraw?(member)
  5182.     i = member.index
  5183.     if member.update_maxmp
  5184.       value = [[member.maxmp, member.base_maxmp, 1].max, member.maxmp_limit].min
  5185.       @maxmp[i] = value
  5186.       member.update_maxmp = nil
  5187.       @first_test = false
  5188.       return true
  5189.     end
  5190.     return true if @current_mp_gauge[i] != (member.mp*@mp_gauge_width/@maxmp[i])
  5191.     return true if @current_mp[i] != member.mp
  5192.     return false
  5193.   end
  5194.  
  5195.   #--------------------------------------------------------------------------
  5196.   # refresh
  5197.   #--------------------------------------------------------------------------
  5198.   def refresh
  5199.     max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
  5200.     @item_max = [$game_party.members.size, max_members].max
  5201.     for i in 0...@item_max; draw_item(i); end
  5202.   end
  5203.  
  5204.   #--------------------------------------------------------------------------
  5205.   # draw_item
  5206.   #--------------------------------------------------------------------------
  5207.   def draw_item(index)
  5208.     rect = item_rect(index)
  5209.     self.contents.clear_rect(rect)
  5210.     actor = $game_party.members[index]
  5211.     return if actor == nil
  5212.     draw_member_mp(actor, rect.clone)
  5213.   end
  5214.  
  5215. end # Window_BattleStatusMP
  5216.  
  5217. #===============================================================================
  5218. # Window_BattleStatusRage
  5219. #===============================================================================
  5220.  
  5221. class Window_BattleStatusRage < Window_BattleStatus
  5222.  
  5223.   #--------------------------------------------------------------------------
  5224.   # initialize
  5225.   #--------------------------------------------------------------------------
  5226.   def initialize
  5227.     super
  5228.     self.active = false
  5229.     self.back_opacity = 0
  5230.     self.opacity = 0
  5231.   end
  5232.  
  5233.   #--------------------------------------------------------------------------
  5234.   # update
  5235.   #--------------------------------------------------------------------------
  5236.   def update
  5237.     super
  5238.     recreate if @current_party != $game_party.members
  5239.     if @updating >= 0
  5240.       draw_item(@updating)
  5241.       return
  5242.     end
  5243.     for member in $game_party.members
  5244.       draw_item(member.index) if redraw?(member)
  5245.       break if redraw?(member)
  5246.     end
  5247.   end
  5248.  
  5249.   #--------------------------------------------------------------------------
  5250.   # redraw?
  5251.   #--------------------------------------------------------------------------
  5252.   def redraw?(member)
  5253.     return false unless member.use_rage?
  5254.     return true if @current_rage[member.index] != member.rage
  5255.     return false
  5256.   end
  5257.  
  5258.   #--------------------------------------------------------------------------
  5259.   # refresh
  5260.   #--------------------------------------------------------------------------
  5261.   def refresh
  5262.     max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
  5263.     @item_max = [$game_party.members.size, max_members].max
  5264.     for i in 0...@item_max; draw_item(i); end
  5265.   end
  5266.  
  5267.   #--------------------------------------------------------------------------
  5268.   # draw_item
  5269.   #--------------------------------------------------------------------------
  5270.   def draw_item(index)
  5271.     rect = item_rect(index)
  5272.     self.contents.clear_rect(rect)
  5273.     actor = $game_party.members[index]
  5274.     return if actor == nil
  5275.     draw_member_rage(actor, rect.clone)
  5276.   end
  5277.  
  5278. end # Window_BattleStatusRage
  5279.  
  5280. #===============================================================================
  5281. # Window_BattleStatusStates
  5282. #===============================================================================
  5283.  
  5284. class Window_BattleStatusStates < Window_BattleStatus
  5285.  
  5286.   #--------------------------------------------------------------------------
  5287.   # initialize
  5288.   #--------------------------------------------------------------------------
  5289.   def initialize
  5290.     super
  5291.     self.active = false
  5292.     self.back_opacity = 0
  5293.     self.opacity = 0
  5294.   end
  5295.  
  5296.   #--------------------------------------------------------------------------
  5297.   # update
  5298.   #--------------------------------------------------------------------------
  5299.   def update
  5300.     super
  5301.     recreate if @current_party != $game_party.members
  5302.     for member in $game_party.members
  5303.       draw_item(member.index) if redraw?(member)
  5304.       break if redraw?(member)
  5305.     end
  5306.   end
  5307.  
  5308.   #--------------------------------------------------------------------------
  5309.   # redraw?
  5310.   #--------------------------------------------------------------------------
  5311.   def redraw?(member)
  5312.     return true if member.update_states
  5313.     return false
  5314.   end
  5315.  
  5316.   #--------------------------------------------------------------------------
  5317.   # refresh
  5318.   #--------------------------------------------------------------------------
  5319.   def refresh
  5320.     max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
  5321.     @item_max = [$game_party.members.size, max_members].max
  5322.     for i in 0...@item_max; draw_item(i); end
  5323.   end
  5324.  
  5325.   #--------------------------------------------------------------------------
  5326.   # draw_item
  5327.   #--------------------------------------------------------------------------
  5328.   def draw_item(index)
  5329.     rect = item_rect(index)
  5330.     self.contents.clear_rect(rect)
  5331.     actor = $game_party.members[index]
  5332.     return if actor == nil
  5333.     draw_member_states(actor, rect.clone)
  5334.   end
  5335.  
  5336. end # Window_BattleStatusStates
  5337.  
  5338. #===============================================================================
  5339. # Window_ComboCounter
  5340. #===============================================================================
  5341.  
  5342. class Window_ComboCounter < Window_Base
  5343.  
  5344.   #--------------------------------------------------------------------------
  5345.   # initialize
  5346.   #--------------------------------------------------------------------------
  5347.   def initialize
  5348.     super(0, -64, Graphics.width, 80)
  5349.     self.back_opacity = 0
  5350.     self.opacity = 0
  5351.     @current = 0
  5352.     @current_active_battler = nil
  5353.     @close_counter = 0
  5354.     @req = YEM::BATTLE_ENGINE::COMBO_WINDOW[:requirehit] - 1
  5355.     @fade_frames  = YEM::BATTLE_ENGINE::COMBO_WINDOW[:fadeframes]
  5356.     @total_sprint = YEM::BATTLE_ENGINE::COMBO_WINDOW[:total_text]
  5357.     @heal_sprint  = YEM::BATTLE_ENGINE::COMBO_WINDOW[:total_heal]
  5358.     @dmg_sprint   = YEM::BATTLE_ENGINE::COMBO_WINDOW[:total_dmg]
  5359.   end
  5360.  
  5361.   #--------------------------------------------------------------------------
  5362.   # update
  5363.   #--------------------------------------------------------------------------
  5364.   def update
  5365.     super
  5366.     return unless $scene.is_a?(Scene_Battle)
  5367.     return if $scene.combo_hits == nil
  5368.     update_combo_damage if $scene.combo_update
  5369.     self.y = [self.y + 4, -14].min if $scene.combo_hits > @req and self.y < -14
  5370.     refresh if @combo_damage != @current
  5371.     return if $scene.combo_hits > @req
  5372.     return if @close_flag
  5373.     @close_counter -= 1
  5374.     return if @close_counter > 0
  5375.     self.y = [self.y - 1, -64].max
  5376.     return unless self.y <= -64
  5377.     self.contents.clear
  5378.     @current = 0
  5379.     @close_flag = true
  5380.   end
  5381.  
  5382.   #--------------------------------------------------------------------------
  5383.   # refresh
  5384.   #--------------------------------------------------------------------------
  5385.   def refresh
  5386.     if @current_active_battler != $scene.active_battler# and !@updating
  5387.       @current_active_battler = $scene.active_battler
  5388.       @combo = $scene.combo_hits
  5389.       @current = 0
  5390.     end
  5391.     return unless $scene.combo_hits > @req# or @updating
  5392.     #---
  5393.     if @combo_damage != @current
  5394.       #maxdmg = @combo_damage
  5395.       #value = [maxdmg/32 + rand(maxdmg/32), 1].max
  5396.       #value = [[value, (@combo_damage-@current).abs].min, 1].max
  5397.       #@current = [@current + value, @combo_damage].min
  5398.       @current = @combo_damage
  5399.     end
  5400.     #@updating = @combo_damage != @current
  5401.     self.contents.clear
  5402.     self.contents.font.color = normal_color
  5403.     self.contents.font.bold = true
  5404.     @combo = [@combo, $scene.combo_hits].max
  5405.     text = sprintf(YEM::BATTLE_ENGINE::COMBO_WINDOW[:combo_text], @combo)
  5406.     self.contents.draw_text(4,WLH*0, contents.width-8, WLH, text, 2)
  5407.     #---
  5408.     update_combo_damage if @combo_direction == nil
  5409.     text = sprintf(@dmg_sprint, @current) if @combo_direction > 0
  5410.     text = sprintf(@heal_sprint, @current) if @combo_direction < 0
  5411.     text = sprintf(@total_sprint, @current) if @combo_direction == 0
  5412.     self.contents.draw_text(4,WLH*1-4, contents.width-8, WLH, text, 2)
  5413.     #---
  5414.     #return unless @updating
  5415.     @close_flag = false
  5416.     @close_counter = @fade_frames
  5417.   end
  5418.  
  5419.   #--------------------------------------------------------------------------
  5420.   # update_combo_damage
  5421.   #--------------------------------------------------------------------------
  5422.   def update_combo_damage
  5423.     $scene.combo_update = false
  5424.     @combo_direction = -1 if $scene.combo_damage < 0
  5425.     @combo_direction = 0 if $scene.combo_damage == 0
  5426.     @combo_direction = 1 if $scene.combo_damage > 0
  5427.     @combo_damage = $scene.combo_damage.abs
  5428.   end
  5429.  
  5430. end # Window_ComboCounter
  5431.  
  5432. #===============================================================================
  5433. # Window_Skill
  5434. #===============================================================================
  5435.  
  5436. class Window_Skill < Window_Selectable
  5437.  
  5438.   #--------------------------------------------------------------------------
  5439.   # public instance variables
  5440.   #--------------------------------------------------------------------------
  5441.   attr_accessor :battle_refresh_call
  5442.  
  5443.   #--------------------------------------------------------------------------
  5444.   # new method: update
  5445.   #--------------------------------------------------------------------------
  5446.   def update
  5447.     if @battle_refresh_call
  5448.       $game_temp.less_spacing = true
  5449.       refresh
  5450.       @battle_refresh_call = false
  5451.       $game_temp.less_spacing = nil
  5452.     end
  5453.     super
  5454.   end
  5455.  
  5456.   #--------------------------------------------------------------------------
  5457.   # overwrite method: refresh
  5458.   #--------------------------------------------------------------------------
  5459.   def refresh
  5460.     @spacing = 4 if $game_temp.less_spacing
  5461.     @data = []
  5462.     for skill in @actor.skills
  5463.       next unless include?(skill) and skill != nil #casha
  5464.       @data.push(skill)
  5465.       if skill.id == @actor.last_skill_id
  5466.         self.index = @data.size - 1 unless @first_time
  5467.       end
  5468.     end
  5469.     @item_max = @data.size
  5470.     self.index = [self.index, @data.size - 1].min
  5471.     create_contents
  5472.     @first_time = true
  5473.     for i in 0...@item_max; draw_item(i); end
  5474.   end
  5475.    
  5476.   #--------------------------------------------------------------------------
  5477.   # new method: include?
  5478.   #--------------------------------------------------------------------------
  5479.   def include?(skill)
  5480.     if skill != nil
  5481.       return false if skill.name == ""
  5482.       return false if $game_temp.in_battle and skill.hide_in_battle
  5483.     end
  5484.     return true
  5485.   end
  5486.  
  5487.   #--------------------------------------------------------------------------
  5488.   # overwrite method: draw_item
  5489.   #--------------------------------------------------------------------------
  5490.   def draw_item(index)
  5491.     rect = item_rect(index)
  5492.     self.contents.clear_rect(rect)
  5493.     skill = @data[index]
  5494.     return if skill == nil
  5495.     enabled = @actor.skill_can_use?(skill)
  5496.     draw_obj_name(skill, rect.clone, enabled)
  5497.     draw_obj_cost(skill, rect.clone, enabled)
  5498.   end
  5499.  
  5500.   #--------------------------------------------------------------------------
  5501.   # new method: draw_obj_name
  5502.   #--------------------------------------------------------------------------
  5503.   def draw_obj_name(obj, rect, enabled)
  5504.     draw_icon(obj.icon_index, rect.x, rect.y, enabled)
  5505.     self.contents.font.size = Font.default_size
  5506.     self.contents.font.color = normal_color
  5507.     self.contents.font.color.alpha = enabled ? 255 : 128
  5508.     rect.width -= 48
  5509.     self.contents.draw_text(rect.x+24, rect.y, rect.width-24, WLH, obj.name)
  5510.   end
  5511.  
  5512.   #--------------------------------------------------------------------------
  5513.   # new method: draw_obj_cost
  5514.   #--------------------------------------------------------------------------
  5515.   def draw_obj_cost(obj, rect, enabled)
  5516.     return unless obj.is_a?(RPG::Skill)
  5517.     return draw_obj_cooldown(obj, rect) if @actor.cooldown(obj) > 0
  5518.     return draw_obj_limited(obj, rect) if @actor.skill_limited?(obj)
  5519.     return if @actor.custom_skill_costs(obj, :calc_cost) <= 0
  5520.     dx = rect.x + rect.width - 48; dy = rect.y
  5521.     if @actor.custom_skill_costs(obj, :use_icon) != 0
  5522.       icon = @actor.custom_skill_costs(obj, :use_icon)
  5523.       draw_icon(icon, rect.x+rect.width-24, rect.y, enabled)
  5524.       text = @actor.custom_skill_costs(obj, :text_cost)
  5525.       dw = 24
  5526.     else
  5527.       cost = @actor.custom_skill_costs(obj, :text_cost)
  5528.       text = @actor.custom_skill_costs(obj, :suffix)
  5529.       text = sprintf(text, cost)
  5530.       dw = 44
  5531.     end
  5532.     self.contents.font.size = @actor.custom_skill_costs(obj, :font_size)
  5533.     colour_id = @actor.custom_skill_costs(obj, :colour)
  5534.     self.contents.font.color = text_color(colour_id)
  5535.     self.contents.font.color.alpha = enabled ? 255 : 128
  5536.     self.contents.draw_text(dx, dy, dw, WLH, text, 2)
  5537.   end
  5538.  
  5539.   #--------------------------------------------------------------------------
  5540.   # new method: draw_obj_cooldown
  5541.   #--------------------------------------------------------------------------
  5542.   def draw_obj_cooldown(obj, rect, enabled = false)
  5543.     hash = YEM::BATTLE_ENGINE::SKILL_SETTINGS
  5544.     dx = rect.x + rect.width - 48; dy = rect.y
  5545.     if Icon.cooldown != 0
  5546.       draw_icon(Icon.cooldown, rect.x+rect.width-24, rect.y, enabled)
  5547.       text = @actor.cooldown(obj)
  5548.       dw = 24
  5549.     else
  5550.       cost = @actor.cooldown(obj)
  5551.       text = hash[:cooldown_suffix]
  5552.       text = sprintf(text, cost)
  5553.       dw = 44
  5554.     end
  5555.     self.contents.font.size = hash[:cooldown_size]
  5556.     colour_id = hash[:cooldown_colour]
  5557.     self.contents.font.color = text_color(colour_id)
  5558.     self.contents.font.color.alpha = enabled ? 255 : 128
  5559.     self.contents.draw_text(dx, dy, dw, WLH, text, 2)
  5560.   end
  5561.  
  5562.   #--------------------------------------------------------------------------
  5563.   # new method: draw_obj_limited
  5564.   #--------------------------------------------------------------------------
  5565.   def draw_obj_limited(obj, rect, enabled = false)
  5566.     hash = YEM::BATTLE_ENGINE::SKILL_SETTINGS
  5567.     dx = rect.x + rect.width - 48; dy = rect.y
  5568.     text = hash[:limited_text]
  5569.     if Icon.cooldown != 0
  5570.       draw_icon(Icon.limited_use, rect.x+rect.width-24, rect.y, enabled)
  5571.       dw = 24
  5572.     else
  5573.       dw = 24
  5574.     end
  5575.     self.contents.font.size = hash[:limited_size]
  5576.     colour_id = hash[:limited_colour]
  5577.     self.contents.font.color = text_color(colour_id)
  5578.     self.contents.font.color.alpha = enabled ? 255 : 128
  5579.     self.contents.draw_text(dx, dy, dw, WLH, text, 2)
  5580.   end
  5581.  
  5582. end # Window_Skill
  5583.  
  5584. #===============================================================================
  5585. # Window_Item
  5586. #===============================================================================
  5587.  
  5588. class Window_Item < Window_Selectable
  5589.  
  5590.   #--------------------------------------------------------------------------
  5591.   # public instance variables
  5592.   #--------------------------------------------------------------------------
  5593.   attr_accessor :battle_refresh_call
  5594.  
  5595.   #--------------------------------------------------------------------------
  5596.   # new method: update
  5597.   #--------------------------------------------------------------------------
  5598.   def update
  5599.     if @battle_refresh_call
  5600.       $game_temp.less_spacing = true
  5601.       refresh
  5602.       @battle_refresh_call = false
  5603.       $game_temp.less_spacing = nil
  5604.     end
  5605.     super
  5606.   end
  5607.  
  5608.   #--------------------------------------------------------------------------
  5609.   # overwrite method: include
  5610.   #--------------------------------------------------------------------------
  5611.   def include?(item)
  5612.     return false if item == nil
  5613.     return false if $game_temp.in_battle and !$game_party.item_can_use?(item)
  5614.     return false if item.name == ""
  5615.     return true
  5616.   end
  5617.  
  5618.   #--------------------------------------------------------------------------
  5619.   # overwrite method: refresh
  5620.   #--------------------------------------------------------------------------
  5621.   def refresh
  5622.     @spacing = 4 if $game_temp.less_spacing
  5623.     @data = []
  5624.     for item in $game_party.items
  5625.       next unless include?(item)
  5626.       @data.push(item)
  5627.       if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
  5628.         self.index = @data.size - 1 unless @first_time
  5629.       end
  5630.     end
  5631.     @data.push(nil) if include?(nil)
  5632.     @item_max = @data.size
  5633.     create_contents
  5634.     @first_time = true
  5635.     for i in 0...@item_max; draw_item(i); end
  5636.   end
  5637.  
  5638.   #--------------------------------------------------------------------------
  5639.   # alias method: enable?
  5640.   #--------------------------------------------------------------------------
  5641.   alias enable_window_item_bem enable? unless $@
  5642.   def enable?(item)
  5643.     if $scene.is_a?(Scene_Battle) and $scene.selected_battler != nil
  5644.       return $scene.selected_battler.item_can_use?(item)
  5645.     end
  5646.     return enable_window_item_bem(item)
  5647.   end
  5648.  
  5649.   #--------------------------------------------------------------------------
  5650.   # overwrite method: draw_item
  5651.   #--------------------------------------------------------------------------
  5652.   def draw_item(index)
  5653.     rect = item_rect(index)
  5654.     self.contents.clear_rect(rect)
  5655.     item = @data[index]
  5656.     return if item == nil
  5657.     enabled = enable?(item)
  5658.     draw_obj_name(item, rect.clone, enabled)
  5659.     draw_obj_charges(item, rect.clone, enabled)
  5660.     draw_obj_total(item, rect.clone, enabled)
  5661.   end
  5662.  
  5663.   #--------------------------------------------------------------------------
  5664.   # new method: draw_obj_name
  5665.   #--------------------------------------------------------------------------
  5666.   def draw_obj_name(obj, rect, enabled)
  5667.     draw_icon(obj.icon_index, rect.x, rect.y, enabled)
  5668.     self.contents.font.size = Font.default_size
  5669.     self.contents.font.color = normal_color
  5670.     self.contents.font.color.alpha = enabled ? 255 : 128
  5671.     rect.width -= 48
  5672.     self.contents.draw_text(rect.x+24, rect.y, rect.width-24, WLH, obj.name)
  5673.   end
  5674.  
  5675.   #--------------------------------------------------------------------------
  5676.   # new method: draw_obj_charges
  5677.   #--------------------------------------------------------------------------
  5678.   def draw_obj_charges(obj, rect, enabled)
  5679.     return unless obj.is_a?(RPG::Item)
  5680.     return unless obj.consumable
  5681.     return if obj.charges <= 1
  5682.     $game_party.item_charges = {} if $game_party.item_charges == nil
  5683.     $game_party.item_charges[obj.id] = obj.charges if
  5684.       $game_party.item_charges[obj.id] == nil
  5685.     charges = $game_party.item_charges[obj.id]
  5686.     dx = rect.x; dy = rect.y + WLH/3
  5687.     self.contents.font.size = YEM::BATTLE_ENGINE::ITEM_SETTINGS[:charge]
  5688.     self.contents.font.color = normal_color
  5689.     self.contents.font.color.alpha = enabled ? 255 : 128
  5690.     self.contents.draw_text(dx, dy, 24, WLH * 2/3, charges, 2)
  5691.     self.contents.font.size = Font.default_size
  5692.   end
  5693.  
  5694.   #--------------------------------------------------------------------------
  5695.   # new method: draw_obj_total
  5696.   #--------------------------------------------------------------------------
  5697.   def draw_obj_total(obj, rect, enabled)
  5698.     hash = YEM::BATTLE_ENGINE::ITEM_SETTINGS
  5699.     number = $game_party.item_number(obj)
  5700.     dx = rect.x + rect.width - 36; dy = rect.y; dw = 32
  5701.     text = sprintf(hash[:text], number)
  5702.     self.contents.font.size = hash[:size]
  5703.     self.contents.font.color = text_color(hash[:colour])
  5704.     self.contents.font.color.alpha = enabled ? 255 : 128
  5705.     self.contents.draw_text(dx, dy, dw, WLH, text, 2)
  5706.   end
  5707.  
  5708. end # Window_Item
  5709.  
  5710. #===============================================================================
  5711. # Window_PartyCommand
  5712. #===============================================================================
  5713.  
  5714. class Window_PartyCommand < Window_Command
  5715.  
  5716.   #--------------------------------------------------------------------------
  5717.   # overwrite method: initialize
  5718.   #--------------------------------------------------------------------------
  5719.   def initialize
  5720.     array = create_command_list
  5721.     super(128, array)
  5722.     self.height = 128
  5723.     self.active = false
  5724.   end
  5725.  
  5726.   #--------------------------------------------------------------------------
  5727.   # item
  5728.   #--------------------------------------------------------------------------
  5729.   def item; return @data[self.index]; end
  5730.  
  5731.   #--------------------------------------------------------------------------
  5732.   # new method: create_command_list
  5733.   #--------------------------------------------------------------------------
  5734.   def create_command_list
  5735.     @data = []; array = []
  5736.     for command in YEM::BATTLE_ENGINE::PARTY_COMMANDS
  5737.       case command
  5738.       when :fight
  5739.         array.push(Vocab.fight)
  5740.       when :execute
  5741.         next unless $scene.dtb?
  5742.         vocab = YEM::BATTLE_ENGINE::PARTY_VOCAB[command]
  5743.         array.push(vocab)
  5744.       when :status, :option
  5745.         vocab = YEM::BATTLE_ENGINE::PARTY_VOCAB[command]
  5746.         array.push(vocab)
  5747.       when :escape
  5748.         next unless $scene.dtb? or $scene.ptb?
  5749.         array.push(Vocab.escape)
  5750.       when :turnskip
  5751.         next unless $scene.ptb?
  5752.         vocab = YEM::BATTLE_ENGINE::PARTY_VOCAB[command]
  5753.         array.push(vocab)
  5754.       when :atb_type
  5755.         next unless $scene.atb?
  5756.         array.push("ATB_COMMAND_TYPE")
  5757.       when :atb_speed
  5758.         next unless $scene.atb?
  5759.         array.push("ATB_COMMAND_SPEED")
  5760.       else; next
  5761.       end
  5762.       @data.push(command)
  5763.     end
  5764.     return array
  5765.   end
  5766.  
  5767.   #--------------------------------------------------------------------------
  5768.   # draw_item
  5769.   #--------------------------------------------------------------------------
  5770.   def draw_item(index, enabled = true)
  5771.     rect = item_rect(index)
  5772.     rect.x += 4
  5773.     rect.width -= 8
  5774.     enabled = enabled?(@data[index])
  5775.     self.contents.clear_rect(rect)
  5776.     self.contents.font.color = normal_color
  5777.     self.contents.font.color.alpha = enabled ? 255 : 128
  5778.     text = @commands[index]
  5779.     #---
  5780.     case text
  5781.     when "ATB_COMMAND_TYPE"
  5782.       case $game_variables[YEM::BATTLE_ENGINE::OPTIONS[:atb_avariable]]
  5783.       when 0; key = :atb_t0
  5784.       when 1; key = :atb_t1
  5785.       when 2; key = :atb_t2
  5786.       when 3; key = :atb_t3
  5787.       else; return
  5788.       end
  5789.       text = YEM::BATTLE_ENGINE::PARTY_VOCAB[key]
  5790.     when "ATB_COMMAND_SPEED"
  5791.       text = YEM::BATTLE_ENGINE::PARTY_VOCAB[:atb_spd]
  5792.       variable = YEM::BATTLE_ENGINE::OPTIONS[:atb_svariable]
  5793.       text = sprintf(text, $game_variables[variable])
  5794.     end
  5795.     #---
  5796.     self.contents.draw_text(rect, text, 1)
  5797.   end
  5798.  
  5799.   #--------------------------------------------------------------------------
  5800.   # enabled?
  5801.   #--------------------------------------------------------------------------
  5802.   def enabled?(obj)
  5803.     return $game_troop.can_escape if obj == :escape
  5804.     return true
  5805.   end
  5806.  
  5807. end # Window_PartyCommand
  5808.  
  5809. #===============================================================================
  5810. # Window_ActorCommand
  5811. #===============================================================================
  5812.  
  5813. class Window_ActorCommand < Window_Command
  5814.  
  5815.   #--------------------------------------------------------------------------
  5816.   # public instance variable
  5817.   #--------------------------------------------------------------------------
  5818.   attr_accessor :actor
  5819.  
  5820.   #--------------------------------------------------------------------------
  5821.   # alias method: initialize
  5822.   #--------------------------------------------------------------------------
  5823.   alias initialize_window_actorcommand_bem initialize unless $@
  5824.   def initialize
  5825.     @disable_empty_commands = YEM::BATTLE_ENGINE::DISABLE_EMPTY_COMMANDS
  5826.     initialize_window_actorcommand_bem
  5827.   end
  5828.  
  5829.   #--------------------------------------------------------------------------
  5830.   # new method: item
  5831.   #--------------------------------------------------------------------------
  5832.   def item; return @data[self.index]; end
  5833.  
  5834.   #--------------------------------------------------------------------------
  5835.   # new method: skill
  5836.   #--------------------------------------------------------------------------
  5837.   def skill; return $data_skills[@skills[item]]; end
  5838.  
  5839.   #--------------------------------------------------------------------------
  5840.   # overwrite method: setup
  5841.   #--------------------------------------------------------------------------
  5842.   def setup(actor)
  5843.     @actor = actor
  5844.     @data = []; @commands = []; @skills = {}
  5845.     data_set = actor.class.id
  5846.     data_set = 0 if !YEM::BATTLE_ENGINE::CLASS_COMMANDS.include?(actor.class.id)
  5847.     #---
  5848.     for item in YEM::BATTLE_ENGINE::CLASS_COMMANDS[data_set]
  5849.       case item
  5850.       when :attack; @commands.push(actor.attack_vocab)
  5851.       when :skill;  @commands.push(actor.skill_vocab)
  5852.       when :guard;  @commands.push(actor.guard_vocab)
  5853.       when :item;   @commands.push(Vocab.item)
  5854.       when :equip;  @commands.push(YEM::BATTLE_ENGINE::EQUIP_VOCAB)
  5855.       when :escape
  5856.         next unless $game_troop.can_escape
  5857.         @commands.push(Vocab.escape)
  5858.       else
  5859.         valid = false
  5860.         if YEM::BATTLE_ENGINE::SKILL_COMMANDS.include?(item)
  5861.           @skills[item] = YEM::BATTLE_ENGINE::SKILL_COMMANDS[item][0]
  5862.           @commands.push(YEM::BATTLE_ENGINE::SKILL_COMMANDS[item][1])
  5863.           valid = true
  5864.         end
  5865.         next unless valid
  5866.       end
  5867.       @data.push(item)
  5868.     end
  5869.     #---
  5870.     @item_max = @commands.size
  5871.     refresh
  5872.     self.index = 0
  5873.   end
  5874.  
  5875.   #--------------------------------------------------------------------------
  5876.   # new method: update
  5877.   #--------------------------------------------------------------------------
  5878.   def update
  5879.     return unless $scene.is_a?(Scene_Battle)
  5880.     super unless Input.trigger?(Input::L) or Input.trigger?(Input::R)
  5881.     return unless @actor == $scene.status_window.actor
  5882.     refresh if @actor != nil and @actor.update_commands
  5883.   end
  5884.  
  5885.   #--------------------------------------------------------------------------
  5886.   # new method: refresh
  5887.   #--------------------------------------------------------------------------
  5888.   def refresh
  5889.     create_contents
  5890.     @actor.update_commands = false if @actor != nil
  5891.     for i in 0...@item_max
  5892.       draw_item(i)
  5893.     end
  5894.   end
  5895.  
  5896.   #--------------------------------------------------------------------------
  5897.   # new method: draw_item
  5898.   #--------------------------------------------------------------------------
  5899.   def draw_item(index, enabled = true)
  5900.     rect = item_rect(index)
  5901.     rect.x += 4
  5902.     rect.width -= 8
  5903.     obj = @data[index]
  5904.     enabled = enabled?(obj)
  5905.     self.contents.clear_rect(rect)
  5906.     self.contents.font.color = normal_color
  5907.     self.contents.font.color.alpha = enabled ? 255 : 128
  5908.     self.contents.draw_text(rect, @commands[index], 1)
  5909.   end
  5910.  
  5911.   #--------------------------------------------------------------------------
  5912.   # new method: enabled?
  5913.   #--------------------------------------------------------------------------
  5914.   def enabled?(obj = nil)
  5915.     return false unless @actor.actor?
  5916.     if @actor.auto_battle
  5917.       return true if obj == :equip and @actor.equip_cooldown.to_i <= 0
  5918.       return true if obj == :escape and $game_troop.can_escape
  5919.       return false
  5920.     end
  5921.     return false unless @actor.inputable?
  5922.     return false if obj == nil
  5923.     return false if obj == :equip and @actor.equip_cooldown.to_i > 0
  5924.     if @disable_empty_commands
  5925.       return false if obj == :skill and @actor.skills.size <= 0
  5926.       return false if obj == :item and $game_party.battle_item_size <= 0
  5927.     end
  5928.     if @skills.include?(obj)
  5929.       skill = $data_skills[@skills[obj]]
  5930.       return @actor.skill_can_use?(skill)
  5931.     end
  5932.     return true
  5933.   end
  5934.  
  5935. end # Window_ActorCommand
  5936.  
  5937. #===============================================================================
  5938. # Window_ConfirmCommand
  5939. #===============================================================================
  5940.  
  5941. class Window_ConfirmCommand < Window_Command
  5942.  
  5943.   #--------------------------------------------------------------------------
  5944.   # initialize
  5945.   #--------------------------------------------------------------------------
  5946.   def initialize
  5947.     array = create_command_list
  5948.     super(128, array)
  5949.     self.openness = 0
  5950.     self.height = 128
  5951.     self.active = false
  5952.   end
  5953.  
  5954.   #--------------------------------------------------------------------------
  5955.   # item
  5956.   #--------------------------------------------------------------------------
  5957.   def item; return @data[self.index]; end
  5958.  
  5959.   #--------------------------------------------------------------------------
  5960.   # create_command_list
  5961.   #--------------------------------------------------------------------------
  5962.   def create_command_list
  5963.     @data = []; array = []
  5964.     for command in YEM::BATTLE_ENGINE::CONFIRM_COMMANDS
  5965.       case command
  5966.       when :confirm
  5967.         next unless $scene.dtb?
  5968.         vocab = YEM::BATTLE_ENGINE::CONFIRM_VOCAB[command]
  5969.         array.push(vocab)
  5970.       when :status, :option
  5971.         vocab = YEM::BATTLE_ENGINE::CONFIRM_VOCAB[command]
  5972.         array.push(vocab)
  5973.       when :escape
  5974.         next unless $scene.dtb? or $scene.ptb?
  5975.         array.push(Vocab.escape)
  5976.       when :turnskip
  5977.         next unless $scene.ptb?
  5978.         vocab = YEM::BATTLE_ENGINE::CONFIRM_VOCAB[command]
  5979.         array.push(vocab)
  5980.       when :atb_type
  5981.         next unless $scene.atb?
  5982.         array.push("ATB_COMMAND_TYPE")
  5983.       when :atb_speed
  5984.         next unless $scene.atb?
  5985.         array.push("ATB_COMMAND_SPEED")
  5986.       else; next
  5987.       end
  5988.       @data.push(command)
  5989.     end
  5990.     return array
  5991.   end
  5992.  
  5993.   #--------------------------------------------------------------------------
  5994.   # draw_item
  5995.   #--------------------------------------------------------------------------
  5996.   def draw_item(index, enabled = true)
  5997.     rect = item_rect(index)
  5998.     rect.x += 4
  5999.     rect.width -= 8
  6000.     enabled = enabled?(@data[index])
  6001.     self.contents.clear_rect(rect)
  6002.     self.contents.font.color = normal_color
  6003.     self.contents.font.color.alpha = enabled ? 255 : 128
  6004.     text = @commands[index]
  6005.     #---
  6006.     case text
  6007.     when "ATB_COMMAND_TYPE"
  6008.       case $game_variables[YEM::BATTLE_ENGINE::OPTIONS[:atb_avariable]]
  6009.       when 0; key = :atb_t0
  6010.       when 1; key = :atb_t1
  6011.       when 2; key = :atb_t2
  6012.       when 3; key = :atb_t3
  6013.       else; return
  6014.       end
  6015.       text = YEM::BATTLE_ENGINE::CONFIRM_VOCAB[key]
  6016.     when "ATB_COMMAND_SPEED"
  6017.       text = YEM::BATTLE_ENGINE::CONFIRM_VOCAB[:atb_spd]
  6018.       variable = YEM::BATTLE_ENGINE::OPTIONS[:atb_svariable]
  6019.       text = sprintf(text, $game_variables[variable])      
  6020.     end
  6021.     #---
  6022.     self.contents.draw_text(rect, text, 1)
  6023.   end
  6024.  
  6025.   #--------------------------------------------------------------------------
  6026.   # enabled?
  6027.   #--------------------------------------------------------------------------
  6028.   def enabled?(obj)
  6029.     return $game_troop.can_escape if obj == :escape
  6030.     return true
  6031.   end
  6032.  
  6033. end # Window_ConfirmCommand
  6034.  
  6035. #===============================================================================
  6036. # Window_BattleActor
  6037. #===============================================================================
  6038.  
  6039. class Window_BattleActor < Window_Base
  6040.  
  6041.   #--------------------------------------------------------------------------
  6042.   # initialize
  6043.   #--------------------------------------------------------------------------
  6044.   def initialize
  6045.     super(0, 0, Graphics.width, Graphics.height - 128)
  6046.     @letter_ranks = YEM::BATTLE_ENGINE::TEXT_RANKS[:enable]
  6047.     refresh
  6048.   end
  6049.  
  6050.   #--------------------------------------------------------------------------
  6051.   # refresh
  6052.   #--------------------------------------------------------------------------
  6053.   def refresh(index = 0)
  6054.     self.contents.clear
  6055.     @actor = $game_party.members[index]
  6056.     return if @actor == nil
  6057.     self.contents.font.size = Font.default_size
  6058.     self.contents.font.color = normal_color
  6059.     dx = 8; dy = 0
  6060.     #--- Left Half ---
  6061.     draw_actor_face(@actor, dx, dy)
  6062.     draw_actor_name(@actor, dx+112, dy); dy += WLH
  6063.     draw_actor_class(@actor, dx+112, dy); dy += WLH
  6064.     draw_actor_level(@actor, dx+112, dy); dy += WLH*2
  6065.     dw = contents.width/2 - dx - 24
  6066.     draw_actor_hp(@actor, dx, dy, dw); dy += WLH
  6067.     draw_actor_mp(@actor, dx, dy, dw); dy += WLH
  6068.     #--- Right Half ---
  6069.     dx = contents.width/2; dy = WLH/2
  6070.     draw_actor_elements(@actor, dx, dy); dy += WLH*3
  6071.     draw_actor_states(@actor, dx, dy); dy = WLH*6 + 8
  6072.     draw_actor_parameters(@actor, dx, dy)
  6073.   end
  6074.  
  6075.   #--------------------------------------------------------------------------
  6076.   # draw_actor_elements
  6077.   #--------------------------------------------------------------------------
  6078.   def draw_actor_elements(actor, dx, dy)
  6079.     self.contents.font.size = YEM::BATTLE_ENGINE::TEXT_RANK_SIZE
  6080.     dw = contents.width - dx
  6081.     spacing = YEM::BATTLE_ENGINE::ELEMENT_SPACING
  6082.     array = YEM::BATTLE_ENGINE::ALLY_ELEMENTS
  6083.     dx = dx + dw - (array.size*(spacing+24)) - spacing*3/2
  6084.     for element_id in array
  6085.       next if element_id > $data_system.elements.size
  6086.       icon = Icon.element(element_id)
  6087.       draw_icon(icon, dx, dy)
  6088.       rate = actor.element_rate(element_id)
  6089.       text = sprintf("%d%%", rate)
  6090.       if rate > 200;    colour = :rank_s
  6091.       elsif rate > 150; colour = :rank_a
  6092.       elsif rate > 100; colour = :rank_b
  6093.       elsif rate > 50;  colour = :rank_c
  6094.       elsif rate > 0;   colour = :rank_d
  6095.       elsif rate == 0;  colour = :rank_e
  6096.       else;             colour = :rank_f
  6097.       end
  6098.       text = YEM::BATTLE_ENGINE::TEXT_RANKS[colour] if @letter_ranks
  6099.       colour = YEM::BATTLE_ENGINE::RANK_COLOURS[colour]
  6100.       self.contents.font.color = text_color(colour)
  6101.       self.contents.draw_text(dx-spacing/2, dy+WLH, spacing+24, WLH, text, 1)
  6102.       dx += spacing+24
  6103.     end
  6104.   end
  6105.  
  6106.   #--------------------------------------------------------------------------
  6107.   # draw_actor_states
  6108.   #--------------------------------------------------------------------------
  6109.   def draw_actor_states(actor, dx, dy)
  6110.     self.contents.font.size = YEM::BATTLE_ENGINE::TEXT_RANK_SIZE
  6111.     dw = contents.width - dx
  6112.     spacing = YEM::BATTLE_ENGINE::STATE_SPACING
  6113.     array = YEM::BATTLE_ENGINE::ALLY_STATES
  6114.     dx = dx + dw - (array.size*(spacing+24)) - spacing*3/2
  6115.     for state_id in array
  6116.       state = $data_states[state_id]
  6117.       next if state == nil
  6118.       icon = state.icon_index
  6119.       draw_icon(icon, dx, dy)
  6120.       rate = actor.state_probability(state_id)
  6121.       text = sprintf("%d%%", rate)
  6122.       if rate > 100;   colour = :rank_s
  6123.       elsif rate > 80; colour = :rank_a
  6124.       elsif rate > 60; colour = :rank_b
  6125.       elsif rate > 40; colour = :rank_c
  6126.       elsif rate > 20; colour = :rank_d
  6127.       elsif rate > 0;  colour = :rank_e
  6128.       else;            colour = :rank_f
  6129.       end
  6130.       text = YEM::BATTLE_ENGINE::TEXT_RANKS[colour] if @letter_ranks
  6131.       colour = YEM::BATTLE_ENGINE::RANK_COLOURS[colour]
  6132.       self.contents.font.color = text_color(colour)
  6133.       self.contents.draw_text(dx-spacing/2, dy+WLH, spacing+24, WLH, text, 1)
  6134.       dx += spacing+24
  6135.     end
  6136.   end
  6137.  
  6138.   #--------------------------------------------------------------------------
  6139.   # draw_actor_parameters
  6140.   #--------------------------------------------------------------------------
  6141.   def draw_actor_parameters(actor, dx, dy)
  6142.     self.contents.font.size = YEM::BATTLE_ENGINE::TEXT_STAT_SIZE
  6143.     fx = dx; fy = dy
  6144.     dw = (contents.width - dx)/2 - 4
  6145.     for stat in YEM::BATTLE_ENGINE::ALLY_STATS
  6146.       case stat
  6147.       when :atk
  6148.         name = Vocab.atk
  6149.         value = actor.atk
  6150.       when :def
  6151.         name = Vocab.def
  6152.         value = actor.def
  6153.       when :spi
  6154.         name = Vocab.spi
  6155.         value = actor.spi
  6156.       when :res
  6157.         next unless $imported["RES Stat"]
  6158.         name = Vocab.res
  6159.         value = actor.res
  6160.       when :dex
  6161.         next unless $imported["DEX Stat"]
  6162.         name = Vocab.dex
  6163.         value = actor.dex
  6164.       when :agi
  6165.         name = Vocab.agi
  6166.         value = actor.agi
  6167.       when :hit
  6168.         name = Vocab.hit
  6169.         value = sprintf("%d%%", [[actor.hit, 1].max, 99].min)
  6170.       when :eva
  6171.         name = Vocab.eva
  6172.         value = sprintf("%d%%", [[actor.eva, 1].max, 99].min)
  6173.       when :cri
  6174.         name = Vocab.cri
  6175.         value = sprintf("%d%%", [[actor.cri, 1].max, 99].min)
  6176.       when :odds
  6177.         name = Vocab.odds
  6178.         value = actor.odds * 100 / total_party_odds
  6179.         value = sprintf("%d%%", [[value, 1].max, 99].min)
  6180.       else; next
  6181.       end
  6182.       draw_icon(Icon.stat(actor, stat), dx, dy)
  6183.       self.contents.font.color = system_color
  6184.       self.contents.draw_text(dx+24, dy, 40, WLH, name)
  6185.       self.contents.font.color = normal_color
  6186.       self.contents.draw_text(dx+64, dy, dw-72, WLH, value, 2)
  6187.       dx += dw + 4
  6188.       if dx + dw + 4 > contents.width
  6189.         dx = fx
  6190.         dy += WLH
  6191.         break if dy + WLH > contents.height
  6192.       end
  6193.     end
  6194.   end
  6195.  
  6196.   #--------------------------------------------------------------------------
  6197.   # total_party_odds
  6198.   #--------------------------------------------------------------------------
  6199.   def total_party_odds
  6200.     return @total_odds if @total_odds != nil
  6201.     @total_odds = 0
  6202.     for member in $game_party.members
  6203.       @total_odds += member.odds
  6204.     end
  6205.     return @total_odds
  6206.   end
  6207.  
  6208. end # Window_BattleActor
  6209.  
  6210. #===============================================================================
  6211. # Window_BattleActorStates
  6212. #===============================================================================
  6213.  
  6214. class Window_BattleActorStates < Window_Selectable
  6215.  
  6216.   #--------------------------------------------------------------------------
  6217.   # initialize
  6218.   #--------------------------------------------------------------------------
  6219.   def initialize
  6220.     dx = 8; dy = WLH*7 - 16
  6221.     super(dx, dy, Graphics.width/2 - dx*2, Graphics.height - 128 - dy)
  6222.     @draw_state_turns = $imported["CoreFixesUpgradesMelody"]
  6223.     self.back_opacity = 0
  6224.     self.opacity = 0
  6225.   end
  6226.  
  6227.   #--------------------------------------------------------------------------
  6228.   # refresh
  6229.   #--------------------------------------------------------------------------
  6230.   def refresh(actor = nil)
  6231.     @data = []
  6232.     @actor = actor
  6233.     if @actor == nil
  6234.       self.index = -1
  6235.       @item_max = 0
  6236.       create_contents
  6237.       return
  6238.     end
  6239.     for state in actor.states
  6240.       next if state == nil
  6241.       @data.push(state)
  6242.     end
  6243.     @data = [:normal] if @data == []
  6244.     @item_max = @data.size
  6245.     create_contents
  6246.     self.index = (@item_max > 0) ? 0 : -1
  6247.     for i in 0...@item_max; draw_item(i); end
  6248.   end
  6249.    
  6250.   #--------------------------------------------------------------------------
  6251.   # draw_item
  6252.   #--------------------------------------------------------------------------
  6253.   def draw_item(index)
  6254.     rect = item_rect(index)
  6255.     self.contents.clear_rect(rect)
  6256.     state = @data[index]
  6257.     return if state == nil
  6258.     if state == :normal
  6259.       draw_icon(Icon.normal_state, rect.x, rect.y)
  6260.       text = YEM::BATTLE_ENGINE::TEXT_NORMAL_STATE
  6261.     else
  6262.       draw_icon(state.icon_index, rect.x, rect.y)
  6263.       draw_state_turns(rect.x, rect.y, state, @actor) if @draw_state_turns
  6264.       text = state.name
  6265.       if @actor.stack(state) > 1
  6266.         display = YEM::BATTLE_ENGINE::STATE_SETTINGS[:stack_display]
  6267.         text = sprintf(display, text, @actor.stack(state).to_s)
  6268.       end
  6269.     end
  6270.     self.contents.font.color = normal_color
  6271.     self.contents.font.bold = Font.default_bold
  6272.     self.contents.font.size = Font.default_size
  6273.     self.contents.draw_text(rect.x+24, rect.y, rect.width-28, WLH, text)
  6274.   end
  6275.  
  6276. end # Window_BattleActorStates
  6277.  
  6278. #===============================================================================
  6279. # Window_BattleOptions
  6280. #===============================================================================
  6281.  
  6282. class Window_BattleOptions < Window_Selectable
  6283.  
  6284.   #--------------------------------------------------------------------------
  6285.   # initialize
  6286.   #--------------------------------------------------------------------------
  6287.   def initialize(dx, dy)
  6288.     super(dx, dy, Graphics.width-dx, Graphics.height-dy-128)
  6289.     self.index = 0
  6290.     refresh
  6291.   end
  6292.  
  6293.   #--------------------------------------------------------------------------
  6294.   # item
  6295.   #--------------------------------------------------------------------------
  6296.   def item; return @data[self.index]; end
  6297.  
  6298.   #--------------------------------------------------------------------------
  6299.   # refresh
  6300.   #--------------------------------------------------------------------------
  6301.   def refresh
  6302.     @data = []
  6303.     for command in YEM::BATTLE_ENGINE::OPTION_COMMANDS
  6304.       case command
  6305.       when :bgm_volume, :bgs_volume, :sfx_volume
  6306.       when :animations, :autocursor, :next_actor, :skill_help
  6307.       when :atb_active, :atb_speeds; next unless $scene.atb?
  6308.       when :cinematics; next
  6309.       else; next
  6310.       end
  6311.       @data.push(command)
  6312.     end
  6313.     @item_max = @data.size
  6314.     create_contents
  6315.     for i in 0...@item_max; draw_item(i); end
  6316.   end
  6317.  
  6318.   #--------------------------------------------------------------------------
  6319.   # draw_item
  6320.   #--------------------------------------------------------------------------
  6321.   def draw_item(index)
  6322.     rect = item_rect(index)
  6323.     self.contents.clear_rect(rect)
  6324.     obj = @data[index]
  6325.     return if obj == nil
  6326.     case obj
  6327.     when :bgm_volume, :bgs_volume, :sfx_volume
  6328.       draw_volume_item(obj, rect.clone)
  6329.     when :animations, :autocursor, :next_actor, :skill_help, :cinematics
  6330.       draw_switch_item(obj, rect.clone)
  6331.     when :atb_active, :atb_speeds
  6332.       draw_atb_item(obj, rect.clone)
  6333.     end
  6334.   end
  6335.  
  6336.   #--------------------------------------------------------------------------
  6337.   # draw_volume_item
  6338.   #--------------------------------------------------------------------------
  6339.   def draw_volume_item(obj, rect)
  6340.     options = YEM::BATTLE_ENGINE::OPTIONS
  6341.     case obj
  6342.     when :bgm_volume
  6343.       title = options[:bgm_volume]
  6344.       value = $game_variables[options[:bgm_variable]]
  6345.       mute  = $game_switches[options[:bgm_mute_sw]]
  6346.     when :bgs_volume
  6347.       title = options[:bgs_volume]
  6348.       value = $game_variables[options[:bgs_variable]]
  6349.       mute  = $game_switches[options[:bgs_mute_sw]]
  6350.     when :sfx_volume
  6351.       title = options[:sfx_volume]
  6352.       value = $game_variables[options[:sfx_variable]]
  6353.       mute  = $game_switches[options[:sfx_mute_sw]]
  6354.     else; return
  6355.     end
  6356.     value = sprintf(options[:audio], value)
  6357.     self.contents.font.color = normal_color
  6358.     self.contents.draw_text(rect.x, rect.y, rect.width/2, WLH, title, 1)
  6359.     self.contents.font.color.alpha = mute ? 128 : 255
  6360.     dx = rect.x + rect.width/2
  6361.     self.contents.draw_text(dx, rect.y, rect.width/4, WLH, value, 1)
  6362.     self.contents.font.color.alpha = mute ? 255 : 128
  6363.     dx = rect.x + rect.width*3/4
  6364.     self.contents.draw_text(dx, rect.y, rect.width/4, WLH, options[:mute], 1)
  6365.   end
  6366.  
  6367.   #--------------------------------------------------------------------------
  6368.   # draw_switch_item
  6369.   #--------------------------------------------------------------------------
  6370.   def draw_switch_item(obj, rect)
  6371.     options = YEM::BATTLE_ENGINE::OPTIONS
  6372.     title = options[obj]
  6373.     case obj
  6374.     when :animations
  6375.       name1 = options[:ani_show]
  6376.       name2 = options[:ani_hide]
  6377.       toggle = $game_switches[options[:animation_sw]]
  6378.     when :autocursor
  6379.       name1 = options[:curmem_on]
  6380.       name2 = options[:curmem_off]
  6381.       toggle = $game_switches[options[:autocursor_sw]]
  6382.     when :next_actor
  6383.       name1 = options[:next_on]
  6384.       name2 = options[:next_off]
  6385.       toggle = $game_switches[options[:next_actor_sw]]
  6386.     when :skill_help
  6387.       name1 = options[:help_on]
  6388.       name2 = options[:help_off]
  6389.       toggle = $game_switches[options[:skill_help_sw]]
  6390.     when :cinematics
  6391.       name1 = options[:cinem_on]
  6392.       name2 = options[:cinem_off]
  6393.       toggle = $game_switches[options[:cinematics_sw]]
  6394.     else; return
  6395.     end
  6396.     self.contents.font.color = normal_color
  6397.     self.contents.draw_text(rect.x, rect.y, rect.width/2, WLH, title, 1)
  6398.     self.contents.font.color.alpha = toggle ? 255 : 128
  6399.     dx = rect.x + rect.width/2
  6400.     self.contents.draw_text(dx, rect.y, rect.width/4, WLH, name1, 1)
  6401.     self.contents.font.color.alpha = toggle ? 128 : 255
  6402.     dx = rect.x + rect.width*3/4
  6403.     self.contents.draw_text(dx, rect.y, rect.width/4, WLH, name2, 1)
  6404.   end
  6405.  
  6406.   #--------------------------------------------------------------------------
  6407.   # draw_atb_item
  6408.   #--------------------------------------------------------------------------
  6409.   def draw_atb_item(obj, rect)
  6410.     options = YEM::BATTLE_ENGINE::OPTIONS
  6411.     case obj
  6412.     when :atb_active
  6413.       title = options[:atb_aname]
  6414.       value = $game_variables[options[:atb_avariable]]
  6415.       #---
  6416.       self.contents.font.color = normal_color
  6417.       name1 = options[:wait_0]
  6418.       dx = rect.x + rect.width/2
  6419.       self.contents.font.color.alpha = (value == 0) ? 255 : 128
  6420.       self.contents.draw_text(dx, rect.y, rect.width/8, WLH, name1, 1)
  6421.       name2 = options[:wait_1]
  6422.       dx = rect.x + rect.width*5/8
  6423.       self.contents.font.color.alpha = (value == 1) ? 255 : 128
  6424.       self.contents.draw_text(dx, rect.y, rect.width/8, WLH, name2, 1)
  6425.       name3 = options[:wait_2]
  6426.       dx = rect.x + rect.width*6/8
  6427.       self.contents.font.color.alpha = (value == 2) ? 255 : 128
  6428.       self.contents.draw_text(dx, rect.y, rect.width/8, WLH, name3, 1)
  6429.       name4 = options[:wait_3]
  6430.       dx = rect.x + rect.width*7/8
  6431.       self.contents.font.color.alpha = (value == 3) ? 255 : 128
  6432.       self.contents.draw_text(dx, rect.y, rect.width/8, WLH, name4, 1)
  6433.       #---
  6434.     when :atb_speeds
  6435.       title = options[:atb_sname]
  6436.       value = $game_variables[options[:atb_svariable]] - 1
  6437.       #---
  6438.       for i in 0...10
  6439.         self.contents.font.color = normal_color
  6440.         name = (i + 1).to_s
  6441.         dx = rect.x + rect.width * (10 + i)/20
  6442.         self.contents.font.color.alpha = (value == i) ? 255 : 128
  6443.         self.contents.draw_text(dx, rect.y, rect.width/20, WLH, name, 1)
  6444.       end
  6445.       #---
  6446.     else; return
  6447.     end
  6448.     self.contents.font.color = normal_color
  6449.     self.contents.draw_text(rect.x, rect.y, rect.width/2, WLH, title, 1)
  6450.   end
  6451.  
  6452.   #--------------------------------------------------------------------------
  6453.   # update
  6454.   #--------------------------------------------------------------------------
  6455.   def update
  6456.     super
  6457.     if Input.trigger?(Input::C)
  6458.       input_case_c
  6459.     elsif Input.repeat?(Input::LEFT)
  6460.       input_case_left
  6461.     elsif Input.repeat?(Input::RIGHT)
  6462.       input_case_right
  6463.     end
  6464.   end
  6465.  
  6466.   #--------------------------------------------------------------------------
  6467.   # input_case_c
  6468.   #--------------------------------------------------------------------------
  6469.   def input_case_c
  6470.     options = YEM::BATTLE_ENGINE::OPTIONS
  6471.     case item
  6472.     when :bgm_volume; switch = options[:bgm_mute_sw]
  6473.     when :bgs_volume; switch = options[:bgs_mute_sw]
  6474.     when :sfx_volume; switch = options[:sfx_mute_sw]
  6475.     when :animations; switch = options[:animation_sw]
  6476.     when :autocursor; switch = options[:autocursor_sw]
  6477.     when :next_actor; switch = options[:next_actor_sw]
  6478.     when :skill_help; switch = options[:skill_help_sw]
  6479.     when :cinematics; switch = options[:cinematics_sw]
  6480.     else; return
  6481.     end
  6482.     $game_switches[switch] = !$game_switches[switch]
  6483.     Sound.play_decision
  6484.     RPG::BGM::last.play if item == :bgm_volume
  6485.     RPG::BGS::last.play if item == :bgs_volume
  6486.     draw_item(self.index)
  6487.   end
  6488.  
  6489.   #--------------------------------------------------------------------------
  6490.   # input_case_left
  6491.   #--------------------------------------------------------------------------
  6492.   def input_case_left
  6493.     options = YEM::BATTLE_ENGINE::OPTIONS
  6494.     ignore = false
  6495.     case item
  6496.     when :bgm_volume, :bgs_volume, :sfx_volume
  6497.       value = Input.press?(Input::SHIFT) ? 10 : 1
  6498.       case item
  6499.       when :bgm_volume; variable = options[:bgm_variable]
  6500.       when :bgs_volume; variable = options[:bgs_variable]
  6501.       when :sfx_volume; variable = options[:sfx_variable]
  6502.       end
  6503.       return if $game_variables[variable] == 0
  6504.       $game_variables[variable] -= value
  6505.       $game_variables[variable] = [$game_variables[variable], 0].max
  6506.       ignore = true
  6507.     when :atb_active
  6508.       variable = options[:atb_avariable]
  6509.       return if $game_variables[variable] == 0
  6510.       $game_variables[variable] -= 1
  6511.       $game_variables[variable] = [$game_variables[variable], 0].max
  6512.       ignore = true
  6513.       if $scene.is_a?(Scene_Battle) and $scene.atb?
  6514.         $scene.party_command_window.refresh
  6515.         $scene.confirm_command_window.refresh
  6516.       end
  6517.     when :atb_speeds
  6518.       variable = options[:atb_svariable]
  6519.       return if $game_variables[variable] == 1
  6520.       $game_variables[variable] -= 1
  6521.       $game_variables[variable] = [$game_variables[variable], 1].max
  6522.       ignore = true
  6523.       if $scene.is_a?(Scene_Battle) and $scene.atb?
  6524.         $scene.party_command_window.refresh
  6525.         $scene.confirm_command_window.refresh
  6526.       end
  6527.     when :animations; switch = options[:animation_sw]
  6528.     when :autocursor; switch = options[:autocursor_sw]
  6529.     when :next_actor; switch = options[:next_actor_sw]
  6530.     when :skill_help; switch = options[:skill_help_sw]
  6531.     when :cinematics; switch = options[:cinematics_sw]
  6532.     else; return
  6533.     end
  6534.     unless ignore
  6535.       return if $game_switches[switch]
  6536.       $game_switches[switch] = true
  6537.     end
  6538.     Sound.play_cursor
  6539.     RPG::BGM::last.play if item == :bgm_volume
  6540.     RPG::BGS::last.play if item == :bgs_volume
  6541.     draw_item(self.index)
  6542.   end
  6543.  
  6544.   #--------------------------------------------------------------------------
  6545.   # input_case_right
  6546.   #--------------------------------------------------------------------------
  6547.   def input_case_right
  6548.     options = YEM::BATTLE_ENGINE::OPTIONS
  6549.     ignore = false
  6550.     case item
  6551.     when :bgm_volume, :bgs_volume, :sfx_volume
  6552.       value = Input.press?(Input::SHIFT) ? 10 : 1
  6553.       case item
  6554.       when :bgm_volume; variable = options[:bgm_variable]
  6555.       when :bgs_volume; variable = options[:bgs_variable]
  6556.       when :sfx_volume; variable = options[:sfx_variable]
  6557.       end
  6558.       return if $game_variables[variable] == 100
  6559.       $game_variables[variable] += value
  6560.       $game_variables[variable] = [$game_variables[variable], 100].min
  6561.       ignore = true
  6562.     when :atb_active
  6563.       variable = options[:atb_avariable]
  6564.       return if $game_variables[variable] == 3
  6565.       $game_variables[variable] += 1
  6566.       $game_variables[variable] = [$game_variables[variable], 3].min
  6567.       ignore = true
  6568.       if $scene.is_a?(Scene_Battle) and $scene.atb?
  6569.         $scene.party_command_window.refresh
  6570.         $scene.confirm_command_window.refresh
  6571.       end
  6572.     when :atb_speeds
  6573.       variable = options[:atb_svariable]
  6574.       return if $game_variables[variable] == 10
  6575.       $game_variables[variable] += 1
  6576.       $game_variables[variable] = [$game_variables[variable], 10].min
  6577.       ignore = true
  6578.       if $scene.is_a?(Scene_Battle) and $scene.atb?
  6579.         $scene.party_command_window.refresh
  6580.         $scene.confirm_command_window.refresh
  6581.       end
  6582.     when :animations; switch = options[:animation_sw]
  6583.     when :autocursor; switch = options[:autocursor_sw]
  6584.     when :next_actor; switch = options[:next_actor_sw]
  6585.     when :skill_help; switch = options[:skill_help_sw]
  6586.     when :cinematics; switch = options[:cinematics_sw]
  6587.     else; return
  6588.     end
  6589.     unless ignore
  6590.       return if !$game_switches[switch]
  6591.       $game_switches[switch] = false
  6592.     end
  6593.     Sound.play_cursor
  6594.     RPG::BGM::last.play if item == :bgm_volume
  6595.     RPG::BGS::last.play if item == :bgs_volume
  6596.     draw_item(self.index)
  6597.   end
  6598.  
  6599.   #--------------------------------------------------------------------------
  6600.   # update_help
  6601.   #--------------------------------------------------------------------------
  6602.   def update_help
  6603.     case item
  6604.     when :bgm_volume; type = :bgm_des
  6605.     when :bgs_volume; type = :bgs_des
  6606.     when :sfx_volume; type = :sfx_des
  6607.     when :animations; type = :ani_des
  6608.     when :autocursor; type = :curmem_des
  6609.     when :next_actor; type = :next_des
  6610.     when :skill_help; type = :help_des
  6611.     when :cinematics; type = :cinem_des
  6612.     when :atb_active
  6613.       case $game_variables[YEM::BATTLE_ENGINE::OPTIONS[:atb_avariable]]
  6614.       when 0; type = :wait_0_des
  6615.       when 1; type = :wait_1_des
  6616.       when 2; type = :wait_2_des
  6617.       when 3: type = :wait_3_des
  6618.       end
  6619.     when :atb_speeds; type = :atb_s_des
  6620.     else; type = nil
  6621.     end
  6622.     text = YEM::BATTLE_ENGINE::OPTIONS[type].to_s
  6623.     @help_window.set_text(text, 1)
  6624.   end
  6625.  
  6626. end # Window_BattleOptions
  6627.  
  6628. #===============================================================================
  6629. # Window_PressTurns
  6630. #===============================================================================
  6631.  
  6632. class Window_PressTurns < Window_Base
  6633.  
  6634.   #--------------------------------------------------------------------------
  6635.   # public instance variables
  6636.   #--------------------------------------------------------------------------
  6637.   attr_accessor :update_call
  6638.  
  6639.   #--------------------------------------------------------------------------
  6640.   # initialize
  6641.   #--------------------------------------------------------------------------
  6642.   def initialize(group)
  6643.     @group = group
  6644.     super(-16, -64, Graphics.width + 16, 80)
  6645.     self.z = 10
  6646.     self.back_opacity = 0
  6647.     self.opacity = 0
  6648.     set_icons
  6649.     @appear = false
  6650.     @disappear = false
  6651.   end
  6652.  
  6653.   #--------------------------------------------------------------------------
  6654.   # set_icons
  6655.   #--------------------------------------------------------------------------
  6656.   def set_icons
  6657.     if @group.is_a?(Game_Party)
  6658.       @turn_icon = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS[:actor][2]
  6659.       @used_icon = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS[:actor][3]
  6660.       @bonus_icon = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS[:actor][4]
  6661.     else
  6662.       @turn_icon = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS[:enemy][2]
  6663.       @used_icon = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS[:enemy][3]
  6664.       @bonus_icon = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS[:enemy][4]
  6665.     end
  6666.   end
  6667.  
  6668.   #--------------------------------------------------------------------------
  6669.   # update
  6670.   #--------------------------------------------------------------------------
  6671.   def update
  6672.     super
  6673.     if @appear
  6674.       self.y = [self.y + 4, -16].min
  6675.       @appear = false if self.y >= -16
  6676.     elsif @disappear
  6677.       self.y = [self.y - 4, -64].max
  6678.       @disappear = false if self.y <= -64
  6679.     end
  6680.     refresh if @update_call
  6681.   end
  6682.  
  6683.   #--------------------------------------------------------------------------
  6684.   # appear
  6685.   #--------------------------------------------------------------------------
  6686.   def appear
  6687.     @appear = true
  6688.     @disappear = false
  6689.     self.z = 11
  6690.     refresh
  6691.   end
  6692.  
  6693.   #--------------------------------------------------------------------------
  6694.   # disappear
  6695.   #--------------------------------------------------------------------------
  6696.   def disappear
  6697.     @disappear = true
  6698.     @appear = false
  6699.     self.z = 10
  6700.   end
  6701.  
  6702.   #--------------------------------------------------------------------------
  6703.   # refresh
  6704.   #--------------------------------------------------------------------------
  6705.   def refresh
  6706.     self.contents.clear
  6707.     @update_call = false
  6708.     dx = draw_turn_icons
  6709.     dx = draw_bonus_icons(dx)
  6710.     draw_used_icons(dx)
  6711.   end
  6712.  
  6713.   #--------------------------------------------------------------------------
  6714.   # draw_turn_icons
  6715.   #--------------------------------------------------------------------------
  6716.   def draw_turn_icons(dx = 12)
  6717.     @dy = 6
  6718.     amount = @group.ptb_total_turns
  6719.     amount -= @group.ptb_bonus_turns
  6720.     amount.times do
  6721.       draw_icon(@turn_icon, dx, @dy)
  6722.       @dy = (@dy == 6) ? 18 : 6
  6723.       dx += 24
  6724.     end
  6725.     return dx
  6726.   end
  6727.  
  6728.   #--------------------------------------------------------------------------
  6729.   # draw_bonus_icons
  6730.   #--------------------------------------------------------------------------
  6731.   def draw_bonus_icons(dx)
  6732.     return dx if @group.ptb_total_turns <= 0
  6733.     amount = @group.ptb_bonus_turns
  6734.     amount.times do
  6735.       draw_icon(@turn_icon, dx, @dy)
  6736.       @dy = (@dy == 6) ? 18 : 6
  6737.       dx += 24
  6738.     end
  6739.     return dx
  6740.   end
  6741.  
  6742.   #--------------------------------------------------------------------------
  6743.   # draw_used_icons
  6744.   #--------------------------------------------------------------------------
  6745.   def draw_used_icons(dx)
  6746.     amount = @group.ptb_member_turns
  6747.     amount -= @group.ptb_total_turns
  6748.     return if amount <= 0
  6749.     amount.times do
  6750.       draw_icon(@used_icon, dx, @dy)
  6751.       @dy = (@dy == 6) ? 18 : 6
  6752.       dx += 24
  6753.     end
  6754.   end
  6755.  
  6756. end # Window_PressTurns
  6757.  
  6758. #===============================================================================
  6759. # Window_EnemyGauge
  6760. #===============================================================================
  6761.  
  6762. class Window_EnemyGauge < Window_Base
  6763.  
  6764.   #--------------------------------------------------------------------------
  6765.   # initialize
  6766.   #--------------------------------------------------------------------------
  6767.   def initialize
  6768.     super(0, 0, 120, WLH*3+32)
  6769.     self.visible = false
  6770.     self.opacity = 0
  6771.     self.back_opacity = 0
  6772.     self.z = 16000
  6773.   end
  6774.  
  6775.   #--------------------------------------------------------------------------
  6776.   # update
  6777.   #--------------------------------------------------------------------------
  6778.   def update
  6779.     super
  6780.     return unless $scene.is_a?(Scene_Battle)
  6781.     return unless $scene.atb?
  6782.     if @battler == nil
  6783.       self.visible = false
  6784.       return
  6785.     end
  6786.     refresh_call = false
  6787.     #---
  6788.     refresh_call = true if @current_hp != @battler.hp
  6789.     refresh_call = true if @current_maxhp != @battler.maxhp
  6790.     refresh_call = true if @current_mp != @battler.mp
  6791.     refresh_call = true if @current_maxmp != @battler.maxmp
  6792.     refresh_call = true if @current_states != @battler.states
  6793.     #---
  6794.     if @current_x != @battler.screen_x or @current_y != @battler.screen_y
  6795.       @current_x = @battler.screen_x
  6796.       @current_y = @battler.screen_y
  6797.       self.x = @battler.screen_x - self.width/2
  6798.       self.x -= $scene.spriteset.viewport1.ox
  6799.       self.y = @battler.screen_y - self.height/2 - WLH + 12
  6800.       self.y -= $scene.spriteset.viewport1.oy
  6801.     end
  6802.     #---
  6803.     refresh if refresh_call
  6804.   end
  6805.  
  6806.   #--------------------------------------------------------------------------
  6807.   # battler=
  6808.   #--------------------------------------------------------------------------
  6809.   def battler=(battler)
  6810.     @battler = battler
  6811.     if @battler == nil
  6812.       self.visible = false
  6813.       return
  6814.     end
  6815.     self.visible = true
  6816.     self.width = @battler.enemy.quick_gauge[:width]
  6817.     @current_x = @battler.screen_x
  6818.     @current_y = @battler.screen_y
  6819.     self.x = @battler.screen_x - self.width/2
  6820.     self.x -= $scene.spriteset.viewport1.ox
  6821.     self.y = @battler.screen_y - self.height/2 - WLH + 12
  6822.     self.y -= $scene.spriteset.viewport1.oy
  6823.     create_contents
  6824.     refresh
  6825.   end
  6826.  
  6827.   #--------------------------------------------------------------------------
  6828.   # refresh
  6829.   #--------------------------------------------------------------------------
  6830.   def refresh
  6831.     dy = 0
  6832.     sw = contents.width
  6833.     #---
  6834.     if $scene.atb?
  6835.       @current_hp = @battler.hp
  6836.       @current_maxhp = @battler.maxhp
  6837.       @current_mp = @battler.mp
  6838.       @current_maxmp = @battler.maxmp
  6839.       @current_states = @battler.states.clone
  6840.     end
  6841.     #---
  6842.     draw_actor_state(@battler,0,WLH,sw) if @battler.enemy.quick_gauge[:states]
  6843.     dy += WLH+8
  6844.     if @battler.enemy.quick_gauge[:show_hp]
  6845.       draw_back_gauge(0, dy, sw)
  6846.       draw_enemy_hp_gauge(@battler,1,dy+1,sw-2)
  6847.       dy += 7
  6848.     end
  6849.     if @battler.enemy.quick_gauge[:show_mp]
  6850.       draw_back_gauge(0, dy, contents.width)
  6851.       if @battler.use_rage?
  6852.         draw_enemy_rage_gauge(@battler,1,dy+1,sw/2-1)
  6853.         draw_enemy_mp_gauge(@battler,sw/2+1,dy+1,sw/2-2)
  6854.       else
  6855.         draw_enemy_mp_gauge(@battler,1,dy+1,sw-2)
  6856.       end
  6857.       dy += 7
  6858.     end
  6859.   end
  6860.  
  6861.   #--------------------------------------------------------------------------
  6862.   # new method: draw_back_gauge
  6863.   #--------------------------------------------------------------------------
  6864.   def draw_back_gauge(x, y, width = 120)
  6865.     self.contents.fill_rect(x, y + WLH - 8, width, 8, gauge_back_color)
  6866.   end
  6867.  
  6868. end # Window_EnemyGauge
  6869.  
  6870. #===============================================================================
  6871. # Scene_Battle
  6872. #===============================================================================
  6873.  
  6874. class Scene_Battle < Scene_Base
  6875.  
  6876.   #--------------------------------------------------------------------------
  6877.   # overwrite method: wait_for_animation
  6878.   #--------------------------------------------------------------------------
  6879.   def wait_for_animation
  6880.     update_basic
  6881.     update_basic while @spriteset.animation?
  6882.   end
  6883.  
  6884.   #--------------------------------------------------------------------------
  6885.   # overwrite method: display_attack_animation
  6886.   #--------------------------------------------------------------------------
  6887.   def display_attack_animation(targets)
  6888.     if @active_battler.is_a?(Game_Enemy)
  6889.       aid1 = @active_battler.atk_animation_id
  6890.       display_normal_animation(targets, aid1)
  6891.     else
  6892.       aid1 = @active_battler.atk_animation_id
  6893.       aid2 = @active_battler.atk_animation_id2
  6894.       display_normal_animation(targets, aid1, false)
  6895.       wait_for_animation if aid2 != 0
  6896.       display_normal_animation(targets, aid2, true)
  6897.     end
  6898.   end
  6899.  
  6900.   #--------------------------------------------------------------------------
  6901.   # overwrite method: display_animation
  6902.   #--------------------------------------------------------------------------
  6903.   def display_animation(targets, animation_id)
  6904.     if animation_id < 0
  6905.       display_attack_animation(targets)
  6906.     else
  6907.       display_normal_animation(targets, animation_id)
  6908.     end
  6909.   end
  6910.  
  6911.   #--------------------------------------------------------------------------
  6912.   # overwrite method: display_normal_animation
  6913.   #--------------------------------------------------------------------------
  6914.   def display_normal_animation(targets, animation_id, mirror = false)
  6915.     return unless show_animation?
  6916.     animation = $data_animations[animation_id]
  6917.     return if animation == nil
  6918.     mirror = !mirror if @action_values.include?("MIRROR")
  6919.     to_screen = (animation.position == 3)
  6920.     ani_check = false
  6921.     for target in targets.uniq
  6922.       if ani_check
  6923.         target.pseudo_ani_id = animation_id
  6924.       else
  6925.         target.animation_id = animation_id
  6926.         target.animation_mirror = target_mirror?(mirror, target)
  6927.         target.animation_mirror = false if animation.anti_mirror
  6928.       end
  6929.       ani_check = true if to_screen
  6930.     end
  6931.   end
  6932.  
  6933.   #--------------------------------------------------------------------------
  6934.   # overwrite method: display_pseudo_animation
  6935.   #--------------------------------------------------------------------------
  6936.   def display_pseudo_animation(targets, animation_id)
  6937.     return unless show_animation?
  6938.     animation = $data_animations[animation_id]
  6939.     return if animation == nil
  6940.     for target in targets.uniq
  6941.       target.pseudo_ani_id = animation_id
  6942.     end
  6943.   end
  6944.  
  6945.   #--------------------------------------------------------------------------
  6946.   # new method: wait_for_movement
  6947.   #--------------------------------------------------------------------------
  6948.   def wait_for_movement
  6949.     return if emptyview?
  6950.     members = $game_party.members + $game_troop.members
  6951.     movers = []; requirement = 0
  6952.     for member in members
  6953.       next unless member.sprite_movable?
  6954.       movers.push(member)
  6955.       requirement += 1
  6956.     end
  6957.     return if requirement == 0
  6958.     loop do
  6959.       check = 0
  6960.       for mover in movers
  6961.         next unless mover.sprite_movable?
  6962.         next if mover.spriteset.move_to_x != nil
  6963.         next if mover.spriteset.move_to_y != nil
  6964.         check += 1
  6965.       end
  6966.       break if check == requirement
  6967.       update_basic
  6968.     end
  6969.   end
  6970.  
  6971.   #--------------------------------------------------------------------------
  6972.   # new method: wait_for_jump
  6973.   #--------------------------------------------------------------------------
  6974.   def wait_for_jump
  6975.     return if emptyview?
  6976.     members = $game_party.members + $game_troop.members
  6977.     movers = []; requirement = 0
  6978.     for member in members
  6979.       next unless member.sprite_movable?
  6980.       movers.push(member)
  6981.       requirement += 1
  6982.     end
  6983.     return if requirement == 0
  6984.     loop do
  6985.       check = 0
  6986.       for mover in movers
  6987.         next unless mover.sprite_movable?
  6988.         next if mover.spriteset.jump_duration != nil
  6989.         check += 1
  6990.       end
  6991.       break if check == requirement
  6992.       update_basic
  6993.     end
  6994.   end
  6995.  
  6996.   #--------------------------------------------------------------------------
  6997.   # new method: start_victory_poses
  6998.   #--------------------------------------------------------------------------
  6999.   def start_victory_poses
  7000.     for member in $game_party.existing_members
  7001.       next unless member.use_battler_animations?
  7002.       member.battler_animation_stance("VICTORY")
  7003.     end
  7004.     return unless $imported["ExtendedMovement"]
  7005.     return unless YEM::BATTLE_ENGINE::AUTO_POSES[:victory]
  7006.     for member in $game_party.existing_members
  7007.       next if member.character == nil
  7008.       member.character.break_pose
  7009.       member.character.mirror = false
  7010.       member.character.pose = "VICTORY"
  7011.     end
  7012.   end
  7013.  
  7014.   #--------------------------------------------------------------------------
  7015.   # new method: update_battler_poses
  7016.   #--------------------------------------------------------------------------
  7017.   def update_battler_poses
  7018.     return unless $scene.is_a?(Scene_Battle)
  7019.     return if @action_occuring
  7020.     for member in @all_members
  7021.       update_stances_individual(member)
  7022.     end
  7023.     #---
  7024.     return unless $imported["ExtendedMovement"]
  7025.     for member in $game_party.existing_members
  7026.       update_pose_individual(member)
  7027.     end
  7028.     for member in $game_troop.existing_members
  7029.       update_pose_individual(member)
  7030.     end
  7031.   end
  7032.  
  7033.   #--------------------------------------------------------------------------
  7034.   # new method: update_stances_individual
  7035.   #--------------------------------------------------------------------------
  7036.   def update_stances_individual(member, ignore_active_battler = false)
  7037.     return unless member.use_battler_animations?
  7038.     return if member == @active_battler and !ignore_active_battler
  7039.     stance = ""
  7040.     if member.dead?
  7041.       stance = "DEAD"
  7042.     elsif member.guarding?
  7043.       stance = "GUARDING"
  7044.     elsif !member.movable?
  7045.       stance = "STASIS"
  7046.     elsif member.hp < member.maxhp / 4
  7047.       stance = "PIYORI"
  7048.     else
  7049.       stance = "IDLE"
  7050.     end
  7051.     return if stance == ""
  7052.     member.battler_animation_stance(stance)
  7053.   end
  7054.  
  7055.   #--------------------------------------------------------------------------
  7056.   # new method: update_pose_individual
  7057.   #--------------------------------------------------------------------------
  7058.   def update_pose_individual(member, ignore_active_battler = false)
  7059.     return unless $scene.is_a?(Scene_Battle)
  7060.     return unless $imported["ExtendedMovement"]
  7061.     return if member == @active_battler and !ignore_active_battler
  7062.     return if member.dead?
  7063.     return if member.character == nil
  7064.     return if member.use_battler_animations?
  7065.     auto_poses = YEM::BATTLE_ENGINE::AUTO_POSES
  7066.     settings = YEM::BATTLE_ENGINE::POSE_SETTINGS
  7067.     if member.hp < member.maxhp / 4
  7068.       pose = :piyori
  7069.       name = "PIYORI"
  7070.       stance = "PIYORI"
  7071.     elsif member.guarding?
  7072.       pose = :guard
  7073.       name = "GUARDING"
  7074.       stance = "GUARDING"
  7075.     else
  7076.       pose = :ready
  7077.       name = "READY"
  7078.       stance = "IDLE"
  7079.     end
  7080.     return if member.character.pose == name.upcase
  7081.     member.character.break_pose
  7082.     member.character.step_anime = true
  7083.     return unless auto_poses[pose]
  7084.     direction = member.character.direction
  7085.     member.character.step_anime = false unless member.movable?
  7086.     return if settings[pose][1].include?(direction)
  7087.     member.character.mirror = settings[pose][0].include?(direction)
  7088.     member.character.pose = name
  7089.     member.character.step_anime = false unless member.movable?
  7090.   end
  7091.  
  7092.   #--------------------------------------------------------------------------
  7093.   # new method: refresh_ptb_windows
  7094.   #--------------------------------------------------------------------------
  7095.   def refresh_battle_windows
  7096.     @skill_window.battle_refresh_call = true if @skill_window != nil
  7097.     @item_window.battle_refresh_call = true if @item_window != nil
  7098.     @mini_window.battle_refresh_call = true if @mini_window != nil
  7099.   end
  7100.  
  7101.   #--------------------------------------------------------------------------
  7102.   # new method: refresh_ptb_windows
  7103.   #--------------------------------------------------------------------------
  7104.   def refresh_ptb_windows
  7105.     return unless ptb?
  7106.     return if @active_battler == nil
  7107.     if @active_battler.actor?
  7108.       @ptb_party_window.update_call = true
  7109.       @spriteset.ptb_update = $game_party
  7110.     else
  7111.       @ptb_troop_window.update_call = true
  7112.       @spriteset.ptb_update = $game_troop
  7113.     end
  7114.   end
  7115.  
  7116.   #--------------------------------------------------------------------------
  7117.   # new method: update_battle_cursor
  7118.   #--------------------------------------------------------------------------
  7119.   def update_battle_cursor
  7120.     return unless $scene.is_a?(Scene_Battle)
  7121.     return if @spriteset.battle_cursor == nil
  7122.     @spriteset.battle_cursor.create_move_to
  7123.   end
  7124.  
  7125.   #--------------------------------------------------------------------------
  7126.   # new method: create_aoe_indicator
  7127.   #--------------------------------------------------------------------------
  7128.   def create_aoe_indicator(window)
  7129.     if atb?
  7130.       case @selected_battler.action.atb_queue_kind
  7131.       when 1 # Skill
  7132.         obj = $data_skills[@selected_battler.action.atb_queue_basic]
  7133.       when 2 # Item
  7134.         obj = $data_items[@selected_battler.action.atb_queue_basic]
  7135.       else; return
  7136.       end
  7137.     else
  7138.       if @selected_battler.action.skill?
  7139.         obj = @selected_battler.action.skill
  7140.       elsif @selected_battler.action.item?
  7141.         obj = @selected_battler.action.item
  7142.       else; return
  7143.       end
  7144.     end
  7145.     #---
  7146.     @spriteset.create_magic_circle(window, obj)
  7147.     @spriteset.create_magic_square(window, obj)
  7148.   end
  7149.  
  7150.   #--------------------------------------------------------------------------
  7151.   # new method: dispose_aoe_indicator
  7152.   #--------------------------------------------------------------------------
  7153.   def dispose_aoe_indicator
  7154.     @spriteset.dispose_magic_circle
  7155.     @spriteset.dispose_magic_square
  7156.   end
  7157.  
  7158. end # Scene_Battle
  7159.  
  7160. #===============================================================================
  7161. #
  7162. # END OF FILE
  7163. #
  7164. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement