Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Nov 20th, 2011  |  syntax: None  |  size: 261.18 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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.       ["EFFECT", ["USER", "WHITE FLASH"]],
  146.       ["WAIT", [45, "SKIP"]],
  147.     ] # Do not remove this.
  148.    
  149.     #===========================================================================
  150.     # Wait Mini-Actions
  151.     # -------------------------------------------------------------------------
  152.     # This is the action command when for waiting battlers. These aren't unique
  153.     # for each weapon or item or enemy. This is universal amongst all waits.
  154.     #===========================================================================
  155.     WAIT_ACTIONS =[
  156.       ["MESSAGE", ["COMMAND WAIT"]],
  157.       ["EFFECT", ["USER", "WHITE FLASH"]],
  158.       ["WAIT", [45, "SKIP"]],
  159.     ] # Do not remove this.
  160.    
  161.     #===========================================================================
  162.     # Enemy Escape Mini-Actions
  163.     # -------------------------------------------------------------------------
  164.     # This is only applied to enemies who can escape. These aren't unique for
  165.     # each enemy. All escaping enemies will draw from the same action list.
  166.     #===========================================================================
  167.     ENEMY_ESCAPE_ACTIONS =[
  168.       ["MESSAGE", ["COMMAND ESCAPE"]],
  169.       ["SE", ["PLAY ESCAPE"]],
  170.       ["TURN USER", ["BACKWARD"]],
  171.       ["STANCE", ["USER", "RETURN"]],
  172.       ["MOVE USER", ["BACKWARD", 32, 30]],
  173.       ["WAIT", [30, "SKIP"]],
  174.       ["ESCAPE EFFECT", ["USER"]],
  175.       ["WAIT", [60, "SKIP"]],
  176.     ] # Do not remove this.
  177.    
  178.     #===========================================================================
  179.     # Actor Escape Mini-Actions
  180.     # -------------------------------------------------------------------------
  181.     # This is only applied to the party when an escape is successful. This will
  182.     # be applied to the whole party at once, but only non-dead members will
  183.     # visually run away.
  184.     #===========================================================================
  185.     ACTOR_ESCAPE_ACTIONS =[
  186.       ["TURN PARTY", ["BACKWARD"]],
  187.       ["STANCE", ["PARTY", "RETURN"]],
  188.       ["MOVE PARTY", ["BACKWARD", 256, 60, "WAIT"]],
  189.     ] # Do not remove this.
  190.    
  191.     #===========================================================================
  192.     # Critical Mini-Actions
  193.     # -------------------------------------------------------------------------
  194.     # This is what will occur when a critical hit occurs. These actions aren't
  195.     # unique per character. All critical hits will play the same action.
  196.     #===========================================================================
  197.     CRITICAL_ACTIONS =[
  198.     # ["POPUP", ["TARGET", "POP_CRITICAL"]],
  199.       ["MESSAGE", ["COMMAND CRITICAL"]],
  200.     ] # Do not remove this.
  201.    
  202.     #===========================================================================
  203.     # Miss Mini-Actions
  204.     # -------------------------------------------------------------------------
  205.     # This is what will occur when a miss event occurs. These actions aren't
  206.     # unique per character. All miss cases will play the same action.
  207.     #===========================================================================
  208.     MISS_ACTIONS =[
  209.       ["STANCE", ["TARGET", "EVADE"]],
  210.       ["POSE", ["TARGET", "EVADE"]],
  211.       ["POPUP", ["TARGET", "POP_MISS"]],
  212.       ["MESSAGE", ["COMMAND MISS"]],
  213.       ["SE", ["PLAY MISS"]],
  214.     ] # Do not remove this.
  215.    
  216.     #===========================================================================
  217.     # Evade Mini-Actions
  218.     # -------------------------------------------------------------------------
  219.     # This is what will occur when a evasion occurs. These actions aren't
  220.     # unique per character. All evasion cases will play the same action.
  221.     #===========================================================================
  222.     EVADE_ACTIONS =[
  223.       ["STANCE", ["TARGET", "EVADE"]],
  224.       ["POSE", ["TARGET", "EVADE"]],
  225.       ["POPUP", ["TARGET", "POP_EVADE"]],
  226.       ["MESSAGE", ["COMMAND EVADE"]],
  227.       ["SE", ["PLAY EVADE"]],
  228.     ] # Do not remove this.
  229.    
  230.     #===========================================================================
  231.     # Fail Mini-Actions
  232.     # -------------------------------------------------------------------------
  233.     # When skills fail or items fail, the fail actions will be called upon to
  234.     # produce a series of actions. All fail cases will play the same action.
  235.     #===========================================================================
  236.     FAIL_ACTIONS =[
  237.       ["POPUP", ["TARGET", "POP_FAIL"]],
  238.       ["MESSAGE", ["COMMAND FAIL"]],
  239.     ] # Do not remove this.
  240.    
  241.     #===========================================================================
  242.     # HP Damage Mini-Actions
  243.     # -------------------------------------------------------------------------
  244.     # The following sets the HP damage series. These are the actions played
  245.     # when a target takes 0 HP damage, receives healing, or the takes damage.
  246.     # Absorption is taken into consideration for healing and damage.
  247.     #===========================================================================
  248.     HP_DAMAGE_NONE =[
  249.       ["POPUP", ["TARGET", "HP_NONE"]],
  250.       ["MESSAGE", ["COMMAND HP DAMAGE", "NONE"]],
  251.     ] # Do not remove this.
  252.     HP_DAMAGE_HEAL =[
  253.       ["POPUP", ["TARGET", "HP_HEAL"]],
  254.       ["MESSAGE", ["COMMAND HP DAMAGE", "HEAL"]],
  255.       ["SE", ["PLAY RECOVERY"]],
  256.     ] # Do not remove this.
  257.     HP_DAMAGE_DMG =[
  258.       ["STANCE", ["TARGET", "DAMAGE"]],
  259.       ["POSE", ["TARGET", "DAMAGE"]],
  260.       ["POPUP", ["TARGET", "HP_DMG"]],
  261.       ["MESSAGE", ["COMMAND HP DAMAGE", "DAMAGE"]],
  262.       ["SE", ["PLAY ACTOR DAMAGE", "if target.actor?"]],
  263.       ["SE", ["PLAY ENEMY DAMAGE", "if target.enemy?"]],
  264.     ] # Do not remove this.
  265.    
  266.     #===========================================================================
  267.     # MP Damage Mini-Actions
  268.     # -------------------------------------------------------------------------
  269.     # The following sets the MP damage series. These are the actions played
  270.     # when a target takes 0 MP damage, receives healing, or the takes damage.
  271.     # Absorption is taken into consideration for healing and damage.
  272.     #===========================================================================
  273.     MP_DAMAGE_HEAL =[
  274.       ["POPUP", ["TARGET", "MP_HEAL"]],
  275.       ["MESSAGE", ["COMMAND MP DAMAGE", "HEAL"]],
  276.       ["SE", ["PLAY RECOVERY"]],
  277.     ] # Do not remove this.
  278.     MP_DAMAGE_DMG =[
  279.       ["POPUP", ["TARGET", "MP_DMG"]],
  280.       ["MESSAGE", ["COMMAND MP DAMAGE", "DAMAGE"]],
  281.       ["SE", ["PLAY ACTOR DAMAGE", "if target.actor?"]],
  282.       ["SE", ["PLAY ENEMY DAMAGE", "if target.enemy?"]],
  283.     ] # Do not remove this.
  284.    
  285.     #===========================================================================
  286.     # State Change Mini-Actions
  287.     # -------------------------------------------------------------------------
  288.     # The following sets the state change series. These actions are played
  289.     # whenever a target receives a state change through an executed action.
  290.     #===========================================================================
  291.     ADD_STATE =[
  292.       ["POPUP", ["TARGET", "POP_ADDSTATE"]],
  293.       ["MESSAGE", ["COMMAND STATES", "ADDED"]],
  294.     ] # Do not remove this.
  295.     REM_STATE =[
  296.       ["POPUP", ["TARGET", "POP_REMSTATE"]],
  297.       ["MESSAGE", ["COMMAND STATES", "REMOVE"]],
  298.     ] # Do not remove this.
  299.     DUR_STATE =[
  300.       ["POPUP", ["TARGET", "POP_DURSTATE"]],
  301.       ["MESSAGE", ["COMMAND STATES", "REMAINED"]],
  302.     ] # Do not remove this.
  303.    
  304.   end # DEFAULT_ACTIONS
  305. end # YEM
  306.  
  307. #===============================================================================
  308. # Editting anything past this point may potentially result in causing computer
  309. # damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
  310. # Therefore, edit at your own risk.
  311. #===============================================================================
  312.  
  313. #===============================================================================
  314. # module Icon
  315. #===============================================================================
  316.  
  317. module Icon
  318.  
  319.   #--------------------------------------------------------------------------
  320.   # self.element
  321.   #--------------------------------------------------------------------------
  322.   def self.element(element_id)
  323.     icon = YEM::BATTLE_ENGINE::ELEMENT_ICONS[element_id]
  324.     return (icon == nil) ? 0 : icon
  325.   end
  326.  
  327.   #--------------------------------------------------------------------------
  328.   # self.stat
  329.   #--------------------------------------------------------------------------
  330.   def self.stat(actor, item)
  331.     limit = actor.parameter_limit
  332.     icon = 0
  333.     case item
  334.     when :atk
  335.       if actor.atk > actor.base_atk
  336.         icon = Icon.stat_up(item)
  337.       elsif actor.atk < actor.base_atk and actor.atk != limit
  338.         icon = Icon.stat_dn(item)
  339.       end
  340.      
  341.     when :def
  342.       if actor.def > actor.base_def
  343.         icon = Icon.stat_up(item)
  344.       elsif actor.def < actor.base_def and actor.def != limit
  345.         icon = Icon.stat_dn(item)
  346.       end
  347.      
  348.     when :spi
  349.       if actor.spi > actor.base_spi
  350.         icon = Icon.stat_up(item)
  351.       elsif actor.spi < actor.base_spi and actor.spi != limit
  352.         icon = Icon.stat_dn(item)
  353.       end
  354.      
  355.     when :res
  356.       return icon unless $imported["RES Stat"]
  357.       if actor.res > actor.base_res
  358.         icon = Icon.stat_up(item)
  359.       elsif actor.res < actor.base_res and actor.res != limit
  360.         icon = Icon.stat_dn(item)
  361.       end
  362.      
  363.     when :dex
  364.       return icon unless $imported["DEX Stat"]
  365.       if actor.dex > actor.base_dex
  366.         icon = Icon.stat_up(item)
  367.       elsif actor.dex < actor.base_dex and actor.dex != limit
  368.         icon = Icon.stat_dn(item)
  369.       end
  370.      
  371.     when :agi
  372.       if actor.agi > actor.base_agi
  373.         icon = Icon.stat_up(item)
  374.       elsif actor.agi < actor.base_agi and actor.agi != limit
  375.         icon = Icon.stat_dn(item)
  376.       end
  377.     end
  378.     return icon
  379.   end
  380.  
  381.   #--------------------------------------------------------------------------
  382.   # self.stat_up
  383.   #--------------------------------------------------------------------------
  384.   def self.stat_up(item = nil)
  385.     return YEM::BATTLE_ENGINE::STAT_ICONS[:stat_up]
  386.   end
  387.  
  388.   #--------------------------------------------------------------------------
  389.   # self.stat_dn
  390.   #--------------------------------------------------------------------------
  391.   def self.stat_dn(item = nil)
  392.     return YEM::BATTLE_ENGINE::STAT_ICONS[:stat_dn]
  393.   end
  394.  
  395.   #--------------------------------------------------------------------------
  396.   # self.normal_state
  397.   #--------------------------------------------------------------------------
  398.   def self.normal_state
  399.     return YEM::BATTLE_ENGINE::STAT_ICONS[:normal]
  400.   end
  401.  
  402.   #--------------------------------------------------------------------------
  403.   # self.mp_cost
  404.   #--------------------------------------------------------------------------
  405.   def self.mp_cost
  406.     return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:mp_icon]
  407.   end
  408.  
  409.   #--------------------------------------------------------------------------
  410.   # self.hp_cost
  411.   #--------------------------------------------------------------------------
  412.   def self.hp_cost
  413.     return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:hp_icon]
  414.   end
  415.  
  416.   #--------------------------------------------------------------------------
  417.   # self.gold_cost
  418.   #--------------------------------------------------------------------------
  419.   def self.gold_cost
  420.     return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:gold_icon]
  421.   end
  422.  
  423.   #--------------------------------------------------------------------------
  424.   # self.rage_cost
  425.   #--------------------------------------------------------------------------
  426.   def self.rage_cost
  427.     return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:rage_icon]
  428.   end
  429.  
  430.   #--------------------------------------------------------------------------
  431.   # self.cooldown
  432.   #--------------------------------------------------------------------------
  433.   def self.cooldown
  434.     return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:cooldown_icon]
  435.   end
  436.  
  437.   #--------------------------------------------------------------------------
  438.   # self.limited_use
  439.   #--------------------------------------------------------------------------
  440.   def self.limited_use
  441.     return YEM::BATTLE_ENGINE::SKILL_SETTINGS[:limited_icon]
  442.   end
  443.  
  444. end # Icon
  445.  
  446. #===============================================================================
  447. # Game_Battler
  448. #===============================================================================
  449.  
  450. class Game_Battler
  451.  
  452.   #--------------------------------------------------------------------------
  453.   # public instance variables
  454.   #--------------------------------------------------------------------------
  455.   attr_accessor :battler_animation_id
  456.   attr_accessor :battler_icon
  457.   attr_accessor :pseudo_ani_id
  458.   attr_accessor :popup_array
  459.   attr_accessor :sub_animation_id
  460.   attr_accessor :vanish_case
  461.  
  462.   #--------------------------------------------------------------------------
  463.   # alias method: clear_sprite_effects
  464.   #--------------------------------------------------------------------------
  465.   alias clear_sprite_effects_bem clear_sprite_effects unless $@
  466.   def clear_sprite_effects
  467.     clear_sprite_effects_bem
  468.     @pseudo_ani_id = 0
  469.   end
  470.  
  471.   #--------------------------------------------------------------------------
  472.   # new method: state_animation_zoom
  473.   #--------------------------------------------------------------------------
  474.   def state_animation_zoom; return 100; end
  475.  
  476.   #--------------------------------------------------------------------------
  477.   # new method: reload_state_animation
  478.   #--------------------------------------------------------------------------
  479.   def reload_state_animation
  480.     return unless $scene.is_a?(Scene_Battle)
  481.     @state_animation_id = 0
  482.     for state in states
  483.       next unless state.state_ani > 0
  484.       @state_animation_id = state.state_ani
  485.       break
  486.     end
  487.   end
  488.  
  489.   #--------------------------------------------------------------------------
  490.   # new method: create_popup
  491.   #--------------------------------------------------------------------------
  492.   def create_popup(value, rules = "DEFAULT", flags = [])
  493.     return unless $scene.is_a?(Scene_Battle)
  494.     if flags.include?("critical") and $scene.ptb?
  495.       bonus = YEM::BATTLE_ENGINE::PTB_RULES[:regain_critical]
  496.       action.opponents_unit.gain_bonus($scene.active_battler, bonus)
  497.     end
  498.     array = [value, rules, flags]
  499.     @popup_array = [] if @popup_array == nil
  500.     @popup_array.push(array)
  501.   end
  502.  
  503.   #--------------------------------------------------------------------------
  504.   # new method: white_flash=
  505.   #--------------------------------------------------------------------------
  506.   def white_flash=(value)
  507.     return unless exist?
  508.     @white_flash = value
  509.   end
  510.  
  511.   #--------------------------------------------------------------------------
  512.   # new methods: bitmap_height and bitmap_width
  513.   #--------------------------------------------------------------------------
  514.   def bitmap_height; return Integer(spriteset.height * zoom); end
  515.   def bitmap_width; return Integer(spriteset.width * zoom); end
  516.    
  517.   #--------------------------------------------------------------------------
  518.   # new method: spriteset
  519.   #--------------------------------------------------------------------------
  520.   def spriteset
  521.     return $scene.spriteset.enemy_sprites.reverse[self.index]
  522.   end
  523.  
  524.   #--------------------------------------------------------------------------
  525.   # new method: attack_icon
  526.   #--------------------------------------------------------------------------
  527.   def attack_icon
  528.     return YEM::BATTLE_ENGINE::ICON_MESSAGE[:atk_icon]
  529.   end
  530.  
  531.   #--------------------------------------------------------------------------
  532.   # new method: guard_icon
  533.   #--------------------------------------------------------------------------
  534.   def guard_icon
  535.     return YEM::BATTLE_ENGINE::ICON_MESSAGE[:grd_icon]
  536.   end
  537.  
  538.   #--------------------------------------------------------------------------
  539.   # new method: sprite_movable?
  540.   #--------------------------------------------------------------------------
  541.   def sprite_movable?
  542.     return false if !exist?
  543.     return true
  544.   end
  545.  
  546.   #--------------------------------------------------------------------------
  547.   # new method: mirror?
  548.   #--------------------------------------------------------------------------
  549.   def mirror?; return false; end
  550.    
  551.   #--------------------------------------------------------------------------
  552.   # new method: zoom
  553.   #--------------------------------------------------------------------------
  554.   def zoom; return 1.0; end
  555.  
  556.   #--------------------------------------------------------------------------
  557.   # use_battler_animations?
  558.   #--------------------------------------------------------------------------
  559.   def use_battler_animations?; return false; end
  560.    
  561.   #--------------------------------------------------------------------------
  562.   # battler_animation_stance
  563.   #--------------------------------------------------------------------------
  564.   def battler_animation_stance(string); return; end
  565.  
  566. end # Game_Battler
  567.  
  568. #===============================================================================
  569. # Game_Actor
  570. #===============================================================================
  571.  
  572. class Game_Actor < Game_Battler
  573.  
  574.   #--------------------------------------------------------------------------
  575.   # quick methods: use_sprite? screen_z battler_name battler_hue
  576.   #--------------------------------------------------------------------------
  577.   def use_sprite?; return true; end
  578.   def battler_name; return ""; end
  579.   def battler_hue; return 0; end
  580.  
  581.   #--------------------------------------------------------------------------
  582.   # alias method: atk_animation_id
  583.   #--------------------------------------------------------------------------
  584.   alias atk_animation_id_bem atk_animation_id unless $@
  585.   def atk_animation_id
  586.     return @cache_atk_animation[1] if @cache_atk_animation[1] != nil
  587.     @cache_atk_animation[1] = atk_animation_id_bem
  588.     for state in states
  589.       next unless state.attack_animation > 0
  590.       @cache_atk_animation[1] = state.attack_animation
  591.       break
  592.     end
  593.     return @cache_atk_animation[1]
  594.   end
  595.  
  596.   #--------------------------------------------------------------------------
  597.   # alias method: atk_animation_id2
  598.   #--------------------------------------------------------------------------
  599.   alias atk_animation_id2_bem atk_animation_id2 unless $@
  600.   def atk_animation_id2
  601.     return @cache_atk_animation[2] if @cache_atk_animation[2] != nil
  602.     @cache_atk_animation[2] = atk_animation_id2_bem
  603.     return @cache_atk_animation[2] if @cache_atk_animation[2] == 0
  604.     for state in states
  605.       next unless state.attack_animation > 0
  606.       @cache_atk_animation[2] = state.attack_animation
  607.       break
  608.     end
  609.     return @cache_atk_animation[2]
  610.   end
  611.  
  612.   #--------------------------------------------------------------------------
  613.   # new method: state_animation_zoom
  614.   #--------------------------------------------------------------------------
  615.   def state_animation_zoom
  616.     return YEM::BATTLE_ENGINE::STATE_SETTINGS[:actor_ani_zoom]
  617.   end
  618.  
  619.   #--------------------------------------------------------------------------
  620.   # new method: screen_x
  621.   #--------------------------------------------------------------------------
  622.   def screen_x
  623.     return 0 unless $scene.is_a?(Scene_Battle)
  624.     if $scene.emptyview? or character == nil
  625.       calc = Graphics.width - 128 - 32
  626.       max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
  627.       maximum = [$game_party.members.size, max_members].max
  628.       calc /= maximum
  629.       width = calc
  630.       n = index * width + width/2 + 16
  631.       n += 128
  632.       n -= $scene.info_viewport.ox if $scene.info_viewport != nil
  633.       return n
  634.     end
  635.     return character.screen_x
  636.   end
  637.  
  638.   #--------------------------------------------------------------------------
  639.   # new method: screen_x=
  640.   #--------------------------------------------------------------------------
  641.   def screen_x=(value); character.screen_x = value; end
  642.  
  643.   #--------------------------------------------------------------------------
  644.   # new method: origin_x
  645.   #--------------------------------------------------------------------------
  646.   def origin_x
  647.     return 0 unless $scene.is_a?(Scene_Battle)
  648.     return screen_x if $scene.emptyview?
  649.     return character.origin_x
  650.   end
  651.  
  652.   #--------------------------------------------------------------------------
  653.   # new method: screen_y
  654.   #--------------------------------------------------------------------------
  655.   def screen_y
  656.     return 0 unless $scene.is_a?(Scene_Battle)
  657.     if $scene.emptyview? or character == nil
  658.       n = Graphics.height - 128
  659.       return n
  660.     end
  661.     return character.screen_y
  662.   end
  663.  
  664.   #--------------------------------------------------------------------------
  665.   # new method: screen_y=
  666.   #--------------------------------------------------------------------------
  667.   def screen_y=(value); character.screen_y = value; end
  668.  
  669.   #--------------------------------------------------------------------------
  670.   # new method: origin_y
  671.   #--------------------------------------------------------------------------
  672.   def origin_y
  673.     return 0 unless $scene.is_a?(Scene_Battle)
  674.     return screen_y if $scene.emptyview?
  675.     return character.origin_y
  676.   end
  677.  
  678.   #--------------------------------------------------------------------------
  679.   # new method: screen_z
  680.   #--------------------------------------------------------------------------
  681.   def screen_z
  682.     return 100 unless $scene.is_a?(Scene_Battle)
  683.     return 100 if $scene.emptyview? or character == nil
  684.     return character.screen_z + character.screen_y
  685.   end
  686.  
  687.   #--------------------------------------------------------------------------
  688.   # new method: screen_z=
  689.   #--------------------------------------------------------------------------
  690.   def screen_z=(value); character.screen_z = value; end
  691.    
  692.   #--------------------------------------------------------------------------
  693.   # new method: spriteset
  694.   #--------------------------------------------------------------------------
  695.   def spriteset
  696.     return $scene.spriteset.actor_sprites[self.index]
  697.   end
  698.  
  699.   #--------------------------------------------------------------------------
  700.   # new method: character
  701.   #--------------------------------------------------------------------------
  702.   def character
  703.     return nil unless $scene.is_a?(Scene_Battle)
  704.     return $scene.characters[self.index]
  705.   end
  706.  
  707.   #--------------------------------------------------------------------------
  708.   # new method: attack_icon
  709.   #--------------------------------------------------------------------------
  710.   def attack_icon
  711.     return super if weapons.compact == []
  712.     return weapon1_icon
  713.   end
  714.  
  715.   #--------------------------------------------------------------------------
  716.   # new method: guard_icon
  717.   #--------------------------------------------------------------------------
  718.   def guard_icon
  719.     for armor in armors.compact
  720.       next unless armor.kind == 0
  721.       return armor.icon_index
  722.     end
  723.     return super
  724.   end
  725.  
  726.   #--------------------------------------------------------------------------
  727.   # new method: battler_icon
  728.   #--------------------------------------------------------------------------
  729.   def battler_icon
  730.     if YEM::BATTLE_ENGINE::BATTLER_ACTOR_ICONS.include?(@actor_id)
  731.       return YEM::BATTLE_ENGINE::BATTLER_ACTOR_ICONS[@actor_id]
  732.     elsif YEM::BATTLE_ENGINE::BATTLER_CLASS_ICONS.include?(@class_id)
  733.       return YEM::BATTLE_ENGINE::BATTLER_CLASS_ICONS[@class_id]
  734.     end
  735.     return YEM::BATTLE_ENGINE::DEFAULT_ACTOR_ICON
  736.   end
  737.  
  738.   #--------------------------------------------------------------------------
  739.   # new method: weapon1_icon
  740.   #--------------------------------------------------------------------------
  741.   def weapon1_icon
  742.     return @cache_weapon_icon[1] if @cache_weapon_icon[1] != nil
  743.     icon = 0
  744.     icon = weapons[0].icon_index if weapons.compact.size > 0
  745.     for state in states
  746.       next unless state.weapon_icon > 0
  747.       icon = state.weapon_icon
  748.       break
  749.     end
  750.     @cache_weapon_icon[1] = icon
  751.     return @cache_weapon_icon[1]
  752.   end
  753.  
  754.   #--------------------------------------------------------------------------
  755.   # new method: weapon2_icon
  756.   #--------------------------------------------------------------------------
  757.   def weapon2_icon
  758.     return @cache_weapon_icon[2] if @cache_weapon_icon[2] != nil
  759.     icon = 0
  760.     icon = weapons[1].icon_index if weapons.compact.size > 1
  761.     for state in states
  762.       next unless state.weapon_icon > 0
  763.       icon = state.weapon_icon
  764.       break
  765.     end
  766.     @cache_weapon_icon[2] = icon
  767.     return @cache_weapon_icon[2]
  768.   end
  769.  
  770.   #--------------------------------------------------------------------------
  771.   # use_battler_animations?
  772.   #--------------------------------------------------------------------------
  773.   def use_battler_animations?
  774.     array = [@character_name, @character_index]
  775.     return YEM::BATTLE_ENGINE::ANIMATION_BATTLER_ACTORS.include?(array)
  776.   end
  777.  
  778.   #--------------------------------------------------------------------------
  779.   # battler_animation_stance
  780.   #--------------------------------------------------------------------------
  781.   def battler_animation_stance(string)
  782.     array = [@character_name, @character_index]
  783.     hash = YEM::BATTLE_ENGINE::ANIMATION_BATTLER_ACTORS[array]
  784.     return unless hash.include?(string)
  785.     @battler_animation_id = hash[string]
  786.   end
  787.  
  788. end # Game_Actor
  789.  
  790. #===============================================================================
  791. # Game_Enemy
  792. #===============================================================================
  793.  
  794. class Game_Enemy < Game_Battler
  795.  
  796.   #--------------------------------------------------------------------------
  797.   # public instance variables
  798.   #--------------------------------------------------------------------------
  799.   attr_accessor :direction
  800.   attr_accessor :origin_x
  801.   attr_accessor :origin_y
  802.  
  803.   #--------------------------------------------------------------------------
  804.   # new method: screen_x
  805.   #--------------------------------------------------------------------------
  806.   def screen_x
  807.     return character == nil ? @screen_x : character.screen_x
  808.   end
  809.  
  810.   #--------------------------------------------------------------------------
  811.   # new method: screen_x=
  812.   #--------------------------------------------------------------------------
  813.   def screen_x=(value)
  814.     @screen_x = value if character == nil
  815.     character.screen_x = value if character != nil
  816.   end
  817.  
  818.   #--------------------------------------------------------------------------
  819.   # new method: screen_y
  820.   #--------------------------------------------------------------------------
  821.   def screen_y
  822.     return character == nil ? @screen_y : character.screen_y
  823.   end
  824.  
  825.   #--------------------------------------------------------------------------
  826.   # new method: screen_y=
  827.   #--------------------------------------------------------------------------
  828.   def screen_y=(value)
  829.     @screen_y = value if character == nil
  830.     character.screen_y = value if character != nil
  831.   end
  832.  
  833.   #--------------------------------------------------------------------------
  834.   # alias method: screen_z
  835.   #--------------------------------------------------------------------------
  836.   alias screen_z_enemy screen_z unless $@
  837.   def screen_z
  838.     return @battle_screen_z if @battle_screen_z != nil
  839.     return screen_z_enemy + self.screen_y
  840.   end
  841.  
  842.   #--------------------------------------------------------------------------
  843.   # new method: screen_z=
  844.   #--------------------------------------------------------------------------
  845.   def screen_z=(value)
  846.     @battle_screen_z = value if character == nil
  847.     character.screen_z = value if character != nil
  848.   end
  849.  
  850.   #--------------------------------------------------------------------------
  851.   # new method: character
  852.   #--------------------------------------------------------------------------
  853.   def character
  854.     if enemy.character_name == "" or !$scene.is_a?(Scene_Battle)
  855.       return nil
  856.     else
  857.       return $scene.enemychars[self]
  858.     end
  859.   end
  860.  
  861.   #--------------------------------------------------------------------------
  862.   # new method: character_name
  863.   #--------------------------------------------------------------------------
  864.   def character_name; return enemy.character_name; end
  865.  
  866.   #--------------------------------------------------------------------------
  867.   # new method: character_index
  868.   #--------------------------------------------------------------------------
  869.   def character_index; return enemy.character_index; end
  870.  
  871.   #--------------------------------------------------------------------------
  872.   # new method: screen_z=
  873.   #--------------------------------------------------------------------------
  874.   def screen_z=(value); @battle_screen_z = value; end
  875.  
  876.   #--------------------------------------------------------------------------
  877.   # new method: state_animation_zoom
  878.   #--------------------------------------------------------------------------
  879.   def state_animation_zoom; return enemy.state_zoom; end
  880.  
  881.   #--------------------------------------------------------------------------
  882.   # new method: atk_animation_id
  883.   #--------------------------------------------------------------------------
  884.   def atk_animation_id
  885.     return @cache_atk_animation[1] if @cache_atk_animation[1] != nil
  886.     @cache_atk_animation[1] = enemy.attack_animation
  887.     for state in states
  888.       next unless state.attack_animation > 0
  889.       @cache_atk_animation[1] = state.attack_animation
  890.       break
  891.     end
  892.     return @cache_atk_animation[1]
  893.   end
  894.  
  895.   #--------------------------------------------------------------------------
  896.   # new method: attack_icon
  897.   #--------------------------------------------------------------------------
  898.   def attack_icon
  899.     return enemy.weapons[0].icon_index if enemy.weapons.compact.size > 0
  900.     return super
  901.   end
  902.  
  903.   #--------------------------------------------------------------------------
  904.   # new method: weapon1_icon
  905.   #--------------------------------------------------------------------------
  906.   def weapon1_icon
  907.     return enemy.weapons[0].icon_index if enemy.weapons.compact.size > 0
  908.     return 0
  909.   end
  910.  
  911.   #--------------------------------------------------------------------------
  912.   # new method: weapon2_icon
  913.   #--------------------------------------------------------------------------
  914.   def weapon2_icon
  915.     return enemy.weapons[1].icon_index if enemy.weapons.compact.size > 1
  916.     return 0
  917.   end
  918.  
  919.   #--------------------------------------------------------------------------
  920.   # new method: guard_icon
  921.   #--------------------------------------------------------------------------
  922.   def guard_icon
  923.     if enemy.shield != nil and enemy.shield.icon_index != 0
  924.       return enemy.shield.icon_index
  925.     end
  926.     return super
  927.   end
  928.  
  929.   #--------------------------------------------------------------------------
  930.   # new method: battler_icon
  931.   #--------------------------------------------------------------------------
  932.   def battler_icon; return enemy.enemy_icon; end
  933.  
  934.   #--------------------------------------------------------------------------
  935.   # new method: mirror?
  936.   #--------------------------------------------------------------------------
  937.   def mirror?
  938.     return false unless $scene.is_a?(Scene_Battle)
  939.     case $scene.view_type
  940.     when 0; return enemy.view_mirror[:empty]
  941.     when 1; return enemy.view_mirror[:front]
  942.     when 2; return enemy.view_mirror[:side]
  943.     when 3; return enemy.view_mirror[:angle]
  944.     end
  945.     return false
  946.   end
  947.  
  948.   #--------------------------------------------------------------------------
  949.   # new method: zoom
  950.   #--------------------------------------------------------------------------
  951.   def zoom
  952.     return false unless $scene.is_a?(Scene_Battle)
  953.     case $scene.view_type
  954.     when 0; return enemy.view_zoom[:empty]
  955.     when 1; return enemy.view_zoom[:front]
  956.     when 2; return enemy.view_zoom[:side]
  957.     when 3; return enemy.view_zoom[:angle]
  958.     end
  959.     return false
  960.   end
  961.  
  962.   #--------------------------------------------------------------------------
  963.   # use_battler_animations?
  964.   #--------------------------------------------------------------------------
  965.   def use_battler_animations?
  966.     return enemy.animation_stance.include?("IDLE")
  967.   end
  968.  
  969.   #--------------------------------------------------------------------------
  970.   # battler_animation_stance
  971.   #--------------------------------------------------------------------------
  972.   def battler_animation_stance(string)
  973.     return unless enemy.animation_stance.include?(string)
  974.     @battler_animation_id = enemy.animation_stance[string]
  975.   end
  976.  
  977.   #--------------------------------------------------------------------------
  978.   # new method: sprite_movable?
  979.   #--------------------------------------------------------------------------
  980.   def sprite_movable?
  981.     return false if enemy.unmoving
  982.     return super
  983.   end
  984.  
  985.   #--------------------------------------------------------------------------
  986.   # new method: weapons
  987.   #--------------------------------------------------------------------------
  988.   def weapons; return enemy.weapons; end
  989.  
  990.   #--------------------------------------------------------------------------
  991.   # new method: armor1_id
  992.   #--------------------------------------------------------------------------
  993.   def armor1_id; return enemy.shield == nil ? 0 : enemy.shield.id; end
  994.  
  995. end # Game_Enemy
  996.  
  997. #===============================================================================
  998. # Game_Troop
  999. #===============================================================================
  1000.  
  1001. class Game_Troop < Game_Unit
  1002.  
  1003.   #--------------------------------------------------------------------------
  1004.   # overwrite method: setup
  1005.   #--------------------------------------------------------------------------
  1006.   def setup(troop_id)
  1007.     clear
  1008.     @troop_id = troop_id
  1009.     @enemies = []
  1010.     case $game_variables[YEM::BATTLE_ENGINE::VIEW_TYPE_VARIABLE]
  1011.     when 1; type = :front
  1012.     when 2; type = :side
  1013.     when 3; type = :angle
  1014.     else    type = :empty
  1015.     end
  1016.     offsets = YEM::BATTLE_ENGINE::AUTO_POSITION_ADJUSTMENTS[type]
  1017.     offsets = [0,0,1.0,0.0,0.0,1.0] if !YEM::BATTLE_ENGINE::AUTO_ENEMY_POSITIONS
  1018.     for member in troop.members
  1019.       next if $data_enemies[member.enemy_id] == nil
  1020.       enemy = Game_Enemy.new(@enemies.size, member.enemy_id)
  1021.       enemy.hidden = member.hidden
  1022.       enemy.immortal = member.immortal
  1023.       #---
  1024.       result_x = (member.x * offsets[2]) + (member.y * offsets[4])
  1025.       result_x += offsets[0] # Offset X
  1026.       #---
  1027.       result_y = (member.x * offsets[3]) + (member.y * offsets[5])
  1028.       result_y += offsets[1] # Offset Y
  1029.       #---
  1030.       enemy.screen_x = Integer(result_x)
  1031.       enemy.screen_y = Integer(result_y)
  1032.       enemy.origin_x = enemy.screen_x
  1033.       enemy.origin_y = enemy.screen_y
  1034.       @enemies.push(enemy)
  1035.     end
  1036.     make_unique_names
  1037.   end
  1038.  
  1039. end # Game_Troop
  1040.  
  1041. #===============================================================================
  1042. # Game_Map
  1043. #===============================================================================
  1044.  
  1045. class Game_Map
  1046.  
  1047.   #--------------------------------------------------------------------------
  1048.   # alias method: loop_horizontal?
  1049.   #--------------------------------------------------------------------------
  1050.   alias loop_horizontal_bem loop_horizontal? unless $@
  1051.   def loop_horizontal?
  1052.     return false if $game_temp.in_battle
  1053.     return loop_horizontal_bem
  1054.   end
  1055.  
  1056.   #--------------------------------------------------------------------------
  1057.   # alias method: loop_vertical?
  1058.   #--------------------------------------------------------------------------
  1059.   alias loop_vertical_bem loop_vertical? unless $@
  1060.   def loop_vertical?
  1061.     return false if $game_temp.in_battle
  1062.     return loop_vertical_bem
  1063.   end
  1064.  
  1065. end # Game_Map
  1066.  
  1067. #===============================================================================
  1068. # Game_Character
  1069. #===============================================================================
  1070.  
  1071. class Game_Character
  1072.  
  1073.   #--------------------------------------------------------------------------
  1074.   # public instance variables
  1075.   #--------------------------------------------------------------------------
  1076.   attr_accessor :mirror
  1077.   attr_accessor :opacity
  1078.   attr_accessor :origin_x
  1079.   attr_accessor :origin_y
  1080.   attr_accessor :step_anime
  1081.  
  1082.   #--------------------------------------------------------------------------
  1083.   # alias method: screen_x
  1084.   #--------------------------------------------------------------------------
  1085.   alias screen_x_character_bem screen_x unless $@
  1086.   def screen_x
  1087.     return @battle_screen_x if @battle_screen_x != nil
  1088.     return screen_x_character_bem
  1089.   end
  1090.  
  1091.   #--------------------------------------------------------------------------
  1092.   # new method: screen_x=
  1093.   #--------------------------------------------------------------------------
  1094.   def screen_x=(value); @battle_screen_x = value; end
  1095.  
  1096.   #--------------------------------------------------------------------------
  1097.   # alias method: screen_y
  1098.   #--------------------------------------------------------------------------
  1099.   alias screen_y_character_bem screen_y unless $@
  1100.   def screen_y
  1101.     return @battle_screen_y if @battle_screen_y != nil
  1102.     return screen_y_character_bem
  1103.   end
  1104.  
  1105.   #--------------------------------------------------------------------------
  1106.   # new method: screen_y=
  1107.   #--------------------------------------------------------------------------
  1108.   def screen_y=(value); @battle_screen_y = value; end
  1109.  
  1110.   #--------------------------------------------------------------------------
  1111.   # alias method: screen_z
  1112.   #--------------------------------------------------------------------------
  1113.   alias screen_z_character_bem screen_z unless $@
  1114.   def screen_z
  1115.     return @battle_screen_z if @battle_screen_z != nil
  1116.     return screen_z_character_bem
  1117.   end
  1118.  
  1119.   #--------------------------------------------------------------------------
  1120.   # new method: screen_z=
  1121.   #--------------------------------------------------------------------------
  1122.   def screen_z=(value); @battle_screen_z = value; end
  1123.  
  1124. end # Game_Character
  1125.  
  1126. #===============================================================================
  1127. # Sprite_Base
  1128. #===============================================================================
  1129.  
  1130. class Sprite_Base < Sprite
  1131.  
  1132.   #--------------------------------------------------------------------------
  1133.   # constants
  1134.   #--------------------------------------------------------------------------
  1135.   RATE = $imported["CoreFixesUpgradesMelody"] ? YEM::FIXES::ANIMATION_RATE : 4
  1136.   @@sub_animations = []
  1137.  
  1138.   #--------------------------------------------------------------------------
  1139.   # alias method: initialize
  1140.   #--------------------------------------------------------------------------
  1141.   alias initialize_sprite_base_bem initialize unless $@
  1142.   def initialize(viewport = nil)
  1143.     initialize_sprite_base_bem(viewport)
  1144.     @no_effect = false
  1145.     @banimation_duration = 0
  1146.     @sub_animation_duration = 0
  1147.   end
  1148.  
  1149.   #--------------------------------------------------------------------------
  1150.   # alias method: dispose
  1151.   #--------------------------------------------------------------------------
  1152.   alias dispose_sprite_base_bem dispose unless $@
  1153.   def dispose
  1154.     dispose_sprite_base_bem
  1155.     dispose_sub_animation
  1156.   end
  1157.  
  1158.   #--------------------------------------------------------------------------
  1159.   # alias method: update
  1160.   #--------------------------------------------------------------------------
  1161.   alias update_sprite_base_bem update unless $@
  1162.   def update
  1163.     update_sprite_base_bem
  1164.     update_sub_animation if @sub_animation != nil
  1165.     @@sub_animations.clear
  1166.   end
  1167.  
  1168.   #--------------------------------------------------------------------------
  1169.   # alias method: start_animation
  1170.   #--------------------------------------------------------------------------
  1171.   alias start_animation_bem start_animation unless $@
  1172.   def start_animation(animation, mirror = false)
  1173.     @no_effect = false
  1174.     start_animation_bem(animation, mirror)
  1175.   end
  1176.  
  1177.   #--------------------------------------------------------------------------
  1178.   # new method: start_pseudo_ani
  1179.   #--------------------------------------------------------------------------
  1180.   def start_pseudo_ani(animation, mirror = false)
  1181.     dispose_animation
  1182.     @animation = animation
  1183.     return if @animation == nil
  1184.     @no_effect = true
  1185.     @animation_mirror = mirror
  1186.     @animation_duration = @animation.frame_max * RATE + 1
  1187.     @animation_sprites = []
  1188.   end
  1189.  
  1190.   #--------------------------------------------------------------------------
  1191.   # overwrite method: animation_process_timing
  1192.   #--------------------------------------------------------------------------
  1193.   def animation_process_timing(timing)
  1194.     timing.se.play unless @no_effect
  1195.     case timing.flash_scope
  1196.     when 1
  1197.       if @battler_animation == nil
  1198.         self.flash(timing.flash_color, timing.flash_duration * RATE)
  1199.       end
  1200.       battler_animation_flash(timing) if @battler_animation != nil
  1201.     when 2
  1202.       return if @no_effect
  1203.       if viewport != nil
  1204.         viewport.flash(timing.flash_color, timing.flash_duration * RATE)
  1205.       end
  1206.     when 3
  1207.       self.flash(nil, timing.flash_duration * RATE)
  1208.       battler_animation_flash(timing) if @battler_animation != nil
  1209.     end
  1210.   end
  1211.  
  1212.   #--------------------------------------------------------------------------
  1213.   # new method: start_sub_animation
  1214.   #--------------------------------------------------------------------------
  1215.   def start_sub_animation(animation, mirror = false)
  1216.     dispose_sub_animation
  1217.     @sub_animation = animation
  1218.     return if @sub_animation == nil
  1219.     @sub_animation_mirror = mirror
  1220.     @sub_animation_duration = @sub_animation.frame_max * RATE + 1
  1221.     load_sub_animation_bitmap
  1222.     @sub_animation_sprites = []
  1223.     if @sub_animation.position != 3 or not @@sub_animations.include?(animation)
  1224.       if @use_sprite
  1225.         for i in 0..15
  1226.           sprite = ::Sprite.new(self.viewport)
  1227.           sprite.visible = false
  1228.           @sub_animation_sprites.push(sprite)
  1229.         end
  1230.         unless @@sub_animations.include?(animation)
  1231.           @@sub_animations.push(animation)
  1232.         end
  1233.       end
  1234.     end
  1235.     if @sub_animation.position == 3
  1236.       if viewport == nil
  1237.         @sub_animation_ox = Graphics.width / 2
  1238.         @sub_animation_oy = Graphics.height / 2
  1239.       else
  1240.         @sub_animation_ox = viewport.rect.width / 2
  1241.         @sub_animation_oy = viewport.rect.height / 2
  1242.       end
  1243.     else
  1244.       @sub_animation_ox = x - ox + width / 2
  1245.       @sub_animation_oy = y - oy + height / 2
  1246.       if @sub_animation.position == 0
  1247.         @sub_animation_oy -= height / 2
  1248.       elsif @sub_animation.position == 2
  1249.         @sub_animation_oy += height / 2
  1250.       end
  1251.     end
  1252.   end
  1253.  
  1254.   #--------------------------------------------------------------------------
  1255.   # new method: load_sub_animation_bitmap
  1256.   #--------------------------------------------------------------------------
  1257.   def load_sub_animation_bitmap
  1258.     animation1_name = @sub_animation.animation1_name
  1259.     animation1_hue = @sub_animation.animation1_hue
  1260.     animation2_name = @sub_animation.animation2_name
  1261.     animation2_hue = @sub_animation.animation2_hue
  1262.     @sub_animation_bitmap1 = Cache.animation(animation1_name, animation1_hue)
  1263.     @sub_animation_bitmap2 = Cache.animation(animation2_name, animation2_hue)
  1264.     if @@_reference_count.include?(@sub_animation_bitmap1)
  1265.       @@_reference_count[@sub_animation_bitmap1] += 1
  1266.     else
  1267.       @@_reference_count[@sub_animation_bitmap1] = 1
  1268.     end
  1269.     if @@_reference_count.include?(@sub_animation_bitmap2)
  1270.       @@_reference_count[@sub_animation_bitmap2] += 1
  1271.     else
  1272.       @@_reference_count[@sub_animation_bitmap2] = 1
  1273.     end
  1274.     Graphics.frame_reset
  1275.   end
  1276.  
  1277.   #--------------------------------------------------------------------------
  1278.   # new method: dispose_sub_animation
  1279.   #--------------------------------------------------------------------------
  1280.   def dispose_sub_animation
  1281.     if @sub_animation_bitmap1 != nil
  1282.       @@_reference_count[@sub_animation_bitmap1] -= 1
  1283.       if @@_reference_count[@sub_animation_bitmap1] == 0
  1284.         @sub_animation_bitmap1.dispose
  1285.       end
  1286.     end
  1287.     if @sub_animation_bitmap2 != nil
  1288.       @@_reference_count[@sub_animation_bitmap2] -= 1
  1289.       if @@_reference_count[@sub_animation_bitmap2] == 0
  1290.         @sub_animation_bitmap2.dispose
  1291.       end
  1292.     end
  1293.     if @sub_animation_sprites != nil
  1294.       for sprite in @sub_animation_sprites
  1295.         sprite.dispose
  1296.       end
  1297.       @sub_animation_sprites = nil
  1298.       @sub_animation = nil
  1299.     end
  1300.     @sub_animation_bitmap1 = nil
  1301.     @sub_animation_bitmap2 = nil
  1302.   end
  1303.  
  1304.   #--------------------------------------------------------------------------
  1305.   # new method: update_sub_animation
  1306.   #--------------------------------------------------------------------------
  1307.   def update_sub_animation
  1308.     @sub_animation_duration -= 1
  1309.     return unless @sub_animation_duration % RATE == 0
  1310.     if @sub_animation_duration > 0
  1311.       frame_index = @sub_animation.frame_max
  1312.       frame_index -= (@sub_animation_duration+RATE-1)/RATE
  1313.       sub_animation_set_sprites(@sub_animation.frames[frame_index])
  1314.       for timing in @sub_animation.timings
  1315.         next unless timing.frame == frame_index
  1316.         animation_process_timing(timing)
  1317.       end
  1318.       return
  1319.     end
  1320.     dispose_sub_animation
  1321.   end
  1322.  
  1323.   #--------------------------------------------------------------------------
  1324.   # new method: sub_animation_set_sprites
  1325.   #--------------------------------------------------------------------------
  1326.   def sub_animation_set_sprites(frame)
  1327.     cell_data = frame.cell_data
  1328.     for i in 0..15
  1329.       sprite = @sub_animation_sprites[i]
  1330.       next if sprite == nil
  1331.       pattern = cell_data[i, 0]
  1332.       if pattern == nil or pattern == -1
  1333.         sprite.visible = false
  1334.         next
  1335.       end
  1336.       if pattern < 100
  1337.         sprite.bitmap = @sub_animation_bitmap1
  1338.       else
  1339.         sprite.bitmap = @sub_animation_bitmap2
  1340.       end
  1341.       sprite.visible = true
  1342.       sprite.src_rect.set(pattern % 5 * 192,
  1343.         pattern % 100 / 5 * 192, 192, 192)
  1344.       if @sub_animation_mirror
  1345.         sprite.x = @sub_animation_ox - cell_data[i, 1]
  1346.         sprite.y = @sub_animation_oy + cell_data[i, 2]
  1347.         sprite.angle = (360 - cell_data[i, 4])
  1348.         sprite.mirror = (cell_data[i, 5] == 0)
  1349.       else
  1350.         sprite.x = @sub_animation_ox + cell_data[i, 1]
  1351.         sprite.y = @sub_animation_oy + cell_data[i, 2]
  1352.         sprite.angle = cell_data[i, 4]
  1353.         sprite.mirror = (cell_data[i, 5] == 1)
  1354.       end
  1355.       sprite.z = self.z + 250 + i
  1356.       sprite.ox = 96
  1357.       sprite.oy = 96
  1358.       sprite.zoom_x = cell_data[i, 3] / 100.0
  1359.       sprite.zoom_y = cell_data[i, 3] / 100.0
  1360.       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  1361.       sprite.blend_type = cell_data[i, 7]
  1362.     end
  1363.   end
  1364.  
  1365. end # Sprite_Base
  1366.  
  1367. #===============================================================================
  1368. # Sprite_Battler
  1369. #===============================================================================
  1370.  
  1371. class Sprite_Battler < Sprite_Base
  1372.  
  1373.   #--------------------------------------------------------------------------
  1374.   # constants
  1375.   #--------------------------------------------------------------------------
  1376.   RATE = $imported["CoreFixesUpgradesMelody"] ? YEM::FIXES::ANIMATION_RATE : 4
  1377.   @@battler_animations = []
  1378.   @@state_animations = []
  1379.  
  1380.   #--------------------------------------------------------------------------
  1381.   # public instance variables
  1382.   #--------------------------------------------------------------------------
  1383.   attr_accessor :character_death_duration
  1384.   attr_accessor :character_sprite
  1385.   attr_accessor :icon_weapon1
  1386.   attr_accessor :icon_weapon2
  1387.   attr_accessor :icon_sprites
  1388.   attr_accessor :icon_shield
  1389.   attr_accessor :icon_item
  1390.   attr_accessor :icon_last
  1391.   attr_accessor :jump_duration
  1392.   attr_accessor :move_to_x
  1393.   attr_accessor :move_to_y
  1394.   attr_accessor :popups
  1395.  
  1396.   #--------------------------------------------------------------------------
  1397.   # alias method: initialize
  1398.   #--------------------------------------------------------------------------
  1399.   alias initialize_sprite_battler_bem initialize unless $@
  1400.   def initialize(viewport, battler = nil)
  1401.     initialize_sprite_battler_bem(viewport, battler)
  1402.     @popups = []
  1403.     @popup_flags = []
  1404.     @state_animation_duration = 0
  1405.     return if @battler == nil
  1406.     self.mirror = @battler.mirror?
  1407.     self.zoom_x = @battler.zoom
  1408.     self.zoom_y = @battler.zoom
  1409.   end
  1410.  
  1411.   #--------------------------------------------------------------------------
  1412.   # alias method: dispose
  1413.   #--------------------------------------------------------------------------
  1414.   alias dispose_sprite_battler_bem dispose
  1415.   def dispose
  1416.     @character_sprite.dispose if @character_sprite != nil
  1417.     dispose_popups
  1418.     dispose_sprite_battler_bem
  1419.     dispose_state_animation
  1420.     dispose_battler_animation
  1421.     return if @icon_sprites == nil
  1422.     for icon_sprite in @icon_sprites; icon_sprite.dispose; end
  1423.   end
  1424.  
  1425.   #--------------------------------------------------------------------------
  1426.   # alias method: update
  1427.   #--------------------------------------------------------------------------
  1428.   alias update_sprite_battler_bem update unless $@
  1429.   def update
  1430.     update_sprite_battler_bem
  1431.     update_battler_animation
  1432.     update_state_animation
  1433.     return if @battler == nil
  1434.     update_popups
  1435.     update_jump
  1436.     update_move_to
  1437.     update_character_sprite
  1438.     update_character_death
  1439.     update_icon_sprites
  1440.   end
  1441.  
  1442.   #--------------------------------------------------------------------------
  1443.   # alias method: setup_new_effect
  1444.   #--------------------------------------------------------------------------
  1445.   alias setup_new_effect_bem setup_new_effect unless $@
  1446.   def setup_new_effect
  1447.     start_character_death if @battler.collapse
  1448.     setup_new_effect_bem unless anti_whiten
  1449.     #---
  1450.     if @battler.vanish_case == 1
  1451.       @battler.vanish_case = nil
  1452.       @effect_type = DISAPPEAR
  1453.       @effect_duration = 32
  1454.     elsif @battler.vanish_case == 2
  1455.       @battler.vanish_case = nil
  1456.       @effect_type = APPEAR
  1457.       @effect_duration = 16
  1458.     elsif @battler.vanish_case == 3
  1459.       @battler.vanish_case = nil
  1460.       self.opacity = 0
  1461.       @battler.character.opacity = 0 if @character_sprite != nil
  1462.     elsif @battler.vanish_case == 4
  1463.       @battler.vanish_case = nil
  1464.       self.opacity = 255
  1465.       @battler.character.opacity = 255 if @character_sprite != nil
  1466.     end
  1467.     #---
  1468.     if @battler.popup_array != [] and @battler.popup_array != nil
  1469.       array = @battler.popup_array.shift
  1470.       create_popup(array[0], array[1], array[2])
  1471.     end
  1472.     #---
  1473.     if @battler.pseudo_ani_id != 0 and @battler.pseudo_ani_id != nil
  1474.       animation = $data_animations[@battler.pseudo_ani_id]
  1475.       start_pseudo_ani(animation)
  1476.       @battler.pseudo_ani_id = 0
  1477.     end
  1478.     #---
  1479.     if @battler.state_animation_id != nil
  1480.       if @battler.state_animation_id == 0
  1481.         dispose_state_animation
  1482.       else
  1483.         start_state_animation($data_animations[@battler.state_animation_id])
  1484.       end
  1485.     end
  1486.     #---
  1487.     if @battler.battler_animation_id != nil
  1488.       start_battler_animation($data_animations[@battler.battler_animation_id])
  1489.     end
  1490.     #---
  1491.     if @battler.sub_animation_id != nil
  1492.       start_sub_animation($data_animations[@battler.sub_animation_id])
  1493.       @battler.sub_animation_id = nil
  1494.     end
  1495.   end
  1496.  
  1497.   #--------------------------------------------------------------------------
  1498.   # alias method: update_appear
  1499.   #--------------------------------------------------------------------------
  1500.   alias update_appear_bem update_appear unless $@
  1501.   def update_appear
  1502.     update_appear_bem
  1503.     return if @character_sprite == nil
  1504.     @battler.character.opacity = (16 - @effect_duration) * 16
  1505.   end
  1506.  
  1507.   #--------------------------------------------------------------------------
  1508.   # alias method: update_disappear
  1509.   #--------------------------------------------------------------------------
  1510.   alias update_disappear_bem update_disappear unless $@
  1511.   def update_disappear
  1512.     update_disappear_bem
  1513.     return if @character_sprite == nil
  1514.     @battler.character.opacity = 256 - (32 - @effect_duration) * 10
  1515.   end
  1516.  
  1517.   #--------------------------------------------------------------------------
  1518.   # alias method: update_collapse
  1519.   #--------------------------------------------------------------------------
  1520.   alias update_collapse_bem update_collapse unless $@
  1521.   def update_collapse
  1522.     if @battler.actor?
  1523.       @effect_duration = 0
  1524.       return
  1525.     end
  1526.     update_collapse_bem
  1527.   end
  1528.  
  1529.   #--------------------------------------------------------------------------
  1530.   # new method: anti_whiten
  1531.   #--------------------------------------------------------------------------
  1532.   def anti_whiten
  1533.     if @battler.white_flash and @battler.state?(1)
  1534.       if @battler.collapse
  1535.         @effect_type = COLLAPSE
  1536.         @effect_duration = 48
  1537.         @battler.collapse = false
  1538.         @battler_visible = false
  1539.       end
  1540.       return true
  1541.     end
  1542.     return false
  1543.   end
  1544.  
  1545.   #--------------------------------------------------------------------------
  1546.   # new method: start_animation
  1547.   #--------------------------------------------------------------------------
  1548.   def start_animation(animation, mirror = false)
  1549.     if @character_sprite != nil
  1550.       @character_sprite.start_animation(animation, mirror)
  1551.       return
  1552.     end
  1553.     super(animation, mirror)
  1554.   end
  1555.  
  1556.   #--------------------------------------------------------------------------
  1557.   # new method: start_pseudo_ani
  1558.   #--------------------------------------------------------------------------
  1559.   def start_pseudo_ani(animation, mirror = false)
  1560.     if @character_sprite != nil
  1561.       @character_sprite.start_pseudo_ani(animation, mirror)
  1562.       return
  1563.     end
  1564.     super(animation, mirror)
  1565.   end
  1566.  
  1567.   #--------------------------------------------------------------------------
  1568.   # new method: start_state_animation
  1569.   #--------------------------------------------------------------------------
  1570.   def start_state_animation(animation)
  1571.     return if @state_animation != nil and @state_animation.id == animation.id
  1572.     dispose_state_animation
  1573.     @state_animation = animation
  1574.     return if @state_animation == nil
  1575.     @state_frame_index = 0
  1576.     @state_animation_mirror = false
  1577.     @state_animation_duration = @state_animation.frame_max * RATE + 1
  1578.     load_state_animation_bitmap
  1579.     @state_animation_sprites = []
  1580.     if @state_animation.position != 3 or !@@state_animations.include?(animation)
  1581.       if @use_sprite
  1582.         for i in 0..15
  1583.           sprite = ::Sprite.new(self.viewport)
  1584.           sprite.visible = false
  1585.           @state_animation_sprites.push(sprite)
  1586.         end
  1587.         unless @@state_animations.include?(animation)
  1588.           @@state_animations.push(animation)
  1589.         end
  1590.       end
  1591.     end
  1592.     if @state_animation.position == 3
  1593.       if viewport == nil
  1594.         @state_animation_ox = Graphics.width / 2
  1595.         @state_animation_oy = Graphics.width / 2
  1596.       else
  1597.         @state_animation_ox = viewport.rect.width / 2
  1598.         @state_animation_oy = viewport.rect.height / 2
  1599.       end
  1600.     else
  1601.       @state_animation_ox = x - ox + width / 2
  1602.       @state_animation_oy = y - oy + height / 2
  1603.       if @state_animation.position == 0
  1604.         @state_animation_oy -= height / 2
  1605.       elsif @state_animation.position == 2
  1606.         @state_animation_oy += height / 2
  1607.       end
  1608.     end
  1609.   end
  1610.  
  1611.   #--------------------------------------------------------------------------
  1612.   # new method: load_state_animation_bitmap
  1613.   #--------------------------------------------------------------------------
  1614.   def load_state_animation_bitmap
  1615.     animation1_name = @state_animation.animation1_name
  1616.     animation1_hue = @state_animation.animation1_hue
  1617.     animation2_name = @state_animation.animation2_name
  1618.     animation2_hue = @state_animation.animation2_hue
  1619.     @state_animation_bitmap1 = Cache.animation(animation1_name, animation1_hue)
  1620.     @state_animation_bitmap2 = Cache.animation(animation2_name, animation2_hue)
  1621.     if @@_reference_count.include?(@state_animation_bitmap1)
  1622.       @@_reference_count[@state_animation_bitmap1] += 1
  1623.     else
  1624.       @@_reference_count[@state_animation_bitmap1] = 1
  1625.     end
  1626.     if @@_reference_count.include?(@state_animation_bitmap2)
  1627.       @@_reference_count[@state_animation_bitmap2] += 1
  1628.     else
  1629.       @@_reference_count[@state_animation_bitmap2] = 1
  1630.     end
  1631.     Graphics.frame_reset
  1632.   end
  1633.  
  1634.   #--------------------------------------------------------------------------
  1635.   # new method: dispose_state_animation
  1636.   #--------------------------------------------------------------------------
  1637.   def dispose_state_animation
  1638.     if @state_animation_bitmap1 != nil
  1639.       @@_reference_count[@state_animation_bitmap1] -= 1
  1640.       if @@_reference_count[@state_animation_bitmap1] == 0
  1641.         @state_animation_bitmap1.dispose
  1642.       end
  1643.     end
  1644.     if @state_animation_bitmap2 != nil
  1645.       @@_reference_count[@state_animation_bitmap2] -= 1
  1646.       if @@_reference_count[@state_animation_bitmap2] == 0
  1647.         @state_animation_bitmap2.dispose
  1648.       end
  1649.     end
  1650.     if @state_animation_sprites != nil
  1651.       for sprite in @state_animation_sprites
  1652.         sprite.dispose
  1653.       end
  1654.       @state_animation_sprites = nil
  1655.       @state_animation = nil
  1656.     end
  1657.     @state_animation_bitmap1 = nil
  1658.     @state_animation_bitmap2 = nil
  1659.   end
  1660.  
  1661.   #--------------------------------------------------------------------------
  1662.   # new method: update_state_animation
  1663.   #--------------------------------------------------------------------------
  1664.   def update_state_animation
  1665.     return if @state_animation == nil
  1666.     update_state_animation_position
  1667.     @state_animation_duration -= 1
  1668.     unless @state_animation_duration % RATE == 0
  1669.       if @state_animation_duration >= 0
  1670.         @state_frame_index = @state_animation.frame_max
  1671.         @state_frame_index -= (@state_animation_duration + RATE - 1) / RATE
  1672.         for timing in @state_animation.timings
  1673.           next unless timing.frame == @state_frame_index
  1674.           state_animation_process_timing(timing)
  1675.         end
  1676.       else
  1677.         @state_frame_index = 0
  1678.         @state_animation_duration = @state_animation.frame_max * RATE
  1679.       end
  1680.     end
  1681.     return if @state_frame_index == nil
  1682.     state_animation_set_sprites(@state_animation.frames[@state_frame_index])
  1683.   end
  1684.  
  1685.   #--------------------------------------------------------------------------
  1686.   # new method: update_state_animation_position
  1687.   #--------------------------------------------------------------------------
  1688.   def update_state_animation_position
  1689.     if @state_animation.position == 3
  1690.       if viewport == nil
  1691.         @state_animation_ox = Graphics.width / 2
  1692.         @state_animation_oy = Graphics.width / 2
  1693.       else
  1694.         @state_animation_ox = viewport.rect.width / 2
  1695.         @state_animation_oy = viewport.rect.height / 2
  1696.       end
  1697.     else
  1698.       @state_animation_ox = x - ox + width / 2
  1699.       @state_animation_oy = y - oy + height / 2
  1700.       if @state_animation.position == 0
  1701.         @state_animation_oy -= height / 2
  1702.       elsif @state_animation.position == 2
  1703.         @state_animation_oy += height / 2
  1704.       end
  1705.     end
  1706.   end
  1707.  
  1708.   #--------------------------------------------------------------------------
  1709.   # new method: state_animation_set_sprites
  1710.   #--------------------------------------------------------------------------
  1711.   def state_animation_set_sprites(frame)
  1712.     return if @state_animation == nil
  1713.     return if frame == nil
  1714.     cell_data = frame.cell_data
  1715.     for i in 0..15
  1716.       sprite = @state_animation_sprites[i]
  1717.       next if sprite == nil
  1718.       pattern = cell_data[i, 0]
  1719.       if pattern == nil or pattern == -1
  1720.         sprite.visible = false
  1721.         next
  1722.       end
  1723.       if pattern < 100
  1724.         sprite.bitmap = @state_animation_bitmap1
  1725.       else
  1726.         sprite.bitmap = @state_animation_bitmap2
  1727.       end
  1728.       sprite.visible = true
  1729.       sprite.src_rect.set(pattern % 5 * 192,
  1730.       #---
  1731.       pattern % 100 / 5 * 192, 192, 192)
  1732.       sprite.x = @state_animation_ox + cell_data[i, 1]
  1733.       sprite.y = @state_animation_oy + cell_data[i, 2]
  1734.       sprite.angle = cell_data[i, 4]
  1735.       sprite.mirror = (cell_data[i, 5] == 1)
  1736.       #---
  1737.       sprite.z = self.z + 200 + i
  1738.       sprite.ox = 96
  1739.       sprite.oy = 96
  1740.       sprite.zoom_x = cell_data[i, 3] / 100.0
  1741.       sprite.zoom_y = cell_data[i, 3] / 100.0
  1742.       sprite.zoom_x *= @battler.state_animation_zoom
  1743.       sprite.zoom_x /= 100
  1744.       sprite.zoom_y *= @battler.state_animation_zoom
  1745.       sprite.zoom_y /= 100
  1746.       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  1747.       sprite.blend_type = cell_data[i, 7]
  1748.     end
  1749.   end
  1750.  
  1751.   #--------------------------------------------------------------------------
  1752.   # new method: state_animation_process_timing
  1753.   #--------------------------------------------------------------------------
  1754.   def state_animation_process_timing(timing)
  1755.     timing.se.play
  1756.     case timing.flash_scope
  1757.     when 1
  1758.       if @battler_animation == nil
  1759.         self.flash(timing.flash_color, timing.flash_duration * RATE)
  1760.       end
  1761.       return if @character_sprite == nil
  1762.       @character_sprite.flash(timing.flash_color, timing.flash_duration*RATE)
  1763.     when 2
  1764.       return if viewport == nil
  1765.       viewport.flash(timing.flash_color, timing.flash_duration * RATE)
  1766.     when 3
  1767.       self.flash(nil, timing.flash_duration * RATE)
  1768.       return if @character_sprite == nil
  1769.       @character_sprite.flash(nil, timing.flash_duration * RATE)
  1770.     end
  1771.   end
  1772.  
  1773.   #--------------------------------------------------------------------------
  1774.   # new method: start_battler_animation
  1775.   #--------------------------------------------------------------------------
  1776.   def start_battler_animation(animation)
  1777.     if $scene.is_a?(Scene_Battle) and $scene.emptyview? and @battler.actor?
  1778.       dispose_battler_animation
  1779.       return
  1780.     end
  1781.     return if @battler_animation != nil and
  1782.       @battler_animation.id == animation.id
  1783.     dispose_battler_animation
  1784.     @battler_animation = animation
  1785.     return if @battler_animation == nil
  1786.     @battler_ani_hash = YEM::BATTLE_ENGINE::ANIMATION_BATTLER_SETTINGS
  1787.     @battler_ani_max_cell = YEM::BATTLE_ENGINE::ANIMATION_BATTLER_MAX_CELLS
  1788.     #---
  1789.     if @battler.actor?
  1790.       @battler_animation_mirror = @battler_ani_hash[:mirror_actor]
  1791.     else
  1792.       @battler_animation_mirror = @battler_ani_hash[:mirror_enemy]
  1793.     end
  1794.     #---
  1795.     @battler_animation_duration = @battler_animation.frame_max * RATE + 1
  1796.     load_battler_animation_bitmap
  1797.     @battler_animation_sprites = []
  1798.     if @battler_animation.position != 3 or
  1799.     !@@battler_animations.include?(animation)
  1800.       if @use_sprite
  1801.         for i in 0..@battler_ani_max_cell
  1802.           sprite = ::Sprite.new(self.viewport)
  1803.           sprite.visible = false
  1804.           @battler_animation_sprites.push(sprite)
  1805.         end
  1806.         unless @@battler_animations.include?(animation)
  1807.           @@battler_animations.push(animation)
  1808.         end
  1809.       end
  1810.     end
  1811.     if @battler_animation.position == 3
  1812.       if viewport == nil
  1813.         @battler_animation_ox = Graphics.width / 2
  1814.         @battler_animation_oy = Graphics.height / 2
  1815.       else
  1816.         @battler_animation_ox = viewport.rect.width / 2
  1817.         @battler_animation_oy = viewport.rect.height / 2
  1818.       end
  1819.     else
  1820.       @battler_animation_ox = x - ox + width/2
  1821.       @battler_animation_oy = y - oy + height/2
  1822.       if @battler_animation.position == 0
  1823.         @battler_animation_oy -= height / 2
  1824.       elsif @battler_animation.position == 2
  1825.         @battler_animation_oy += height / 2
  1826.       end
  1827.     end
  1828.     @battler_frame_index = 0
  1829.   end
  1830.  
  1831.   #--------------------------------------------------------------------------
  1832.   # new method: load_battler_animation_bitmap
  1833.   #--------------------------------------------------------------------------
  1834.   def load_battler_animation_bitmap
  1835.     animation1_name = @battler_animation.animation1_name
  1836.     animation1_hue = @battler_animation.animation1_hue
  1837.     animation1_hue += @battler.enemy.animation_hue if @battler.enemy?
  1838.     animation2_name = @battler_animation.animation2_name
  1839.     animation2_hue = @battler_animation.animation2_hue
  1840.     animation2_hue += @battler.enemy.animation_hue if @battler.enemy?
  1841.     @battler_animation_bitmap1 = Cache.animation(animation1_name,animation1_hue)
  1842.     @battler_animation_bitmap2 = Cache.animation(animation2_name,animation2_hue)
  1843.     if @@_reference_count.include?(@battler_animation_bitmap1)
  1844.       @@_reference_count[@battler_animation_bitmap1] += 1
  1845.     else
  1846.       @@_reference_count[@battler_animation_bitmap1] = 1
  1847.     end
  1848.     if @@_reference_count.include?(@battler_animation_bitmap2)
  1849.       @@_reference_count[@battler_animation_bitmap2] += 1
  1850.     else
  1851.       @@_reference_count[@battler_animation_bitmap2] = 1
  1852.     end
  1853.     Graphics.frame_reset
  1854.   end
  1855.  
  1856.   #--------------------------------------------------------------------------
  1857.   # new method: dispose_battler_animation
  1858.   #--------------------------------------------------------------------------
  1859.   def dispose_battler_animation
  1860.     if @battler_animation_bitmap1 != nil
  1861.       @@_reference_count[@battler_animation_bitmap1] -= 1
  1862.       if @@_reference_count[@battler_animation_bitmap1] == 0
  1863.         @battler_animation_bitmap1.dispose
  1864.       end
  1865.     end
  1866.     if @battler_animation_bitmap2 != nil
  1867.       @@_reference_count[@battler_animation_bitmap2] -= 1
  1868.       if @@_reference_count[@battler_animation_bitmap2] == 0
  1869.         @battler_animation_bitmap2.dispose
  1870.       end
  1871.     end
  1872.     if @battler_animation_sprites != nil
  1873.       for sprite in @battler_animation_sprites
  1874.         sprite.dispose
  1875.       end
  1876.       @battler_animation_sprites = nil
  1877.       @battler_animation = nil
  1878.     end
  1879.     @battler_animation_bitmap1 = nil
  1880.     @battler_animation_bitmap2 = nil
  1881.   end
  1882.  
  1883.   #--------------------------------------------------------------------------
  1884.   # new method: update_battler_animation
  1885.   #--------------------------------------------------------------------------
  1886.   def update_battler_animation
  1887.     return if @battler_animation == nil
  1888.     update_battler_animation_position
  1889.     @battler_animation_duration -= 1
  1890.     unless @battler_animation_duration % RATE == 0
  1891.       if @battler_animation_duration >= 0
  1892.         @battler_frame_index = @battler_animation.frame_max
  1893.         @battler_frame_index -= (@battler_animation_duration + RATE - 1) / RATE
  1894.         for timing in @battler_animation.timings
  1895.           next unless timing.frame == @battler_frame_index
  1896.           battler_animation_process_timing(timing)
  1897.         end
  1898.       elsif @battler_animation.battler_looping
  1899.         @battler_frame_index = 0
  1900.         @battler_animation_duration = @battler_animation.frame_max * RATE
  1901.       end
  1902.     end
  1903.     return if @battler_frame_index == nil
  1904.     frame = @battler_animation.frames[@battler_frame_index]
  1905.     battler_animation_set_sprites(frame)
  1906.   end
  1907.  
  1908.   #--------------------------------------------------------------------------
  1909.   # new method: update_battler_animation_position
  1910.   #--------------------------------------------------------------------------
  1911.   def update_battler_animation_position
  1912.     if @battler_animation.position == 3
  1913.       if viewport == nil
  1914.         @battler_animation_ox = Graphics.width / 2
  1915.         @battler_animation_oy = Graphics.width / 2
  1916.       else
  1917.         @battler_animation_ox = viewport.rect.width / 2
  1918.         @battler_animation_oy = viewport.rect.height / 2
  1919.       end
  1920.     else
  1921.       @battler_animation_ox = x - ox + width/2
  1922.       @battler_animation_oy = y - oy + height/2
  1923.       if @battler_animation.position == 0
  1924.         @battler_animation_oy -= height / 2
  1925.       elsif @battler_animation.position == 2
  1926.         @battler_animation_oy += height / 2
  1927.       end
  1928.     end
  1929.   end
  1930.  
  1931.   #--------------------------------------------------------------------------
  1932.   # new method: battler_animation_set_sprites
  1933.   #--------------------------------------------------------------------------
  1934.   def battler_animation_set_sprites(frame)
  1935.     return if @battler_animation == nil
  1936.     return if frame == nil
  1937.     cell_data = frame.cell_data
  1938.     for i in 0..@battler_ani_max_cell
  1939.       sprite = @battler_animation_sprites[i]
  1940.       next if sprite == nil
  1941.       pattern = cell_data[i, 0]
  1942.       if pattern == nil or pattern == -1
  1943.         sprite.visible = false
  1944.         next
  1945.       end
  1946.       if pattern < 100
  1947.         sprite.bitmap = @battler_animation_bitmap1
  1948.       else
  1949.         sprite.bitmap = @battler_animation_bitmap2
  1950.       end
  1951.       sprite.visible = true
  1952.       sprite.src_rect.set(pattern % 5 * 192,
  1953.         pattern % 100 / 5 * 192, 192, 192)
  1954.       if @battler_animation_mirror
  1955.         sprite.x = @battler_animation_ox - cell_data[i, 1]
  1956.         sprite.y = @battler_animation_oy + cell_data[i, 2]
  1957.         sprite.angle = (360 - cell_data[i, 4])
  1958.         sprite.mirror = (cell_data[i, 5] == 0)
  1959.       else
  1960.         sprite.x = @battler_animation_ox + cell_data[i, 1]
  1961.         sprite.y = @battler_animation_oy + cell_data[i, 2]
  1962.         sprite.angle = cell_data[i, 4]
  1963.         sprite.mirror = (cell_data[i, 5] == 1)
  1964.       end
  1965.       sprite.z = self.z + 50 + i
  1966.       sprite.ox = 96
  1967.       sprite.oy = 96
  1968.       sprite.zoom_x = cell_data[i, 3] / 100.0
  1969.       sprite.zoom_y = cell_data[i, 3] / 100.0
  1970.       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  1971.       sprite.blend_type = cell_data[i, 7]
  1972.       #---
  1973.       sprite.color = self.color
  1974.       sprite.visible = self.visible
  1975.       sprite.update
  1976.     end
  1977.     self.flash(nil, 60 * RATE)
  1978.     return if @character_sprite == nil
  1979.     @character_sprite.flash(nil, 60 * RATE)
  1980.   end
  1981.  
  1982.   #--------------------------------------------------------------------------
  1983.   # new method: battler_animation_process_timing
  1984.   #--------------------------------------------------------------------------
  1985.   def battler_animation_process_timing(timing)
  1986.     timing.se.play if @battler_ani_hash[:allow_sound]
  1987.     case timing.flash_scope
  1988.     when 1
  1989.       if @battler_animation == nil
  1990.         self.flash(timing.flash_color, timing.flash_duration * RATE)
  1991.       end
  1992.       battler_animation_flash(timing)
  1993.     when 2
  1994.       return if viewport == nil
  1995.       return unless @battler_ani_hash[:allow_flash]
  1996.       viewport.flash(timing.flash_color, timing.flash_duration * RATE)
  1997.     end
  1998.   end
  1999.  
  2000.   #--------------------------------------------------------------------------
  2001.   # new method: battler_animation_flash
  2002.   #--------------------------------------------------------------------------
  2003.   def battler_animation_flash(timing)
  2004.     frame = @battler_animation.frames[@battler_frame_index]
  2005.     return if @battler_animation == nil
  2006.     return if frame == nil
  2007.     cell_data = frame.cell_data
  2008.     colour = (timing.flash_scope == 1) ? timing.flash_color : nil
  2009.     for i in 0..@battler_ani_max_cell
  2010.       sprite = @battler_animation_sprites[i]
  2011.       next if sprite == nil
  2012.       sprite.flash(colour, timing.flash_duration * RATE)
  2013.     end
  2014.   end
  2015.  
  2016.   #--------------------------------------------------------------------------
  2017.   # new method: create_popup
  2018.   #--------------------------------------------------------------------------
  2019.   def create_popup(value, rules, flags)
  2020.     return if @battler == nil
  2021.     return if flags & @popup_flags != []
  2022.     array = YEM::BATTLE_ENGINE::POPUP_RULES[rules]
  2023.     for popup in @popups
  2024.       popup.y -= array[2]*9/11
  2025.     end
  2026.     #---
  2027.     view = $scene.spriteset.viewportB
  2028.     new_popup = Sprite_Popup.new(view, @battler, value, rules, flags)
  2029.     @popups.push(new_popup)
  2030.     @popup_flags.push("weakness") if flags.include?("weakness")
  2031.     @popup_flags.push("resistant") if flags.include?("resistant")
  2032.     @popup_flags.push("immune") if flags.include?("immune")
  2033.     @popup_flags.push("absorbed") if flags.include?("absorbed")
  2034.   end
  2035.  
  2036.   #--------------------------------------------------------------------------
  2037.   # new method: dispose_popups
  2038.   #--------------------------------------------------------------------------
  2039.   def dispose_popups
  2040.     for popup in @popups
  2041.       @popups.delete(popup)
  2042.       popup.dispose
  2043.       popup = nil
  2044.     end
  2045.   end
  2046.  
  2047.   #--------------------------------------------------------------------------
  2048.   # new method: update_popups
  2049.   #--------------------------------------------------------------------------
  2050.   def update_popups
  2051.     @popups = [] if @popups == nil
  2052.     for popup in @popups
  2053.       popup.update
  2054.       next unless popup.opacity <= 0
  2055.       popup.bitmap.dispose
  2056.       popup.dispose
  2057.       @popups.delete(popup)
  2058.       popup = nil
  2059.     end
  2060.     @popup_flags = [] if @popups == [] and @popup_flags != []
  2061.     return unless $scene.is_a?(Scene_Battle)
  2062.     if @current_active_battler != $scene.active_battler
  2063.       @current_active_battler = $scene.active_battler
  2064.       @popup_flags = []
  2065.     end
  2066.   end
  2067.  
  2068.   #--------------------------------------------------------------------------
  2069.   # new method: create_character_dimensions
  2070.   #--------------------------------------------------------------------------
  2071.   def create_character_dimensions
  2072.     return if @character_sprite == nil
  2073.     @width  = YEM::BATTLE_ENGINE::ACTOR_ASPECTS[:width]
  2074.     @height = YEM::BATTLE_ENGINE::ACTOR_ASPECTS[:height]
  2075.     self.ox = @width/2
  2076.     self.oy = @height
  2077.   end
  2078.  
  2079.   #--------------------------------------------------------------------------
  2080.   # new method: update_character_sprite
  2081.   #--------------------------------------------------------------------------
  2082.   def update_character_sprite
  2083.     return if @character_sprite == nil
  2084.     if @battler.character.character_name != @battler.character_name or
  2085.     @battler.character.character_index != @battler.character_index
  2086.       char_name = @battler.character_name
  2087.       char_index = @battler.character_index
  2088.       @battler.character.set_graphic(char_name, char_index)
  2089.     end
  2090.     @character_sprite.update
  2091.     @character_sprite.z = self.z
  2092.   end
  2093.  
  2094.   #--------------------------------------------------------------------------
  2095.   # new method: create_move_to
  2096.   #--------------------------------------------------------------------------
  2097.   def create_move_to(destination_x, destination_y, total_frames = 60)
  2098.     return unless @battler.sprite_movable?
  2099.     den = [total_frames, 1].max
  2100.     if destination_x != nil
  2101.       @move_to_x = Integer(destination_x)
  2102.       @move_rate_x = [(@battler.screen_x - @move_to_x).abs/den, 2].max
  2103.     end
  2104.     if destination_y != nil
  2105.       @move_to_y = Integer(destination_y)
  2106.       @move_rate_y = [(@battler.screen_y - @move_to_y).abs/den, 2].max
  2107.     end
  2108.     return if @character_sprite == nil
  2109.   end
  2110.  
  2111.   #--------------------------------------------------------------------------
  2112.   # new method: update_move_to
  2113.   #--------------------------------------------------------------------------
  2114.   def update_move_to
  2115.     if @move_to_x != nil
  2116.       value = [(@battler.screen_x - @move_to_x).abs, @move_rate_x].min
  2117.       @battler.screen_x += (@move_to_x > @battler.screen_x) ? value : -value
  2118.       @move_to_x = nil if @battler.screen_x == @move_to_x
  2119.     end
  2120.     if @move_to_y != nil
  2121.       value = [(@battler.screen_y - @move_to_y).abs, @move_rate_y].min
  2122.       @battler.screen_y += (@move_to_y > @battler.screen_y) ? value : -value
  2123.       @move_to_y = nil if @battler.screen_y == @move_to_y
  2124.     end
  2125.   end
  2126.  
  2127.   #--------------------------------------------------------------------------
  2128.   # new method: face_coordinate
  2129.   #--------------------------------------------------------------------------
  2130.   def face_coordinate(destination_x, destination_y)
  2131.     if @character_sprite != nil
  2132.       @battler.character.break_pose if $imported["ExtendedMovement"]
  2133.       @battler.character.step_anime = true
  2134.       @battler.character.mirror = false
  2135.     end
  2136.     x1 = Integer(@battler.screen_x)
  2137.     x2 = Integer(destination_x)
  2138.     y1 = Graphics.height - Integer(@battler.screen_y)
  2139.     y2 = Graphics.height - Integer(destination_y)
  2140.     return if x1 == x2 and y1 == y2
  2141.     #---
  2142.     angle = Integer(Math.atan2((y2-y1),(x2-x1)) * 1800 / Math::PI)
  2143.     if (0..225) === angle or (-225..0) === angle
  2144.       direction = 6
  2145.     elsif (226..675) === angle
  2146.       direction = 9
  2147.     elsif (676..1125) === angle
  2148.       direction = 8
  2149.     elsif (1126..1575) === angle
  2150.       direction = 7
  2151.     elsif (1576..1800) === angle or (-1800..-1576) === angle
  2152.       direction = 4
  2153.     elsif (-1575..-1126) === angle
  2154.       direction = 1
  2155.     elsif (-1125..-676) === angle
  2156.       direction = 2
  2157.     elsif (-675..-226) === angle
  2158.       direction = 3
  2159.     end
  2160.     #---
  2161.     @battler.direction = direction if @battler.enemy?
  2162.     if @character_sprite != nil
  2163.       direction = $scene.spriteset.correct_direction(direction)
  2164.       @battler.character.set_direction(direction)
  2165.     end
  2166.   end
  2167.  
  2168.   #--------------------------------------------------------------------------
  2169.   # new method: turn_direction
  2170.   #--------------------------------------------------------------------------
  2171.   def turn_direction(direction, backward = false)
  2172.     return if @character_sprite == nil
  2173.     return unless [1,2,3,4,6,7,8,9].include?(direction)
  2174.     back_hash = {1=>9,2=>8,3=>7,4=>6,6=>4,7=>3,8=>2,9=>1}
  2175.     direction = back_hash[direction] if backward
  2176.     direction = back_hash[direction] if @battler.enemy?
  2177.     direction = $scene.spriteset.correct_direction(direction)
  2178.     @battler.character.break_pose if $imported["ExtendedMovement"]
  2179.     @battler.character.set_direction(direction)
  2180.   end
  2181.  
  2182.   #--------------------------------------------------------------------------
  2183.   # new method: start_character_death
  2184.   #--------------------------------------------------------------------------
  2185.   def start_character_death
  2186.     return if @character_sprite == nil
  2187.     return if @character_death_duration != nil
  2188.     @character_death_duration = 9
  2189.     @battler.character.step_anime = false
  2190.     @battler.character.mirror = @battler.enemy?
  2191.     @battler.character.set_direction(4)
  2192.     if @battler.use_battler_animations?
  2193.       @battler.battler_animation_stance("DEAD")
  2194.       return
  2195.     end
  2196.     if $imported["ExtendedMovement"] and @character_sprite.appropiate_filename?
  2197.       @battler.character.pose = "fallen"
  2198.       @character_sprite.ox *= @battler.actor? ? 2 : 0
  2199.       @character_sprite.angle = @battler.actor? ? -90 : 90
  2200.       @character_sprite.mirror = @battler.enemy?
  2201.       @character_sprite.update
  2202.     end
  2203.   end
  2204.  
  2205.   #--------------------------------------------------------------------------
  2206.   # new method: update_character_death
  2207.   #--------------------------------------------------------------------------
  2208.   def update_character_death
  2209.     return if @character_death_duration == nil
  2210.     return if @character_sprite == nil
  2211.     return if @character_death_duration == 0
  2212.     @character_sprite.angle += @battler.actor? ? 10 : -10
  2213.     @character_death_duration -= 1
  2214.     return unless @character_death_duration == 0
  2215.     if $imported["ExtendedMovement"] and @character_sprite.appropiate_filename?
  2216.       @character_sprite.angle = 0
  2217.     else
  2218.       @battler.character.set_direction(8)
  2219.       @character_sprite.angle = @battler.actor? ? 90 : -90
  2220.     end
  2221.   end
  2222.  
  2223.   #--------------------------------------------------------------------------
  2224.   # new method: revive_character_death
  2225.   #--------------------------------------------------------------------------
  2226.   def revive_character_death
  2227.     return if @character_sprite == nil
  2228.     @character_death_duration = nil
  2229.     @character_sprite.angle = 0
  2230.     @character_sprite.ox = @character_sprite.width/2
  2231.     @battler.character.break_pose if $imported["ExtendedMovement"]
  2232.     @battler.character.step_anime = true
  2233.     case $scene.view_type
  2234.     when 1; type = :front
  2235.     when 2; type = :side
  2236.     when 3; type = :angle
  2237.     else; return
  2238.     end
  2239.     direction = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[type][0]
  2240.     turn_direction(direction)
  2241.     create_move_to(@battler.origin_x, @battler.origin_y, 20)
  2242.     $scene.update_battler_poses
  2243.   end
  2244.  
  2245.   #--------------------------------------------------------------------------
  2246.   # new method: create_icon
  2247.   #--------------------------------------------------------------------------
  2248.   def create_icon(icon, attachment)
  2249.     return if @character_sprite == nil
  2250.     @icon_sprites = [] if @icon_sprites == nil
  2251.     #---
  2252.     case icon
  2253.     when :weapon1
  2254.       return if @battler.weapons.compact.size <= 0
  2255.       dispose_icon(@icon_weapon1, icon)
  2256.       icon_index = @battler.weapon1_icon
  2257.     when :weapon2
  2258.       return if @battler.weapons.compact.size <= 1
  2259.       dispose_icon(@icon_weapon2, icon)
  2260.       icon_index = @battler.weapon2_icon
  2261.     when :shield
  2262.       return if @battler.armor1_id == 0
  2263.       dispose_icon(@icon_shield, icon)
  2264.       icon_index = @battler.guard_icon
  2265.     when :item
  2266.       return unless @battler.action.item?
  2267.       dispose_icon(@icon_item, icon)
  2268.       icon_index = @battler.action.item.icon_index
  2269.     else
  2270.       return if icon.to_i == 0
  2271.       icon_index = icon.to_i
  2272.       icon = :last
  2273.     end
  2274.     #---
  2275.     icon_sprite = Sprite_Icon.new(viewport, icon_index, @battler)
  2276.     @icon_sprites.push(icon_sprite)
  2277.     icon_sprite.set_origin(attachment)
  2278.     #---
  2279.     case icon
  2280.     when :weapon1
  2281.       @icon_weapon1 = icon_sprite
  2282.     when :weapon2
  2283.       @icon_weapon2 = icon_sprite
  2284.     when :shield
  2285.       @icon_shield = icon_sprite
  2286.     when :item
  2287.       @icon_item = icon_sprite
  2288.     end
  2289.     @icon_last = @icon_sprites[-1]
  2290.   end
  2291.  
  2292.   #--------------------------------------------------------------------------
  2293.   # new method: dispose_icon
  2294.   #--------------------------------------------------------------------------
  2295.   def dispose_icon(icon_sprite, type = nil)
  2296.     return if icon_sprite == nil
  2297.     icon_sprite.dispose
  2298.     case type
  2299.     when :weapon1; @icon_weapon1 = nil
  2300.     when :weapon2; @icon_weapon2 = nil
  2301.     when :shield; @icon_armour = nil
  2302.     when :item; @icon_item = nil
  2303.     end
  2304.     @icon_sprites.delete(icon_sprite)
  2305.     icon_sprite = nil
  2306.     @icon_last = @icon_sprites[-1]
  2307.   end
  2308.  
  2309.   #--------------------------------------------------------------------------
  2310.   # new method: update_icon_sprites
  2311.   #--------------------------------------------------------------------------
  2312.   def update_icon_sprites
  2313.     return if @icon_sprites == nil
  2314.     return unless @icon_sprites != []
  2315.     for icon_sprite in @icon_sprites; icon_sprite.update; end
  2316.   end
  2317.  
  2318.   #--------------------------------------------------------------------------
  2319.   # new method: clear_jump
  2320.   #--------------------------------------------------------------------------
  2321.   def clear_jump
  2322.     @jump_count = nil
  2323.     @jump_duration = nil
  2324.     @jump_peak = nil
  2325.     @jump_height = nil
  2326.   end
  2327.  
  2328.   #--------------------------------------------------------------------------
  2329.   # new method: create_jump
  2330.   #--------------------------------------------------------------------------
  2331.   def create_jump(height, duration)
  2332.     @jump_count = duration
  2333.     @jump_duration = duration
  2334.     @jump_peak = height
  2335.     @jump_height = 0
  2336.   end
  2337.  
  2338.   #--------------------------------------------------------------------------
  2339.   # new method: update_jump
  2340.   #--------------------------------------------------------------------------
  2341.   def update_jump
  2342.     return if @jump_count == nil
  2343.     @jump_duration -= 1
  2344.     if @jump_duration < 0
  2345.       clear_jump
  2346.       return
  2347.     end
  2348.     #---
  2349.     @battler.screen_y += @jump_height
  2350.     if @move_to_y != nil
  2351.       value = [(@battler.screen_y - @move_to_y).abs, @move_rate_y].min
  2352.       difference = (@move_to_y > @battler.screen_y) ? value : -value
  2353.       @battler.screen_y += difference
  2354.     end
  2355.     #---
  2356.     if @jump_duration > @jump_count*7/8
  2357.       n = @jump_height + [@jump_peak/@jump_count, 1].max * 1.50
  2358.     elsif @jump_duration > @jump_count*6/8
  2359.       n = @jump_height + [@jump_peak/@jump_count, 1].max * 1.45
  2360.     elsif @jump_duration > @jump_count*5/8
  2361.       n = @jump_height + [@jump_peak/@jump_count, 1].max * 1.30
  2362.     elsif @jump_duration > @jump_count*4/8
  2363.       n = @jump_height + [@jump_peak/@jump_count, 1].max * 1.00
  2364.     elsif @jump_duration > @jump_count*3/8
  2365.       n = @jump_height - [@jump_peak/@jump_count, 1].max * 1.00
  2366.     elsif @jump_duration > @jump_count*2/8
  2367.       n = @jump_height - [@jump_peak/@jump_count, 1].max * 1.30
  2368.     elsif @jump_duration > @jump_count*1/8
  2369.       n = @jump_height - [@jump_peak/@jump_count, 1].max * 1.45
  2370.     else
  2371.       n = @jump_height - [@jump_peak/@jump_count, 1].max * 1.50
  2372.     end
  2373.     @jump_height = [Integer(n), 0].max
  2374.     @battler.screen_y = @battler.screen_y - @jump_height
  2375.   end
  2376.  
  2377. end # Sprite_Battler
  2378.  
  2379. #===============================================================================
  2380. # Sprite_Popup
  2381. #===============================================================================
  2382.  
  2383. class Sprite_Popup < Sprite_Base
  2384.  
  2385.   #--------------------------------------------------------------------------
  2386.   # public instance variables
  2387.   #--------------------------------------------------------------------------
  2388.   attr_accessor :flags
  2389.  
  2390.   #--------------------------------------------------------------------------
  2391.   # initialize
  2392.   #--------------------------------------------------------------------------
  2393.   def initialize(viewport, battler, value, rules, flags)
  2394.     super(viewport)
  2395.     @value = value
  2396.     @rules = rules
  2397.     @rules = "DEFAULT" unless YEM::BATTLE_ENGINE::POPUP_RULES.include?(@rules)
  2398.     @fade = YEM::BATTLE_ENGINE::POPUP_SETTINGS[:fade]
  2399.     @full = YEM::BATTLE_ENGINE::POPUP_SETTINGS[:full]
  2400.     @flags = flags
  2401.     @battler = battler
  2402.     create_popup_bitmap
  2403.   end
  2404.  
  2405.   #--------------------------------------------------------------------------
  2406.   # create_popup_bitmap
  2407.   #--------------------------------------------------------------------------
  2408.   def create_popup_bitmap
  2409.     array = YEM::BATTLE_ENGINE::POPUP_RULES[@rules]
  2410.     bw = YEM::BATTLE_ENGINE::POPUP_SETTINGS[:width]
  2411.     bw += 48 if @flags.include?("state")
  2412.     size = array[2]
  2413.     size = Integer(size * 1.2) if @flags.include?("critical")
  2414.     bh = size * 2
  2415.     bitmap = Bitmap.new(bw, bh)
  2416.     bitmap.font.name = array[8]
  2417.     bitmap.font.size = size
  2418.     bitmap.font.bold = array[3]
  2419.     bitmap.font.italic = array[4]
  2420.     bitmap.font.shadow = false
  2421.     if flags.include?("critical")
  2422.       crit_rules = YEM::BATTLE_ENGINE::POPUP_RULES["CRITICAL"]
  2423.       bitmap.font.color.set(crit_rules[5], crit_rules[6], crit_rules[7])
  2424.     else
  2425.       bitmap.font.color.set(0, 0, 0)
  2426.     end
  2427.     self.bitmap = bitmap
  2428.     dx = 0; dy = 0; dw = 0
  2429.     dx += 24 if @flags.include?("state")
  2430.     dw += 24 if @flags.include?("state")
  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.draw_text(dx-1, dy+1, bw-dw, bh, @value, 1)
  2434.     bitmap.draw_text(dx-1, dy-1, bw-dw, bh, @value, 1)
  2435.     bitmap.font.color.set(array[5], array[6], array[7])
  2436.     bitmap.draw_text(dx, dy, bw-dw, bh, @value, 1)
  2437.     if @flags.include?("state")
  2438.       c_width = bitmap.text_size(@value).width
  2439.       icon_bitmap = $game_temp.iconset
  2440.       icon_index = flag_state_icon
  2441.       rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  2442.       bitmap.blt(dx+(bw-c_width)/2-36, (bh/2-dy)/2-2, icon_bitmap, rect, 255)
  2443.     end
  2444.     self.bitmap = bitmap
  2445.     self.x = @battler.screen_x
  2446.     self.x += rand(4) - rand(4) if @battler.spriteset.popups.size >= 1
  2447.     self.x -= $scene.spriteset.viewport1.ox
  2448.     self.y = @battler.screen_y - @battler.spriteset.oy/2
  2449.     self.y += YEM::BATTLE_ENGINE::POPUP_SETTINGS[:offset] if !$scene.emptyview?
  2450.     self.y -= $scene.spriteset.viewport1.oy
  2451.     self.ox = bw/2; self.oy = bh/2
  2452.     self.zoom_x = self.zoom_y = array[0]
  2453.     if @flags.include?("no zoom")
  2454.       self.zoom_x = self.zoom_y = array[1]
  2455.     end
  2456.     @target_zoom = array[1]
  2457.     @zoom_direction = (self.zoom_x > @target_zoom) ? "down" : "up"
  2458.     self.z = 500
  2459.   end
  2460.  
  2461.   #--------------------------------------------------------------------------
  2462.   # update
  2463.   #--------------------------------------------------------------------------
  2464.   def update
  2465.     super
  2466.     #---
  2467.     if @flags.include?("critical") and
  2468.     YEM::BATTLE_ENGINE::POPUP_SETTINGS[:flash]
  2469.       @hue_duration = 2 if @hue_duration == nil or @hue_duration == 0
  2470.       @hue_duration -= 1
  2471.       self.bitmap.hue_change(15) if @hue_duration <= 0
  2472.     end
  2473.     #---
  2474.     if @zoom_direction == "up"
  2475.       self.zoom_x = [self.zoom_x + 0.075, @target_zoom].min
  2476.       self.zoom_y = [self.zoom_y + 0.075, @target_zoom].min
  2477.     else
  2478.       self.zoom_x = [self.zoom_x - 0.075, @target_zoom].max
  2479.       self.zoom_y = [self.zoom_y - 0.075, @target_zoom].max
  2480.     end
  2481.     #---
  2482.     @full -= 1
  2483.     return if @full > 0
  2484.     self.y -= 1
  2485.     self.opacity -= @fade
  2486.   end
  2487.  
  2488.   #--------------------------------------------------------------------------
  2489.   # flag_state_icon
  2490.   #--------------------------------------------------------------------------
  2491.   def flag_state_icon
  2492.     for item in @flags; return item if item.is_a?(Integer); end
  2493.     return 0
  2494.   end
  2495.  
  2496. end # Sprite_Popup
  2497.  
  2498. #===============================================================================
  2499. # Sprite_OrderBattler
  2500. #===============================================================================
  2501.  
  2502. class Sprite_OrderBattler < Sprite_Base
  2503.  
  2504.   #--------------------------------------------------------------------------
  2505.   # public instance variables
  2506.   #--------------------------------------------------------------------------
  2507.   attr_accessor :first_time
  2508.  
  2509.   #--------------------------------------------------------------------------
  2510.   # initialize
  2511.   #--------------------------------------------------------------------------
  2512.   def initialize(viewport, battler, battle_type = 0)
  2513.     super(viewport)
  2514.     @battler = battler
  2515.     @battle_type = battle_type
  2516.     @destination = 48
  2517.     @move_rate_x = 1
  2518.     @move_rate_y = 1
  2519.     @update_wait = 0
  2520.     @hash = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS
  2521.     @show_dead = YEM::BATTLE_ENGINE::TURNS_DEAD_BATTLERS
  2522.     @charge_icon_id = YEM::BATTLE_ENGINE::CTB_RULES[:chargeicon]
  2523.     @charge_size = Integer(YEM::BATTLE_ENGINE::CTB_RULES[:chargesize] * 24)
  2524.     create_battler_bitmap
  2525.   end
  2526.  
  2527.   #--------------------------------------------------------------------------
  2528.   # dispose
  2529.   #--------------------------------------------------------------------------
  2530.   def dispose
  2531.     self.bitmap.dispose if self.bitmap != nil
  2532.     super
  2533.   end
  2534.  
  2535.   #--------------------------------------------------------------------------
  2536.   # create_battler_bitmap
  2537.   #--------------------------------------------------------------------------
  2538.   def create_battler_bitmap
  2539.     case @battle_type
  2540.     when 0 # Default Turn Battle
  2541.       create_dtb_style
  2542.     when 1 # Press Turn Battle
  2543.       # Unused
  2544.     when 2 # Active Turn Battle
  2545.       create_atb_style
  2546.     when 3 # Press Turn Battle
  2547.       create_dtb_style
  2548.     end
  2549.   end
  2550.  
  2551.   #--------------------------------------------------------------------------
  2552.   # create_dtb_style
  2553.   #--------------------------------------------------------------------------
  2554.   def create_dtb_style
  2555.     bitmap = Bitmap.new(24, 24)
  2556.     icon_bitmap = Cache.system("Iconset")
  2557.     #--- Create Battler Background ---
  2558.     icon_index = @battler.actor? ? @hash[:actor][0] : @hash[:enemy][0]
  2559.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  2560.     bitmap.blt(0, 0, icon_bitmap, rect)
  2561.     #--- Create Battler Icon ---
  2562.     icon_index = @battler.battler_icon
  2563.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  2564.     temp_bitmap = Bitmap.new(24, 24)
  2565.     temp_bitmap.blt(0, 0, icon_bitmap, rect)
  2566.     temp_bitmap.hue_change(@battler.enemy.enemy_icon_hue) if @battler.enemy?
  2567.     bitmap.blt(0, 0, temp_bitmap, Rect.new(0, 0, 24, 24))
  2568.     temp_bitmap.dispose
  2569.     #--- Create Battler Border ---
  2570.     icon_index = @battler.actor? ? @hash[:actor][1] : @hash[:enemy][1]
  2571.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  2572.     bitmap.blt(0, 0, icon_bitmap, rect)
  2573.     #--- Create Battler Letter ---
  2574.     @draw_letter = draw_letter?
  2575.     @charge_icon = charge_icon?
  2576.     if @draw_letter
  2577.       bitmap.font.name = ["Droid Sans", "UmePlus Gothic", "Courier New"]
  2578.       bitmap.font.color.set(247,233,186)
  2579.       bitmap.font.size = 12
  2580.       bitmap.draw_text(-2, 10, 18, 18, @battler.letter.to_s, 0)
  2581.     end
  2582.     if @charge_icon
  2583.       icon_index = @charge_icon_id
  2584.       rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  2585.       dest_rect = Rect.new(0, 0, @charge_size, @charge_size)
  2586.       bitmap.stretch_blt(dest_rect, icon_bitmap, rect)
  2587.     end
  2588.     #---
  2589.     self.bitmap.dispose if self.bitmap != nil
  2590.     self.bitmap = bitmap
  2591.     return if @created_icon
  2592.     @created_icon = true
  2593.     self.ox = 12; self.oy = 12
  2594.     self.x = 24
  2595.     self.y = 24
  2596.     self.z = 8000
  2597.   end
  2598.  
  2599.   #--------------------------------------------------------------------------
  2600.   # create_atb_style
  2601.   #--------------------------------------------------------------------------
  2602.   def create_atb_style
  2603.     bitmap = Bitmap.new(24, 48)
  2604.     icon_bitmap = Cache.system("Iconset")
  2605.     #--- Create Battler Background ---
  2606.     icon_index = @battler.actor? ? @hash[:actor][0] : @hash[:enemy][0]
  2607.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  2608.     bitmap.blt(0, 24, icon_bitmap, rect)
  2609.     #--- Create Battler Icon ---
  2610.     icon_index = @battler.battler_icon
  2611.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  2612.     temp_bitmap = Bitmap.new(24, 24)
  2613.     temp_bitmap.blt(0, 0, icon_bitmap, rect)
  2614.     temp_bitmap.hue_change(@battler.enemy.enemy_icon_hue) if @battler.enemy?
  2615.     bitmap.blt(0, 24, temp_bitmap, Rect.new(0, 0, 24, 24))
  2616.     temp_bitmap.dispose
  2617.     #--- Create Battler Border ---
  2618.     icon_index = @battler.actor? ? @hash[:actor][1] : @hash[:enemy][1]
  2619.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  2620.     bitmap.blt(0, 24, icon_bitmap, rect)
  2621.     #--- Create Battler Letter ---
  2622.     @draw_letter = draw_letter?
  2623.     @charge_icon = charge_icon?
  2624.     if @draw_letter
  2625.       bitmap.font.name = ["Droid Sans", "UmePlus Gothic", "Courier New"]
  2626.       bitmap.font.color.set(255, 255, 255)
  2627.       bitmap.font.size = 12
  2628.       bitmap.draw_text(-3, 34, 12, 12, @battler.letter.to_s, 0)
  2629.     end
  2630.     #--- Create Battler Arrow ---
  2631.     icon_index = @battler.actor? ? @hash[:actor][5] : @hash[:enemy][5]
  2632.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  2633.     bitmap.blt(0, 0, icon_bitmap, rect)
  2634.     #---
  2635.     self.bitmap.dispose if self.bitmap != nil
  2636.     self.bitmap = bitmap
  2637.     return if @created_icon
  2638.     @created_icon = true
  2639.     self.ox = 12; self.oy = 18
  2640.     self.x = 6
  2641.     self.y = 12
  2642.     self.z = 8000 + self.x
  2643.   end
  2644.  
  2645.   #--------------------------------------------------------------------------
  2646.   # draw_letter?
  2647.   #--------------------------------------------------------------------------
  2648.   def draw_letter?
  2649.     return false unless @battler.enemy?
  2650.     return @battler.plural
  2651.   end
  2652.  
  2653.   #--------------------------------------------------------------------------
  2654.   # charge_icon?
  2655.   #--------------------------------------------------------------------------
  2656.   def charge_icon?
  2657.     return false unless $scene.is_a?(Scene_Battle)
  2658.     return false unless $scene.ctb?
  2659.     return @battler.ctb_speed_bonus < 0
  2660.   end
  2661.  
  2662.   #--------------------------------------------------------------------------
  2663.   # update
  2664.   #--------------------------------------------------------------------------
  2665.   def update
  2666.     super
  2667.     return unless $scene.is_a?(Scene_Battle)
  2668.     if (@draw_letter != draw_letter?) or (@charge_icon != charge_icon?)
  2669.       create_battler_bitmap
  2670.     end
  2671.     #---
  2672.     case @battle_type
  2673.     when 0 # Default Turn Battle
  2674.       update_dtb_style
  2675.     when 1 # Press Turn Battle
  2676.       # No update
  2677.     when 2 # Active Turn Battle
  2678.       update_atb_style
  2679.     when 3 # Charge Turn Battle
  2680.       update_dtb_style
  2681.     end
  2682.   end
  2683.  
  2684.   #--------------------------------------------------------------------------
  2685.   # update_dtb_style
  2686.   #--------------------------------------------------------------------------
  2687.   def update_dtb_style
  2688.     return if @move_to_x == nil
  2689.     if @battler.hidden or (!@show_dead and @battler.dead? and
  2690.     self.opacity <= 64)
  2691.       @move_to_x = -48
  2692.       self.x = -48
  2693.       return
  2694.     end
  2695.     self.z = (@battler.dead?) ? 6000 : 8000
  2696.     @move_to_y = 24
  2697.     if self.x != @move_to_x
  2698.       self.z = (@move_to_x < self.x) ? 7500 : 8500
  2699.       @move_to_y = (@move_to_x < self.x) ? 18 : 30 if @first_time
  2700.       value = [[(@move_to_x-self.x).abs, @move_rate_x].min, 1].max
  2701.       self.x += (@move_to_x > self.x) ? value : -value
  2702.       @first_time = true if self.x == @move_to_x
  2703.     end
  2704.     #---
  2705.     if $scene.target_actor_window != nil
  2706.       @move_to_y = 12 if $scene.highlighted_targets.include?(@battler)
  2707.       @move_to_y = 12 if $scene.target_actor_window.actor == @battler
  2708.     end
  2709.     if $scene.target_enemy_window != nil
  2710.       @move_to_y = 12 if $scene.highlighted_targets.include?(@battler)
  2711.       @move_to_y = 12 if $scene.target_enemy_window.enemy == @battler
  2712.     end
  2713.     #---
  2714.     if self.y != @move_to_y
  2715.       @update_wait -= 1
  2716.       if @update_wait <= 0
  2717.         value = [[(@move_to_y-self.y).abs, @move_rate_y].min, 1].max
  2718.         self.y += (@move_to_y > self.y) ? value : -value
  2719.       end
  2720.     end
  2721.     if self.y == @move_to_y and $scene.target_enemy_window != nil
  2722.       @update_wait = 4
  2723.     end
  2724.     self.opacity += (@battler.exist?) ? 8 : -4
  2725.     self.opacity = [[self.opacity, 255].min, 0].max
  2726.   end
  2727.  
  2728.   #--------------------------------------------------------------------------
  2729.   # make_dtb_destination
  2730.   #--------------------------------------------------------------------------
  2731.   def make_dtb_destination
  2732.     if @battler.hidden
  2733.       self.opacity = 0
  2734.       return
  2735.     end
  2736.     array = $scene.performed_actors.reverse
  2737.     action = $scene.action_battlers.reverse - $scene.performed_actors.reverse
  2738.     array += action
  2739.     result = []
  2740.     #---
  2741.     if @show_dead
  2742.       for member in array
  2743.         next if member.hidden
  2744.         result.push(member) if member.dead?
  2745.       end
  2746.     end
  2747.     for member in array
  2748.       next if member.hidden
  2749.       result.push(member) unless member.dead?
  2750.       action.delete(member) if member.dead? and !@show_dead
  2751.     end
  2752.     #---
  2753.     index = result.index(@battler).to_i
  2754.     @move_to_x = 24 + index * 24
  2755.     if dtb_spacing?
  2756.       @move_to_x += 6 if action.include?(@battler)
  2757.       @move_to_x += 6 if (index + 1 == result.size) and action.size > 1
  2758.     end
  2759.     den = @first_time ? 12 : 24
  2760.     @move_rate_x = [(self.x - @move_to_x).abs/den, 1].max
  2761.   end
  2762.  
  2763.   #--------------------------------------------------------------------------
  2764.   # dtb_spacing?
  2765.   #--------------------------------------------------------------------------
  2766.   def dtb_spacing?
  2767.     return false if $scene.party_input_flag
  2768.     return true
  2769.   end
  2770.  
  2771.   #--------------------------------------------------------------------------
  2772.   # update_atb_style
  2773.   #--------------------------------------------------------------------------
  2774.   def update_atb_style
  2775.     if self.x >= 6 + @battler.atb_position
  2776.       self.x = [self.x-16, 6 + @battler.atb_position].max
  2777.     else
  2778.       difference = (6 + @battler.atb_position) - self.x
  2779.       value = [difference / $scene.atb_speed, 1].max
  2780.       self.x = [self.x+value, 6 + @battler.atb_position].min
  2781.     end
  2782.     self.z = 8000 + self.x
  2783.     self.opacity += @battler.exist? ? 8 : -8
  2784.   end
  2785.  
  2786.   #--------------------------------------------------------------------------
  2787.   # new method: make_ctb_destination
  2788.   #--------------------------------------------------------------------------
  2789.   def make_ctb_destination
  2790.     if @battler.hidden
  2791.       self.opacity = 0
  2792.       return
  2793.     end
  2794.     array = $scene.action_battlers.reverse
  2795.     result = []
  2796.     #---
  2797.     if @show_dead
  2798.       for member in array
  2799.         next if member.hidden
  2800.         next unless member.dead?
  2801.         result.push(member)
  2802.       end
  2803.     end
  2804.     for member in array
  2805.       next if member.hidden
  2806.       next if member.dead?
  2807.       next if member.movable?
  2808.       result.push(member)
  2809.     end
  2810.     for member in array
  2811.       next if member.hidden
  2812.       next if member.dead?
  2813.       next unless member.movable?
  2814.       result.push(member)
  2815.     end
  2816.     #---
  2817.     index = result.index(@battler).to_i
  2818.     @move_to_x = 24 + index * 24
  2819.     den = @first_time ? 12 : 24
  2820.     @move_rate_x = [(self.x - @move_to_x).abs/den, 1].max
  2821.   end
  2822.  
  2823. end # Sprite_OrderBattler
  2824.  
  2825. #===============================================================================
  2826. # Sprite_Icon
  2827. #===============================================================================
  2828.  
  2829. class Sprite_Icon < Sprite_Base
  2830.  
  2831.   #--------------------------------------------------------------------------
  2832.   # public instance variables
  2833.   #--------------------------------------------------------------------------
  2834.   attr_accessor :battler
  2835.   attr_accessor :icon
  2836.   attr_accessor :offset_x
  2837.   attr_accessor :offset_y
  2838.   attr_accessor :offset_z
  2839.  
  2840.   #--------------------------------------------------------------------------
  2841.   # initialize
  2842.   #--------------------------------------------------------------------------
  2843.   def initialize(viewport, icon, battler = nil)
  2844.     super(viewport)
  2845.     @battler = battler
  2846.     @icon = icon
  2847.     @attach_x = 0
  2848.     @attach_y = 0
  2849.     @offset_x = 0
  2850.     @offset_y = 0
  2851.     @offset_z = 0
  2852.     create_icon_bitmap
  2853.   end
  2854.  
  2855.   #--------------------------------------------------------------------------
  2856.   # dispose
  2857.   #--------------------------------------------------------------------------
  2858.   def dispose
  2859.     self.bitmap.dispose if self.bitmap != nil
  2860.     super
  2861.   end
  2862.  
  2863.   #--------------------------------------------------------------------------
  2864.   # create_icon_bitmap
  2865.   #--------------------------------------------------------------------------
  2866.   def create_icon_bitmap
  2867.     return if @icon == nil
  2868.     self.bitmap = Cache.system("Iconset")
  2869.     self.src_rect.set(@icon % 16 * 24, @icon / 16 * 24, 24, 24)
  2870.   end
  2871.  
  2872.   #--------------------------------------------------------------------------
  2873.   # set_origin
  2874.   #--------------------------------------------------------------------------
  2875.   def set_origin(type)
  2876.     @offset_z = 2
  2877.     @attachment = type
  2878.     case type
  2879.     when :item
  2880.       self.ox = 12
  2881.       self.oy = 12
  2882.       @offset_y = -@battler.bitmap_height
  2883.       @offset_x = -@battler.bitmap_width / 2
  2884.     when :hand1
  2885.       self.ox = 24
  2886.       self.oy = 24
  2887.       @attach_y = -@battler.bitmap_height/3
  2888.       @attach_x = -@battler.bitmap_width/5
  2889.     when :hand2
  2890.       self.ox = 24
  2891.       self.oy = 24
  2892.       @attach_y = -@battler.bitmap_height/3
  2893.       @attach_x = @battler.bitmap_width/5
  2894.     when :middle
  2895.       self.ox = 12
  2896.       self.oy = 12
  2897.       @offset_y = -@battler.bitmap_height/2
  2898.     when :top
  2899.       self.ox = 12
  2900.       self.oy = 24
  2901.       @offset_y = -@battler.bitmap_height
  2902.     when :base
  2903.       self.ox = 12
  2904.       self.oy = 24
  2905.     end
  2906.   end
  2907.  
  2908.   #--------------------------------------------------------------------------
  2909.   # update
  2910.   #--------------------------------------------------------------------------
  2911.   def update
  2912.     super
  2913.     update_rotate
  2914.     update_opacity
  2915.     update_move
  2916.     update_position
  2917.   end
  2918.  
  2919.   #--------------------------------------------------------------------------
  2920.   # update_position
  2921.   #--------------------------------------------------------------------------
  2922.   def update_position
  2923.     if @battler != nil
  2924.       self.mirror = mirror_battler?
  2925.       update_attachment(self.mirror)
  2926.       attach_x = self.mirror ? -@attach_x : @attach_x
  2927.       self.x = @battler.screen_x + attach_x + @offset_x
  2928.       self.y = @battler.screen_y + @attach_y + @offset_y
  2929.       self.z = @battler.screen_z + @offset_z - 1
  2930.     else
  2931.       self.x = @offset_x
  2932.       self.y = @offset_y
  2933.       self.z = @offset_z
  2934.     end
  2935.   end
  2936.  
  2937.   #--------------------------------------------------------------------------
  2938.   # update_attachment
  2939.   #--------------------------------------------------------------------------
  2940.   def update_attachment(mirror = false)
  2941.     case @attachment
  2942.     when :hand1
  2943.       self.ox = mirror ? 0 : 24
  2944.       self.oy = 24
  2945.       @attach_y = -@battler.bitmap_height/3
  2946.       @attach_x = -@battler.bitmap_width/5
  2947.     when :hand2
  2948.       self.ox = mirror ? 0 : 24
  2949.       self.oy = 24
  2950.       @attach_y = -@battler.bitmap_height/3
  2951.       @attach_x = @battler.bitmap_width/5
  2952.     else
  2953.       @attach_x = 0
  2954.       @attach_y = 0
  2955.     end
  2956.   end
  2957.  
  2958.   #--------------------------------------------------------------------------
  2959.   # mirror_battler?
  2960.   #--------------------------------------------------------------------------
  2961.   def mirror_battler?
  2962.     return false if @battler.spriteset.character_sprite == nil
  2963.     return true if @battler.character.direction == 8
  2964.     return @battler.character.mirror
  2965.   end
  2966.  
  2967.   #--------------------------------------------------------------------------
  2968.   # change_angle
  2969.   #--------------------------------------------------------------------------
  2970.   def change_angle(value); self.angle = value; end
  2971.    
  2972.   #--------------------------------------------------------------------------
  2973.   # rotate
  2974.   #--------------------------------------------------------------------------
  2975.   def rotate(set_angle, set_speed, clockwise = false)
  2976.     @rotate_angle = set_angle
  2977.     @turn_angle = 0
  2978.     @rotate_speed = set_speed
  2979.     @clockwise = clockwise
  2980.   end
  2981.  
  2982.   #--------------------------------------------------------------------------
  2983.   # update_rotate
  2984.   #--------------------------------------------------------------------------
  2985.   def update_rotate
  2986.     return if @rotate_angle == nil
  2987.     clockwise = @clockwise
  2988.     clockwise = !clockwise if self.mirror
  2989.     self.angle += clockwise ? -@rotate_speed : @rotate_speed
  2990.     @turn_angle += @rotate_speed
  2991.     if @rotate_angle.is_a?(Integer) and @turn_angle >= @rotate_angle
  2992.       @rotate_angle = nil
  2993.     end
  2994.   end
  2995.  
  2996.   #--------------------------------------------------------------------------
  2997.   # opacity_rate
  2998.   #--------------------------------------------------------------------------
  2999.   def opacity_rate(rate); @opacity_rate = rate; end
  3000.  
  3001.   #--------------------------------------------------------------------------
  3002.   # update_opacity
  3003.   #--------------------------------------------------------------------------
  3004.   def update_opacity
  3005.     return if @opacity_rate == nil or @opacity_rate == 0
  3006.     self.opacity += @opacity_rate
  3007.   end
  3008.  
  3009.   #--------------------------------------------------------------------------
  3010.   # move_direction
  3011.   #--------------------------------------------------------------------------
  3012.   def move_direction(direction, speed, frames)
  3013.     case direction
  3014.     when 1 # Down Left
  3015.       @move_2 = @move_4 = speed
  3016.       @move_2_count  = @move_4_count  = 0
  3017.       @move_2_frames = @move_4_frames = frames
  3018.     when 2 # Down
  3019.       @move_2 = speed
  3020.       @move_2_count  = 0
  3021.       @move_2_frames = frames
  3022.     when 3 # Down Right
  3023.       @move_2 = @move_6 = speed
  3024.       @move_2_count  = @move_6_count  = 0
  3025.       @move_2_frames = @move_6_frames = frames
  3026.     when 4 # Left
  3027.       @move_4 = speed
  3028.       @move_4_count  = 0
  3029.       @move_4_frames = frames
  3030.     when 6 # Right
  3031.       @move_6 = speed
  3032.       @move_6_count  = 0
  3033.       @move_6_frames = frames
  3034.     when 7 # Up Left
  3035.       @move_8 = @move_4 = speed
  3036.       @move_8_count  = @move_4_count  = 0
  3037.       @move_8_frames = @move_4_frames = frames
  3038.     when 8 # Up
  3039.       @move_8 = speed
  3040.       @move_8_count  = 0
  3041.       @move_8_frames = frames
  3042.     when 9 # Up Right
  3043.       @move_8 = @move_6 = speed
  3044.       @move_8_count  = @move_6_count  = 0
  3045.       @move_8_frames = @move_6_frames = frames
  3046.     else; return
  3047.     end
  3048.   end
  3049.  
  3050.   #--------------------------------------------------------------------------
  3051.   # update_move
  3052.   #--------------------------------------------------------------------------
  3053.   def update_move
  3054.     if @move_2 != nil # Down Move
  3055.       @offset_y += @move_2
  3056.       @move_2_count += 1
  3057.       if @move_2_count >= @move_2_frames
  3058.         @move_2 = @move_2_count = @move_2_frames = nil
  3059.       end
  3060.     end
  3061.     if @move_4 != nil # Left Move
  3062.       @offset_x -= @move_4
  3063.       @move_4_count += 1
  3064.       if @move_4_count >= @move_4_frames
  3065.         @move_4 = @move_4_count = @move_4_frames = nil
  3066.       end
  3067.     end
  3068.     if @move_6 != nil # Right Move
  3069.       @offset_x += @move_6
  3070.       @move_6_count += 1
  3071.       if @move_6_count >= @move_6_frames
  3072.         @move_6 = @move_6_count = @move_6_frames = nil
  3073.       end
  3074.     end
  3075.     if @move_8 != nil # Up Move
  3076.       @offset_y -= @move_8
  3077.       @move_8_count += 1
  3078.       if @move_8_count >= @move_8_frames
  3079.         @move_8 = @move_8_count = @move_8_frames = nil
  3080.       end
  3081.     end
  3082.   end
  3083.  
  3084. end # Sprite_Icon
  3085.  
  3086. #===============================================================================
  3087. # Sprite_PTB
  3088. #===============================================================================
  3089.  
  3090. class Sprite_PTB < Sprite_Base
  3091.  
  3092.   #--------------------------------------------------------------------------
  3093.   # initialize
  3094.   #--------------------------------------------------------------------------
  3095.   def initialize(viewport, dx, dy, group, index)
  3096.     super(viewport)
  3097.     self.x = dx
  3098.     self.y = dy
  3099.     self.z = 100
  3100.     @group = group
  3101.     @index = index
  3102.     create_bitmap
  3103.   end
  3104.  
  3105.   #--------------------------------------------------------------------------
  3106.   # create_bitmap
  3107.   #--------------------------------------------------------------------------
  3108.   def create_bitmap
  3109.     return unless @index > @group.ptb_total_turns - @group.ptb_bonus_turns
  3110.     return unless @index <= @group.ptb_total_turns
  3111.     hash = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS
  3112.     icon_index = (@group == $game_party) ? hash[:actor][4] : hash[:enemy][4]
  3113.     bitmap = Bitmap.new(24, 24)
  3114.     icon_bitmap = Cache.system("Iconset")
  3115.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  3116.     bitmap.blt(0, 0, icon_bitmap, rect)
  3117.     self.bitmap = bitmap
  3118.     self.blend_type = 1
  3119.     self.ox = 12; self.oy = 12
  3120.     self.x += 12; self.y += 12
  3121.     @allow_update = true
  3122.     @up_glow = false
  3123.   end
  3124.  
  3125.   #--------------------------------------------------------------------------
  3126.   # update
  3127.   #--------------------------------------------------------------------------
  3128.   def update
  3129.     super
  3130.     return unless @allow_update
  3131.     self.opacity += @up_glow ? 8 : -8
  3132.     if self.opacity <= 0
  3133.       @up_glow = true
  3134.     elsif self.opacity >= 255
  3135.       @up_glow = false
  3136.     end
  3137.   end
  3138.  
  3139. end # Sprite_PTB
  3140.  
  3141. #===============================================================================
  3142. # Sprite_BattleCursor
  3143. #===============================================================================
  3144.  
  3145. class Sprite_BattleCursor < Sprite
  3146.  
  3147.   #--------------------------------------------------------------------------
  3148.   # initialize
  3149.   #--------------------------------------------------------------------------
  3150.   def initialize(viewport)
  3151.     super(viewport)
  3152.     create_cursor
  3153.     self.x = Graphics.width/2
  3154.     self.y = Graphics.height/2
  3155.     self.z = 200
  3156.     self.opacity = 0
  3157.   end
  3158.  
  3159.   #--------------------------------------------------------------------------
  3160.   # create_cursor
  3161.   #--------------------------------------------------------------------------
  3162.   def create_cursor
  3163.     self.bitmap = Cache.system(YEM::BATTLE_ENGINE::BATTLE_CURSOR[:filename])
  3164.     self.ox = self.width / 2
  3165.     self.ox += YEM::BATTLE_ENGINE::BATTLE_CURSOR[:x_offset]
  3166.     self.oy = self.height
  3167.     self.oy += YEM::BATTLE_ENGINE::BATTLE_CURSOR[:y_offset]
  3168.   end
  3169.  
  3170.   #--------------------------------------------------------------------------
  3171.   # update
  3172.   #--------------------------------------------------------------------------
  3173.   def update
  3174.     super
  3175.     #---
  3176.     return unless $scene.is_a?(Scene_Battle)
  3177.     update_opacity
  3178.     update_move_to
  3179.     update_follow
  3180.   end
  3181.  
  3182.   #--------------------------------------------------------------------------
  3183.   # update_opacity
  3184.   #--------------------------------------------------------------------------
  3185.   def update_opacity
  3186.     value = opaque? ? 16 : -16
  3187.     self.opacity += value
  3188.   end
  3189.  
  3190.   #--------------------------------------------------------------------------
  3191.   # opaque?
  3192.   #--------------------------------------------------------------------------
  3193.   def opaque?
  3194.     return false unless $scene.is_a?(Scene_Battle)
  3195.     return false if $scene.hide_battlecursor
  3196.     return false if @battler != nil and @battler.actor? and $scene.emptyview?
  3197.     if $scene.actor_command_window != nil
  3198.       return true if $scene.actor_command_window.active
  3199.     end
  3200.     return true if $scene.target_actor_window != nil
  3201.     return true if $scene.target_enemy_window != nil
  3202.     return false
  3203.   end
  3204.  
  3205.   #--------------------------------------------------------------------------
  3206.   # create_move_to
  3207.   #--------------------------------------------------------------------------
  3208.   def create_move_to
  3209.     return unless $scene.is_a?(Scene_Battle)
  3210.     if $scene.target_actor_window != nil
  3211.       @battler = $scene.target_actor_window.actor
  3212.     elsif $scene.target_enemy_window != nil
  3213.       @battler = $scene.target_enemy_window.enemy
  3214.     elsif $scene.actor_command_window.active
  3215.       @battler = $scene.actor_command_window.actor
  3216.     else
  3217.       return
  3218.     end
  3219.     return if @battler == nil
  3220.     return if @battler.actor? and $scene.emptyview?
  3221.     @move_to_x = @battler.screen_x
  3222.     @move_to_x += YEM::BATTLE_ENGINE::BATTLE_CURSOR[:actor_x] if @battler.actor?
  3223.     @move_to_x -= $scene.spriteset.viewport1.ox
  3224.     @move_to_y = @battler.screen_y - @battler.bitmap_height
  3225.     @move_to_y -= YEM::BATTLE_ENGINE::BATTLE_CURSOR[:actor_y] if @battler.actor?
  3226.     @move_to_y -= $scene.spriteset.viewport1.oy
  3227.     #---
  3228.     if @first_time
  3229.       distance_x = (@move_to_x - self.x).abs
  3230.       distance_y = (@move_to_y - self.y).abs
  3231.       @move_rate_x = [distance_x/10, 1].max
  3232.       @move_rate_y = [distance_y/10, 1].max
  3233.     else
  3234.       @first_time = true
  3235.       self.x = @move_to_x
  3236.       self.y = @move_to_y
  3237.     end
  3238.   end
  3239.  
  3240.   #--------------------------------------------------------------------------
  3241.   # update_move_to
  3242.   #--------------------------------------------------------------------------
  3243.   def update_move_to
  3244.     return unless $scene.is_a?(Scene_Battle)
  3245.     return if @battler == nil
  3246.     if @move_to_x != nil and @move_rate_x != nil
  3247.       value = [(self.x - @move_to_x).abs, @move_rate_x].min
  3248.       self.x += (@move_to_x > self.x) ? value : -value
  3249.       @move_to_x = nil if self.x == @move_to_x
  3250.     end
  3251.     if @move_to_y != nil and @move_rate_y != nil
  3252.       value = [(self.y - @move_to_y).abs, @move_rate_y].min
  3253.       self.y += (@move_to_y > self.y) ? value : -value
  3254.       @move_to_y = nil if self.y == @move_to_y
  3255.     end
  3256.   end
  3257.  
  3258.   #--------------------------------------------------------------------------
  3259.   # update_follow
  3260.   #--------------------------------------------------------------------------
  3261.   def update_follow
  3262.     return unless $scene.is_a?(Scene_Battle)
  3263.     return unless $scene.atb?
  3264.     return if @battler == nil
  3265.     require_update = false
  3266.     if @battler_x != @battler.screen_x - $scene.spriteset.viewport1.ox
  3267.       require_update = true
  3268.     elsif @battler_y != @battler.screen_y - $scene.spriteset.viewport1.oy
  3269.       require_update = true
  3270.     end
  3271.     if require_update
  3272.       @battler_x = @battler.screen_x - $scene.spriteset.viewport1.ox
  3273.       @battler_y = @battler.screen_y - $scene.spriteset.viewport1.oy
  3274.       create_move_to
  3275.     end
  3276.   end
  3277.  
  3278. end # Sprite_BattleCursor
  3279.  
  3280. #===============================================================================
  3281. # Spriteset_Battle
  3282. #===============================================================================
  3283.  
  3284. class Spriteset_Battle
  3285.  
  3286.   #--------------------------------------------------------------------------
  3287.   # public instance variable
  3288.   #--------------------------------------------------------------------------
  3289.   attr_accessor :actor_sprites
  3290.   attr_accessor :enemy_sprites
  3291.   attr_accessor :battle_cursor
  3292.   attr_accessor :battleback_sprite
  3293.   attr_accessor :camera_x
  3294.   attr_accessor :camera_y
  3295.   attr_accessor :order_sprites
  3296.   attr_accessor :ptb_update
  3297.   attr_accessor :viewport1
  3298.   attr_accessor :viewportA
  3299.   attr_accessor :viewportB
  3300.   attr_accessor :viewportC
  3301.  
  3302.   #--------------------------------------------------------------------------
  3303.   # overwrite method: create_viewports
  3304.   #--------------------------------------------------------------------------
  3305.   def create_viewports
  3306.     create_camera
  3307.     #---
  3308.     @viewport1 = Viewport.new(0, 0, Graphics.width, Graphics.height)
  3309.     @viewport2 = Viewport.new(0, 0, Graphics.width, Graphics.height)
  3310.     @viewport3 = Viewport.new(0, 0, Graphics.width, Graphics.height)
  3311.     @viewportA = Viewport.new(0, 0, Graphics.width, Graphics.height)
  3312.     @viewportB = Viewport.new(0, 0, Graphics.width, Graphics.height)
  3313.     @viewportC = Viewport.new(0, 0, Graphics.width, Graphics.height)
  3314.     @viewport2.z = 50
  3315.     @viewport3.z = 100
  3316.     @viewportA.z = 250
  3317.     @viewportB.z = 200
  3318.     @viewportC.z = 500
  3319.     #---
  3320.     create_order_sprites
  3321.     create_battle_cursor
  3322.   end
  3323.  
  3324.   #--------------------------------------------------------------------------
  3325.   # alias method: dispose_viewports
  3326.   #--------------------------------------------------------------------------
  3327.   alias dispose_viewports_spriteset_battle_bem dispose_viewports unless $@
  3328.   def dispose_viewports
  3329.     dispose_viewports_spriteset_battle_bem
  3330.     dispose_order_sprites
  3331.     dispose_battle_cursor
  3332.     @viewportA.dispose
  3333.     @viewportB.dispose
  3334.   end
  3335.  
  3336.   #--------------------------------------------------------------------------
  3337.   # overwrite method: update_viewports
  3338.   #--------------------------------------------------------------------------
  3339.   def update_viewports
  3340.     update_camera
  3341.     update_order_sprites
  3342.     update_ptb_call
  3343.     #---
  3344.     @viewport1.tone = $game_troop.screen.tone
  3345.     @viewport1.ox = @camera_x + $game_troop.screen.shake
  3346.     @viewport1.oy = @camera_y
  3347.     @viewport2.color = $game_troop.screen.flash_color
  3348.     @viewport3.color.set(0, 0, 0, 255 - $game_troop.screen.brightness)
  3349.     @viewport1.update
  3350.     @viewport2.update
  3351.     @viewport3.update
  3352.     #---
  3353.     if $scene.is_a?(Scene_Battle) and $scene.target_help_window != nil
  3354.       if $scene.target_help_window.active and !$scene.win_loss_flag
  3355.         @viewportA.rect.y = [@viewportA.rect.y+4, 56].min
  3356.       else
  3357.         @viewportA.rect.y = [@viewportA.rect.y-4, 0].max
  3358.       end
  3359.     end
  3360.     @viewportA.update
  3361.     @viewportB.update
  3362.     #---
  3363.     update_battle_cursor
  3364.     update_magic_circle
  3365.     update_magic_square
  3366.     update_battleback_lighting
  3367.   end
  3368.  
  3369.   #--------------------------------------------------------------------------
  3370.   # overwrite method: create_enemies
  3371.   #--------------------------------------------------------------------------
  3372.   def create_enemies
  3373.     dispose_enemies if @enemy_sprites != nil
  3374.     $scene.enemychars = {}
  3375.     @enemy_sprites = []
  3376.     for enemy in $game_troop.members.reverse
  3377.       if $scene.view_type == 0 or enemy.character_name == ""
  3378.         @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
  3379.       else
  3380.         character = Game_Character.new
  3381.         character.set_graphic(enemy.character_name, enemy.character_index)
  3382.         character.opacity = 0 if enemy.hidden
  3383.         character.step_anime = true
  3384.         character_sprite = Sprite_Character.new(@viewport1, character)
  3385.         create_enemy_coordinates(character, enemy)
  3386.         battler_sprite = Sprite_Battler.new(@viewport1, enemy)
  3387.         battler_sprite.character_sprite = character_sprite
  3388.         @enemy_sprites.push(battler_sprite)
  3389.         @enemy_sprites[@enemy_sprites.size-1].create_character_dimensions
  3390.         $scene.enemychars[enemy] = character
  3391.         if enemy.dead?
  3392.           battler_sprite.start_character_death
  3393.           battler_sprite.character_death_duration = 1
  3394.           battler_sprite.update_character_death
  3395.         end
  3396.       end
  3397.     end
  3398.   end
  3399.  
  3400.   #--------------------------------------------------------------------------
  3401.   # new method: create_enemy_coordinates
  3402.   #--------------------------------------------------------------------------
  3403.   def create_enemy_coordinates(character, enemy)
  3404.     character.origin_x = enemy.origin_x
  3405.     character.origin_y = enemy.origin_y
  3406.     case $scene.view_type
  3407.     when 1; array = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[:front]
  3408.     when 2; array = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[:side]
  3409.     when 3; array = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[:angle]
  3410.     end
  3411.     back_hash = {1=>9,2=>8,3=>7,4=>6,6=>4,7=>3,8=>2,9=>1}
  3412.     backdir = back_hash[array[0]]
  3413.     direction = correct_direction(backdir)
  3414.     character.set_direction(direction)
  3415.     character.screen_x = character.origin_x
  3416.     character.screen_y = character.origin_y
  3417.     character.screen_z = 200
  3418.   end
  3419.  
  3420.   #--------------------------------------------------------------------------
  3421.   # overwrite method: create_actors
  3422.   #--------------------------------------------------------------------------
  3423.   def create_actors
  3424.     dispose_actors if @actor_sprites != nil
  3425.     $scene.characters = {}
  3426.     @actor_sprites = []
  3427.     unless [1, 2, 3].include?($scene.view_type)
  3428.       for member in $game_party.members
  3429.         @actor_sprites.push(Sprite_Battler.new(@viewport1, member))
  3430.       end
  3431.       return
  3432.     end
  3433.     for actor in $game_party.members
  3434.       character = Game_Character.new
  3435.       character.set_graphic(actor.character_name, actor.character_index)
  3436.       character.step_anime = true
  3437.       character_sprite = Sprite_Character.new(@viewport1, character)
  3438.       create_actor_coordinates(character, actor)
  3439.       battler_sprite = Sprite_Battler.new(@viewport1, actor)
  3440.       battler_sprite.character_sprite = character_sprite
  3441.       @actor_sprites.push(battler_sprite)
  3442.       @actor_sprites[@actor_sprites.size-1].create_character_dimensions
  3443.       $scene.characters[actor.index] = character
  3444.       if actor.dead?
  3445.         battler_sprite.start_character_death
  3446.         battler_sprite.character_death_duration = 1
  3447.         battler_sprite.update_character_death
  3448.       end
  3449.     end
  3450.   end
  3451.  
  3452.   #--------------------------------------------------------------------------
  3453.   # new method: create_actor_coordinates
  3454.   #--------------------------------------------------------------------------
  3455.   def create_actor_coordinates(character, actor)
  3456.     index = actor.index
  3457.     index = 0 unless YEM::BATTLE_ENGINE::ACTOR_COORDINATES.include?(index)
  3458.     array = YEM::BATTLE_ENGINE::ACTOR_COORDINATES[index][$scene.view_type]
  3459.     character.origin_x = array[0]
  3460.     character.origin_y = array[1]
  3461.     case $scene.view_type
  3462.     when 1; array = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[:front]
  3463.     when 2; array = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[:side]
  3464.     when 3; array = YEM::BATTLE_ENGINE::ACTOR_OFFSETS[:angle]
  3465.     end
  3466.     direction = correct_direction(array[0])
  3467.     character.set_direction(direction)
  3468.     case actor.class.position
  3469.     when 0
  3470.       character.origin_x += array[1]
  3471.       character.origin_y += array[2]
  3472.     when 1
  3473.       character.origin_x += array[3]
  3474.       character.origin_y += array[4]
  3475.     when 2
  3476.       character.origin_x += array[5]
  3477.       character.origin_y += array[6]
  3478.     end
  3479.     character.screen_x = character.origin_x
  3480.     character.screen_y = character.origin_y
  3481.     character.screen_z = 200
  3482.   end
  3483.  
  3484.   #--------------------------------------------------------------------------
  3485.   # new method: correct_direction
  3486.   #--------------------------------------------------------------------------
  3487.   def correct_direction(direction)
  3488.     return direction if $imported["ExtendedMovement"]
  3489.     correction ={ 1=>2, 2=>2, 3=>6, 4=>4, 6=>6, 7=>4, 8=>8, 9=>8 }
  3490.     return correction[direction]
  3491.   end
  3492.  
  3493.   #--------------------------------------------------------------------------
  3494.   # alias method: update_enemies
  3495.   #--------------------------------------------------------------------------
  3496.   alias update_enemies_bem update_enemies unless $@
  3497.   def update_enemies
  3498.     return unless $scene.is_a?(Scene_Battle)
  3499.     update_enemies_bem
  3500.     for key in $scene.enemychars
  3501.       character = key[1]
  3502.       character.update
  3503.     end
  3504.   end
  3505.  
  3506.   #--------------------------------------------------------------------------
  3507.   # overwrite method: update_actors
  3508.   #--------------------------------------------------------------------------
  3509.   def update_actors
  3510.     return unless $scene.is_a?(Scene_Battle)
  3511.     for sprite in @actor_sprites
  3512.       sprite.update
  3513.     end
  3514.     for key in $scene.characters
  3515.       character = key[1]
  3516.       character.update
  3517.     end
  3518.   end
  3519.  
  3520.   #--------------------------------------------------------------------------
  3521.   # overwrite method: animation?
  3522.   #--------------------------------------------------------------------------
  3523.   def animation?
  3524.     for sprite in @enemy_sprites + @actor_sprites
  3525.       return true if sprite.animation?
  3526.       next if sprite.character_sprite == nil
  3527.       return true if sprite.character_sprite.animation?
  3528.     end
  3529.     return false
  3530.   end
  3531.  
  3532.   #--------------------------------------------------------------------------
  3533.   # new method: create_camera
  3534.   #--------------------------------------------------------------------------
  3535.   def create_camera
  3536.     @camera_x = 0
  3537.     @camera_y = 0
  3538.     @camera_to_x = 0
  3539.     @camera_to_y = 0
  3540.     @camera_to_x_rate = 4
  3541.     @camera_to_y_rate = 4
  3542.   end
  3543.  
  3544.   #--------------------------------------------------------------------------
  3545.   # new method: update_camera
  3546.   #--------------------------------------------------------------------------
  3547.   def update_camera
  3548.     if @camera_x != @camera_to_x
  3549.       value = [[(@camera_to_x-@camera_x).abs, @camera_to_x_rate].min, 1].max
  3550.       @camera_x += (@camera_to_x > @camera_x) ? value : -value
  3551.     end
  3552.     if @camera_y != @camera_to_y
  3553.       value = [[(@camera_to_y-@camera_y).abs, @camera_to_y_rate].min, 1].max
  3554.       @camera_y += (@camera_to_y > @camera_y) ? value : -value
  3555.     end
  3556.   end
  3557.  
  3558.   #--------------------------------------------------------------------------
  3559.   # new method: set_camera_desintation
  3560.   #--------------------------------------------------------------------------
  3561.   def set_camera_destination(to_x, to_y, frames = 60)
  3562.     @camera_to_x = to_x
  3563.     @camera_to_y = to_y
  3564.     @camera_to_x_rate = [(@camera_to_x-@camera_x).abs/[frames, 1].max, 1].max
  3565.     @camera_to_y_rate = [(@camera_to_y-@camera_y).abs/[frames, 1].max, 1].max
  3566.   end
  3567.  
  3568.   #--------------------------------------------------------------------------
  3569.   # new method: scroll_camera
  3570.   #--------------------------------------------------------------------------
  3571.   def scroll_camera(direction, distance, frames = 60)
  3572.     to_x = @camera_to_x
  3573.     to_y = @camera_to_y
  3574.     case direction
  3575.     when 1 # Down Left
  3576.       to_x += distance
  3577.       to_y -= distance
  3578.     when 2 # Down
  3579.       to_y -= distance
  3580.     when 3 # Down Right
  3581.       to_x -= distance
  3582.       to_y -= distance
  3583.     when 4 # Left
  3584.       to_x -= distance
  3585.     when 6 # Right
  3586.       to_x += distance
  3587.     when 7 # Up Left
  3588.       to_x -= distance
  3589.       to_y += distance
  3590.     when 8 # Up
  3591.       to_y += distance
  3592.     when 9 # Up Right
  3593.       to_x += distance
  3594.       to_y += distance
  3595.     end
  3596.     set_camera_destination(to_x, to_y, frames)
  3597.   end
  3598.  
  3599.   #--------------------------------------------------------------------------
  3600.   # new method: create_order_sprites
  3601.   #--------------------------------------------------------------------------
  3602.   def create_order_sprites
  3603.     case $scene.battle_type
  3604.     when 0 # Default Turn Battle
  3605.       create_dtb_sprites
  3606.     when 1 # Press Turn Battle
  3607.       # none, reset in battle
  3608.     when 2 # Active Turn Battle
  3609.       create_atb_sprites
  3610.     when 3 # Charge Turn Battle
  3611.       create_ctb_sprites
  3612.     end
  3613.   end
  3614.  
  3615.   #--------------------------------------------------------------------------
  3616.   # new method: update_order_sprites
  3617.   #--------------------------------------------------------------------------
  3618.   def update_order_sprites
  3619.     return if @order_sprites == nil
  3620.     for sprite in @order_sprites
  3621.       sprite.update
  3622.     end
  3623.   end
  3624.  
  3625.   #--------------------------------------------------------------------------
  3626.   # new method: dispose_order_sprites
  3627.   #--------------------------------------------------------------------------
  3628.   def dispose_order_sprites
  3629.     return if @order_sprites == nil
  3630.     for sprite in @order_sprites
  3631.       sprite.dispose
  3632.       sprite = nil
  3633.     end
  3634.     @order_sprites = nil
  3635.   end
  3636.  
  3637.   #--------------------------------------------------------------------------
  3638.   # new method: create_dtb_sprites
  3639.   #--------------------------------------------------------------------------
  3640.   def create_dtb_sprites
  3641.     dispose_order_sprites
  3642.     @order_sprites = []
  3643.     array = $game_party.members + $game_troop.members
  3644.     for member in array.reverse
  3645.       sprite = Sprite_OrderBattler.new(@viewportA, member, 0)
  3646.       @order_sprites.push(sprite)
  3647.     end
  3648.   end
  3649.  
  3650.   #--------------------------------------------------------------------------
  3651.   # new method: update_dtb_order
  3652.   #--------------------------------------------------------------------------
  3653.   def update_dtb_order
  3654.     return unless $scene.is_a?(Scene_Battle)
  3655.     return unless $scene.dtb?
  3656.     return if @order_sprites == nil
  3657.     for sprite in @order_sprites
  3658.       sprite.make_dtb_destination
  3659.     end
  3660.   end
  3661.  
  3662.   #--------------------------------------------------------------------------
  3663.   # new method: update_ptb_call
  3664.   #--------------------------------------------------------------------------
  3665.   def update_ptb_call
  3666.     return if @ptb_update == nil
  3667.     refresh_ptb_counters(@ptb_update)
  3668.   end
  3669.  
  3670.   #--------------------------------------------------------------------------
  3671.   # new method: refresh_ptb_counters
  3672.   #--------------------------------------------------------------------------
  3673.   def refresh_ptb_counters(group)
  3674.     @ptb_update = nil
  3675.     dispose_order_sprites
  3676.     @order_sprites = []
  3677.     amount = group.ptb_total_turns
  3678.     index = 1; dx = 12; dy = 6
  3679.     amount.times do
  3680.       sprite = Sprite_PTB.new(@viewportA, dx, dy, group, index)
  3681.       @order_sprites.push(sprite)
  3682.       index += 1
  3683.       dx += 24
  3684.       dy = (dy == 6) ? 18 : 6
  3685.     end
  3686.   end
  3687.  
  3688.   #--------------------------------------------------------------------------
  3689.   # create_atb_sprites
  3690.   #--------------------------------------------------------------------------
  3691.   def create_atb_sprites
  3692.     dispose_order_sprites
  3693.     @order_sprites = []
  3694.     create_atb_gauge
  3695.     array = $game_party.members + $game_troop.members
  3696.     for member in array.reverse
  3697.       sprite = Sprite_OrderBattler.new(@viewportA, member, 2)
  3698.       @order_sprites.push(sprite)
  3699.     end
  3700.   end
  3701.  
  3702.   #--------------------------------------------------------------------------
  3703.   # create_atb_gauge
  3704.   #--------------------------------------------------------------------------
  3705.   def create_atb_gauge
  3706.     sprite = Sprite_Base.new(@viewportA)
  3707.     bitmap = Cache.system(YEM::BATTLE_ENGINE::ATB_GAUGE)
  3708.     sprite.bitmap = bitmap
  3709.     sprite.x = 5
  3710.     sprite.y = 5
  3711.     @order_sprites.push(sprite)
  3712.   end
  3713.  
  3714.   #--------------------------------------------------------------------------
  3715.   # new method: create_ctb_sprites
  3716.   #--------------------------------------------------------------------------
  3717.   def create_ctb_sprites
  3718.     dispose_order_sprites
  3719.     @order_sprites = []
  3720.     array = $game_party.members + $game_troop.members
  3721.     for member in array.reverse
  3722.       sprite = Sprite_OrderBattler.new(@viewportA, member, 3)
  3723.       @order_sprites.push(sprite)
  3724.     end
  3725.   end
  3726.  
  3727.   #--------------------------------------------------------------------------
  3728.   # new method: update_ctb_order
  3729.   #--------------------------------------------------------------------------
  3730.   def update_ctb_order
  3731.     return unless $scene.is_a?(Scene_Battle)
  3732.     return unless $scene.ctb?
  3733.     return if @order_sprites == nil
  3734.     for sprite in @order_sprites
  3735.       sprite.make_ctb_destination
  3736.     end
  3737.   end
  3738.  
  3739.   #--------------------------------------------------------------------------
  3740.   # new method: mark_first_time_order
  3741.   #--------------------------------------------------------------------------
  3742.   def mark_first_time_order
  3743.     return unless $scene.is_a?(Scene_Battle)
  3744.     return if @marked_first_time
  3745.     @marked_first_time = true
  3746.     return if $scene.ptb?
  3747.     return if @order_sprites == nil
  3748.     for sprite in @order_sprites
  3749.       sprite.first_time = true
  3750.     end
  3751.   end
  3752.  
  3753.   #--------------------------------------------------------------------------
  3754.   # new method: create_battle_cursor
  3755.   #--------------------------------------------------------------------------
  3756.   def create_battle_cursor
  3757.     return unless YEM::BATTLE_ENGINE::BATTLE_CURSOR[:enable]
  3758.     @battle_cursor = Sprite_BattleCursor.new(@viewportB)
  3759.   end
  3760.  
  3761.   #--------------------------------------------------------------------------
  3762.   # new method: update_battle_cursor
  3763.   #--------------------------------------------------------------------------
  3764.   def update_battle_cursor
  3765.     return if @battle_cursor == nil
  3766.     @battle_cursor.update
  3767.   end
  3768.  
  3769.   #--------------------------------------------------------------------------
  3770.   # new method: dispose_battle_cursor
  3771.   #--------------------------------------------------------------------------
  3772.   def dispose_battle_cursor
  3773.     return if @battle_cursor == nil
  3774.     @battle_cursor.dispose
  3775.   end
  3776.  
  3777.   #--------------------------------------------------------------------------
  3778.   # new method: create_magic_circle
  3779.   #--------------------------------------------------------------------------
  3780.   def create_magic_circle(window, obj)
  3781.     if obj.is_a?(RPG::Skill) or obj.is_a?(RPG::Item)
  3782.       return if obj.aoe_radius <= 0
  3783.     else; return
  3784.     end
  3785.     #---
  3786.     @aoe_window = window
  3787.     @magic_circle_sprite = Sprite.new(@viewport1)
  3788.     @magic_circle_sprite.bitmap = Cache.picture(obj.aoe_image)
  3789.     diameter = obj.aoe_radius * 2 + 1
  3790.     @magic_circle_sprite.blend_type = obj.aoe_blend
  3791.     @magic_circle_sprite.zoom_x = diameter * 1.125 /
  3792.       @magic_circle_sprite.width
  3793.     @magic_circle_sprite.zoom_y = @magic_circle_sprite.zoom_x *
  3794.       (obj.aoe_height + 0.01)
  3795.     @magic_circle_sprite.ox = @magic_circle_sprite.width/2
  3796.     @magic_circle_sprite.oy = @magic_circle_sprite.height/2
  3797.     @magic_circle_sprite.z = 2
  3798.   end
  3799.  
  3800.   #--------------------------------------------------------------------------
  3801.   # new method: dispose_magic_circle
  3802.   #--------------------------------------------------------------------------
  3803.   def dispose_magic_circle
  3804.     @magic_circle_sprite.dispose if @magic_circle_sprite != nil
  3805.     @magic_circle_sprite = nil
  3806.     @aoe_window = nil
  3807.   end
  3808.  
  3809.   #--------------------------------------------------------------------------
  3810.   # new method: update_magic_circle
  3811.   #--------------------------------------------------------------------------
  3812.   def update_magic_circle
  3813.     return if @magic_circle_sprite == nil
  3814.     if @aoe_window != nil
  3815.       if @aoe_window.is_a?(Window_TargetEnemy)
  3816.         target = @aoe_window.enemy
  3817.         group = $game_troop
  3818.         value_x = target.screen_x + target.enemy.target_offset_x
  3819.         value_y = target.screen_y + target.enemy.target_offset_y
  3820.       elsif @aoe_window.is_a?(Window_BattleStatus)
  3821.         target = @aoe_window.actor
  3822.         group = $game_party
  3823.         value_x = target.screen_x
  3824.         value_y = target.screen_y
  3825.       end
  3826.       #---
  3827.       update_highlight = false
  3828.       if @magic_circle_sprite.x != value_x
  3829.         update_highlight = true
  3830.         @magic_circle_sprite.x = value_x
  3831.       end
  3832.       if @magic_circle_sprite.y != value_y
  3833.         update_highlight = true
  3834.         @magic_circle_sprite.y = value_y
  3835.       end
  3836.       $scene.create_highlighted_targets(group) if update_highlight
  3837.       #---
  3838.     end
  3839.     @magic_circle_sprite.opacity += @magic_circle_sprite_upward ? 8 : -8
  3840.     if @magic_circle_sprite.opacity <= 0
  3841.       @magic_circle_sprite_upward = true
  3842.     elsif @magic_circle_sprite.opacity >= 255
  3843.       @magic_circle_sprite_upward = false
  3844.     end
  3845.   end
  3846.  
  3847.   #--------------------------------------------------------------------------
  3848.   # new method: create_magic_square
  3849.   #--------------------------------------------------------------------------
  3850.   def create_magic_square(window, obj)
  3851.     if obj.is_a?(RPG::Skill) or obj.is_a?(RPG::Item)
  3852.       return if obj.rect_type <= 0
  3853.     else; return
  3854.     end
  3855.     @aoe_window = window
  3856.     @magic_square_sprite = Sprite.new(@viewport1)
  3857.     @magic_square_sprite.bitmap = Cache.picture(obj.rect_image)
  3858.     @magic_square_sprite.blend_type = obj.rect_blend
  3859.     @magic_square_type = obj.rect_type
  3860.     rect_value = obj.rect_value * 2 + 1
  3861.     case @magic_square_type
  3862.     when 1 # Column
  3863.       @magic_square_sprite.zoom_x = rect_value * 1.0 /
  3864.         @magic_square_sprite.width
  3865.       @magic_square_sprite.zoom_y = Graphics.height * 1.0 /
  3866.         @magic_square_sprite.height
  3867.       @magic_square_sprite.ox = @magic_square_sprite.width/2
  3868.     when 2 # Row
  3869.       @magic_square_sprite.zoom_x = Graphics.width * 1.0 /
  3870.         @magic_square_sprite.width
  3871.       @magic_square_sprite.zoom_y = rect_value * 1.0 /
  3872.         @magic_square_sprite.height
  3873.       @magic_square_sprite.oy = @magic_square_sprite.height/2
  3874.     when 3 # Map
  3875.       @magic_square_sprite.zoom_x = Graphics.width * 1.0 /
  3876.         @magic_square_sprite.width
  3877.       @magic_square_sprite.zoom_y = Graphics.height * 1.0 /
  3878.         @magic_square_sprite.height
  3879.     end
  3880.     @magic_square_sprite.z = 3
  3881.   end
  3882.  
  3883.   #--------------------------------------------------------------------------
  3884.   # new method: dispose_magic_square
  3885.   #--------------------------------------------------------------------------
  3886.   def dispose_magic_square
  3887.     @magic_square_sprite.dispose if @magic_square_sprite != nil
  3888.     @magic_square_sprite = nil
  3889.     @aoe_window = nil
  3890.   end
  3891.  
  3892.   #--------------------------------------------------------------------------
  3893.   # new method: update_magic_square
  3894.   #--------------------------------------------------------------------------
  3895.   def update_magic_square
  3896.     return if @magic_square_sprite == nil
  3897.     if @aoe_window != nil
  3898.       if @aoe_window.is_a?(Window_TargetEnemy)
  3899.         group = $game_troop
  3900.         target = @aoe_window.enemy
  3901.         case @magic_square_type
  3902.         when 1 # Column
  3903.           value_x = target.screen_x
  3904.           value_x += target.enemy.target_offset_x
  3905.           value_y = 0
  3906.         when 2 # Row
  3907.           value_x = 0
  3908.           value_y = target.screen_y
  3909.           value_y += target.enemy.target_offset_y
  3910.         when 3 # Map
  3911.           value_x = 0
  3912.           value_y = 0
  3913.         end
  3914.       elsif @aoe_window.is_a?(Window_BattleStatus)
  3915.         group = $game_party
  3916.         target = @aoe_window.actor
  3917.         case @magic_square_type
  3918.         when 1 # Column
  3919.           value_x = target.screen_x
  3920.           value_y = 0
  3921.         when 2 # Row
  3922.           value_x = 0
  3923.           value_y = target.screen_y
  3924.         when 3 # Map
  3925.           value_x = 0
  3926.           value_y = 0
  3927.         end
  3928.       end
  3929.       #---
  3930.       update_highlight = false
  3931.       if @magic_square_sprite.x != value_x
  3932.         update_highlight = true
  3933.         @magic_square_sprite.x = value_x
  3934.       end
  3935.       if @magic_square_sprite.y != value_y
  3936.         update_highlight = true
  3937.         @magic_square_sprite.y = value_y
  3938.       end
  3939.       $scene.create_highlighted_targets(group) if update_highlight
  3940.       #---
  3941.     end
  3942.     @magic_square_sprite.opacity += @magic_square_sprite_upward ? 8 : -8
  3943.     if @magic_square_sprite.opacity <= 0
  3944.       @magic_square_sprite_upward = true
  3945.     elsif @magic_square_sprite.opacity >= 255
  3946.       @magic_square_sprite_upward = false
  3947.     end
  3948.   end
  3949.  
  3950.   #--------------------------------------------------------------------------
  3951.   # new method: start_battleback_darken
  3952.   #--------------------------------------------------------------------------
  3953.   def start_battleback_darken
  3954.     @battleback_darken_duration = 32
  3955.     @battleback_sprite.color.set(0,0,0,0)
  3956.   end
  3957.  
  3958.   #--------------------------------------------------------------------------
  3959.   # new method: start_battleback_lighten
  3960.   #--------------------------------------------------------------------------
  3961.   def start_battleback_lighten
  3962.     @battleback_lighten_duration = 16
  3963.     @battleback_sprite.color.set(0,0,0,128)
  3964.   end
  3965.  
  3966.   #--------------------------------------------------------------------------
  3967.   # new method: update_battleback_lighting
  3968.   #--------------------------------------------------------------------------
  3969.   def update_battleback_lighting
  3970.     if @battleback_darken_duration != nil
  3971.       @battleback_darken_duration -= 1
  3972.       duration = @battleback_darken_duration
  3973.       @battleback_sprite.color.alpha += 4
  3974.       @battleback_darken_duration = nil if @battleback_darken_duration <= 0
  3975.       return
  3976.     end
  3977.     if @battleback_lighten_duration != nil
  3978.       @battleback_lighten_duration -= 1
  3979.       @battleback_sprite.color.alpha -= 8
  3980.       @battleback_lighten_duration = nil if @battleback_lighten_duration <= 0
  3981.     end
  3982.   end
  3983.  
  3984. end # Spriteset_Battle
  3985.  
  3986. #==============================================================================
  3987. # Window_Base
  3988. #==============================================================================
  3989.  
  3990. class Window_Base < Window
  3991.  
  3992.   #--------------------------------------------------------------------------
  3993.   # alias method: initialize
  3994.   #--------------------------------------------------------------------------
  3995.   alias initialize_window_base_bem initialize unless $@
  3996.   def initialize(x, y, width, height)
  3997.     initialize_window_base_bem(x, y, width, height)
  3998.     if $game_temp.in_battle
  3999.       $disposable_melody_windows = [] if $disposable_melody_windows == nil
  4000.       $disposable_melody_windows.push(self)
  4001.     end
  4002.   end
  4003.  
  4004.   #--------------------------------------------------------------------------
  4005.   # alias method: dispose
  4006.   #--------------------------------------------------------------------------
  4007.   alias dispose_window_base_bem dispose unless $@
  4008.   def dispose
  4009.     if $game_temp.in_battle
  4010.       $disposable_melody_windows = [] if $disposable_melody_windows == nil
  4011.       $disposable_melody_windows.delete(self)
  4012.     end
  4013.     dispose_window_base_bem
  4014.   end
  4015.  
  4016.   #--------------------------------------------------------------------------
  4017.   # rage_gauge_color1
  4018.   #--------------------------------------------------------------------------
  4019.   def rage_gauge_color1
  4020.     return text_color(YEM::BATTLE_ENGINE::SKILL_SETTINGS[:rage_gauge1])
  4021.   end
  4022.  
  4023.   #--------------------------------------------------------------------------
  4024.   # rage_gauge_color2
  4025.   #--------------------------------------------------------------------------
  4026.   def rage_gauge_color2
  4027.     return text_color(YEM::BATTLE_ENGINE::SKILL_SETTINGS[:rage_gauge2])
  4028.   end
  4029.  
  4030.   #--------------------------------------------------------------------------
  4031.   # new method: draw_actor_rage_gauge
  4032.   #--------------------------------------------------------------------------
  4033.   unless $imported["CoreFixesUpgradesMelody"]
  4034.   def draw_actor_rage_gauge(actor, x, y, width = 120, height = nil)
  4035.     gc0 = gauge_back_color
  4036.     gc1 = text_color(YEM::BATTLE_ENGINE::RAGE[:rage_gauge1])
  4037.     gc2 = text_color(YEM::BATTLE_ENGINE::RAGE[:rage_gauge2])
  4038.     gh = 6
  4039.     gy = y + WLH - 8 - (gh - 6)
  4040.     gb = width
  4041.     self.contents.fill_rect(x, gy, gb, gh, gc0)
  4042.     gw = [[gb * actor.rage / actor.max_rage, width].min, 0].max
  4043.     self.contents.gradient_fill_rect(x, gy, gw, gh, gc1, gc2)
  4044.   end
  4045.   end
  4046.  
  4047.   #--------------------------------------------------------------------------
  4048.   # new method: draw_enemy_hp_gauge
  4049.   #--------------------------------------------------------------------------
  4050.   def draw_enemy_hp_gauge(battler, x, y, width = 120)
  4051.     battler.hp = [battler.hp, battler.maxhp].min
  4052.     gc0 = gauge_back_color
  4053.     gc1 = text_color(battler.enemy.quick_gauge[:hp_gauge1])
  4054.     gc2 = text_color(battler.enemy.quick_gauge[:hp_gauge2])
  4055.     gh = 6
  4056.     gy = y + WLH - 8 - (gh - 6)
  4057.     if battler.maxhp < battler.base_maxhp and battler.base_maxhp > 0 and
  4058.     !(battler.base_maxhp > battler.maxhp_limit)
  4059.       gb = width * battler.maxhp / battler.base_maxhp
  4060.       self.contents.fill_rect(x, gy, width, gh, text_color(7))
  4061.     else
  4062.       gb = width
  4063.     end
  4064.     self.contents.fill_rect(x, gy, gb, gh, gc0)
  4065.     gw = gb * battler.hp / battler.maxhp
  4066.     self.contents.gradient_fill_rect(x, gy, gw, gh, gc1, gc2)
  4067.   end
  4068.  
  4069.   #--------------------------------------------------------------------------
  4070.   # new method: draw_enemy_mp_gauge
  4071.   #--------------------------------------------------------------------------
  4072.   def draw_enemy_mp_gauge(battler, x, y, width = 120, height = nil)
  4073.     battler.mp = [battler.mp, battler.maxmp].min
  4074.     gc0 = gauge_back_color
  4075.     gc1 = text_color(battler.enemy.quick_gauge[:mp_gauge1])
  4076.     gc2 = text_color(battler.enemy.quick_gauge[:mp_gauge2])
  4077.     gh = 6
  4078.     gy = y + WLH - 8 - (gh - 6)
  4079.     if battler.maxmp < battler.base_maxmp and battler.base_maxmp > 0 and
  4080.     !(battler.base_maxmp > battler.maxmp_limit)
  4081.       gb = width * battler.maxmp / battler.base_maxmp
  4082.       self.contents.fill_rect(x, gy, width, gh, text_color(7))
  4083.     else
  4084.       gb = width
  4085.     end
  4086.     self.contents.fill_rect(x, gy, gb, gh, gc0)
  4087.     if battler.maxmp <= 0
  4088.       if battler.base_maxmp <= 0
  4089.         gw = width
  4090.       else
  4091.         gw = 0
  4092.       end
  4093.     else
  4094.       gw = gb * battler.mp / battler.maxmp
  4095.     end
  4096.     self.contents.gradient_fill_rect(x, gy, gw, gh, gc1, gc2)
  4097.   end
  4098.  
  4099.   #--------------------------------------------------------------------------
  4100.   # new method: draw_enemy_rage_gauge
  4101.   #--------------------------------------------------------------------------
  4102.   def draw_enemy_rage_gauge(actor, x, y, width = 120, height = nil)
  4103.     gc0 = gauge_back_color
  4104.     gc1 = text_color(YEM::BATTLE_ENGINE::SKILL_SETTINGS[:rage_gauge1])
  4105.     gc2 = text_color(YEM::BATTLE_ENGINE::SKILL_SETTINGS[:rage_gauge2])
  4106.     gh = $imported["CoreFixesUpgradesMelody"] ? YEM::UPGRADE::GAUGE_HEIGHT : 6
  4107.     gy = y + WLH - 8 - (gh - 6)
  4108.     gb = width
  4109.     self.contents.fill_rect(x, gy, gb, gh, gc0)
  4110.     gw = [[gb * actor.rage / actor.max_rage, width].min, 0].max
  4111.     self.contents.gradient_fill_rect(x, gy, gw, gh, gc1, gc2)
  4112.   end
  4113.  
  4114. end # Window_Base
  4115.  
  4116. #==============================================================================
  4117. # Window_Command_Centered
  4118. #==============================================================================
  4119.  
  4120. class Window_Command_Centered < Window_Command
  4121.  
  4122.   #--------------------------------------------------------------------------
  4123.   # new method: draw_item
  4124.   #--------------------------------------------------------------------------
  4125.   def draw_item(index, enabled = true)
  4126.     rect = item_rect(index)
  4127.     rect.x += 4
  4128.     rect.width -= 8
  4129.     self.contents.clear_rect(rect)
  4130.     self.contents.font.color = normal_color
  4131.     self.contents.font.color.alpha = enabled ? 255 : 128
  4132.     self.contents.draw_text(rect, @commands[index],1)
  4133.   end
  4134.  
  4135. end # Window_Command_Centered
  4136.  
  4137. #===============================================================================
  4138. # Window_BattleDebug
  4139. #===============================================================================
  4140.  
  4141. class Window_BattleDebug < Window_Base
  4142.  
  4143.   #--------------------------------------------------------------------------
  4144.   # initialize
  4145.   #--------------------------------------------------------------------------
  4146.   def initialize
  4147.     super(0, 16, Graphics.width, 56)
  4148.     self.back_opacity = 0
  4149.     self.opacity = 0
  4150.   end
  4151.  
  4152.   #--------------------------------------------------------------------------
  4153.   # update
  4154.   #--------------------------------------------------------------------------
  4155.   def update
  4156.     super
  4157.     call_enable
  4158.     return unless @enabled
  4159.     return unless $scene.is_a?(Scene_Battle)
  4160.     refresh if @current_selected != $scene.selected_battler
  4161.     refresh if @current_active != $scene.active_battler
  4162.     refresh if @current_turn != $game_troop.turn_count
  4163.   end
  4164.  
  4165.   #--------------------------------------------------------------------------
  4166.   # call_enable
  4167.   #--------------------------------------------------------------------------
  4168.   def call_enable
  4169.     return if @enabled
  4170.     if Input.press?(Input::CTRL) and Input.press?(Input::ALT)
  4171.       @enabled = true
  4172.       Sound.play_decision
  4173.     end
  4174.   end
  4175.  
  4176.   #--------------------------------------------------------------------------
  4177.   # refresh
  4178.   #--------------------------------------------------------------------------
  4179.   def refresh
  4180.     self.contents.clear
  4181.     self.contents.font.size = 16
  4182.     dw = contents.width/4
  4183.     @current_selected = $scene.selected_battler
  4184.     @current_active = $scene.active_battler
  4185.     @current_turn = $game_troop.turn_count
  4186.     if @current_turn != nil
  4187.       turn = @current_turn
  4188.       text = sprintf("Turn: %s", turn)
  4189.       self.contents.draw_text(dw*0, 0, dw, WLH, text, 0)
  4190.     end
  4191.     if @current_selected != nil
  4192.       name = @current_selected.name
  4193.       text = sprintf("Sel: %s", name)
  4194.       self.contents.draw_text(dw*2, 0, dw, WLH, text, 0)
  4195.     end
  4196.     if @current_active != nil
  4197.       name = @current_active.name
  4198.       text = sprintf("Act: %s", name)
  4199.       self.contents.draw_text(dw*3, 0, dw, WLH, text, 0)
  4200.     end
  4201.   end
  4202.  
  4203. end # Window_BattleDebug
  4204.  
  4205. #==============================================================================
  4206. # Window_TargetEnemy
  4207. #==============================================================================
  4208.  
  4209. class Window_TargetEnemy < Window_Command
  4210.  
  4211.   #--------------------------------------------------------------------------
  4212.   # overwrite method: initialize
  4213.   #--------------------------------------------------------------------------
  4214.   def initialize
  4215.     commands = []
  4216.     super(416, commands, 8, 1)
  4217.   end
  4218.  
  4219.   #--------------------------------------------------------------------------
  4220.   # overwrite method: refresh
  4221.   #--------------------------------------------------------------------------
  4222.   def refresh
  4223.     @commands = []
  4224.     @enemies = []
  4225.     for enemy in $game_troop.members
  4226.       next unless enemy.exist?
  4227.       @commands.push(enemy.name)
  4228.       @enemies.push(enemy)
  4229.     end
  4230.     @enemies.sort! { |a,b| a.screen_x <=> b.screen_x }
  4231.     self.contents.clear
  4232.     @item_max = @commands.size
  4233.     for i in 0...@item_max; draw_item(i); end
  4234.   end
  4235.  
  4236. end # Window_TargetEnemy
  4237.  
  4238. #===============================================================================
  4239. # Window_TargetHelp
  4240. #===============================================================================
  4241.  
  4242. class Window_TargetHelp < Window_Base
  4243.  
  4244.   #--------------------------------------------------------------------------
  4245.   # initialize
  4246.   #--------------------------------------------------------------------------
  4247.   def initialize
  4248.     super(0, 0, Graphics.width, 56)
  4249.     refresh
  4250.   end
  4251.  
  4252.   #--------------------------------------------------------------------------
  4253.   # refresh
  4254.   #--------------------------------------------------------------------------
  4255.   def refresh(target = nil, battler = nil)
  4256.     self.contents.clear
  4257.     return if target == nil
  4258.     if draw_unique_name?(battler)
  4259.       draw_obj_selection(battler)
  4260.       return
  4261.     end
  4262.     name = target.name
  4263.     if $imported["EnemyLevels"] and target.enemy?
  4264.       name = sprintf(YEM::ENEMY_LEVEL::LEVEL_TEXT, target.level, name)
  4265.     end
  4266.     self.contents.draw_text(0, 0, contents.width, WLH, name, 1)
  4267.   end
  4268.  
  4269.   #--------------------------------------------------------------------------
  4270.   # draw_unique_name?
  4271.   #--------------------------------------------------------------------------
  4272.   def draw_unique_name?(battler)
  4273.     return false if battler == nil
  4274.     return false if battler.action == nil
  4275.     return false if battler.action.attack?
  4276.     obj = battler.action.skill if battler.action.skill?
  4277.     obj = battler.action.item if battler.action.item?
  4278.     if $scene.atb?
  4279.       case battler.action.atb_queue_kind
  4280.       when 0; return false
  4281.       when 1; obj = $data_skills[battler.action.atb_queue_basic]
  4282.       when 2; obj = $data_items[battler.action.atb_queue_basic]
  4283.       end
  4284.     end
  4285.     return false if obj == nil
  4286.     return true if obj.target_text != nil
  4287.     return true if !obj.need_selection?
  4288.     return false
  4289.   end
  4290.  
  4291.   #--------------------------------------------------------------------------
  4292.   # draw_obj_selection
  4293.   #--------------------------------------------------------------------------
  4294.   def draw_obj_selection(battler)
  4295.     obj = battler.action.skill if battler.action.skill?
  4296.     obj = battler.action.item if battler.action.item?
  4297.     if $scene.atb?
  4298.       case battler.action.atb_queue_kind
  4299.       when 1; obj = $data_skills[battler.action.atb_queue_basic]
  4300.       when 2; obj = $data_items[battler.action.atb_queue_basic]
  4301.       end
  4302.     end
  4303.     if obj.for_user?
  4304.       text = YEM::BATTLE_ENGINE::TARGET_WINDOW[:user]
  4305.     elsif obj.for_friend?
  4306.       if obj.for_one?
  4307.         text = YEM::BATTLE_ENGINE::TARGET_WINDOW[:actor]
  4308.       else
  4309.         text = YEM::BATTLE_ENGINE::TARGET_WINDOW[:actors]
  4310.       end
  4311.       if obj.for_dead_friend?
  4312.         text = sprintf(YEM::BATTLE_ENGINE::TARGET_WINDOW[:dead], text)
  4313.       end
  4314.     elsif obj.for_opponent?
  4315.       if obj.for_one?
  4316.         text = YEM::BATTLE_ENGINE::TARGET_WINDOW[:enemy]
  4317.       else
  4318.         text = YEM::BATTLE_ENGINE::TARGET_WINDOW[:enemies]
  4319.       end
  4320.     else
  4321.       text = YEM::BATTLE_ENGINE::TARGET_WINDOW[:none]
  4322.       self.contents.draw_text(0, 0, contents.width, WLH, text, 1)
  4323.       return
  4324.     end
  4325.     if obj.for_random?
  4326.       n = obj.random_targets
  4327.       text = sprintf(YEM::BATTLE_ENGINE::TARGET_WINDOW[:random], n, text)
  4328.     end
  4329.     if obj.for_all?
  4330.       text = sprintf(YEM::BATTLE_ENGINE::TARGET_WINDOW[:all], text)
  4331.     end
  4332.     if obj.target_text != nil
  4333.       name = ""
  4334.       if $scene.target_enemy_window != nil
  4335.         name = $scene.target_enemy_window.enemy.name
  4336.         if $imported["EnemyLevels"] and $scene.target_enemy_window.enemy.enemy?
  4337.           level = $scene.target_enemy_window.enemy.level
  4338.           name = sprintf(YEM::ENEMY_LEVEL::LEVEL_TEXT, level, name)
  4339.         end
  4340.       elsif $scene.target_actor_window != nil
  4341.         name = $scene.target_enemy_window.actor.name
  4342.       end
  4343.       text = sprintf(obj.target_text, name)
  4344.     end
  4345.     self.contents.draw_text(0, 0, contents.width, WLH, text, 1)
  4346.   end
  4347.  
  4348. end # Window_TargetHelp
  4349.  
  4350. #===============================================================================
  4351. # Window_BattleMessageMelody
  4352. #===============================================================================
  4353.  
  4354. class Window_BattleMessageMelody < Window_BattleMessage
  4355.  
  4356.   #--------------------------------------------------------------------------
  4357.   # public instance variables
  4358.   #--------------------------------------------------------------------------
  4359.   attr_accessor :align
  4360.   attr_accessor :icon
  4361.  
  4362.   #--------------------------------------------------------------------------
  4363.   # initialize
  4364.   #--------------------------------------------------------------------------
  4365.   def initialize
  4366.     super
  4367.     self.x = 0
  4368.     self.y = 32
  4369.     self.z = 300
  4370.     self.back_opacity = 0
  4371.     self.opacity = 0
  4372.     self.windowskin = Cache.system("Window")
  4373.     @align = YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:alignment]
  4374.     create_background_sprite
  4375.     change_viewport($scene.spriteset.viewportB)
  4376.   end
  4377.  
  4378.   #--------------------------------------------------------------------------
  4379.   # dispose
  4380.   #--------------------------------------------------------------------------
  4381.   def dispose
  4382.     super
  4383.     @leftsprite.bitmap.dispose
  4384.     @leftsprite.dispose
  4385.     @centersprite.bitmap.dispose
  4386.     @centersprite.dispose
  4387.     @rightsprite.bitmap.dispose
  4388.     @rightsprite.dispose
  4389.   end
  4390.  
  4391.   #--------------------------------------------------------------------------
  4392.   # create_background_sprite
  4393.   #--------------------------------------------------------------------------
  4394.   def create_background_sprite
  4395.     gw = Graphics.width
  4396.     g1 = YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:gradient1]
  4397.     g2 = YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:gradient2]
  4398.     #--- Create Left Aligned Sprite ---
  4399.     bitmap = Bitmap.new(gw, 112)
  4400.     bitmap.gradient_fill_rect(0, 16, gw, 96, g1, g2)
  4401.     @leftsprite = Sprite.new(self.viewport)
  4402.     @leftsprite.bitmap = bitmap
  4403.     @leftsprite.x = self.x
  4404.     @leftsprite.y = self.y
  4405.     @leftsprite.z = self.z - 1
  4406.     @leftsprite.src_rect.height = 16
  4407.     #--- Create Center Aligned Sprite ---
  4408.     bitmap = Bitmap.new(gw, 112)
  4409.     bitmap.gradient_fill_rect(0, 16, gw/2, 96, g2, g1)
  4410.     bitmap.gradient_fill_rect(gw/2, 16, gw/2, 96, g1, g2)
  4411.     @centersprite = Sprite.new(self.viewport)
  4412.     @centersprite.bitmap = bitmap
  4413.     @centersprite.x = self.x
  4414.     @centersprite.y = self.y
  4415.     @centersprite.z = self.z - 1
  4416.     @centersprite.src_rect.height = 16
  4417.     #--- Create Right Aligned Sprite ---
  4418.     bitmap = Bitmap.new(gw, 112)
  4419.     bitmap.gradient_fill_rect(0, 16, gw, 96, g2, g1)
  4420.     @rightsprite = Sprite.new(self.viewport)
  4421.     @rightsprite.bitmap = bitmap
  4422.     @rightsprite.x = self.x
  4423.     @rightsprite.y = self.y
  4424.     @rightsprite.z = self.z - 1
  4425.     @rightsprite.src_rect.height = 16
  4426.     #--- Hide Sprites ---
  4427.     @leftsprite.opacity = 0
  4428.     @centersprite.opacity = 0
  4429.     @rightsprite.opacity = 0
  4430.   end
  4431.  
  4432.   #--------------------------------------------------------------------------
  4433.   # change_viewport
  4434.   #--------------------------------------------------------------------------
  4435.   def change_viewport(viewport)
  4436.     return if self.viewport == viewport
  4437.     self.viewport = viewport
  4438.     @leftsprite.viewport = self.viewport
  4439.     @centersprite.viewport = self.viewport
  4440.     @rightsprite.viewport = self.viewport
  4441.   end
  4442.  
  4443.   #--------------------------------------------------------------------------
  4444.   # new_page
  4445.   #--------------------------------------------------------------------------
  4446.   def new_page
  4447.     super
  4448.     self.windowskin = Cache.system("Window")
  4449.     self.contents.font.shadow = true
  4450.     self.contents.font.color = normal_color
  4451.   end
  4452.  
  4453.   #--------------------------------------------------------------------------
  4454.   # clear
  4455.   #--------------------------------------------------------------------------
  4456.   def clear
  4457.     super
  4458.     @icon = nil
  4459.   end
  4460.  
  4461.   #--------------------------------------------------------------------------
  4462.   # refresh
  4463.   #--------------------------------------------------------------------------
  4464.   def refresh
  4465.     update
  4466.     super
  4467.   end
  4468.  
  4469.   #--------------------------------------------------------------------------
  4470.   # update
  4471.   #--------------------------------------------------------------------------
  4472.   def update
  4473.     return if @anti_update
  4474.     if self.viewport != nil
  4475.       #---
  4476.       self.x = self.viewport.ox
  4477.       @leftsprite.x = @centersprite.x = @rightsprite.x = self.x
  4478.       #---
  4479.       self.y = self.viewport.oy + 32
  4480.       @leftsprite.y = @centersprite.y = @rightsprite.y = self.y
  4481.       #---
  4482.     end
  4483.     if self.visible and (@lines.size > 0) or
  4484.     (@text != nil or self.pause or @index > -1)
  4485.       if @text != nil
  4486.         lines = 4
  4487.       else
  4488.         lines = (!self.pause or @index > -1) ? @lines.size : 4
  4489.       end
  4490.       case @align
  4491.       when 1
  4492.         @centersprite.opacity += YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:opacity]
  4493.         @centersprite.src_rect.height = 16 + (lines * 24)
  4494.       when 2
  4495.         @rightsprite.opacity += YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:opacity]
  4496.         @rightsprite.src_rect.height = 16 + (lines * 24)
  4497.       else
  4498.         @leftsprite.opacity += YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:opacity]
  4499.         @leftsprite.src_rect.height = 16 + (lines * 24)
  4500.       end
  4501.       @countdown = 8
  4502.     elsif @countdown != nil and @countdown > 0
  4503.       @countdown -= 1
  4504.     elsif @countdown != nil
  4505.       @centersprite.opacity -= YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:opacity]
  4506.       @leftsprite.opacity -= YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:opacity]
  4507.       @rightsprite.opacity -= YEM::BATTLE_ENGINE::MESSAGE_SETTINGS[:opacity]
  4508.     end
  4509.     super
  4510.   end
  4511.  
  4512.   #--------------------------------------------------------------------------
  4513.   # draw_line
  4514.   #--------------------------------------------------------------------------
  4515.   def draw_line(index)
  4516.     rect = Rect.new(0, 0, 0, 0)
  4517.     rect.x += 4
  4518.     rect.y += index * WLH
  4519.     rect.width = contents.width - 8
  4520.     rect.height = WLH
  4521.     dx = rect.x; dy = rect.y; dw = rect.width; dh = rect.height
  4522.     self.contents.clear_rect(rect)
  4523.     if $imported["CustomMessageMelody"] and $game_message.busy
  4524.       self.contents.font.name = YEM::MESSAGE::MESSAGE_WINDOW_FONT
  4525.     else
  4526.       self.contents.font.name = Font.default_name
  4527.     end
  4528.     self.contents.font.color = normal_color
  4529.     if index == 0 and (@icon != nil and @icon != 0)
  4530.       fx = contents.text_size(@lines[index]).width
  4531.       case @align
  4532.       when 0 # Left Aligned
  4533.         draw_icon(@icon, dx, dy)
  4534.         dx += 24
  4535.       when 1 # Center Aligned
  4536.         draw_icon(@icon, (dw-fx)/2-12, dy)
  4537.         dx += 12
  4538.       when 2 # Right Aligned
  4539.         draw_icon(@icon, dw-fx-24, dy)
  4540.       end
  4541.     end
  4542.     self.contents.draw_text(dx, dy, dw, dh, @lines[index], @align)
  4543.   end
  4544.  
  4545. end # Window_BattleMessageMelody
  4546.  
  4547. #===============================================================================
  4548. # Window_BattleStatus
  4549. #===============================================================================
  4550.  
  4551. class Window_BattleStatus < Window_Selectable
  4552.  
  4553.   #--------------------------------------------------------------------------
  4554.   # public instance variables
  4555.   #--------------------------------------------------------------------------
  4556.   attr_accessor :battle_refresh_call
  4557.   attr_accessor :frozen_cursor
  4558.   attr_accessor :highlight_all
  4559.   attr_accessor :highlight_user
  4560.   attr_accessor :highlight_none
  4561.   attr_accessor :highlight_dead
  4562.   attr_accessor :target_highlight
  4563.  
  4564.   #--------------------------------------------------------------------------
  4565.   # overwrite method: initialize
  4566.   #--------------------------------------------------------------------------
  4567.   def initialize(minimum = false)
  4568.     super(0, 0, Graphics.width - 128, 128)
  4569.     max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
  4570.     @item_max = [$game_party.members.size, max_members].max
  4571.     @column_max = @item_max
  4572.     @minimum = minimum
  4573.     @current_party = $game_party.members
  4574.     recreate unless @miniature
  4575.     self.active = false
  4576.   end
  4577.  
  4578.   #--------------------------------------------------------------------------
  4579.   # actor
  4580.   #--------------------------------------------------------------------------
  4581.   def actor; return $game_party.members[self.index]; end
  4582.  
  4583.   #--------------------------------------------------------------------------
  4584.   # recreate
  4585.   #--------------------------------------------------------------------------
  4586.   def recreate
  4587.     max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
  4588.     @item_max = [$game_party.members.size, max_members].max
  4589.     @item_max = 1 if @minitature
  4590.     @updating = -1
  4591.     @current_party = $game_party.members
  4592.     @current_hp = {}; @current_hp_gauge = {}; @maxhp = {}
  4593.     @current_mp = {}; @current_mp_gauge = {}; @maxmp = {}
  4594.     @current_rage = {}; @current_rage_gauge = {}; @max_rage = {}
  4595.     temp_rect = item_rect(0)
  4596.     @hp_gauge_width = temp_rect.width-4
  4597.     @mp_gauge_width = temp_rect.width-4
  4598.     @rg_gauge_width = temp_rect.width-4
  4599.     for i in 0...@current_party.size
  4600.       actor = $game_party.members[i]
  4601.       #--
  4602.       @current_hp[i] = actor.hp
  4603.       maxhp = [[actor.maxhp, actor.base_maxhp, 1].max, actor.maxhp_limit].min
  4604.       @current_hp_gauge[i] = (actor.hp * @hp_gauge_width / maxhp)
  4605.       @maxhp[i] = maxhp
  4606.       #--
  4607.       maxmp = [[actor.maxmp, actor.base_maxmp, 1].max, actor.maxmp_limit].min
  4608.       @current_mp[i] = actor.mp
  4609.       @current_mp_gauge[i] = (actor.mp * @mp_gauge_width / [actor.maxmp,1].max)
  4610.       @maxmp[i] = maxmp
  4611.       #---
  4612.       actor.rage = 0 if actor.rage == nil
  4613.       @current_rage[i] = actor.rage
  4614.       @current_rage_gauge[i] = actor.rage * @rg_gauge_width / actor.max_rage
  4615.       @max_rage[i] = actor.max_rage
  4616.     end
  4617.     refresh
  4618.   end
  4619.  
  4620.   #--------------------------------------------------------------------------
  4621.   # new method: update
  4622.   #--------------------------------------------------------------------------
  4623.   def update
  4624.     super unless prevent_left_right?
  4625.     redraw if @last_index != self.index
  4626.     redraw if @battle_refresh_call
  4627.     return unless @minimum
  4628.     recreate if @current_party != $game_party.members
  4629.     return unless $scene.is_a?(Scene_Battle)
  4630.     for member in $game_party.members; redraw if member.update_states; end
  4631.     redraw if @last_active_battler != $scene.active_battler
  4632.   end
  4633.  
  4634.   #--------------------------------------------------------------------------
  4635.   # new method: prevent_left_right
  4636.   #--------------------------------------------------------------------------
  4637.   def prevent_left_right?
  4638.     return true if (@frozen_cursor and (Input.repeat?(Input::LEFT) or
  4639.       Input.repeat?(Input::RIGHT)))
  4640.     if Input.repeat?(Input::LEFT) and $game_party.members[self.index-1] == nil
  4641.       return true
  4642.     end
  4643.     if Input.repeat?(Input::RIGHT) and $game_party.members[self.index+1] == nil
  4644.       return true
  4645.     end
  4646.     return false
  4647.   end
  4648.  
  4649.   #--------------------------------------------------------------------------
  4650.   # new method: redraw
  4651.   #--------------------------------------------------------------------------
  4652.   def redraw
  4653.     return unless $scene.is_a?(Scene_Battle)
  4654.     @last_index = self.index
  4655.     @last_active_battler = $scene.active_battler
  4656.     @battle_refresh_call = false
  4657.     refresh
  4658.   end
  4659.  
  4660.   #--------------------------------------------------------------------------
  4661.   # overwrite method: refresh
  4662.   #--------------------------------------------------------------------------
  4663.   def refresh
  4664.     return if @miniature
  4665.     max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
  4666.     @item_max = [$game_party.members.size, max_members].max
  4667.     @column_max = @item_max
  4668.     for i in 0...@item_max; draw_item(i); end
  4669.   end
  4670.  
  4671.   #--------------------------------------------------------------------------
  4672.   # overwrite method: draw_item
  4673.   #--------------------------------------------------------------------------
  4674.   def draw_item(index)
  4675.     rect = item_rect(index)
  4676.     self.contents.clear_rect(rect)
  4677.     actor = $game_party.members[index]
  4678.     return if actor == nil
  4679.     draw_member_face(actor, rect.clone)
  4680.     draw_member_action(actor, rect.clone)
  4681.     return if @minimum
  4682.     draw_member_name(actor, rect.clone)
  4683.     draw_member_states(actor, rect.clone)
  4684.     draw_member_hp(actor, rect.clone)
  4685.     draw_member_mp(actor, rect.clone)
  4686.     draw_member_rage(actor, rect.clone)
  4687.   end
  4688.  
  4689.   #--------------------------------------------------------------------------
  4690.   # new method: item_rect
  4691.   #--------------------------------------------------------------------------
  4692.   def item_rect(index)
  4693.     rect = Rect.new(0, 0, 0, 0)
  4694.     rect.width = contents.width / @item_max
  4695.     rect.height = contents.height
  4696.     rect.x = index * rect.width
  4697.     rect.y = 0
  4698.     return rect
  4699.   end
  4700.  
  4701.   #--------------------------------------------------------------------------
  4702.   # new method: draw_member_face
  4703.   #--------------------------------------------------------------------------
  4704.   def draw_member_face(actor, content_rect)
  4705.     lower_opacity = YEM::BATTLE_ENGINE::PARTY_WINDOW[:face_opacity]
  4706.     opacity = opacity?(actor) ? 255 : lower_opacity
  4707.     face_name = actor.face_name
  4708.     face_index = actor.face_index
  4709.     bitmap = Cache.face(face_name)
  4710.     rect = Rect.new(0, 0, 0, 0)
  4711.     rect.width = [content_rect.width-4, 92].min
  4712.     rect.height = [contents.height-4, 92].min
  4713.     rect.x = face_index % 4 * 96 + (96-rect.width) / 2
  4714.     rect.y = face_index / 4 * 96 + (96-rect.height) / 2
  4715.     self.contents.blt(content_rect.x+2, content_rect.y+2, bitmap, rect, opacity)
  4716.   end
  4717.  
  4718.   #--------------------------------------------------------------------------
  4719.   # new method: draw_member_action
  4720.   #--------------------------------------------------------------------------
  4721.   def draw_member_action(actor, rect)
  4722.     return unless YEM::BATTLE_ENGINE::PARTY_WINDOW[:action_icons]
  4723.     icon = YEM::BATTLE_ENGINE::ICON_MESSAGE[:wait_icon]
  4724.     case actor.action.kind
  4725.     when 0 # Basic
  4726.       case actor.action.basic
  4727.       when 0 # Attack
  4728.         icon = actor.attack_icon
  4729.       when 1 # Guard
  4730.         icon = actor.guard_icon
  4731.       when 2 # Escape
  4732.         icon = YEM::BATTLE_ENGINE::ICON_MESSAGE[:flee_icon]
  4733.       end
  4734.     when 1 # Skill
  4735.       icon = actor.action.skill.icon_index
  4736.     when 2 # Item
  4737.       icon = actor.action.item.icon_index
  4738.     end
  4739.     enabled = actor.action.valid?
  4740.     enabled = false if actor.action.kind == 0 and actor.action.basic == 3
  4741.     if $scene.is_a?(Scene_Battle) and $scene.ctb? and actor.action.guard?
  4742.       icon = actor.guard_icon
  4743.       enabled = true
  4744.     end
  4745.     draw_icon(icon, rect.x, rect.y, enabled)
  4746.   end
  4747.  
  4748.   #--------------------------------------------------------------------------
  4749.   # new method: opacity?
  4750.   #--------------------------------------------------------------------------
  4751.   def opacity?(actor)
  4752.     return false if actor == nil
  4753.     if $scene.is_a?(Scene_Battle) and $scene.ctb?
  4754.       return true if actor.ctb_active? and !@minimum
  4755.     end
  4756.     return true if self.is_a?(Window_BattleStatus_Mini)
  4757.     return false if actor == nil
  4758.     return false if @highlight_none
  4759.     return true if @highlight_all
  4760.     if @highlight_dead
  4761.       return true if self.index == actor.index and actor.dead?
  4762.       return false
  4763.     end
  4764.     return false if actor.dead?
  4765.     if !@target_highlight and $scene.is_a?(Scene_Battle)
  4766.       return true if actor.active_battler?
  4767.     end
  4768.     if @highlight_user and $scene.is_a?(Scene_Battle)
  4769.       return true if actor == $scene.selected_battler
  4770.     end
  4771.     return false if @highlight_user
  4772.     return true if self.index == actor.index
  4773.     return false if !@minimum
  4774.     return false
  4775.   end
  4776.  
  4777.   #--------------------------------------------------------------------------
  4778.   # new method: draw_member_name
  4779.   #--------------------------------------------------------------------------
  4780.   def draw_member_name(actor, rect)
  4781.     name = actor.name
  4782.     self.contents.font.size = YEM::BATTLE_ENGINE::PARTY_WINDOW[:name_size]
  4783.     dy = rect.y
  4784.     if YEM::BATTLE_ENGINE::PARTY_WINDOW[:action_icons]
  4785.       dx = rect.x+24
  4786.       dw = rect.width-28
  4787.     else
  4788.       dx = rect.x+4
  4789.       dw = rect.width-8
  4790.     end
  4791.     self.contents.font.color = hp_color(actor)
  4792.  #  self.contents.draw_text(dx, dy, dw, WLH, name)  # MK remove name?
  4793.   end
  4794.  
  4795.   #--------------------------------------------------------------------------
  4796.   # new method: draw_member_states
  4797.   #--------------------------------------------------------------------------
  4798.   def draw_member_states(actor, rect)
  4799.     dw = [YEM::BATTLE_ENGINE::PARTY_WINDOW[:max_states] * 24, rect.width].min
  4800.     draw_actor_state(actor, rect.x, rect.y + WLH, dw)
  4801.     actor.update_states = false
  4802.   end
  4803.  
  4804.   #--------------------------------------------------------------------------
  4805.   # new method: draw_member_hp
  4806.   #--------------------------------------------------------------------------
  4807.   def draw_member_hp(actor, rect)
  4808.     @updating = -1
  4809.     i = actor.index
  4810.     maxhp = @maxhp[i]
  4811.     dy = (WLH * 3 - YEM::BATTLE_ENGINE::PARTY_WINDOW[:stat_size]) + 4
  4812.     dx = rect.x + 2
  4813.     self.contents.fill_rect(dx, dy+WLH-8, @hp_gauge_width, YEM::UPGRADE::GAUGE_HEIGHT+2, gauge_back_color) # 8
  4814.     #---
  4815.     target_gauge = (actor.hp * @hp_gauge_width / maxhp)
  4816.     if @current_hp_gauge[i] > target_gauge
  4817.       @updating = i
  4818.       @current_hp_gauge[i] -= [2, (@current_hp_gauge[i]-target_gauge).abs].min
  4819.       @current_hp_gauge[i] = [@current_hp_gauge[i], 0].max
  4820.       gw = @current_hp_gauge[i]
  4821.       gw = [gw, 3].max if actor.hp > 0
  4822.       gc1 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:hp_dmg_gauge])
  4823.       gc2 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:hp_dmg_gauge])
  4824.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, YEM::UPGRADE::GAUGE_HEIGHT, gc1, gc2)#gw-2, 6,
  4825.       gw = @hp_gauge_width * actor.hp / maxhp
  4826.       gw = [gw, 3].max if actor.hp > 0
  4827.       gc1 = hp_gauge_color1
  4828.       gc2 = hp_gauge_color2
  4829.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, YEM::UPGRADE::GAUGE_HEIGHT, gc1, gc2)
  4830.     elsif @current_hp_gauge[i] < target_gauge
  4831.       @updating = i
  4832.       @current_hp_gauge[i] += [2, (@current_hp_gauge[i]-target_gauge).abs].min
  4833.       @current_hp_gauge[i] = [@current_hp_gauge[i], @hp_gauge_width].min
  4834.       gw = @hp_gauge_width * actor.hp / maxhp
  4835.       gw = [gw, 3].max if actor.hp > 0
  4836.       gc1 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:hp_heal_gauge])
  4837.       gc2 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:hp_heal_gauge])
  4838.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, YEM::UPGRADE::GAUGE_HEIGHT, gc1, gc2)
  4839.       gw = @current_hp_gauge[i]
  4840.       gw = [gw, 3].max if actor.hp > 0
  4841.       gc1 = hp_gauge_color1
  4842.       gc2 = hp_gauge_color2
  4843.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, YEM::UPGRADE::GAUGE_HEIGHT, gc1, gc2)
  4844.     else
  4845.       gw = @current_hp_gauge[i]
  4846.       gw = [gw, 3].max if actor.hp > 0
  4847.       gc1 = hp_gauge_color1
  4848.       gc2 = hp_gauge_color2
  4849.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, YEM::UPGRADE::GAUGE_HEIGHT, gc1, gc2)
  4850.     end
  4851.     #---
  4852.     if maxhp > actor.maxhp
  4853.       gce = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:exhaust_gauge])
  4854.       gbw = @hp_gauge_width * (actor.base_maxhp - actor.maxhp) / maxhp + 1
  4855.       gbc = gauge_back_color
  4856.       self.contents.fill_rect(dx+@hp_gauge_width-gbw-2, dy+WLH-8, gbw, YEM::UPGRADE::GAUGE_HEIGHT, gbc) # 8
  4857.       self.contents.fill_rect(dx+@hp_gauge_width-gbw-1, dy+WLH-7, gbw, YEM::UPGRADE::GAUGE_HEIGHT, gce)  # 6
  4858.     end
  4859.     #---
  4860.     if @current_hp[i] != actor.hp
  4861.       @updating = i
  4862.       den = [@hp_gauge_width/3 + rand(@hp_gauge_width/2), 1].max
  4863.       value = [[maxhp/den, (@current_hp[i]-actor.hp).abs].min, 1].max
  4864.       @current_hp[i] += (@current_hp[i] > actor.hp) ? -value : value
  4865.       @current_hp[i] = actor.hp if @current_hp_gauge[i] == target_gauge
  4866.     end
  4867.     #---
  4868.     dy += 4
  4869.     self.contents.font.size = YEM::BATTLE_ENGINE::PARTY_WINDOW[:stat_size]
  4870.     self.contents.font.color = system_color
  4871.     self.contents.draw_text(dx, dy-2, rect.width-4, WLH, Vocab::hp_a, 0) # dy was left alone
  4872.     self.contents.font.color = hp_color(actor)
  4873.     text = @current_hp[i]
  4874.     self.contents.draw_text(dx, dy-2, rect.width-4, WLH, text, 2)
  4875.     #---
  4876.   end
  4877.  
  4878.   #--------------------------------------------------------------------------
  4879.   # new method: draw_member_mp
  4880.   #--------------------------------------------------------------------------
  4881.   def draw_member_mp(actor, rect)
  4882.     @updating = -1
  4883.     i = actor.index
  4884.     maxmp = @maxmp[i]
  4885.     dy = WLH * 3 + 2         # - 2
  4886.     dx = rect.x + 2
  4887.     mp_gw = @mp_gauge_width
  4888.     if actor.use_rage?
  4889.       dx += rect.width/2
  4890.       dx -= 3
  4891.       mp_gw = mp_gw/2+1
  4892.     end
  4893.     self.contents.fill_rect(dx, dy+WLH-8, mp_gw, YEM::UPGRADE::GAUGE_HEIGHT+2, gauge_back_color)
  4894.     #---
  4895.     target_gauge = (actor.mp * @mp_gauge_width / maxmp)
  4896.     if @current_mp_gauge[i] > target_gauge and !@miniature
  4897.       @updating = i
  4898.       @current_mp_gauge[i] -= [2, (@current_mp_gauge[i]-target_gauge).abs].min
  4899.       @current_mp_gauge[i] = [@current_mp_gauge[i], 0].max
  4900.       gw = @current_mp_gauge[i]
  4901.       gw = gw/2+1 if actor.use_rage?
  4902.       gw = [gw, 3].max if actor.mp > 0
  4903.       gc1 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:mp_dmg_gauge])
  4904.       gc2 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:mp_dmg_gauge])
  4905.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, YEM::UPGRADE::GAUGE_HEIGHT, gc1, gc2)
  4906.       gw = mp_gw * actor.mp / maxmp
  4907.       gw = [gw, 3].max if actor.mp > 0
  4908.       gc1 = mp_gauge_color1
  4909.       gc2 = mp_gauge_color2
  4910.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, YEM::UPGRADE::GAUGE_HEIGHT, gc1, gc2)
  4911.     elsif @current_mp_gauge[i] < target_gauge and !@miniature
  4912.       @updating = i
  4913.       @current_mp_gauge[i] += [2, (@current_mp_gauge[i]-target_gauge).abs].min
  4914.       @current_mp_gauge[i] = [@current_mp_gauge[i], @mp_gauge_width].min
  4915.       gw = mp_gw * actor.mp / maxmp
  4916.       gw = [gw, 3].max if actor.mp > 0
  4917.       gc1 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:mp_heal_gauge])
  4918.       gc2 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:mp_heal_gauge])
  4919.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, YEM::UPGRADE::GAUGE_HEIGHT, gc1, gc2)
  4920.       gw = @current_mp_gauge[i]
  4921.       gw = gw/2+1 if actor.use_rage?
  4922.       gw = [gw, 3].max if actor.mp > 0
  4923.       gc1 = mp_gauge_color1
  4924.       gc2 = mp_gauge_color2
  4925.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, YEM::UPGRADE::GAUGE_HEIGHT, gc1, gc2)
  4926.     else
  4927.       gw = mp_gw * actor.mp / maxmp
  4928.       gw = [gw, 3].max if actor.mp > 0
  4929.       gc1 = mp_gauge_color1
  4930.       gc2 = mp_gauge_color2
  4931.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, YEM::UPGRADE::GAUGE_HEIGHT, gc1, gc2)
  4932.     end
  4933.     #---
  4934.     if actor.base_maxmp > actor.maxmp
  4935.       gce = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:exhaust_gauge])
  4936.       gbw = mp_gw
  4937.       gbw *= (actor.base_maxmp - actor.maxmp) / [actor.base_maxmp, 1].max + 1
  4938.       gbc = gauge_back_color
  4939.       self.contents.fill_rect(dx+mp_gw-gbw-2, dy+WLH-8, gbw, YEM::UPGRADE::GAUGE_HEIGHT, gbc)
  4940.       self.contents.fill_rect(dx+mp_gw-gbw-1, dy+WLH-7, gbw, YEM::UPGRADE::GAUGE_HEIGHT, gce)
  4941.     end
  4942.     #---
  4943.     if @current_mp[i] != actor.mp
  4944.       @updating = i
  4945.       den = [mp_gw/3 + rand(mp_gw/2), 1].max
  4946.       value = [[maxmp/den, (@current_mp[i]-actor.mp).abs].min, 1].max
  4947.       @current_mp[i] += (@current_mp[i] > actor.mp) ? -value : value
  4948.       @current_mp[i] = actor.mp if @current_mp_gauge[i] == target_gauge
  4949.     end
  4950.     #---
  4951.     dy += 4
  4952.     self.contents.font.size = YEM::BATTLE_ENGINE::PARTY_WINDOW[:stat_size]
  4953.     self.contents.font.color = system_color
  4954.     self.contents.draw_text(dx, dy-2, rect.width-4, WLH, Vocab::mp_a, 0)
  4955.     self.contents.font.color = mp_color(actor)
  4956.     text = @current_mp[i]
  4957.     dw = rect.width-4
  4958.     dw /= 2 if actor.use_rage?
  4959.     self.contents.draw_text(dx, dy-2, dw, WLH, text, 2)
  4960.     #---
  4961.   end
  4962.  
  4963.   #--------------------------------------------------------------------------
  4964.   # new method: draw_member_rage
  4965.   #--------------------------------------------------------------------------
  4966.   def draw_member_rage(actor, rect)
  4967.     return unless actor.use_rage?
  4968.     @updating = -1
  4969.     i = actor.index
  4970.     max_rage = @max_rage[i]
  4971.     dy = WLH * 3 + 2     # - 2  
  4972.     dx = rect.x + 2
  4973.     rg_gw = @rg_gauge_width / 2
  4974.     self.contents.fill_rect(dx, dy+WLH-8, rg_gw, YEM::UPGRADE::GAUGE_HEIGHT+2, gauge_back_color)
  4975.     #---
  4976.     target_gauge = (actor.rage * @rg_gauge_width / max_rage)
  4977.     target_gauge += 2 if actor.rage > 0
  4978.     if @current_rage_gauge[i] > target_gauge
  4979.       @updating = i
  4980.       value = [2,(@current_rage_gauge[i]-target_gauge).abs].min
  4981.       @current_rage_gauge[i] -= value
  4982.       @current_rage_gauge[i] = [@current_rage_gauge[i], 0].max
  4983.       gw = @current_rage_gauge[i] / 2
  4984.       gw = [gw, 3].max if actor.rage > 0
  4985.       gc1 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:rg_dmg_gauge])
  4986.       gc2 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:rg_dmg_gauge])
  4987.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, YEM::UPGRADE::GAUGE_HEIGHT, gc1, gc2)
  4988.       gw = rg_gw * actor.rage / max_rage
  4989.       gw = [gw, 3].max if actor.rage > 0
  4990.       gc1 = rage_gauge_color1
  4991.       gc2 = rage_gauge_color2
  4992.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, YEM::UPGRADE::GAUGE_HEIGHT, gc1, gc2)
  4993.     elsif @current_rage_gauge[i] < target_gauge
  4994.       @updating = i
  4995.       value = [2,(@current_rage_gauge[i]-target_gauge).abs].min
  4996.       @current_rage_gauge[i] += value
  4997.       @current_rage_gauge[i] = [@current_rage_gauge[i], rg_gw*2].min
  4998.       gw = rg_gw * actor.rage / max_rage
  4999.       gw = [gw, 3].max if actor.rage > 0
  5000.       gc1 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:rg_heal_gauge])
  5001.       gc2 = text_color(YEM::BATTLE_ENGINE::PARTY_WINDOW[:rg_heal_gauge])
  5002.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, YEM::UPGRADE::GAUGE_HEIGHT, gc1, gc2)
  5003.       gw = @current_rage_gauge[i] / 2
  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, YEM::UPGRADE::GAUGE_HEIGHT, gc1, gc2)
  5008.     else
  5009.       gw = @current_rage_gauge[i] / 2
  5010.       gw = [gw, 3].max if actor.rage > 0
  5011.       gc1 = rage_gauge_color1
  5012.       gc2 = rage_gauge_color2
  5013.       self.contents.gradient_fill_rect(dx+1, dy+WLH-7, gw-2, YEM::UPGRADE::GAUGE_HEIGHT, gc1, gc2)
  5014.     end
  5015.     #---
  5016.     if @current_rage[i] != actor.rage
  5017.       @updating = i
  5018.       @current_rage[i] += (@current_rage[i] > actor.rage) ? -1 : 1
  5019.       @current_rage[i] = actor.rage if @current_rage_gauge[i] == target_gauge
  5020.     end
  5021.     #---
  5022.     dy += 4
  5023.     self.contents.font.size = YEM::BATTLE_ENGINE::PARTY_WINDOW[:stat_size]
  5024.     self.contents.font.color = system_color
  5025.     self.contents.draw_text(dx, dy-2, rect.width/2-2, WLH, Vocab::rage_a, 0)
  5026.     self.contents.font.color = normal_color
  5027.     text = @current_rage[i]
  5028.     self.contents.draw_text(dx, dy-2, rect.width/2-4, WLH, text, 2)
  5029.     #---
  5030.   end
  5031.  
  5032. end # Window_BattleStatus
  5033.  
  5034. #===============================================================================
  5035. # Window_BattleStatus_Mini
  5036. #===============================================================================
  5037.  
  5038. class Window_BattleStatus_Mini < Window_BattleStatus
  5039.  
  5040.   #--------------------------------------------------------------------------
  5041.   # initialize
  5042.   #--------------------------------------------------------------------------
  5043.   def initialize
  5044.     @miniature = true
  5045.     super
  5046.     self.x = Graphics.width - 128
  5047.     self.y = Graphics.height - 128
  5048.     self.width = 128
  5049.     self.height = 128
  5050.     create_contents
  5051.     recreate
  5052.   end
  5053.  
  5054.   #--------------------------------------------------------------------------
  5055.   # refresh
  5056.   #--------------------------------------------------------------------------
  5057.   def refresh
  5058.     self.contents.clear
  5059.     draw_item($scene.selected_battler.index)
  5060.   end
  5061.  
  5062.   #--------------------------------------------------------------------------
  5063.   # new method: item_rect
  5064.   #--------------------------------------------------------------------------
  5065.   def item_rect(index)
  5066.     rect = Rect.new(0, 0, 96, 96)
  5067.     return rect
  5068.   end
  5069.  
  5070. end # Window_BattleStatus_Mini
  5071.  
  5072. #===============================================================================
  5073. # Window_BattleStatusHP
  5074. #===============================================================================
  5075.  
  5076. class Window_BattleStatusHP < Window_BattleStatus
  5077.  
  5078.   #--------------------------------------------------------------------------
  5079.   # initialize
  5080.   #--------------------------------------------------------------------------
  5081.   def initialize
  5082.     super
  5083.     self.active = false
  5084.     self.back_opacity = 0
  5085.     self.opacity = 0
  5086.   end
  5087.  
  5088.   #--------------------------------------------------------------------------
  5089.   # update
  5090.   #--------------------------------------------------------------------------
  5091.   def update
  5092.     super
  5093.     recreate if @current_party != $game_party.members
  5094.     if @updating >= 0
  5095.       draw_item(@updating)
  5096.       return
  5097.     end
  5098.     for member in $game_party.members
  5099.       draw_item(member.index) if redraw?(member)
  5100.       break if redraw?(member)
  5101.     end
  5102.   end
  5103.  
  5104.   #--------------------------------------------------------------------------
  5105.   # redraw?
  5106.   #--------------------------------------------------------------------------
  5107.   def redraw?(member)
  5108.     i = member.index
  5109.     if member.update_maxhp
  5110.       value = [[member.maxhp, member.base_maxhp, 1].max, member.maxhp_limit].min
  5111.       @maxhp[i] = value
  5112.       member.update_maxhp = nil
  5113.       return true
  5114.     end
  5115.     return true if @current_hp_gauge[i] != (member.hp*@hp_gauge_width/@maxhp[i])
  5116.     return true if @current_hp[i] != member.hp
  5117.     return false
  5118.   end
  5119.  
  5120.   #--------------------------------------------------------------------------
  5121.   # refresh
  5122.   #--------------------------------------------------------------------------
  5123.   def refresh
  5124.     max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
  5125.     @item_max = [$game_party.members.size, max_members].max
  5126.     for i in 0...@item_max; draw_item(i); end
  5127.   end
  5128.  
  5129.   #--------------------------------------------------------------------------
  5130.   # draw_item
  5131.   #--------------------------------------------------------------------------
  5132.   def draw_item(index)
  5133.     rect = item_rect(index)
  5134.     self.contents.clear_rect(rect)
  5135.     actor = $game_party.members[index]
  5136.     return if actor == nil
  5137.     draw_member_name(actor, rect.clone)
  5138.     draw_member_hp(actor, rect.clone)
  5139.   end
  5140.  
  5141. end # Window_BattleStatusHP
  5142.  
  5143. #===============================================================================
  5144. # Window_BattleStatusMP
  5145. #===============================================================================
  5146.  
  5147. class Window_BattleStatusMP < Window_BattleStatus
  5148.  
  5149.   #--------------------------------------------------------------------------
  5150.   # initialize
  5151.   #--------------------------------------------------------------------------
  5152.   def initialize
  5153.     super
  5154.     self.active = false
  5155.     self.back_opacity = 0
  5156.     self.opacity = 0
  5157.   end
  5158.  
  5159.   #--------------------------------------------------------------------------
  5160.   # update
  5161.   #--------------------------------------------------------------------------
  5162.   def update
  5163.     super
  5164.     recreate if @current_party != $game_party.members
  5165.     if @updating >= 0
  5166.       draw_item(@updating)
  5167.       return
  5168.     end
  5169.     for member in $game_party.members
  5170.       draw_item(member.index) if redraw?(member)
  5171.       break if redraw?(member)
  5172.     end
  5173.   end
  5174.  
  5175.   #--------------------------------------------------------------------------
  5176.   # redraw?
  5177.   #--------------------------------------------------------------------------
  5178.   def redraw?(member)
  5179.     i = member.index
  5180.     if member.update_maxmp
  5181.       value = [[member.maxmp, member.base_maxmp, 1].max, member.maxmp_limit].min
  5182.       @maxmp[i] = value
  5183.       member.update_maxmp = nil
  5184.       @first_test = false
  5185.       return true
  5186.     end
  5187.     return true if @current_mp_gauge[i] != (member.mp*@mp_gauge_width/@maxmp[i])
  5188.     return true if @current_mp[i] != member.mp
  5189.     return false
  5190.   end
  5191.  
  5192.   #--------------------------------------------------------------------------
  5193.   # refresh
  5194.   #--------------------------------------------------------------------------
  5195.   def refresh
  5196.     max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
  5197.     @item_max = [$game_party.members.size, max_members].max
  5198.     for i in 0...@item_max; draw_item(i); end
  5199.   end
  5200.  
  5201.   #--------------------------------------------------------------------------
  5202.   # draw_item
  5203.   #--------------------------------------------------------------------------
  5204.   def draw_item(index)
  5205.     rect = item_rect(index)
  5206.     self.contents.clear_rect(rect)
  5207.     actor = $game_party.members[index]
  5208.     return if actor == nil
  5209.     draw_member_mp(actor, rect.clone)
  5210.   end
  5211.  
  5212. end # Window_BattleStatusMP
  5213.  
  5214. #===============================================================================
  5215. # Window_BattleStatusRage
  5216. #===============================================================================
  5217.  
  5218. class Window_BattleStatusRage < Window_BattleStatus
  5219.  
  5220.   #--------------------------------------------------------------------------
  5221.   # initialize
  5222.   #--------------------------------------------------------------------------
  5223.   def initialize
  5224.     super
  5225.     self.active = false
  5226.     self.back_opacity = 0
  5227.     self.opacity = 0
  5228.   end
  5229.  
  5230.   #--------------------------------------------------------------------------
  5231.   # update
  5232.   #--------------------------------------------------------------------------
  5233.   def update
  5234.     super
  5235.     recreate if @current_party != $game_party.members
  5236.     if @updating >= 0
  5237.       draw_item(@updating)
  5238.       return
  5239.     end
  5240.     for member in $game_party.members
  5241.       draw_item(member.index) if redraw?(member)
  5242.       break if redraw?(member)
  5243.     end
  5244.   end
  5245.  
  5246.   #--------------------------------------------------------------------------
  5247.   # redraw?
  5248.   #--------------------------------------------------------------------------
  5249.   def redraw?(member)
  5250.     return false unless member.use_rage?
  5251.     return true if @current_rage[member.index] != member.rage
  5252.     return false
  5253.   end
  5254.  
  5255.   #--------------------------------------------------------------------------
  5256.   # refresh
  5257.   #--------------------------------------------------------------------------
  5258.   def refresh
  5259.     max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
  5260.     @item_max = [$game_party.members.size, max_members].max
  5261.     for i in 0...@item_max; draw_item(i); end
  5262.   end
  5263.  
  5264.   #--------------------------------------------------------------------------
  5265.   # draw_item
  5266.   #--------------------------------------------------------------------------
  5267.   def draw_item(index)
  5268.     rect = item_rect(index)
  5269.     self.contents.clear_rect(rect)
  5270.     actor = $game_party.members[index]
  5271.     return if actor == nil
  5272.     draw_member_rage(actor, rect.clone)
  5273.   end
  5274.  
  5275. end # Window_BattleStatusRage
  5276.  
  5277. #===============================================================================
  5278. # Window_BattleStatusStates
  5279. #===============================================================================
  5280.  
  5281. class Window_BattleStatusStates < Window_BattleStatus
  5282.  
  5283.   #--------------------------------------------------------------------------
  5284.   # initialize
  5285.   #--------------------------------------------------------------------------
  5286.   def initialize
  5287.     super
  5288.     self.active = false
  5289.     self.back_opacity = 0
  5290.     self.opacity = 0
  5291.   end
  5292.  
  5293.   #--------------------------------------------------------------------------
  5294.   # update
  5295.   #--------------------------------------------------------------------------
  5296.   def update
  5297.     super
  5298.     recreate if @current_party != $game_party.members
  5299.     for member in $game_party.members
  5300.       draw_item(member.index) if redraw?(member)
  5301.       break if redraw?(member)
  5302.     end
  5303.   end
  5304.  
  5305.   #--------------------------------------------------------------------------
  5306.   # redraw?
  5307.   #--------------------------------------------------------------------------
  5308.   def redraw?(member)
  5309.     return true if member.update_states
  5310.     return false
  5311.   end
  5312.  
  5313.   #--------------------------------------------------------------------------
  5314.   # refresh
  5315.   #--------------------------------------------------------------------------
  5316.   def refresh
  5317.     max_members = YEM::BATTLE_ENGINE::MAXIMUM_PARTY_MEMBERS
  5318.     @item_max = [$game_party.members.size, max_members].max
  5319.     for i in 0...@item_max; draw_item(i); end
  5320.   end
  5321.  
  5322.   #--------------------------------------------------------------------------
  5323.   # draw_item
  5324.   #--------------------------------------------------------------------------
  5325.   def draw_item(index)
  5326.     rect = item_rect(index)
  5327.     self.contents.clear_rect(rect)
  5328.     actor = $game_party.members[index]
  5329.     return if actor == nil
  5330.     draw_member_states(actor, rect.clone)
  5331.   end
  5332.  
  5333. end # Window_BattleStatusStates
  5334.  
  5335. #===============================================================================
  5336. # Window_ComboCounter
  5337. #===============================================================================
  5338.  
  5339. class Window_ComboCounter < Window_Base
  5340.  
  5341.   #--------------------------------------------------------------------------
  5342.   # initialize
  5343.   #--------------------------------------------------------------------------
  5344.   def initialize
  5345.     super(0, -64, Graphics.width, 80)
  5346.     self.back_opacity = 0
  5347.     self.opacity = 0
  5348.     @current = 0
  5349.     @current_active_battler = nil
  5350.     @close_counter = 0
  5351.     @req = YEM::BATTLE_ENGINE::COMBO_WINDOW[:requirehit] - 1
  5352.     @fade_frames  = YEM::BATTLE_ENGINE::COMBO_WINDOW[:fadeframes]
  5353.     @total_sprint = YEM::BATTLE_ENGINE::COMBO_WINDOW[:total_text]
  5354.     @heal_sprint  = YEM::BATTLE_ENGINE::COMBO_WINDOW[:total_heal]
  5355.     @dmg_sprint   = YEM::BATTLE_ENGINE::COMBO_WINDOW[:total_dmg]
  5356.   end
  5357.  
  5358.   #--------------------------------------------------------------------------
  5359.   # update
  5360.   #--------------------------------------------------------------------------
  5361.   def update
  5362.     super
  5363.     return unless $scene.is_a?(Scene_Battle)
  5364.     return if $scene.combo_hits == nil
  5365.     update_combo_damage if $scene.combo_update
  5366.     self.y = [self.y + 4, -14].min if $scene.combo_hits > @req and self.y < -14
  5367.     refresh if @combo_damage != @current
  5368.     return if $scene.combo_hits > @req
  5369.     return if @close_flag
  5370.     @close_counter -= 1
  5371.     return if @close_counter > 0
  5372.     self.y = [self.y - 1, -64].max
  5373.     return unless self.y <= -64
  5374.     self.contents.clear
  5375.     @current = 0
  5376.     @close_flag = true
  5377.   end
  5378.  
  5379.   #--------------------------------------------------------------------------
  5380.   # refresh
  5381.   #--------------------------------------------------------------------------
  5382.   def refresh
  5383.     if @current_active_battler != $scene.active_battler# and !@updating
  5384.       @current_active_battler = $scene.active_battler
  5385.       @combo = $scene.combo_hits
  5386.       @current = 0
  5387.     end
  5388.     return unless $scene.combo_hits > @req# or @updating
  5389.     #---
  5390.     if @combo_damage != @current
  5391.       #maxdmg = @combo_damage
  5392.       #value = [maxdmg/32 + rand(maxdmg/32), 1].max
  5393.       #value = [[value, (@combo_damage-@current).abs].min, 1].max
  5394.       #@current = [@current + value, @combo_damage].min
  5395.       @current = @combo_damage
  5396.     end
  5397.     #@updating = @combo_damage != @current
  5398.     self.contents.clear
  5399.     self.contents.font.color = normal_color
  5400.     self.contents.font.bold = true
  5401.     @combo = [@combo, $scene.combo_hits].max
  5402.     text = sprintf(YEM::BATTLE_ENGINE::COMBO_WINDOW[:combo_text], @combo)
  5403.     self.contents.draw_text(4,WLH*0, contents.width-8, WLH, text, 2)
  5404.     #---
  5405.     update_combo_damage if @combo_direction == nil
  5406.     text = sprintf(@dmg_sprint, @current) if @combo_direction > 0
  5407.     text = sprintf(@heal_sprint, @current) if @combo_direction < 0
  5408.     text = sprintf(@total_sprint, @current) if @combo_direction == 0
  5409.     self.contents.draw_text(4,WLH*1-4, contents.width-8, WLH, text, 2)
  5410.     #---
  5411.     #return unless @updating
  5412.     @close_flag = false
  5413.     @close_counter = @fade_frames
  5414.   end
  5415.  
  5416.   #--------------------------------------------------------------------------
  5417.   # update_combo_damage
  5418.   #--------------------------------------------------------------------------
  5419.   def update_combo_damage
  5420.     $scene.combo_update = false
  5421.     @combo_direction = -1 if $scene.combo_damage < 0
  5422.     @combo_direction = 0 if $scene.combo_damage == 0
  5423.     @combo_direction = 1 if $scene.combo_damage > 0
  5424.     @combo_damage = $scene.combo_damage.abs
  5425.   end
  5426.  
  5427. end # Window_ComboCounter
  5428.  
  5429. #===============================================================================
  5430. # Window_Skill
  5431. #===============================================================================
  5432.  
  5433. class Window_Skill < Window_Selectable
  5434.  
  5435.   #--------------------------------------------------------------------------
  5436.   # public instance variables
  5437.   #--------------------------------------------------------------------------
  5438.   attr_accessor :battle_refresh_call
  5439.  
  5440.   #--------------------------------------------------------------------------
  5441.   # new method: update
  5442.   #--------------------------------------------------------------------------
  5443.   def update
  5444.     if @battle_refresh_call
  5445.       $game_temp.less_spacing = true
  5446.       refresh
  5447.       @battle_refresh_call = false
  5448.       $game_temp.less_spacing = nil
  5449.     end
  5450.     super
  5451.   end
  5452.  
  5453.   #--------------------------------------------------------------------------
  5454.   # overwrite method: refresh
  5455.   #--------------------------------------------------------------------------
  5456.   def refresh
  5457.     @spacing = 4 if $game_temp.less_spacing
  5458.     @data = []
  5459.     for skill in @actor.skills
  5460.       next unless include?(skill)
  5461.       @data.push(skill)
  5462.       if skill.id == @actor.last_skill_id
  5463.         self.index = @data.size - 1 unless @first_time
  5464.       end
  5465.     end
  5466.     @item_max = @data.size
  5467.     self.index = [self.index, @data.size - 1].min
  5468.     create_contents
  5469.     @first_time = true
  5470.     for i in 0...@item_max; draw_item(i); end
  5471.   end
  5472.    
  5473.   #--------------------------------------------------------------------------
  5474.   # new method: include?
  5475.   #--------------------------------------------------------------------------
  5476.   def include?(skill)
  5477.     if skill != nil
  5478.       return false if skill.name == ""
  5479.       return false if $game_temp.in_battle and skill.hide_in_battle
  5480.     end
  5481.     return true
  5482.   end
  5483.  
  5484.   #--------------------------------------------------------------------------
  5485.   # overwrite method: draw_item
  5486.   #--------------------------------------------------------------------------
  5487.   def draw_item(index)
  5488.     rect = item_rect(index)
  5489.     self.contents.clear_rect(rect)
  5490.     skill = @data[index]
  5491.     return if skill == nil
  5492.     enabled = @actor.skill_can_use?(skill)
  5493.     draw_obj_name(skill, rect.clone, enabled)
  5494.     draw_obj_cost(skill, rect.clone, enabled)
  5495.   end
  5496.  
  5497.   #--------------------------------------------------------------------------
  5498.   # new method: draw_obj_name
  5499.   #--------------------------------------------------------------------------
  5500.   def draw_obj_name(obj, rect, enabled)
  5501.     draw_icon(obj.icon_index, rect.x, rect.y, enabled)
  5502.     self.contents.font.size = Font.default_size
  5503.     self.contents.font.color = normal_color
  5504.     self.contents.font.color.alpha = enabled ? 255 : 128
  5505.     rect.width -= 48
  5506.     self.contents.draw_text(rect.x+24, rect.y, rect.width-24, WLH, obj.name)
  5507.   end
  5508.  
  5509.   #--------------------------------------------------------------------------
  5510.   # new method: draw_obj_cost
  5511.   #--------------------------------------------------------------------------
  5512.   def draw_obj_cost(obj, rect, enabled)
  5513.     return unless obj.is_a?(RPG::Skill)
  5514.     return draw_obj_cooldown(obj, rect) if @actor.cooldown(obj) > 0
  5515.     return draw_obj_limited(obj, rect) if @actor.skill_limited?(obj)
  5516.     return if @actor.custom_skill_costs(obj, :calc_cost) <= 0
  5517.     dx = rect.x + rect.width - 48; dy = rect.y
  5518.     if @actor.custom_skill_costs(obj, :use_icon) != 0
  5519.       icon = @actor.custom_skill_costs(obj, :use_icon)
  5520.       draw_icon(icon, rect.x+rect.width-24, rect.y, enabled)
  5521.       text = @actor.custom_skill_costs(obj, :text_cost)
  5522.       dw = 24
  5523.     else
  5524.       cost = @actor.custom_skill_costs(obj, :text_cost)
  5525.       text = @actor.custom_skill_costs(obj, :suffix)
  5526.       text = sprintf(text, cost)
  5527.       dw = 44
  5528.     end
  5529.     self.contents.font.size = @actor.custom_skill_costs(obj, :font_size)
  5530.     colour_id = @actor.custom_skill_costs(obj, :colour)
  5531.     self.contents.font.color = text_color(colour_id)
  5532.     self.contents.font.color.alpha = enabled ? 255 : 128
  5533.     self.contents.draw_text(dx, dy, dw, WLH, text, 2)
  5534.   end
  5535.  
  5536.   #--------------------------------------------------------------------------
  5537.   # new method: draw_obj_cooldown
  5538.   #--------------------------------------------------------------------------
  5539.   def draw_obj_cooldown(obj, rect, enabled = false)
  5540.     hash = YEM::BATTLE_ENGINE::SKILL_SETTINGS
  5541.     dx = rect.x + rect.width - 48; dy = rect.y
  5542.     if Icon.cooldown != 0
  5543.       draw_icon(Icon.cooldown, rect.x+rect.width-24, rect.y, enabled)
  5544.       text = @actor.cooldown(obj)
  5545.       dw = 24
  5546.     else
  5547.       cost = @actor.cooldown(obj)
  5548.       text = hash[:cooldown_suffix]
  5549.       text = sprintf(text, cost)
  5550.       dw = 44
  5551.     end
  5552.     self.contents.font.size = hash[:cooldown_size]
  5553.     colour_id = hash[:cooldown_colour]
  5554.     self.contents.font.color = text_color(colour_id)
  5555.     self.contents.font.color.alpha = enabled ? 255 : 128
  5556.     self.contents.draw_text(dx, dy, dw, WLH, text, 2)
  5557.   end
  5558.  
  5559.   #--------------------------------------------------------------------------
  5560.   # new method: draw_obj_limited
  5561.   #--------------------------------------------------------------------------
  5562.   def draw_obj_limited(obj, rect, enabled = false)
  5563.     hash = YEM::BATTLE_ENGINE::SKILL_SETTINGS
  5564.     dx = rect.x + rect.width - 48; dy = rect.y
  5565.     text = hash[:limited_text]
  5566.     if Icon.cooldown != 0
  5567.       draw_icon(Icon.limited_use, rect.x+rect.width-24, rect.y, enabled)
  5568.       dw = 24
  5569.     else
  5570.       dw = 24
  5571.     end
  5572.     self.contents.font.size = hash[:limited_size]
  5573.     colour_id = hash[:limited_colour]
  5574.     self.contents.font.color = text_color(colour_id)
  5575.     self.contents.font.color.alpha = enabled ? 255 : 128
  5576.     self.contents.draw_text(dx, dy, dw, WLH, text, 2)
  5577.   end
  5578.  
  5579. end # Window_Skill
  5580.  
  5581. #===============================================================================
  5582. # Window_Item
  5583. #===============================================================================
  5584.  
  5585. class Window_Item < Window_Selectable
  5586.  
  5587.   #--------------------------------------------------------------------------
  5588.   # public instance variables
  5589.   #--------------------------------------------------------------------------
  5590.   attr_accessor :battle_refresh_call
  5591.  
  5592.   #--------------------------------------------------------------------------
  5593.   # new method: update
  5594.   #--------------------------------------------------------------------------
  5595.   def update
  5596.     if @battle_refresh_call
  5597.       $game_temp.less_spacing = true
  5598.       refresh
  5599.       @battle_refresh_call = false
  5600.       $game_temp.less_spacing = nil
  5601.     end
  5602.     super
  5603.   end
  5604.  
  5605.   #--------------------------------------------------------------------------
  5606.   # overwrite method: include
  5607.   #--------------------------------------------------------------------------
  5608.   def include?(item)
  5609.     return false if item == nil
  5610.     return false if $game_temp.in_battle and !$game_party.item_can_use?(item)
  5611.     return false if item.name == ""
  5612.     return true
  5613.   end
  5614.  
  5615.   #--------------------------------------------------------------------------
  5616.   # overwrite method: refresh
  5617.   #--------------------------------------------------------------------------
  5618.   def refresh
  5619.     @spacing = 4 if $game_temp.less_spacing
  5620.     @data = []
  5621.     for item in $game_party.items
  5622.       next unless include?(item)
  5623.       @data.push(item)
  5624.       if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
  5625.         self.index = @data.size - 1 unless @first_time
  5626.       end
  5627.     end
  5628.     @data.push(nil) if include?(nil)
  5629.     @item_max = @data.size
  5630.     create_contents
  5631.     @first_time = true
  5632.     for i in 0...@item_max; draw_item(i); end
  5633.   end
  5634.  
  5635.   #--------------------------------------------------------------------------
  5636.   # alias method: enable?
  5637.   #--------------------------------------------------------------------------
  5638.   alias enable_window_item_bem enable? unless $@
  5639.   def enable?(item)
  5640.     if $scene.is_a?(Scene_Battle) and $scene.selected_battler != nil
  5641.       return $scene.selected_battler.item_can_use?(item)
  5642.     end
  5643.     return enable_window_item_bem(item)
  5644.   end
  5645.  
  5646.   #--------------------------------------------------------------------------
  5647.   # overwrite method: draw_item
  5648.   #--------------------------------------------------------------------------
  5649.   def draw_item(index)
  5650.     rect = item_rect(index)
  5651.     self.contents.clear_rect(rect)
  5652.     item = @data[index]
  5653.     return if item == nil
  5654.     enabled = enable?(item)
  5655.     draw_obj_name(item, rect.clone, enabled)
  5656.     draw_obj_charges(item, rect.clone, enabled)
  5657.     draw_obj_total(item, rect.clone, enabled)
  5658.   end
  5659.  
  5660.   #--------------------------------------------------------------------------
  5661.   # new method: draw_obj_name
  5662.   #--------------------------------------------------------------------------
  5663.   def draw_obj_name(obj, rect, enabled)
  5664.     draw_icon(obj.icon_index, rect.x, rect.y, enabled)
  5665.     self.contents.font.size = Font.default_size
  5666.     self.contents.font.color = normal_color
  5667.     self.contents.font.color.alpha = enabled ? 255 : 128
  5668.     rect.width -= 48
  5669.     self.contents.draw_text(rect.x+24, rect.y, rect.width-24, WLH, obj.name)
  5670.   end
  5671.  
  5672.   #--------------------------------------------------------------------------
  5673.   # new method: draw_obj_charges
  5674.   #--------------------------------------------------------------------------
  5675.   def draw_obj_charges(obj, rect, enabled)
  5676.     return unless obj.is_a?(RPG::Item)
  5677.     return unless obj.consumable
  5678.     return if obj.charges <= 1
  5679.     $game_party.item_charges = {} if $game_party.item_charges == nil
  5680.     $game_party.item_charges[obj.id] = obj.charges if
  5681.       $game_party.item_charges[obj.id] == nil
  5682.     charges = $game_party.item_charges[obj.id]
  5683.     dx = rect.x; dy = rect.y + WLH/3
  5684.     self.contents.font.size = YEM::BATTLE_ENGINE::ITEM_SETTINGS[:charge]
  5685.     self.contents.font.color = normal_color
  5686.     self.contents.font.color.alpha = enabled ? 255 : 128
  5687.     self.contents.draw_text(dx, dy, 24, WLH * 2/3, charges, 2)
  5688.     self.contents.font.size = Font.default_size
  5689.   end
  5690.  
  5691.   #--------------------------------------------------------------------------
  5692.   # new method: draw_obj_total
  5693.   #--------------------------------------------------------------------------
  5694.   def draw_obj_total(obj, rect, enabled)
  5695.     hash = YEM::BATTLE_ENGINE::ITEM_SETTINGS
  5696.     number = $game_party.item_number(obj)
  5697.     dx = rect.x + rect.width - 36; dy = rect.y; dw = 32
  5698.     text = sprintf(hash[:text], number)
  5699.     self.contents.font.size = hash[:size]
  5700.     self.contents.font.color = text_color(hash[:colour])
  5701.     self.contents.font.color.alpha = enabled ? 255 : 128
  5702.     self.contents.draw_text(dx, dy, dw, WLH, text, 2)
  5703.   end
  5704.  
  5705. end # Window_Item
  5706.  
  5707. #===============================================================================
  5708. # Window_PartyCommand
  5709. #===============================================================================
  5710.  
  5711. class Window_PartyCommand < Window_Command
  5712.  
  5713.   #--------------------------------------------------------------------------
  5714.   # overwrite method: initialize
  5715.   #--------------------------------------------------------------------------
  5716.   def initialize
  5717.     array = create_command_list
  5718.     super(128, array)
  5719.     self.height = 128
  5720.     self.active = false
  5721.   end
  5722.  
  5723.   #--------------------------------------------------------------------------
  5724.   # item
  5725.   #--------------------------------------------------------------------------
  5726.   def item; return @data[self.index]; end
  5727.  
  5728.   #--------------------------------------------------------------------------
  5729.   # new method: create_command_list
  5730.   #--------------------------------------------------------------------------
  5731.   def create_command_list
  5732.     @data = []; array = []
  5733.     for command in YEM::BATTLE_ENGINE::PARTY_COMMANDS
  5734.       case command
  5735.       when :fight
  5736.         array.push(Vocab.fight)
  5737.       when :execute
  5738.         next unless $scene.dtb?
  5739.         vocab = YEM::BATTLE_ENGINE::PARTY_VOCAB[command]
  5740.         array.push(vocab)
  5741.       when :status, :option
  5742.         vocab = YEM::BATTLE_ENGINE::PARTY_VOCAB[command]
  5743.         array.push(vocab)
  5744.       when :escape
  5745.         next unless $scene.dtb? or $scene.ptb?
  5746.         array.push(Vocab.escape)
  5747.       when :turnskip
  5748.         next unless $scene.ptb?
  5749.         vocab = YEM::BATTLE_ENGINE::PARTY_VOCAB[command]
  5750.         array.push(vocab)
  5751.       when :atb_type
  5752.         next unless $scene.atb?
  5753.         array.push("ATB_COMMAND_TYPE")
  5754.       when :atb_speed
  5755.         next unless $scene.atb?
  5756.         array.push("ATB_COMMAND_SPEED")
  5757.       else; next
  5758.       end
  5759.       @data.push(command)
  5760.     end
  5761.     return array
  5762.   end
  5763.  
  5764.   #--------------------------------------------------------------------------
  5765.   # draw_item
  5766.   #--------------------------------------------------------------------------
  5767.   def draw_item(index, enabled = true)
  5768.     rect = item_rect(index)
  5769.     rect.x += 4
  5770.     rect.width -= 8
  5771.     enabled = enabled?(@data[index])
  5772.     self.contents.clear_rect(rect)
  5773.     self.contents.font.color = normal_color
  5774.     self.contents.font.color.alpha = enabled ? 255 : 128
  5775.     text = @commands[index]
  5776.     #---
  5777.     case text
  5778.     when "ATB_COMMAND_TYPE"
  5779.       case $game_variables[YEM::BATTLE_ENGINE::OPTIONS[:atb_avariable]]
  5780.       when 0; key = :atb_t0
  5781.       when 1; key = :atb_t1
  5782.       when 2; key = :atb_t2
  5783.       when 3; key = :atb_t3
  5784.       else; return
  5785.       end
  5786.       text = YEM::BATTLE_ENGINE::PARTY_VOCAB[key]
  5787.     when "ATB_COMMAND_SPEED"
  5788.       text = YEM::BATTLE_ENGINE::PARTY_VOCAB[:atb_spd]
  5789.       variable = YEM::BATTLE_ENGINE::OPTIONS[:atb_svariable]
  5790.       text = sprintf(text, $game_variables[variable])
  5791.     end
  5792.     #---
  5793.     self.contents.draw_text(rect, text, 1)
  5794.   end
  5795.  
  5796.   #--------------------------------------------------------------------------
  5797.   # enabled?
  5798.   #--------------------------------------------------------------------------
  5799.   def enabled?(obj)
  5800.     return $game_troop.can_escape if obj == :escape
  5801.     return true
  5802.   end
  5803.  
  5804. end # Window_PartyCommand
  5805.  
  5806. #===============================================================================
  5807. # Window_ActorCommand
  5808. #===============================================================================
  5809.  
  5810. class Window_ActorCommand < Window_Command
  5811.  
  5812.   #--------------------------------------------------------------------------
  5813.   # public instance variable
  5814.   #--------------------------------------------------------------------------
  5815.   attr_accessor :actor
  5816.  
  5817.   #--------------------------------------------------------------------------
  5818.   # alias method: initialize
  5819.   #--------------------------------------------------------------------------
  5820.   alias initialize_window_actorcommand_bem initialize unless $@
  5821.   def initialize
  5822.     @disable_empty_commands = YEM::BATTLE_ENGINE::DISABLE_EMPTY_COMMANDS
  5823.     initialize_window_actorcommand_bem
  5824.   end
  5825.  
  5826.   #--------------------------------------------------------------------------
  5827.   # new method: item
  5828.   #--------------------------------------------------------------------------
  5829.   def item; return @data[self.index]; end
  5830.  
  5831.   #--------------------------------------------------------------------------
  5832.   # new method: skill
  5833.   #--------------------------------------------------------------------------
  5834.   def skill; return $data_skills[@skills[item]]; end
  5835.  
  5836.   #--------------------------------------------------------------------------
  5837.   # overwrite method: setup
  5838.   #--------------------------------------------------------------------------
  5839.   def setup(actor)
  5840.     @actor = actor
  5841.     @data = []; @commands = []; @skills = {}
  5842.     data_set = actor.class.id
  5843.     data_set = 0 if !YEM::BATTLE_ENGINE::CLASS_COMMANDS.include?(actor.class.id)
  5844.     #---
  5845.     for item in YEM::BATTLE_ENGINE::CLASS_COMMANDS[data_set]
  5846.       case item
  5847.       when :attack; @commands.push(actor.attack_vocab)
  5848.       when :skill;  @commands.push(actor.skill_vocab)
  5849.       when :guard;  @commands.push(actor.guard_vocab)
  5850.       when :item;   @commands.push(Vocab.item)
  5851.       when :equip;  @commands.push(YEM::BATTLE_ENGINE::EQUIP_VOCAB)
  5852.       when :escape
  5853.         next unless $game_troop.can_escape
  5854.         @commands.push(Vocab.escape)
  5855.       else
  5856.         valid = false
  5857.         if YEM::BATTLE_ENGINE::SKILL_COMMANDS.include?(item)
  5858.           @skills[item] = YEM::BATTLE_ENGINE::SKILL_COMMANDS[item][0]
  5859.           @commands.push(YEM::BATTLE_ENGINE::SKILL_COMMANDS[item][1])
  5860.           valid = true
  5861.         end
  5862.         next unless valid
  5863.       end
  5864.       @data.push(item)
  5865.     end
  5866.     #---
  5867.     @item_max = @commands.size
  5868.     refresh
  5869.     self.index = 0
  5870.   end
  5871.  
  5872.   #--------------------------------------------------------------------------
  5873.   # new method: update
  5874.   #--------------------------------------------------------------------------
  5875.   def update
  5876.     return unless $scene.is_a?(Scene_Battle)
  5877.     super unless Input.trigger?(Input::L) or Input.trigger?(Input::R)
  5878.     return unless @actor == $scene.status_window.actor
  5879.     refresh if @actor != nil and @actor.update_commands
  5880.   end
  5881.  
  5882.   #--------------------------------------------------------------------------
  5883.   # new method: refresh
  5884.   #--------------------------------------------------------------------------
  5885.   def refresh
  5886.     create_contents
  5887.     @actor.update_commands = false if @actor != nil
  5888.     for i in 0...@item_max
  5889.       draw_item(i)
  5890.     end
  5891.   end
  5892.  
  5893.   #--------------------------------------------------------------------------
  5894.   # new method: draw_item
  5895.   #--------------------------------------------------------------------------
  5896.   def draw_item(index, enabled = true)
  5897.     rect = item_rect(index)
  5898.     rect.x += 4
  5899.     rect.width -= 8
  5900.     obj = @data[index]
  5901.     enabled = enabled?(obj)
  5902.     self.contents.clear_rect(rect)
  5903.     self.contents.font.color = normal_color
  5904.     self.contents.font.color.alpha = enabled ? 255 : 128
  5905.     self.contents.draw_text(rect, @commands[index], 1)
  5906.   end
  5907.  
  5908.   #--------------------------------------------------------------------------
  5909.   # new method: enabled?
  5910.   #--------------------------------------------------------------------------
  5911.   def enabled?(obj = nil)
  5912.     return false unless @actor.actor?
  5913.     if @actor.auto_battle
  5914.       return true if obj == :equip and @actor.equip_cooldown.to_i <= 0
  5915.       return true if obj == :escape and $game_troop.can_escape
  5916.       return false
  5917.     end
  5918.     return false unless @actor.inputable?
  5919.     return false if obj == nil
  5920.     return false if obj == :equip and @actor.equip_cooldown.to_i > 0
  5921.     if @disable_empty_commands
  5922.       return false if obj == :skill and @actor.skills.size <= 0
  5923.       return false if obj == :item and $game_party.battle_item_size <= 0
  5924.     end
  5925.     if @skills.include?(obj)
  5926.       skill = $data_skills[@skills[obj]]
  5927.       return @actor.skill_can_use?(skill)
  5928.     end
  5929.     return true
  5930.   end
  5931.  
  5932. end # Window_ActorCommand
  5933.  
  5934. #===============================================================================
  5935. # Window_ConfirmCommand
  5936. #===============================================================================
  5937.  
  5938. class Window_ConfirmCommand < Window_Command
  5939.  
  5940.   #--------------------------------------------------------------------------
  5941.   # initialize
  5942.   #--------------------------------------------------------------------------
  5943.   def initialize
  5944.     array = create_command_list
  5945.     super(128, array)
  5946.     self.openness = 0
  5947.     self.height = 128
  5948.     self.active = false
  5949.   end
  5950.  
  5951.   #--------------------------------------------------------------------------
  5952.   # item
  5953.   #--------------------------------------------------------------------------
  5954.   def item; return @data[self.index]; end
  5955.  
  5956.   #--------------------------------------------------------------------------
  5957.   # create_command_list
  5958.   #--------------------------------------------------------------------------
  5959.   def create_command_list
  5960.     @data = []; array = []
  5961.     for command in YEM::BATTLE_ENGINE::CONFIRM_COMMANDS
  5962.       case command
  5963.       when :confirm
  5964.         next unless $scene.dtb?
  5965.         vocab = YEM::BATTLE_ENGINE::CONFIRM_VOCAB[command]
  5966.         array.push(vocab)
  5967.       when :status, :option
  5968.         vocab = YEM::BATTLE_ENGINE::CONFIRM_VOCAB[command]
  5969.         array.push(vocab)
  5970.       when :escape
  5971.         next unless $scene.dtb? or $scene.ptb?
  5972.         array.push(Vocab.escape)
  5973.       when :turnskip
  5974.         next unless $scene.ptb?
  5975.         vocab = YEM::BATTLE_ENGINE::CONFIRM_VOCAB[command]
  5976.         array.push(vocab)
  5977.       when :atb_type
  5978.         next unless $scene.atb?
  5979.         array.push("ATB_COMMAND_TYPE")
  5980.       when :atb_speed
  5981.         next unless $scene.atb?
  5982.         array.push("ATB_COMMAND_SPEED")
  5983.       else; next
  5984.       end
  5985.       @data.push(command)
  5986.     end
  5987.     return array
  5988.   end
  5989.  
  5990.   #--------------------------------------------------------------------------
  5991.   # draw_item
  5992.   #--------------------------------------------------------------------------
  5993.   def draw_item(index, enabled = true)
  5994.     rect = item_rect(index)
  5995.     rect.x += 4
  5996.     rect.width -= 8
  5997.     enabled = enabled?(@data[index])
  5998.     self.contents.clear_rect(rect)
  5999.     self.contents.font.color = normal_color
  6000.     self.contents.font.color.alpha = enabled ? 255 : 128
  6001.     text = @commands[index]
  6002.     #---
  6003.     case text
  6004.     when "ATB_COMMAND_TYPE"
  6005.       case $game_variables[YEM::BATTLE_ENGINE::OPTIONS[:atb_avariable]]
  6006.       when 0; key = :atb_t0
  6007.       when 1; key = :atb_t1
  6008.       when 2; key = :atb_t2
  6009.       when 3; key = :atb_t3
  6010.       else; return
  6011.       end
  6012.       text = YEM::BATTLE_ENGINE::CONFIRM_VOCAB[key]
  6013.     when "ATB_COMMAND_SPEED"
  6014.       text = YEM::BATTLE_ENGINE::CONFIRM_VOCAB[:atb_spd]
  6015.       variable = YEM::BATTLE_ENGINE::OPTIONS[:atb_svariable]
  6016.       text = sprintf(text, $game_variables[variable])      
  6017.     end
  6018.     #---
  6019.     self.contents.draw_text(rect, text, 1)
  6020.   end
  6021.  
  6022.   #--------------------------------------------------------------------------
  6023.   # enabled?
  6024.   #--------------------------------------------------------------------------
  6025.   def enabled?(obj)
  6026.     return $game_troop.can_escape if obj == :escape
  6027.     return true
  6028.   end
  6029.  
  6030. end # Window_ConfirmCommand
  6031.  
  6032. #===============================================================================
  6033. # Window_BattleActor
  6034. #===============================================================================
  6035.  
  6036. class Window_BattleActor < Window_Base
  6037.  
  6038.   #--------------------------------------------------------------------------
  6039.   # initialize
  6040.   #--------------------------------------------------------------------------
  6041.   def initialize
  6042.     super(0, 0, Graphics.width, Graphics.height - 128)
  6043.     @letter_ranks = YEM::BATTLE_ENGINE::TEXT_RANKS[:enable]
  6044.     refresh
  6045.   end
  6046.  
  6047.   #--------------------------------------------------------------------------
  6048.   # refresh
  6049.   #--------------------------------------------------------------------------
  6050.   def refresh(index = 0)
  6051.     self.contents.clear
  6052.     @actor = $game_party.members[index]
  6053.     return if @actor == nil
  6054.     self.contents.font.size = Font.default_size
  6055.     self.contents.font.color = normal_color
  6056.     dx = 8; dy = 0
  6057.     #--- Left Half ---
  6058.     draw_actor_face(@actor, dx, dy)
  6059.     draw_actor_name(@actor, dx+112, dy); dy += WLH
  6060.     draw_actor_class(@actor, dx+112, dy); dy += WLH
  6061.     draw_actor_level(@actor, dx+112, dy); dy += WLH*2
  6062.     dw = contents.width/2 - dx - 24
  6063.     draw_actor_hp(@actor, dx, dy, dw); dy += WLH
  6064.     draw_actor_mp(@actor, dx, dy, dw); dy += WLH
  6065.     #--- Right Half ---
  6066.     dx = contents.width/2; dy = WLH/2
  6067.     draw_actor_elements(@actor, dx, dy); dy += WLH*3
  6068.     draw_actor_states(@actor, dx, dy); dy = WLH*6 + 8
  6069.     draw_actor_parameters(@actor, dx, dy)
  6070.   end
  6071.  
  6072.   #--------------------------------------------------------------------------
  6073.   # draw_actor_elements
  6074.   #--------------------------------------------------------------------------
  6075.   def draw_actor_elements(actor, dx, dy)
  6076.     self.contents.font.size = YEM::BATTLE_ENGINE::TEXT_RANK_SIZE
  6077.     dw = contents.width - dx
  6078.     spacing = YEM::BATTLE_ENGINE::ELEMENT_SPACING
  6079.     array = YEM::BATTLE_ENGINE::ALLY_ELEMENTS
  6080.     dx = dx + dw - (array.size*(spacing+24)) - spacing*3/2
  6081.     for element_id in array
  6082.       next if element_id > $data_system.elements.size
  6083.       icon = Icon.element(element_id)
  6084.       draw_icon(icon, dx, dy)
  6085.       rate = actor.element_rate(element_id)
  6086.       text = sprintf("%d%%", rate)
  6087.       if rate > 200;    colour = :rank_s
  6088.       elsif rate > 150; colour = :rank_a
  6089.       elsif rate > 100; colour = :rank_b
  6090.       elsif rate > 50;  colour = :rank_c
  6091.       elsif rate > 0;   colour = :rank_d
  6092.       elsif rate == 0;  colour = :rank_e
  6093.       else;             colour = :rank_f
  6094.       end
  6095.       text = YEM::BATTLE_ENGINE::TEXT_RANKS[colour] if @letter_ranks
  6096.       colour = YEM::BATTLE_ENGINE::RANK_COLOURS[colour]
  6097.       self.contents.font.color = text_color(colour)
  6098.       self.contents.draw_text(dx-spacing/2, dy+WLH, spacing+24, WLH, text, 1)
  6099.       dx += spacing+24
  6100.     end
  6101.   end
  6102.  
  6103.   #--------------------------------------------------------------------------
  6104.   # draw_actor_states
  6105.   #--------------------------------------------------------------------------
  6106.   def draw_actor_states(actor, dx, dy)
  6107.     self.contents.font.size = YEM::BATTLE_ENGINE::TEXT_RANK_SIZE
  6108.     dw = contents.width - dx
  6109.     spacing = YEM::BATTLE_ENGINE::STATE_SPACING
  6110.     array = YEM::BATTLE_ENGINE::ALLY_STATES
  6111.     dx = dx + dw - (array.size*(spacing+24)) - spacing*3/2
  6112.     for state_id in array
  6113.       state = $data_states[state_id]
  6114.       next if state == nil
  6115.       icon = state.icon_index
  6116.       draw_icon(icon, dx, dy)
  6117.       rate = actor.state_probability(state_id)
  6118.       text = sprintf("%d%%", rate)
  6119.       if rate > 100;   colour = :rank_s
  6120.       elsif rate > 80; colour = :rank_a
  6121.       elsif rate > 60; colour = :rank_b
  6122.       elsif rate > 40; colour = :rank_c
  6123.       elsif rate > 20; colour = :rank_d
  6124.       elsif rate > 0;  colour = :rank_e
  6125.       else;            colour = :rank_f
  6126.       end
  6127.       text = YEM::BATTLE_ENGINE::TEXT_RANKS[colour] if @letter_ranks
  6128.       colour = YEM::BATTLE_ENGINE::RANK_COLOURS[colour]
  6129.       self.contents.font.color = text_color(colour)
  6130.       self.contents.draw_text(dx-spacing/2, dy+WLH, spacing+24, WLH, text, 1)
  6131.       dx += spacing+24
  6132.     end
  6133.   end
  6134.  
  6135.   #--------------------------------------------------------------------------
  6136.   # draw_actor_parameters
  6137.   #--------------------------------------------------------------------------
  6138.   def draw_actor_parameters(actor, dx, dy)
  6139.     self.contents.font.size = YEM::BATTLE_ENGINE::TEXT_STAT_SIZE
  6140.     fx = dx; fy = dy
  6141.     dw = (contents.width - dx)/2 - 4
  6142.     for stat in YEM::BATTLE_ENGINE::ALLY_STATS
  6143.       case stat
  6144.       when :atk
  6145.         name = Vocab.atk
  6146.         value = actor.atk
  6147.       when :def
  6148.         name = Vocab.def
  6149.         value = actor.def
  6150.       when :spi
  6151.         name = Vocab.spi
  6152.         value = actor.spi
  6153.       when :res
  6154.         next unless $imported["RES Stat"]
  6155.         name = Vocab.res
  6156.         value = actor.res
  6157.       when :dex
  6158.         next unless $imported["DEX Stat"]
  6159.         name = Vocab.dex
  6160.         value = actor.dex
  6161.       when :agi
  6162.         name = Vocab.agi
  6163.         value = actor.agi
  6164.       when :hit
  6165.         name = Vocab.hit
  6166.         value = sprintf("%d%%", [[actor.hit, 1].max, 99].min)
  6167.       when :eva
  6168.         name = Vocab.eva
  6169.         value = sprintf("%d%%", [[actor.eva, 1].max, 99].min)
  6170.       when :cri
  6171.         name = Vocab.cri
  6172.         value = sprintf("%d%%", [[actor.cri, 1].max, 99].min)
  6173.       when :odds
  6174.         name = Vocab.odds
  6175.         value = actor.odds * 100 / total_party_odds
  6176.         value = sprintf("%d%%", [[value, 1].max, 99].min)
  6177.       else; next
  6178.       end
  6179.       draw_icon(Icon.stat(actor, stat), dx, dy)
  6180.       self.contents.font.color = system_color
  6181.       self.contents.draw_text(dx+24, dy, 40, WLH, name)
  6182.       self.contents.font.color = normal_color
  6183.       self.contents.draw_text(dx+64, dy, dw-72, WLH, value, 2)
  6184.       dx += dw + 4
  6185.       if dx + dw + 4 > contents.width
  6186.         dx = fx
  6187.         dy += WLH
  6188.         break if dy + WLH > contents.height
  6189.       end
  6190.     end
  6191.   end
  6192.  
  6193.   #--------------------------------------------------------------------------
  6194.   # total_party_odds
  6195.   #--------------------------------------------------------------------------
  6196.   def total_party_odds
  6197.     return @total_odds if @total_odds != nil
  6198.     @total_odds = 0
  6199.     for member in $game_party.members
  6200.       @total_odds += member.odds
  6201.     end
  6202.     return @total_odds
  6203.   end
  6204.  
  6205. end # Window_BattleActor
  6206.  
  6207. #===============================================================================
  6208. # Window_BattleActorStates
  6209. #===============================================================================
  6210.  
  6211. class Window_BattleActorStates < Window_Selectable
  6212.  
  6213.   #--------------------------------------------------------------------------
  6214.   # initialize
  6215.   #--------------------------------------------------------------------------
  6216.   def initialize
  6217.     dx = 8; dy = WLH*7 - 16
  6218.     super(dx, dy, Graphics.width/2 - dx*2, Graphics.height - 128 - dy)
  6219.     @draw_state_turns = $imported["CoreFixesUpgradesMelody"]
  6220.     self.back_opacity = 0
  6221.     self.opacity = 0
  6222.   end
  6223.  
  6224.   #--------------------------------------------------------------------------
  6225.   # refresh
  6226.   #--------------------------------------------------------------------------
  6227.   def refresh(actor = nil)
  6228.     @data = []
  6229.     @actor = actor
  6230.     if @actor == nil
  6231.       self.index = -1
  6232.       @item_max = 0
  6233.       create_contents
  6234.       return
  6235.     end
  6236.     for state in actor.states
  6237.       next if state == nil
  6238.       @data.push(state)
  6239.     end
  6240.     @data = [:normal] if @data == []
  6241.     @item_max = @data.size
  6242.     create_contents
  6243.     self.index = (@item_max > 0) ? 0 : -1
  6244.     for i in 0...@item_max; draw_item(i); end
  6245.   end
  6246.    
  6247.   #--------------------------------------------------------------------------
  6248.   # draw_item
  6249.   #--------------------------------------------------------------------------
  6250.   def draw_item(index)
  6251.     rect = item_rect(index)
  6252.     self.contents.clear_rect(rect)
  6253.     state = @data[index]
  6254.     return if state == nil
  6255.     if state == :normal
  6256.       draw_icon(Icon.normal_state, rect.x, rect.y)
  6257.       text = YEM::BATTLE_ENGINE::TEXT_NORMAL_STATE
  6258.     else
  6259.       draw_icon(state.icon_index, rect.x, rect.y)
  6260.       draw_state_turns(rect.x, rect.y, state, @actor) if @draw_state_turns
  6261.       text = state.name
  6262.       if @actor.stack(state) > 1
  6263.         display = YEM::BATTLE_ENGINE::STATE_SETTINGS[:stack_display]
  6264.         text = sprintf(display, text, @actor.stack(state).to_s)
  6265.       end
  6266.     end
  6267.     self.contents.font.color = normal_color
  6268.     self.contents.font.bold = Font.default_bold
  6269.     self.contents.font.size = Font.default_size
  6270.     self.contents.draw_text(rect.x+24, rect.y, rect.width-28, WLH, text)
  6271.   end
  6272.  
  6273. end # Window_BattleActorStates
  6274.  
  6275. #===============================================================================
  6276. # Window_BattleOptions
  6277. #===============================================================================
  6278.  
  6279. class Window_BattleOptions < Window_Selectable
  6280.  
  6281.   #--------------------------------------------------------------------------
  6282.   # initialize
  6283.   #--------------------------------------------------------------------------
  6284.   def initialize(dx, dy)
  6285.     super(dx, dy, Graphics.width-dx, Graphics.height-dy-128)
  6286.     self.index = 0
  6287.     refresh
  6288.   end
  6289.  
  6290.   #--------------------------------------------------------------------------
  6291.   # item
  6292.   #--------------------------------------------------------------------------
  6293.   def item; return @data[self.index]; end
  6294.  
  6295.   #--------------------------------------------------------------------------
  6296.   # refresh
  6297.   #--------------------------------------------------------------------------
  6298.   def refresh
  6299.     @data = []
  6300.     for command in YEM::BATTLE_ENGINE::OPTION_COMMANDS
  6301.       case command
  6302.       when :bgm_volume, :bgs_volume, :sfx_volume
  6303.       when :animations, :autocursor, :next_actor, :skill_help
  6304.       when :atb_active, :atb_speeds; next unless $scene.atb?
  6305.       when :cinematics; next
  6306.       else; next
  6307.       end
  6308.       @data.push(command)
  6309.     end
  6310.     @item_max = @data.size
  6311.     create_contents
  6312.     for i in 0...@item_max; draw_item(i); end
  6313.   end
  6314.  
  6315.   #--------------------------------------------------------------------------
  6316.   # draw_item
  6317.   #--------------------------------------------------------------------------
  6318.   def draw_item(index)
  6319.     rect = item_rect(index)
  6320.     self.contents.clear_rect(rect)
  6321.     obj = @data[index]
  6322.     return if obj == nil
  6323.     case obj
  6324.     when :bgm_volume, :bgs_volume, :sfx_volume
  6325.       draw_volume_item(obj, rect.clone)
  6326.     when :animations, :autocursor, :next_actor, :skill_help, :cinematics
  6327.       draw_switch_item(obj, rect.clone)
  6328.     when :atb_active, :atb_speeds
  6329.       draw_atb_item(obj, rect.clone)
  6330.     end
  6331.   end
  6332.  
  6333.   #--------------------------------------------------------------------------
  6334.   # draw_volume_item
  6335.   #--------------------------------------------------------------------------
  6336.   def draw_volume_item(obj, rect)
  6337.     options = YEM::BATTLE_ENGINE::OPTIONS
  6338.     case obj
  6339.     when :bgm_volume
  6340.       title = options[:bgm_volume]
  6341.       value = $game_variables[options[:bgm_variable]]
  6342.       mute  = $game_switches[options[:bgm_mute_sw]]
  6343.     when :bgs_volume
  6344.       title = options[:bgs_volume]
  6345.       value = $game_variables[options[:bgs_variable]]
  6346.       mute  = $game_switches[options[:bgs_mute_sw]]
  6347.     when :sfx_volume
  6348.       title = options[:sfx_volume]
  6349.       value = $game_variables[options[:sfx_variable]]
  6350.       mute  = $game_switches[options[:sfx_mute_sw]]
  6351.     else; return
  6352.     end
  6353.     value = sprintf(options[:audio], value)
  6354.     self.contents.font.color = normal_color
  6355.     self.contents.draw_text(rect.x, rect.y, rect.width/2, WLH, title, 1)
  6356.     self.contents.font.color.alpha = mute ? 128 : 255
  6357.     dx = rect.x + rect.width/2
  6358.     self.contents.draw_text(dx, rect.y, rect.width/4, WLH, value, 1)
  6359.     self.contents.font.color.alpha = mute ? 255 : 128
  6360.     dx = rect.x + rect.width*3/4
  6361.     self.contents.draw_text(dx, rect.y, rect.width/4, WLH, options[:mute], 1)
  6362.   end
  6363.  
  6364.   #--------------------------------------------------------------------------
  6365.   # draw_switch_item
  6366.   #--------------------------------------------------------------------------
  6367.   def draw_switch_item(obj, rect)
  6368.     options = YEM::BATTLE_ENGINE::OPTIONS
  6369.     title = options[obj]
  6370.     case obj
  6371.     when :animations
  6372.       name1 = options[:ani_show]
  6373.       name2 = options[:ani_hide]
  6374.       toggle = $game_switches[options[:animation_sw]]
  6375.     when :autocursor
  6376.       name1 = options[:curmem_on]
  6377.       name2 = options[:curmem_off]
  6378.       toggle = $game_switches[options[:autocursor_sw]]
  6379.     when :next_actor
  6380.       name1 = options[:next_on]
  6381.       name2 = options[:next_off]
  6382.       toggle = $game_switches[options[:next_actor_sw]]
  6383.     when :skill_help
  6384.       name1 = options[:help_on]
  6385.       name2 = options[:help_off]
  6386.       toggle = $game_switches[options[:skill_help_sw]]
  6387.     when :cinematics
  6388.       name1 = options[:cinem_on]
  6389.       name2 = options[:cinem_off]
  6390.       toggle = $game_switches[options[:cinematics_sw]]
  6391.     else; return
  6392.     end
  6393.     self.contents.font.color = normal_color
  6394.     self.contents.draw_text(rect.x, rect.y, rect.width/2, WLH, title, 1)
  6395.     self.contents.font.color.alpha = toggle ? 255 : 128
  6396.     dx = rect.x + rect.width/2
  6397.     self.contents.draw_text(dx, rect.y, rect.width/4, WLH, name1, 1)
  6398.     self.contents.font.color.alpha = toggle ? 128 : 255
  6399.     dx = rect.x + rect.width*3/4
  6400.     self.contents.draw_text(dx, rect.y, rect.width/4, WLH, name2, 1)
  6401.   end
  6402.  
  6403.   #--------------------------------------------------------------------------
  6404.   # draw_atb_item
  6405.   #--------------------------------------------------------------------------
  6406.   def draw_atb_item(obj, rect)
  6407.     options = YEM::BATTLE_ENGINE::OPTIONS
  6408.     case obj
  6409.     when :atb_active
  6410.       title = options[:atb_aname]
  6411.       value = $game_variables[options[:atb_avariable]]
  6412.       #---
  6413.       self.contents.font.color = normal_color
  6414.       name1 = options[:wait_0]
  6415.       dx = rect.x + rect.width/2
  6416.       self.contents.font.color.alpha = (value == 0) ? 255 : 128
  6417.       self.contents.draw_text(dx, rect.y, rect.width/8, WLH, name1, 1)
  6418.       name2 = options[:wait_1]
  6419.       dx = rect.x + rect.width*5/8
  6420.       self.contents.font.color.alpha = (value == 1) ? 255 : 128
  6421.       self.contents.draw_text(dx, rect.y, rect.width/8, WLH, name2, 1)
  6422.       name3 = options[:wait_2]
  6423.       dx = rect.x + rect.width*6/8
  6424.       self.contents.font.color.alpha = (value == 2) ? 255 : 128
  6425.       self.contents.draw_text(dx, rect.y, rect.width/8, WLH, name3, 1)
  6426.       name4 = options[:wait_3]
  6427.       dx = rect.x + rect.width*7/8
  6428.       self.contents.font.color.alpha = (value == 3) ? 255 : 128
  6429.       self.contents.draw_text(dx, rect.y, rect.width/8, WLH, name4, 1)
  6430.       #---
  6431.     when :atb_speeds
  6432.       title = options[:atb_sname]
  6433.       value = $game_variables[options[:atb_svariable]] - 1
  6434.       #---
  6435.       for i in 0...10
  6436.         self.contents.font.color = normal_color
  6437.         name = (i + 1).to_s
  6438.         dx = rect.x + rect.width * (10 + i)/20
  6439.         self.contents.font.color.alpha = (value == i) ? 255 : 128
  6440.         self.contents.draw_text(dx, rect.y, rect.width/20, WLH, name, 1)
  6441.       end
  6442.       #---
  6443.     else; return
  6444.     end
  6445.     self.contents.font.color = normal_color
  6446.     self.contents.draw_text(rect.x, rect.y, rect.width/2, WLH, title, 1)
  6447.   end
  6448.  
  6449.   #--------------------------------------------------------------------------
  6450.   # update
  6451.   #--------------------------------------------------------------------------
  6452.   def update
  6453.     super
  6454.     if Input.trigger?(Input::C)
  6455.       input_case_c
  6456.     elsif Input.repeat?(Input::LEFT)
  6457.       input_case_left
  6458.     elsif Input.repeat?(Input::RIGHT)
  6459.       input_case_right
  6460.     end
  6461.   end
  6462.  
  6463.   #--------------------------------------------------------------------------
  6464.   # input_case_c
  6465.   #--------------------------------------------------------------------------
  6466.   def input_case_c
  6467.     options = YEM::BATTLE_ENGINE::OPTIONS
  6468.     case item
  6469.     when :bgm_volume; switch = options[:bgm_mute_sw]
  6470.     when :bgs_volume; switch = options[:bgs_mute_sw]
  6471.     when :sfx_volume; switch = options[:sfx_mute_sw]
  6472.     when :animations; switch = options[:animation_sw]
  6473.     when :autocursor; switch = options[:autocursor_sw]
  6474.     when :next_actor; switch = options[:next_actor_sw]
  6475.     when :skill_help; switch = options[:skill_help_sw]
  6476.     when :cinematics; switch = options[:cinematics_sw]
  6477.     else; return
  6478.     end
  6479.     $game_switches[switch] = !$game_switches[switch]
  6480.     Sound.play_decision
  6481.     RPG::BGM::last.play if item == :bgm_volume
  6482.     RPG::BGS::last.play if item == :bgs_volume
  6483.     draw_item(self.index)
  6484.   end
  6485.  
  6486.   #--------------------------------------------------------------------------
  6487.   # input_case_left
  6488.   #--------------------------------------------------------------------------
  6489.   def input_case_left
  6490.     options = YEM::BATTLE_ENGINE::OPTIONS
  6491.     ignore = false
  6492.     case item
  6493.     when :bgm_volume, :bgs_volume, :sfx_volume
  6494.       value = Input.press?(Input::SHIFT) ? 10 : 1
  6495.       case item
  6496.       when :bgm_volume; variable = options[:bgm_variable]
  6497.       when :bgs_volume; variable = options[:bgs_variable]
  6498.       when :sfx_volume; variable = options[:sfx_variable]
  6499.       end
  6500.       return if $game_variables[variable] == 0
  6501.       $game_variables[variable] -= value
  6502.       $game_variables[variable] = [$game_variables[variable], 0].max
  6503.       ignore = true
  6504.     when :atb_active
  6505.       variable = options[:atb_avariable]
  6506.       return if $game_variables[variable] == 0
  6507.       $game_variables[variable] -= 1
  6508.       $game_variables[variable] = [$game_variables[variable], 0].max
  6509.       ignore = true
  6510.       if $scene.is_a?(Scene_Battle) and $scene.atb?
  6511.         $scene.party_command_window.refresh
  6512.         $scene.confirm_command_window.refresh
  6513.       end
  6514.     when :atb_speeds
  6515.       variable = options[:atb_svariable]
  6516.       return if $game_variables[variable] == 1
  6517.       $game_variables[variable] -= 1
  6518.       $game_variables[variable] = [$game_variables[variable], 1].max
  6519.       ignore = true
  6520.       if $scene.is_a?(Scene_Battle) and $scene.atb?
  6521.         $scene.party_command_window.refresh
  6522.         $scene.confirm_command_window.refresh
  6523.       end
  6524.     when :animations; switch = options[:animation_sw]
  6525.     when :autocursor; switch = options[:autocursor_sw]
  6526.     when :next_actor; switch = options[:next_actor_sw]
  6527.     when :skill_help; switch = options[:skill_help_sw]
  6528.     when :cinematics; switch = options[:cinematics_sw]
  6529.     else; return
  6530.     end
  6531.     unless ignore
  6532.       return if $game_switches[switch]
  6533.       $game_switches[switch] = true
  6534.     end
  6535.     Sound.play_cursor
  6536.     RPG::BGM::last.play if item == :bgm_volume
  6537.     RPG::BGS::last.play if item == :bgs_volume
  6538.     draw_item(self.index)
  6539.   end
  6540.  
  6541.   #--------------------------------------------------------------------------
  6542.   # input_case_right
  6543.   #--------------------------------------------------------------------------
  6544.   def input_case_right
  6545.     options = YEM::BATTLE_ENGINE::OPTIONS
  6546.     ignore = false
  6547.     case item
  6548.     when :bgm_volume, :bgs_volume, :sfx_volume
  6549.       value = Input.press?(Input::SHIFT) ? 10 : 1
  6550.       case item
  6551.       when :bgm_volume; variable = options[:bgm_variable]
  6552.       when :bgs_volume; variable = options[:bgs_variable]
  6553.       when :sfx_volume; variable = options[:sfx_variable]
  6554.       end
  6555.       return if $game_variables[variable] == 100
  6556.       $game_variables[variable] += value
  6557.       $game_variables[variable] = [$game_variables[variable], 100].min
  6558.       ignore = true
  6559.     when :atb_active
  6560.       variable = options[:atb_avariable]
  6561.       return if $game_variables[variable] == 3
  6562.       $game_variables[variable] += 1
  6563.       $game_variables[variable] = [$game_variables[variable], 3].min
  6564.       ignore = true
  6565.       if $scene.is_a?(Scene_Battle) and $scene.atb?
  6566.         $scene.party_command_window.refresh
  6567.         $scene.confirm_command_window.refresh
  6568.       end
  6569.     when :atb_speeds
  6570.       variable = options[:atb_svariable]
  6571.       return if $game_variables[variable] == 10
  6572.       $game_variables[variable] += 1
  6573.       $game_variables[variable] = [$game_variables[variable], 10].min
  6574.       ignore = true
  6575.       if $scene.is_a?(Scene_Battle) and $scene.atb?
  6576.         $scene.party_command_window.refresh
  6577.         $scene.confirm_command_window.refresh
  6578.       end
  6579.     when :animations; switch = options[:animation_sw]
  6580.     when :autocursor; switch = options[:autocursor_sw]
  6581.     when :next_actor; switch = options[:next_actor_sw]
  6582.     when :skill_help; switch = options[:skill_help_sw]
  6583.     when :cinematics; switch = options[:cinematics_sw]
  6584.     else; return
  6585.     end
  6586.     unless ignore
  6587.       return if !$game_switches[switch]
  6588.       $game_switches[switch] = false
  6589.     end
  6590.     Sound.play_cursor
  6591.     RPG::BGM::last.play if item == :bgm_volume
  6592.     RPG::BGS::last.play if item == :bgs_volume
  6593.     draw_item(self.index)
  6594.   end
  6595.  
  6596.   #--------------------------------------------------------------------------
  6597.   # update_help
  6598.   #--------------------------------------------------------------------------
  6599.   def update_help
  6600.     case item
  6601.     when :bgm_volume; type = :bgm_des
  6602.     when :bgs_volume; type = :bgs_des
  6603.     when :sfx_volume; type = :sfx_des
  6604.     when :animations; type = :ani_des
  6605.     when :autocursor; type = :curmem_des
  6606.     when :next_actor; type = :next_des
  6607.     when :skill_help; type = :help_des
  6608.     when :cinematics; type = :cinem_des
  6609.     when :atb_active
  6610.       case $game_variables[YEM::BATTLE_ENGINE::OPTIONS[:atb_avariable]]
  6611.       when 0; type = :wait_0_des
  6612.       when 1; type = :wait_1_des
  6613.       when 2; type = :wait_2_des
  6614.       when 3: type = :wait_3_des
  6615.       end
  6616.     when :atb_speeds; type = :atb_s_des
  6617.     else; type = nil
  6618.     end
  6619.     text = YEM::BATTLE_ENGINE::OPTIONS[type].to_s
  6620.     @help_window.set_text(text, 1)
  6621.   end
  6622.  
  6623. end # Window_BattleOptions
  6624.  
  6625. #===============================================================================
  6626. # Window_PressTurns
  6627. #===============================================================================
  6628.  
  6629. class Window_PressTurns < Window_Base
  6630.  
  6631.   #--------------------------------------------------------------------------
  6632.   # public instance variables
  6633.   #--------------------------------------------------------------------------
  6634.   attr_accessor :update_call
  6635.  
  6636.   #--------------------------------------------------------------------------
  6637.   # initialize
  6638.   #--------------------------------------------------------------------------
  6639.   def initialize(group)
  6640.     @group = group
  6641.     super(-16, -64, Graphics.width + 16, 80)
  6642.     self.z = 10
  6643.     self.back_opacity = 0
  6644.     self.opacity = 0
  6645.     set_icons
  6646.     @appear = false
  6647.     @disappear = false
  6648.   end
  6649.  
  6650.   #--------------------------------------------------------------------------
  6651.   # set_icons
  6652.   #--------------------------------------------------------------------------
  6653.   def set_icons
  6654.     if @group.is_a?(Game_Party)
  6655.       @turn_icon = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS[:actor][2]
  6656.       @used_icon = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS[:actor][3]
  6657.       @bonus_icon = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS[:actor][4]
  6658.     else
  6659.       @turn_icon = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS[:enemy][2]
  6660.       @used_icon = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS[:enemy][3]
  6661.       @bonus_icon = YEM::BATTLE_ENGINE::BATTLER_ICON_BORDERS[:enemy][4]
  6662.     end
  6663.   end
  6664.  
  6665.   #--------------------------------------------------------------------------
  6666.   # update
  6667.   #--------------------------------------------------------------------------
  6668.   def update
  6669.     super
  6670.     if @appear
  6671.       self.y = [self.y + 4, -16].min
  6672.       @appear = false if self.y >= -16
  6673.     elsif @disappear
  6674.       self.y = [self.y - 4, -64].max
  6675.       @disappear = false if self.y <= -64
  6676.     end
  6677.     refresh if @update_call
  6678.   end
  6679.  
  6680.   #--------------------------------------------------------------------------
  6681.   # appear
  6682.   #--------------------------------------------------------------------------
  6683.   def appear
  6684.     @appear = true
  6685.     @disappear = false
  6686.     self.z = 11
  6687.     refresh
  6688.   end
  6689.  
  6690.   #--------------------------------------------------------------------------
  6691.   # disappear
  6692.   #--------------------------------------------------------------------------
  6693.   def disappear
  6694.     @disappear = true
  6695.     @appear = false
  6696.     self.z = 10
  6697.   end
  6698.  
  6699.   #--------------------------------------------------------------------------
  6700.   # refresh
  6701.   #--------------------------------------------------------------------------
  6702.   def refresh
  6703.     self.contents.clear
  6704.     @update_call = false
  6705.     dx = draw_turn_icons
  6706.     dx = draw_bonus_icons(dx)
  6707.     draw_used_icons(dx)
  6708.   end
  6709.  
  6710.   #--------------------------------------------------------------------------
  6711.   # draw_turn_icons
  6712.   #--------------------------------------------------------------------------
  6713.   def draw_turn_icons(dx = 12)
  6714.     @dy = 6
  6715.     amount = @group.ptb_total_turns
  6716.     amount -= @group.ptb_bonus_turns
  6717.     amount.times do
  6718.       draw_icon(@turn_icon, dx, @dy)
  6719.       @dy = (@dy == 6) ? 18 : 6
  6720.       dx += 24
  6721.     end
  6722.     return dx
  6723.   end
  6724.  
  6725.   #--------------------------------------------------------------------------
  6726.   # draw_bonus_icons
  6727.   #--------------------------------------------------------------------------
  6728.   def draw_bonus_icons(dx)
  6729.     return dx if @group.ptb_total_turns <= 0
  6730.     amount = @group.ptb_bonus_turns
  6731.     amount.times do
  6732.       draw_icon(@turn_icon, dx, @dy)
  6733.       @dy = (@dy == 6) ? 18 : 6
  6734.       dx += 24
  6735.     end
  6736.     return dx
  6737.   end
  6738.  
  6739.   #--------------------------------------------------------------------------
  6740.   # draw_used_icons
  6741.   #--------------------------------------------------------------------------
  6742.   def draw_used_icons(dx)
  6743.     amount = @group.ptb_member_turns
  6744.     amount -= @group.ptb_total_turns
  6745.     return if amount <= 0
  6746.     amount.times do
  6747.       draw_icon(@used_icon, dx, @dy)
  6748.       @dy = (@dy == 6) ? 18 : 6
  6749.       dx += 24
  6750.     end
  6751.   end
  6752.  
  6753. end # Window_PressTurns
  6754.  
  6755. #===============================================================================
  6756. # Window_EnemyGauge
  6757. #===============================================================================
  6758.  
  6759. class Window_EnemyGauge < Window_Base
  6760.  
  6761.   #--------------------------------------------------------------------------
  6762.   # initialize
  6763.   #--------------------------------------------------------------------------
  6764.   def initialize
  6765.     super(0, 0, 120, WLH*3+32)
  6766.     self.visible = false
  6767.     self.opacity = 0
  6768.     self.back_opacity = 0
  6769.     self.z = 16000
  6770.   end
  6771.  
  6772.   #--------------------------------------------------------------------------
  6773.   # update
  6774.   #--------------------------------------------------------------------------
  6775.   def update
  6776.     super
  6777.     return unless $scene.is_a?(Scene_Battle)
  6778.     return unless $scene.atb?
  6779.     if @battler == nil
  6780.       self.visible = false
  6781.       return
  6782.     end
  6783.     refresh_call = false
  6784.     #---
  6785.     refresh_call = true if @current_hp != @battler.hp
  6786.     refresh_call = true if @current_maxhp != @battler.maxhp
  6787.     refresh_call = true if @current_mp != @battler.mp
  6788.     refresh_call = true if @current_maxmp != @battler.maxmp
  6789.     refresh_call = true if @current_states != @battler.states
  6790.     #---
  6791.     if @current_x != @battler.screen_x or @current_y != @battler.screen_y
  6792.       @current_x = @battler.screen_x
  6793.       @current_y = @battler.screen_y
  6794.       self.x = @battler.screen_x - self.width/2
  6795.       self.x -= $scene.spriteset.viewport1.ox
  6796.       self.y = @battler.screen_y - self.height/2 - WLH + 12
  6797.       self.y -= $scene.spriteset.viewport1.oy
  6798.     end
  6799.     #---
  6800.     refresh if refresh_call
  6801.   end
  6802.  
  6803.   #--------------------------------------------------------------------------
  6804.   # battler=
  6805.   #--------------------------------------------------------------------------
  6806.   def battler=(battler)
  6807.     @battler = battler
  6808.     if @battler == nil
  6809.       self.visible = false
  6810.       return
  6811.     end
  6812.     self.visible = true
  6813.     self.width = @battler.enemy.quick_gauge[:width]
  6814.     @current_x = @battler.screen_x
  6815.     @current_y = @battler.screen_y
  6816.     self.x = @battler.screen_x - self.width/2
  6817.     self.x -= $scene.spriteset.viewport1.ox
  6818.     self.y = @battler.screen_y - self.height/2 - WLH + 12
  6819.     self.y -= $scene.spriteset.viewport1.oy
  6820.     create_contents
  6821.     refresh
  6822.   end
  6823.  
  6824.   #--------------------------------------------------------------------------
  6825.   # refresh
  6826.   #--------------------------------------------------------------------------
  6827.   def refresh
  6828.     dy = 0
  6829.     sw = contents.width
  6830.     #---
  6831.     if $scene.atb?
  6832.       @current_hp = @battler.hp
  6833.       @current_maxhp = @battler.maxhp
  6834.       @current_mp = @battler.mp
  6835.       @current_maxmp = @battler.maxmp
  6836.       @current_states = @battler.states.clone
  6837.     end
  6838.     #---
  6839.     draw_actor_state(@battler,0,WLH,sw) if @battler.enemy.quick_gauge[:states]
  6840.     dy += WLH+8
  6841.     if @battler.enemy.quick_gauge[:show_hp]
  6842.       draw_back_gauge(0, dy, sw)
  6843.       draw_enemy_hp_gauge(@battler,1,dy+1,sw-2)
  6844.       dy += 7
  6845.     end
  6846.     if @battler.enemy.quick_gauge[:show_mp]
  6847.       draw_back_gauge(0, dy, contents.width)
  6848.       if @battler.use_rage?
  6849.         draw_enemy_rage_gauge(@battler,1,dy+1,sw/2-1)
  6850.         draw_enemy_mp_gauge(@battler,sw/2+1,dy+1,sw/2-2)
  6851.       else
  6852.         draw_enemy_mp_gauge(@battler,1,dy+1,sw-2)
  6853.       end
  6854.       dy += 7
  6855.     end
  6856.   end
  6857.  
  6858.   #--------------------------------------------------------------------------
  6859.   # new method: draw_back_gauge
  6860.   #--------------------------------------------------------------------------
  6861.   def draw_back_gauge(x, y, width = 120)
  6862.     self.contents.fill_rect(x, y + WLH - 8, width, 8, gauge_back_color)
  6863.   end
  6864.  
  6865. end # Window_EnemyGauge
  6866.  
  6867. #===============================================================================
  6868. # Scene_Battle
  6869. #===============================================================================
  6870.  
  6871. class Scene_Battle < Scene_Base
  6872.  
  6873.   #--------------------------------------------------------------------------
  6874.   # overwrite method: wait_for_animation
  6875.   #--------------------------------------------------------------------------
  6876.   def wait_for_animation
  6877.     update_basic
  6878.     update_basic while @spriteset.animation?
  6879.   end
  6880.  
  6881.   #--------------------------------------------------------------------------
  6882.   # overwrite method: display_attack_animation
  6883.   #--------------------------------------------------------------------------
  6884.   def display_attack_animation(targets)
  6885.     if @active_battler.is_a?(Game_Enemy)
  6886.       aid1 = @active_battler.atk_animation_id
  6887.       display_normal_animation(targets, aid1)
  6888.     else
  6889.       aid1 = @active_battler.atk_animation_id
  6890.       aid2 = @active_battler.atk_animation_id2
  6891.       display_normal_animation(targets, aid1, false)
  6892.       wait_for_animation if aid2 != 0
  6893.       display_normal_animation(targets, aid2, true)
  6894.     end
  6895.   end
  6896.  
  6897.   #--------------------------------------------------------------------------
  6898.   # overwrite method: display_animation
  6899.   #--------------------------------------------------------------------------
  6900.   def display_animation(targets, animation_id)
  6901.     if animation_id < 0
  6902.       display_attack_animation(targets)
  6903.     else
  6904.       display_normal_animation(targets, animation_id)
  6905.     end
  6906.   end
  6907.  
  6908.   #--------------------------------------------------------------------------
  6909.   # overwrite method: display_normal_animation
  6910.   #--------------------------------------------------------------------------
  6911.   def display_normal_animation(targets, animation_id, mirror = false)
  6912.     return unless show_animation?
  6913.     animation = $data_animations[animation_id]
  6914.     return if animation == nil
  6915.     mirror = !mirror if @action_values.include?("MIRROR")
  6916.     to_screen = (animation.position == 3)
  6917.     ani_check = false
  6918.     for target in targets.uniq
  6919.       if ani_check
  6920.         target.pseudo_ani_id = animation_id
  6921.       else
  6922.         target.animation_id = animation_id
  6923.         target.animation_mirror = target_mirror?(mirror, target)
  6924.         target.animation_mirror = false if animation.anti_mirror
  6925.       end
  6926.       ani_check = true if to_screen
  6927.     end
  6928.   end
  6929.  
  6930.   #--------------------------------------------------------------------------
  6931.   # overwrite method: display_pseudo_animation
  6932.   #--------------------------------------------------------------------------
  6933.   def display_pseudo_animation(targets, animation_id)
  6934.     return unless show_animation?
  6935.     animation = $data_animations[animation_id]
  6936.     return if animation == nil
  6937.     for target in targets.uniq
  6938.       target.pseudo_ani_id = animation_id
  6939.     end
  6940.   end
  6941.  
  6942.   #--------------------------------------------------------------------------
  6943.   # new method: wait_for_movement
  6944.   #--------------------------------------------------------------------------
  6945.   def wait_for_movement
  6946.     return if emptyview?
  6947.     members = $game_party.members + $game_troop.members
  6948.     movers = []; requirement = 0
  6949.     for member in members
  6950.       next unless member.sprite_movable?
  6951.       movers.push(member)
  6952.       requirement += 1
  6953.     end
  6954.     return if requirement == 0
  6955.     loop do
  6956.       check = 0
  6957.       for mover in movers
  6958.         next unless mover.sprite_movable?
  6959.         next if mover.spriteset.move_to_x != nil
  6960.         next if mover.spriteset.move_to_y != nil
  6961.         check += 1
  6962.       end
  6963.       break if check == requirement
  6964.       update_basic
  6965.     end
  6966.   end
  6967.  
  6968.   #--------------------------------------------------------------------------
  6969.   # new method: wait_for_jump
  6970.   #--------------------------------------------------------------------------
  6971.   def wait_for_jump
  6972.     return if emptyview?
  6973.     members = $game_party.members + $game_troop.members
  6974.     movers = []; requirement = 0
  6975.     for member in members
  6976.       next unless member.sprite_movable?
  6977.       movers.push(member)
  6978.       requirement += 1
  6979.     end
  6980.     return if requirement == 0
  6981.     loop do
  6982.       check = 0
  6983.       for mover in movers
  6984.         next unless mover.sprite_movable?
  6985.         next if mover.spriteset.jump_duration != nil
  6986.         check += 1
  6987.       end
  6988.       break if check == requirement
  6989.       update_basic
  6990.     end
  6991.   end
  6992.  
  6993.   #--------------------------------------------------------------------------
  6994.   # new method: start_victory_poses
  6995.   #--------------------------------------------------------------------------
  6996.   def start_victory_poses
  6997.     for member in $game_party.existing_members
  6998.       next unless member.use_battler_animations?
  6999.       member.battler_animation_stance("VICTORY")
  7000.     end
  7001.     return unless $imported["ExtendedMovement"]
  7002.     return unless YEM::BATTLE_ENGINE::AUTO_POSES[:victory]
  7003.     for member in $game_party.existing_members
  7004.       next if member.character == nil
  7005.       member.character.break_pose
  7006.       member.character.mirror = false
  7007.       member.character.pose = "VICTORY"
  7008.     end
  7009.   end
  7010.  
  7011.   #--------------------------------------------------------------------------
  7012.   # new method: update_battler_poses
  7013.   #--------------------------------------------------------------------------
  7014.   def update_battler_poses
  7015.     return unless $scene.is_a?(Scene_Battle)
  7016.     return if @action_occuring
  7017.     for member in @all_members
  7018.       update_stances_individual(member)
  7019.     end
  7020.     #---
  7021.     return unless $imported["ExtendedMovement"]
  7022.     for member in $game_party.existing_members
  7023.       update_pose_individual(member)
  7024.     end
  7025.     for member in $game_troop.existing_members
  7026.       update_pose_individual(member)
  7027.     end
  7028.   end
  7029.  
  7030.   #--------------------------------------------------------------------------
  7031.   # new method: update_stances_individual
  7032.   #--------------------------------------------------------------------------
  7033.   def update_stances_individual(member, ignore_active_battler = false)
  7034.     return unless member.use_battler_animations?
  7035.     return if member == @active_battler and !ignore_active_battler
  7036.     stance = ""
  7037.     if member.dead?
  7038.       stance = "DEAD"
  7039.     elsif !member.movable?
  7040.       stance = "STASIS"
  7041.     elsif member.hp < member.maxhp / 4
  7042.       stance = "PIYORI"
  7043.     else
  7044.       stance = "IDLE"
  7045.     end
  7046.     return if stance == ""
  7047.     member.battler_animation_stance(stance)
  7048.   end
  7049.  
  7050.   #--------------------------------------------------------------------------
  7051.   # new method: update_pose_individual
  7052.   #--------------------------------------------------------------------------
  7053.   def update_pose_individual(member, ignore_active_battler = false)
  7054.     return unless $scene.is_a?(Scene_Battle)
  7055.     return unless $imported["ExtendedMovement"]
  7056.     return if member == @active_battler and !ignore_active_battler
  7057.     return if member.dead?
  7058.     return if member.character == nil
  7059.     if member.spriteset.character_sprite != nil
  7060.       return unless member.spriteset.character_sprite.appropiate_filename?
  7061.     end
  7062.     return if member.use_battler_animations?
  7063.     auto_poses = YEM::BATTLE_ENGINE::AUTO_POSES
  7064.     settings = YEM::BATTLE_ENGINE::POSE_SETTINGS
  7065.     if member.hp < member.maxhp / 4
  7066.       pose = :piyori
  7067.       name = "PIYORI"
  7068.       stance = "PIYORI"
  7069.     else
  7070.       pose = :ready
  7071.       name = "READY"
  7072.       stance = "IDLE"
  7073.     end
  7074.     return if member.character.pose == name.upcase
  7075.     member.character.break_pose
  7076.     member.character.step_anime = true
  7077.     return unless auto_poses[pose]
  7078.     direction = member.character.direction
  7079.     member.character.step_anime = false unless member.movable?
  7080.     return if settings[pose][1].include?(direction)
  7081.     member.character.mirror = settings[pose][0].include?(direction)
  7082.     member.character.pose = name
  7083.     member.character.step_anime = false unless member.movable?
  7084.   end
  7085.  
  7086.   #--------------------------------------------------------------------------
  7087.   # new method: refresh_ptb_windows
  7088.   #--------------------------------------------------------------------------
  7089.   def refresh_battle_windows
  7090.     @skill_window.battle_refresh_call = true if @skill_window != nil
  7091.     @item_window.battle_refresh_call = true if @item_window != nil
  7092.     @mini_window.battle_refresh_call = true if @mini_window != nil
  7093.   end
  7094.  
  7095.   #--------------------------------------------------------------------------
  7096.   # new method: refresh_ptb_windows
  7097.   #--------------------------------------------------------------------------
  7098.   def refresh_ptb_windows
  7099.     return unless ptb?
  7100.     return if @active_battler == nil
  7101.     if @active_battler.actor?
  7102.       @ptb_party_window.update_call = true
  7103.       @spriteset.ptb_update = $game_party
  7104.     else
  7105.       @ptb_troop_window.update_call = true
  7106.       @spriteset.ptb_update = $game_troop
  7107.     end
  7108.   end
  7109.  
  7110.   #--------------------------------------------------------------------------
  7111.   # new method: update_battle_cursor
  7112.   #--------------------------------------------------------------------------
  7113.   def update_battle_cursor
  7114.     return unless $scene.is_a?(Scene_Battle)
  7115.     return if @spriteset.battle_cursor == nil
  7116.     @spriteset.battle_cursor.create_move_to
  7117.   end
  7118.  
  7119.   #--------------------------------------------------------------------------
  7120.   # new method: create_aoe_indicator
  7121.   #--------------------------------------------------------------------------
  7122.   def create_aoe_indicator(window)
  7123.     if atb?
  7124.       case @selected_battler.action.atb_queue_kind
  7125.       when 1 # Skill
  7126.         obj = $data_skills[@selected_battler.action.atb_queue_basic]
  7127.       when 2 # Item
  7128.         obj = $data_items[@selected_battler.action.atb_queue_basic]
  7129.       else; return
  7130.       end
  7131.     else
  7132.       if @selected_battler.action.skill?
  7133.         obj = @selected_battler.action.skill
  7134.       elsif @selected_battler.action.item?
  7135.         obj = @selected_battler.action.item
  7136.       else; return
  7137.       end
  7138.     end
  7139.     #---
  7140.     @spriteset.create_magic_circle(window, obj)
  7141.     @spriteset.create_magic_square(window, obj)
  7142.   end
  7143.  
  7144.   #--------------------------------------------------------------------------
  7145.   # new method: dispose_aoe_indicator
  7146.   #--------------------------------------------------------------------------
  7147.   def dispose_aoe_indicator
  7148.     @spriteset.dispose_magic_circle
  7149.     @spriteset.dispose_magic_square
  7150.   end
  7151.  
  7152. end # Scene_Battle
  7153.  
  7154. #===============================================================================
  7155. #
  7156. # END OF FILE
  7157. #
  7158. #===============================================================================
  7159.