查看: 4172|回复: 12

[已经解决] 请问如何做到动画结束后在造成伤害?

[复制链接]
梦石
0
星屑
50
在线时间
82 小时
注册时间
2013-3-17
回帖
49
发表于 2013-7-17 20:38:12 | 显示全部楼层 |阅读模式
悬赏1星屑已解决
如题,脚本见范例。艾利克的“111”技能动画为陨石,但是动画刚刚播放就造成伤害(见图)。请问如何等到动画放完后再造成伤害??
可能相关的脚本
  1. #==============================================================================
  2. # ** Victor Engine - Animated Battle
  3. #------------------------------------------------------------------------------
  4. # Author : Victor Sant
  5. #
  6. # Version History:
  7. #  v beta - 2012.01.28 > Beta relase
  8. #------------------------------------------------------------------------------
  9. #  VE - Animated battle Beta
  10. #------------------------------------------------------------------------------
  11. # Compatibility
  12. #   Requires the script 'Victor Engine - Basic Module'
  13. #
  14. #------------------------------------------------------------------------------
  15. # Instructions:
  16. #  To instal the script, open you script editor and paste this script on
  17. #  a new section on bellow the Materials section. This script must also
  18. #  be bellow the script 'Victor Engine - Basic'
  19. #==============================================================================

  20. #==============================================================================
  21. # ** Victor Engine
  22. #------------------------------------------------------------------------------
  23. #   Setting module for the Victor Engine
  24. #==============================================================================

  25. $imported[:ve_animated_battle] = true

  26. #==============================================================================
  27. # ** Object
  28. #------------------------------------------------------------------------------
  29. #  This class is the superclass of all other classes.
  30. #==============================================================================

  31. class Object
  32.   #--------------------------------------------------------------------------
  33.   # *
  34.   #--------------------------------------------------------------------------
  35.   def custom_pose(type)
  36.     note =~ /<#{type.upcase} POSE: (\w[\w ]+)>/i ? make_symbol($1) : nil
  37.   end
  38. end

  39. #==============================================================================
  40. # ** BattleManager
  41. #------------------------------------------------------------------------------
  42. #  This module handles the battle processing
  43. #==============================================================================

  44. class << BattleManager
  45.   #--------------------------------------------------------------------------
  46.   # *
  47.   #--------------------------------------------------------------------------
  48.   attr_accessor :old_tone
  49.   #--------------------------------------------------------------------------
  50.   # *
  51.   #--------------------------------------------------------------------------
  52.   alias :init_members_ve_animated_battle :init_members
  53.   def init_members
  54.     $game_party.members.each {|member| member.clear_poses }
  55.     init_members_ve_animated_battle
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # *
  59.   #--------------------------------------------------------------------------
  60.   alias :battle_end_ve_animated_battle :battle_end
  61.   def battle_end(result)
  62.     $game_party.members.each {|member| member.clear_poses }
  63.     battle_end_ve_animated_battle(result)
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # *
  67.   #--------------------------------------------------------------------------
  68.   alias :process_victory_ve_animated_battle :process_victory
  69.   def process_victory
  70.     process_victory_pose
  71.     process_victory_ve_animated_battle
  72.   end
  73.   #--------------------------------------------------------------------------
  74.   # *
  75.   #--------------------------------------------------------------------------
  76.   alias :process_escape_ve_animated_battle :process_escape
  77.   def process_escape
  78.     @escaping = true
  79.     success   = process_escape_ve_animated_battle
  80.     @escaping = false
  81.     return success
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   # *
  85.   #--------------------------------------------------------------------------
  86.   alias :process_abort_ve_animated_battle :process_abort
  87.   def process_abort
  88.     process_escape_pose if @escaping
  89.     process_abort_ve_animated_battle
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   # *
  93.   #--------------------------------------------------------------------------
  94.   def process_victory_pose
  95.     SceneManager.scene.update_basic while $game_party.not_in_position?
  96.     $game_party.movable_members.each do |member|
  97.       member.clear_idle_poses
  98.       member.call_pose(:victory)
  99.     end
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # *
  103.   #--------------------------------------------------------------------------
  104.   def process_escape_pose
  105.     $game_party.movable_members.each do |member|
  106.       member.clear_idle_poses
  107.       member.call_pose(:escape)
  108.     end
  109.     5.times { SceneManager.scene.update_basic }
  110.     SceneManager.scene.update_basic while $game_party.moving?
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # *
  114.   #--------------------------------------------------------------------------
  115.   def set_active_pose
  116.     return unless actor
  117.     actor.set_active_pose
  118.     actor.reset_pose
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # *
  122.   #--------------------------------------------------------------------------
  123.   def clear_active_pose
  124.     return unless actor
  125.     actor.active_pose = nil
  126.     actor.reset_pose
  127.   end
  128. end

  129. #==============================================================================
  130. # ** Game_Screen
  131. #------------------------------------------------------------------------------
  132. #  This class handles screen maintenance data, such as change in color tone,
  133. # flashes, etc. It's used within the Game_Map and Game_Troop classes.
  134. #==============================================================================

  135. class Game_Screen
  136.   #--------------------------------------------------------------------------
  137.   # *
  138.   #--------------------------------------------------------------------------
  139.   attr_reader   :low_tone
  140.   attr_reader   :high_tone
  141.   attr_accessor :old_tone
  142.   attr_accessor :old_low_tone
  143.   attr_accessor :old_high_tone
  144.   #--------------------------------------------------------------------------
  145.   # *
  146.   #--------------------------------------------------------------------------
  147.   alias :clear_tone_ve_animated_battle :clear_tone
  148.   def clear_tone
  149.     clear_tone_ve_animated_battle
  150.     @low_tone  = Tone.new
  151.     @high_tone = Tone.new
  152.     @low_tone_target  = Tone.new
  153.     @high_tone_target = Tone.new
  154.     @low_tone_duration  = 0
  155.     @high_tone_duration = 0
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # *
  159.   #--------------------------------------------------------------------------
  160.   alias :update_ve_animated_battle :update
  161.   def update
  162.     update_ve_animated_battle
  163.     low_update_tone
  164.     high_update_tone
  165.   end
  166.   #--------------------------------------------------------------------------
  167.   # *
  168.   #--------------------------------------------------------------------------
  169.   def start_low_tone_change(tone, duration)
  170.     @low_tone_target = tone.clone
  171.     @low_tone_duration = duration
  172.     @low_tone = @low_tone_target.clone if @low_tone_duration == 0
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # *
  176.   #--------------------------------------------------------------------------
  177.   def start_high_tone_change(tone, duration)
  178.     @high_tone_target = tone.clone
  179.     @high_tone_duration = duration
  180.     @high_tone = @high_tone_target.clone if @high_tone_duration == 0
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # *
  184.   #--------------------------------------------------------------------------
  185.   def low_update_tone
  186.     if @low_tone_duration > 0
  187.       d    = @low_tone_duration
  188.       tone = @low_tone_target
  189.       @low_tone.red   = (@low_tone.red   * (d - 1) + tone.red)   / d
  190.       @low_tone.green = (@low_tone.green * (d - 1) + tone.green) / d
  191.       @low_tone.blue  = (@low_tone.blue  * (d - 1) + tone.blue)  / d
  192.       @low_tone.gray  = (@low_tone.gray  * (d - 1) + tone.gray)  / d
  193.       @low_tone_duration -= 1
  194.     end
  195.   end  
  196.   #--------------------------------------------------------------------------
  197.   # *
  198.   #--------------------------------------------------------------------------
  199.   def high_update_tone
  200.     if @high_tone_duration > 0
  201.       d    = @high_tone_duration
  202.       tone = @high_tone_target
  203.       @high_tone.red   = (@high_tone.red   * (d - 1) + tone.red)   / d
  204.       @high_tone.green = (@high_tone.green * (d - 1) + tone.green) / d
  205.       @high_tone.blue  = (@high_tone.blue  * (d - 1) + tone.blue)  / d
  206.       @high_tone.gray  = (@high_tone.gray  * (d - 1) + tone.gray)  / d
  207.       @high_tone_duration -= 1
  208.     end
  209.   end
  210.   #--------------------------------------------------------------------------
  211.   # * New method: tone_change?
  212.   #--------------------------------------------------------------------------
  213.   def tone_change?
  214.     @tone_duration > 0 || @low_tone_duration > 0 || @high_tone_duration > 0
  215.   end
  216. end

  217. #==============================================================================
  218. # ** Game_ActionResult
  219. #------------------------------------------------------------------------------
  220. #  This class handles the results of actions. This class is used within the
  221. # Game_Battler class.
  222. #==============================================================================

  223. class Game_ActionResult
  224.   #--------------------------------------------------------------------------
  225.   # * New method: damage_value_adjust
  226.   #--------------------------------------------------------------------------
  227.   def damage_value_adjust(value, item)
  228.     @hp_damage *= value
  229.     @mp_damage *= value
  230.     @hp_damage = @hp_damage.to_i
  231.     @mp_damage = [@battler.mp, @mp_damage.to_i].min
  232.     @hp_drain = @hp_damage if item.damage.drain?
  233.     @mp_drain = @mp_damage if item.damage.drain?
  234.     @hp_drain = [@battler.hp, @hp_drain].min
  235.   end
  236. end

  237. #==============================================================================
  238. # ** Game_Battler
  239. #------------------------------------------------------------------------------
  240. #  This class deals with battlers. It's used as a superclass of the Game_Actor
  241. # and Game_Enemy classes.
  242. #==============================================================================

  243. class Game_Battler < Game_BattlerBase
  244.   #--------------------------------------------------------------------------
  245.   # *
  246.   #--------------------------------------------------------------------------
  247.   attr_accessor :row
  248.   attr_accessor :frame
  249.   attr_accessor :timing
  250.   attr_accessor :freeze
  251.   
  252.   attr_accessor :direction
  253.   attr_accessor :move_speed
  254.   attr_accessor :jumping
  255.   attr_accessor :shake
  256.   
  257.   attr_accessor :pose_list
  258.   
  259.   attr_accessor :immortals
  260.   
  261.   attr_accessor :attack_flag
  262.   attr_accessor :damage_flag
  263.   attr_accessor :result_flag
  264.   attr_accessor :target_flag
  265.   
  266.   attr_accessor :spin
  267.   attr_accessor :angle
  268.   attr_accessor :sufix
  269.   attr_accessor :active
  270.   attr_accessor :targets
  271.   attr_accessor :teleport
  272.   attr_accessor :x_adj
  273.   attr_accessor :y_adj
  274.   
  275.   attr_accessor :call_anim
  276.   attr_accessor :call_effect
  277.   attr_accessor :animation
  278.   attr_accessor :countered
  279.   attr_accessor :substitution
  280.   
  281.   attr_accessor :action_targets
  282.   attr_accessor :active_pose
  283.   attr_accessor :pose_loop_anim
  284.   
  285.   attr_accessor :previous_action
  286.   
  287.   attr_accessor :icon_list
  288.   attr_accessor :throw_list
  289.   
  290.   attr_accessor :current_item
  291.   
  292.   attr_accessor :target_position
  293.   attr_accessor :current_position
  294.   attr_accessor :default_position

  295.   #--------------------------------------------------------------------------
  296.   # *
  297.   #--------------------------------------------------------------------------
  298.   alias :initialize_ve_animated_battle :initialize
  299.   def initialize
  300.     init_anim_battlers_variables
  301.     initialize_ve_animated_battle
  302.   end
  303.   #--------------------------------------------------------------------------
  304.   # *
  305.   #--------------------------------------------------------------------------
  306.   alias :item_apply_ve_animated_battle :item_apply
  307.   def item_apply(user, item)
  308.     item_apply_ve_animated_battle(user, item)
  309.     call_damage_pose(item, user) if movable?
  310.     [url=home.php?mod=space&uid=131733]@substitution[/url]    = false
  311.     user.result_flag = @result.hit? ? :hit : :miss
  312.   end
  313.   #--------------------------------------------------------------------------
  314.   # * Alias method: make_damage_value
  315.   #--------------------------------------------------------------------------
  316.   alias :make_damage_value_ve_animated_battle :make_damage_value
  317.   def make_damage_value(user, item)
  318.     make_damage_value_ve_animated_battle(user, item)
  319.     @result.damage_value_adjust(user.damage_flag, item) if user.damage_flag
  320.   end
  321.   #--------------------------------------------------------------------------
  322.   # *
  323.   #--------------------------------------------------------------------------
  324.   alias :regenerate_hp_ve_animated_battle :regenerate_hp
  325.   def regenerate_hp
  326.     regenerate_hp_ve_animated_battle
  327.     call_pose(:hurt, :clear) if @result.hp_damage > 0 && movable?
  328.   end
  329.   #--------------------------------------------------------------------------
  330.   # *
  331.   #--------------------------------------------------------------------------
  332.   def dead?
  333.     super && !immortal?
  334.   end
  335.   #--------------------------------------------------------------------------
  336.   # *
  337.   #--------------------------------------------------------------------------
  338.   def refresh
  339.     state_resist_set.each {|state_id| erase_state(state_id) }
  340.     @hp = [[@hp, mhp].min, 0].max
  341.     @mp = [[@mp, mmp].min, 0].max
  342.     die if [url=home.php?mod=space&uid=90807]@Dying[/url] && !immortal?
  343.     return if @dying
  344.     valid = @hp == 0 && !immortal?
  345.     valid ? add_state(death_state_id) : remove_state(death_state_id)
  346.     reset_pose
  347.   end
  348.   #--------------------------------------------------------------------------
  349.   # *
  350.   #--------------------------------------------------------------------------
  351.   def immortal?
  352.     return false unless $game_party.in_battle
  353.     members = $game_troop.members + $game_party.battle_members
  354.     members.any? {|member| member.immortals.include?(self) }
  355.   end
  356.   #--------------------------------------------------------------------------
  357.   # *
  358.   #--------------------------------------------------------------------------
  359.   alias :die_ve_animated_battle :die
  360.   def die
  361.     return @dying = true if immortal?
  362.     call_pose(:die, :clear)
  363.     @dying = false
  364.     die_ve_animated_battle
  365.   end
  366.   #--------------------------------------------------------------------------
  367.   # *
  368.   #--------------------------------------------------------------------------
  369.   alias :revive_ve_animated_battle :revive
  370.   def revive
  371.     call_pose(:revive, :clear)
  372.     revive_ve_animated_battle
  373.   end
  374.   #--------------------------------------------------------------------------
  375.   # *
  376.   #--------------------------------------------------------------------------
  377.   def init_anim_battlers_variables
  378.     clear_poses
  379.   end
  380.   #--------------------------------------------------------------------------
  381.   # *
  382.   #--------------------------------------------------------------------------
  383.   def clear_poses
  384.     @sufix = ""
  385.     @row   = 0
  386.     @frame = 0
  387.     [url=home.php?mod=space&uid=124954]@Angle[/url] = 0
  388.     @spin  = 0
  389.     @x_adj = 0
  390.     @y_adj = 0
  391.     @direction  = 2
  392.     @move_speed = 1.0
  393.     @pose_list  = []
  394.     @targets    = []
  395.     @immortals  = []
  396.     @throw_list = []
  397.     @icon_list  = {}
  398.     @timing     = {}
  399.     @action_targets = []
  400.     clear_shake
  401.     clear_position
  402.   end
  403.   #--------------------------------------------------------------------------
  404.   # *
  405.   #--------------------------------------------------------------------------
  406.   def clear_shake
  407.     @shake_power = 0
  408.     @shake_speed = 0
  409.     @shake_duration = 0
  410.     @shake_direction = 1
  411.     @shake = 0
  412.   end
  413.   #--------------------------------------------------------------------------
  414.   # *
  415.   #--------------------------------------------------------------------------
  416.   def clear_position
  417.     @target_position  = {x: 0, y: 0, h: 0, j: 0}
  418.     @current_position = {x: 0, y: 0, h: 0, j: 0}
  419.     @default_position = {x: 0, y: 0, h: 0, j: 0}
  420.   end
  421.   #--------------------------------------------------------------------------
  422.   # *
  423.   #--------------------------------------------------------------------------
  424.   def call_pose(symbol, insert = nil, item = nil, battler = nil)
  425.     skip_pose if insert == :clear && pose_name_list.first == symbol
  426.     pose  = make_string(symbol)
  427.     note  = item ? item.note : ""
  428.     notes = get_all_poses(note)
  429.     code  = "ACTION: #{pose}((?: *, *[\\w ]+)+)?"
  430.     setup_pose(symbol, notes, code, insert, battler)
  431.   end
  432.   #--------------------------------------------------------------------------
  433.   # *
  434.   #--------------------------------------------------------------------------
  435.   def get_all_poses(note = "")
  436.     note + get_all_notes + battler_settings + default_settings
  437.   end
  438.   #--------------------------------------------------------------------------
  439.   # *
  440.   #--------------------------------------------------------------------------
  441.   def default_settings
  442.     VE_DEFAULT_ACTION
  443.   end
  444.   #--------------------------------------------------------------------------
  445.   # *
  446.   #--------------------------------------------------------------------------
  447.   def battler_settings
  448.     VE_ACTION_SETTINGS[battler_mode] ? VE_ACTION_SETTINGS[battler_mode] : ""
  449.   end
  450.   #--------------------------------------------------------------------------
  451.   # *
  452.   #--------------------------------------------------------------------------
  453.   def battler_mode
  454.     sprite_value(:action)
  455.   end
  456.   #--------------------------------------------------------------------------
  457.   # *
  458.   #--------------------------------------------------------------------------
  459.   def sprite_value(value)
  460.     sprite_settings[value] ? sprite_settings[value] : VE_DEFAULT_SPRITE[value]
  461.   end
  462.   #--------------------------------------------------------------------------
  463.   # *
  464.   #--------------------------------------------------------------------------
  465.   def sprite_settings
  466.     VE_SPRITE_SETTINGS[@battler_name] ? VE_SPRITE_SETTINGS[@battler_name] :
  467.     VE_DEFAULT_SPRITE
  468.   end
  469.   #--------------------------------------------------------------------------
  470.   # *
  471.   #--------------------------------------------------------------------------
  472.   def setup_pose(pose, notes, code, insert, battler)
  473.     regexp = /<#{code}>((?:[^<]|<[^\/])*)<\/ACTION>/im
  474.     if notes.gsub(/\r\n/i, "") =~ regexp
  475.       time, last = get_values($1)
  476.       value = setup_value($2, battler == :skip ? nil : battler)
  477.       return if value.empty?
  478.       time.times do
  479.         list = {pose: pose, next: last, value: value.dup, battler: battler}
  480.         insert ? @pose_list.unshift(list) : @pose_list.push(list)
  481.       end
  482.     end
  483.   end
  484.   #--------------------------------------------------------------------------
  485.   # *
  486.   #--------------------------------------------------------------------------
  487.   def pose_name_list
  488.     @pose_list.collect {|pose| pose[:pose]}
  489.   end
  490.   #--------------------------------------------------------------------------
  491.   # *
  492.   #--------------------------------------------------------------------------
  493.   def pose_name
  494.     pose_name_list.first
  495.   end
  496.   #--------------------------------------------------------------------------
  497.   # *
  498.   #--------------------------------------------------------------------------
  499.   def skip_pose
  500.     @current_pose = pose_name
  501.     @pose_list.shift while @current_pose == pose_name && !@pose_list.empty?
  502.   end
  503.   #--------------------------------------------------------------------------
  504.   # *
  505.   #--------------------------------------------------------------------------
  506.   def get_values(value)
  507.     if value
  508.       time = value =~ /([^,]+) TIMES/i ? [eval($1), 1].max : 1
  509.       last = value =~ /(\w[\w ]+)/i    ? make_symbol($1)   : nil
  510.       [time, last]
  511.     else
  512.       [1, nil]
  513.     end
  514.   end
  515.   #--------------------------------------------------------------------------
  516.   # *
  517.   #--------------------------------------------------------------------------
  518.   def clear_idle_poses
  519.     @pose_list.delete_if {|pose| idle_pose?(pose[:pose]) }
  520.   end
  521.   #--------------------------------------------------------------------------
  522.   # *
  523.   #--------------------------------------------------------------------------
  524.   def battler
  525.     @pose[:battler] ? @pose[:battler] : self
  526.   end
  527.   #--------------------------------------------------------------------------
  528.   # *
  529.   #--------------------------------------------------------------------------
  530.   def idle_pose?(pose)
  531.     idle_pose_list.include?(pose.downcase.to_sym)
  532.   end
  533.   #--------------------------------------------------------------------------
  534.   # *
  535.   #--------------------------------------------------------------------------
  536.   def idle_pose_list
  537.     [:idle, :guard, :danger, :dead, :item_cast, :magic_cast, :skill_cast,
  538.      :default_cast] + states_pose
  539.   end
  540.   #--------------------------------------------------------------------------
  541.   # *
  542.   #--------------------------------------------------------------------------
  543.   def states_pose
  544.     $data_states.compact.collect {|state| state.custom_pose("STATE") }.compact
  545.   end
  546.   #--------------------------------------------------------------------------
  547.   # *
  548.   #--------------------------------------------------------------------------
  549.   def setup_value(settings, battler)
  550.     values = []
  551.     settings.scan(/(\w+)(?:: ([^;]+)[;\n\r])?/i) do |type, value|
  552.       values.push(set_pose_value(type, value ? value : '', battler))
  553.     end
  554.     values
  555.   end
  556.   #--------------------------------------------------------------------------
  557.   # *
  558.   #--------------------------------------------------------------------------
  559.   def set_pose_value(type, value, battler)
  560.     @pose = {}
  561.     @pose[:battler] = battler
  562.     @pose[:type] = make_symbol(type)
  563.     @pose[:hit]  = value =~ /HIT ONLY/i  ? true : false
  564.     @pose[:miss] = value =~ /MISS ONLY/i ? true : false
  565.     set_pose_setting("#{type} #{value}")
  566.     @pose
  567.   end
  568.   #--------------------------------------------------------------------------
  569.   # *
  570.   #--------------------------------------------------------------------------
  571.   def set_pose_setting(value)
  572.     case value
  573.     when /^POSE (.*)/i then set_pose($1)
  574.     when /^WAIT (.*)/i then set_wait($1)
  575.     when /^MOVE (.*)/i then set_move($1)
  576.     when /^JUMP (.*)/i then set_jump($1)
  577.     when /^ANIM (.*)/i then set_anim($1)
  578.     when /^ICON (.*)/i then set_icon($1)
  579.     when /^LOOP (.*)/i then set_loop($1)
  580.     when /^TONE (.*)/i then set_tone($1)
  581.     when /^THROW (.*)/i then set_throw($1)
  582.     when /^SOUND (.*)/i then set_sound($1)
  583.     when /^PLANE (.*)/i then set_plane($1)
  584.     when /^FLASH (.*)/i then set_flash($1)
  585.     when /^SHAKE (.*)/i then set_shake($1)
  586.     when /^MOVIE (.*)/i then set_movie($1)
  587.     when /^ACTION (.*)/i then set_action($1)
  588.     when /^FREEZE (.*)/i then set_freeze($1)
  589.     when /^EFFECT (.*)/i then set_effect($1)
  590.     when /^PICTURE (.*)/i then set_picture($1)
  591.     when /^COUNTER (.*)/i then set_counter($1)
  592.     when /^DIRECTION (.*)/i then set_direction($1)
  593.     end
  594.   end
  595.   #--------------------------------------------------------------------------
  596.   # *
  597.   #--------------------------------------------------------------------------
  598.   def set_pose(value)
  599.     @pose[:target] = set_targets(value)
  600.     @pose[:row]    = battler.set_row(value)
  601.     @pose[:angle]  = value =~ /ANGLE ([+-]?\d+)/i  ? $1.to_i : 0
  602.     @pose[:spin]   = value =~ /SPIN ([+-]?\d+)/i   ? $1.to_i : 0
  603.     @pose[:sufix]  = value =~ /SUFIX ([\[\]\w]+)/i ? $1.to_s : ""
  604.     @pose[:x] = value =~ /X ([+-]?\d+)/i   ? $1.to_i : 0
  605.     @pose[:y] = value =~ /Y ([+-]?\d+)/i   ? $1.to_i : 0
  606.     if value =~ /(\d+|ALL) FRAMES?/i
  607.       w = [value =~ /WAIT (\d+)/i ? $1.to_i : 1, 1].max
  608.       m = /(\d+) FRAMES/i ? $1.to_i : :all
  609.       l = value =~ /RETURN/i ? true : false
  610.       r = value =~ /REVERT/i ? true : false
  611.       @pose[:frame] = value =~ /FRAME (\d+)/i ? $1.to_i : 1
  612.       @pose[:pose]  = {wait: w, time: w, frame: m, loop: l, revert: r}
  613.     else
  614.       @pose[:pose]  = {}
  615.       @pose[:frame] = value =~ /FRAME (\d+)/i ? $1.to_i : 1
  616.     end
  617.   end
  618.   #--------------------------------------------------------------------------
  619.   # *
  620.   #--------------------------------------------------------------------------
  621.   def set_wait(value)
  622.     @pose[:target] = set_targets(value)
  623.     case value
  624.     when /(\d+)/i
  625.       @pose[:time] = $1.to_i
  626.       @pose[:wait] = $1.to_i
  627.     when /(ACTION|ANIMATION|MOVEMENT|ORIGIN|THROW|COUNTER|SUBSTITUTION|TONE)/i
  628.       @pose[:time] = make_symbol($1)
  629.       @pose[:wait] = make_symbol($1)
  630.     end
  631.   end
  632.   #--------------------------------------------------------------------------
  633.   # *
  634.   #--------------------------------------------------------------------------
  635.   def set_move(value)
  636.     regexp = /(MOVE TO|STEP FOWARD|STEP BACKWARD|RETREAT|ESCAPE)/i
  637.     @pose[:value]  = make_symbol($1) if value =~ regexp
  638.     @pose[:target] = battler.set_targets(value)
  639.     @pose[:x]      = value =~ /X ([+-]?\d+)/i ? $1.to_i : 0
  640.     @pose[:y]      = value =~ /Y ([+-]?\d+)/i ? $1.to_i : 0
  641.     @pose[:h]      = value =~ /HEIGHT (\d+)/i ? $1.to_i : 0
  642.     @pose[:speed]  = value =~ /SPEED (\d+)/i  ? $1.to_i / 10.0 : 1.0
  643.     @pose[:targets]  = @action_targets if @pose[:value] == :move_to
  644.     @pose[:teleport] = value =~ /TELEPORT/i
  645.   end
  646.   #--------------------------------------------------------------------------
  647.   # *
  648.   #--------------------------------------------------------------------------
  649.   def set_jump(value)
  650.     @pose[:target] = set_targets(value)
  651.     @pose[:move]   = value =~ /MOVE/i
  652.     @pose[:height] = value =~ /HEIGHT (\d+)/i ? [$1.to_i, 1].max : 5
  653.     @pose[:speed]  = value =~ /SPEED (\d+)/i  ? [$1.to_i, 1].max : 10
  654.   end
  655.   #--------------------------------------------------------------------------
  656.   # *
  657.   #--------------------------------------------------------------------------
  658.   def set_action(value)
  659.     @pose[:target] = set_targets(value)
  660.     value.scan(/(\w[\w ]+)/) do
  661.       not_action = ['target','actor','friend','enemy', 'user','self']
  662.       next if not_action.include?($1.downcase)
  663.       @pose[:action] = make_symbol($1)
  664.     end
  665.   end
  666.   #--------------------------------------------------------------------------
  667.   # *
  668.   #--------------------------------------------------------------------------
  669.   def set_freeze(value)
  670.     @pose[:target]   = set_targets(value)
  671.     @pose[:duration] = value =~ /DURATION (\d+)/i ? [$1.to_i, 1].max : 1
  672.   end
  673.   #--------------------------------------------------------------------------
  674.   # *
  675.   #--------------------------------------------------------------------------
  676.   def set_sound(value)
  677.     @pose[:name]   = value =~ /NAME #{get_filename}/i ? $1 : ""
  678.     @pose[:volume] = value =~ /VOLUME (\d+)/i ? $1.to_i : 100
  679.     @pose[:pitch]  = value =~ /PITCH (\d+)/i  ? $1.to_i : 100
  680.   end
  681.   #--------------------------------------------------------------------------
  682.   # *
  683.   #--------------------------------------------------------------------------
  684.   def set_anim(value)
  685.     @pose[:target] = set_targets(value)
  686.     item = current_item ? current_item : nil
  687.     case value
  688.     when /CAST/i
  689.       cast = item && $imported[:ve_cast_animation]
  690.       anim = cast ? battler.cast_animation_id(item) : 0
  691.       @pose[:anim] = anim
  692.     when /EFFECT/i
  693.       @pose[:anim] = item ? item.animation_id : 0
  694.     when /ID (\d+)/i
  695.       @pose[:anim] = $1.to_i
  696.     when /WEAPON *(\d+)?/i
  697.       @pose[:anim] = battler.atk_animation_id1
  698.       @pose[:anim] = battler.atk_animation_id2 if $1 && $1.to_i == 2
  699.     else
  700.       @pose[:anim] = 0
  701.     end
  702.   end
  703.   #--------------------------------------------------------------------------
  704.   # *
  705.   #--------------------------------------------------------------------------
  706.   def set_icon(value)
  707.     @pose[:target] = set_targets(value)
  708.     @pose[:index]  = value =~ /INDEX ([+-]?\d+)/i      ? $1.to_i : 0
  709.     @pose[:image]  = value =~ /IMAGE #{get_filename}/i ? $1.to_s : nil
  710.     @pose[:delete] = value =~ /DELETE/i ? true : false
  711.     return if @pose[:delete]
  712.     set_action_icon(value)
  713.     @pose[:x] = value =~ /X ([+-]?\d+)/i  ? $1.to_i : 0
  714.     @pose[:y] = value =~ /Y ([+-]?\d+)/i  ? $1.to_i : 0
  715.     @pose[:z] = value =~ /Z ([+-]?\d+)/i  ? $1.to_i : -1
  716.     @pose[:a] = value =~ /ANGLE ([+-]?\d+)/i   ? $1.to_i : 0
  717.     @pose[:o] = value =~ /OPACITY (\d+)/i      ? $1.to_i : 255
  718.     @pose[:spin] = value =~ /SPIN ([+-]\d+)/i  ? $1.to_i : 0
  719.     @pose[:fin]  = value =~ /FADE IN (\d+)/i   ? $1.to_i : 0
  720.     @pose[:fout] = value =~ /FADE OUT (\d+)/i  ? $1.to_i : 0
  721.     @pose[:izm]  = value =~ /INIT ZOOM (\d+)/i ? $1.to_i / 100.0 : 1.0
  722.     @pose[:ezm]  = value =~ /END ZOOM (\d+)/i  ? $1.to_i / 100.0 : 1.0
  723.     @pose[:szm]  = value =~ /ZOOM SPD (\d+)/i  ? $1.to_i / 100.0 : 0.1
  724.   end
  725.   #--------------------------------------------------------------------------
  726.   # *
  727.   #--------------------------------------------------------------------------
  728.   def set_picture(value)
  729.     @pose[:id] = value =~ /ID (\d+)/i ? [$1.to_i, 1].max : 1
  730.     @pose[:delete] = value =~ /DELETE/i ? true : false
  731.     return if @pose[:delete]
  732.     name = value =~ /NAME #{get_filename}/i ? $1.to_s : ""
  733.     orig = value =~ /ORIGIN CENTER/i ? 1 : 0
  734.     x    = value =~ /POS X ([+-]?\d+)/i ? $1.to_i : 0
  735.     y    = value =~ /POS Y ([+-]?\d+)/i ? $1.to_i : 0
  736.     zoom_x  = value =~ /ZOOM X ([+-]?\d+)/i ? $1.to_i : 100.0
  737.     zoom_y  = value =~ /ZOOM X ([+-]?\d+)/i ? $1.to_i : 100.0
  738.     opacity = value =~ /OPACITY (\d+)/i     ? $1.to_i : 255
  739.     blend   = value =~ /BLEND ([+-]\d+)/i   ? $1.to_i : 0
  740.     duration = value =~ /DURATION (\d+)/i    ? $1.to_i : 0
  741.     if value =~ /SHOW/i
  742.       @pose[:show] = [name, orig, x, y, zoom_x, zoom_y, opacity, blend]
  743.     elsif value =~ /MOVE/i
  744.       @pose[:move] = [orig, x, y, zoom_x, zoom_y, opacity, blend, duration]
  745.     end
  746.   end
  747.   #--------------------------------------------------------------------------
  748.   # *
  749.   #--------------------------------------------------------------------------
  750.   def set_plane(value)
  751.     @pose[:delete]   = value =~ /DELETE/i ? true : false
  752.     @pose[:duration] = value =~ /DURATION (\d+)/i ? $1.to_i : 0
  753.     return if @pose[:delete]
  754.     name = value =~ /NAME #{get_filename}/i ? $1.to_s : ""
  755.     x    = value =~ /MOVE X ([+-]?\d+)/i ? $1.to_i : 0
  756.     y    = value =~ /MOVE Y ([+-]?\d+)/i ? $1.to_i : 0
  757.     z    = value =~ /Z ([+-]?\d+)/i      ? $1.to_i : 100
  758.     zoom_x  = value =~ /ZOOM X ([+-]?\d+)/i ? $1.to_i : 100.0
  759.     zoom_y  = value =~ /ZOOM X ([+-]?\d+)/i ? $1.to_i : 100.0
  760.     opacity = value =~ /OPACITY (\d+)/i     ? $1.to_i : 160
  761.     blend   = value =~ /BLEND ([+-]\d+)/i   ? $1.to_i : 0
  762.     duration = @pose[:duration]
  763.     @pose[:list] = [name, x, y, z, zoom_x, zoom_y, opacity, blend, duration]
  764.   end
  765.   #--------------------------------------------------------------------------
  766.   # *
  767.   #--------------------------------------------------------------------------
  768.   def set_throw(value)
  769.     @pose[:target] = set_targets(value)
  770.     @pose[:image]  = value =~ /IMAGE #{get_filename}/i ? $1.to_s : nil
  771.     set_action_icon(value)
  772.     @pose[:revert] = value =~ /REVERT/i
  773.     @pose[:return] = value =~ /RETURN/i
  774.     @pose[:init_x] = value =~ /INIT X ([+-]?\d+)/i ? $1.to_i : 0
  775.     @pose[:init_y] = value =~ /INIT Y ([+-]?\d+)/i ? $1.to_i : 0
  776.     @pose[:end_x]  = value =~ /END X ([+-]?\d+)/i  ? $1.to_i : 0
  777.     @pose[:end_y]  = value =~ /END Y ([+-]?\d+)/i  ? $1.to_i : 0
  778.     @pose[:anim]   = value =~ /ANIM (\d+)/i    ? $1.to_i : nil
  779.     @pose[:arc]    = value =~ /ARC (\d+)/i     ? $1.to_i : 0
  780.     @pose[:speed]  = value =~ /SPEED (\d+)/i   ? $1.to_i / 10.0 : 1.0
  781.     @pose[:spin] = value =~ /SPIN ([+-]\d+)/i  ? $1.to_i : 0
  782.     @pose[:fin]  = value =~ /FADE IN (\d+)/i   ? $1.to_i : 0
  783.     @pose[:fout] = value =~ /FADE OUT (\d+)/i  ? $1.to_i : 0
  784.     @pose[:izm]  = value =~ /INIT ZOOM (\d+)/i ? $1.to_i / 100.0 : 1.0
  785.     @pose[:ezm]  = value =~ /END ZOOM (\d+)/i  ? $1.to_i / 100.0 : 1.0
  786.     @pose[:szm]  = value =~ /ZOOM SPD (\d+)/i  ? $1.to_i / 100.0 : 0.1
  787.     @pose[:z] = value =~ /Z ([+-]?\d+)/i  ? $1.to_i : 0
  788.     @pose[:o] = value =~ /OPACITY (\d+)/i ? $1.to_i : 255
  789.     @pose[:a] = value =~ /ANGLE (\d+)/i   ? $1.to_i : 0
  790.   end
  791.   #--------------------------------------------------------------------------
  792.   # *
  793.   #--------------------------------------------------------------------------
  794.   def set_action_icon(value)
  795.     icon = weapon_icon($1.to_i) if value =~ /WEAPON (\d+)/i && battler.actor?
  796.     icon = armor_icon($1.to_i)  if value =~ /ARMOR (\d+)/i  && battler.actor?
  797.     icon = armor_icon(1)        if value =~ /SHIELD/i       && battler.actor?
  798.     icon = action_icon if value =~ /ACTION/i
  799.     icon = $1.to_i     if value =~ /ICON (\d+)/i
  800.     @pose[:icon] = icon ? icon : 0
  801.   end
  802.   #--------------------------------------------------------------------------
  803.   # *
  804.   #--------------------------------------------------------------------------
  805.   def set_shake(value)
  806.     @pose[:target] = set_targets(value)
  807.     @pose[:screen] = value =~ /SCREEN/i ? true : false
  808.     power = value =~ /POWER (\d+)/i ? [$1.to_i, 2].max : 5
  809.     speed = value =~ /SPEED (\d+)/i ? [$1.to_i, 2].max : 5
  810.     duration = value =~ /DURATION (\d+)/i ? [$1.to_i, 1].max : 10
  811.     @pose[:shake] = [power / 2.0, speed / 2.0, duration]
  812.   end
  813.   #--------------------------------------------------------------------------
  814.   # *
  815.   #--------------------------------------------------------------------------
  816.   def set_movie(value)
  817.     @pose[:name] = value =~ /NAME #{get_filename}/i ? $1.to_s : ""
  818.     set_tone(value)
  819.   end
  820.   #--------------------------------------------------------------------------
  821.   # *
  822.   #--------------------------------------------------------------------------
  823.   def set_tone(value)
  824.     r = value =~ /RED ([+-]?\d+)/i   ? $1.to_i : 0
  825.     g = value =~ /GREEN ([+-]?\d+)/i ? $1.to_i : 0
  826.     b = value =~ /BLUE ([+-]?\d+)/i  ? $1.to_i : 0
  827.     a = value =~ /GRAY ([+-]?\d+)/i  ? $1.to_i : 0
  828.     tone  = [r, g, b, a]
  829.     tone  = [ 255,  255,  255, 0] if value =~ /WHITE/i
  830.     tone  = [-255, -255, -255, 0] if value =~ /BLACK/i
  831.     @pose[:tone]  = Tone.new(*tone)
  832.     @pose[:clear] = true if value =~ /CLEAR/i
  833.     @pose[:duration] = value =~ /DURATION (\d+)/i ? $1.to_i : 0
  834.     @pose[:priority] = :normal
  835.     @pose[:priority] = :high if value =~ /HIGH PRIORITY/i
  836.     @pose[:priority] = :low  if value =~ /LOW PRIORITY/i
  837.   end
  838.   #--------------------------------------------------------------------------
  839.   # *
  840.   #--------------------------------------------------------------------------
  841.   def set_flash(value)
  842.     @pose[:target] = set_targets(value)
  843.     @pose[:screen] = value =~ /SCREEN/i ? true : false
  844.     r = value =~ /RED (\d+)/i   ? $1.to_i : 255
  845.     g = value =~ /GREEN (\d+)/i ? $1.to_i : 255
  846.     b = value =~ /BLUE (\d+)/i  ? $1.to_i : 255
  847.     a = value =~ /ALPHA (\d+)/i ? $1.to_i : 160
  848.     duration = value =~ /DURATION (\d+)/i ? [$1.to_i, 1].max : 10
  849.     @pose[:flash] = [Color.new(r, g, b, a), duration]
  850.   end
  851.   #--------------------------------------------------------------------------
  852.   # *
  853.   #--------------------------------------------------------------------------
  854.   def set_loop(value)
  855.     @pose[:target]    = set_targets(value)
  856.     @pose[:loop_anim] = value =~ /ANIM (\d+)/i ? $1.to_i : 0
  857.   end
  858.   #--------------------------------------------------------------------------
  859.   # *
  860.   #--------------------------------------------------------------------------
  861.   def set_effect(value)
  862.     @pose[:target] = set_targets(value)
  863.     @pose[:damage] = $1.to_i / 100.0  if value =~ /(\d+)%/i
  864.     @pose[:weapon] = [$1.to_i, 1].max if value =~ /WEAPON (\d+)/i
  865.   end
  866.   #--------------------------------------------------------------------------
  867.   # *
  868.   #--------------------------------------------------------------------------
  869.   def set_counter(value)
  870.     @pose[:target]  = set_targets(value)
  871.     @pose[:counter] = true  if value =~ /ON/i
  872.     @pose[:counter] = false if value =~ /OFF/i
  873.   end
  874.   #--------------------------------------------------------------------------
  875.   # *
  876.   #--------------------------------------------------------------------------
  877.   def set_direction(value)
  878.     @pose[:targets]   = true if value =~ /TARGETS/i
  879.     @pose[:return]    = true if value =~ /RETURN/i
  880.     @pose[:direction] = 2 if value =~ /DOWN/i
  881.     @pose[:direction] = 4 if value =~ /LEFT/i
  882.     @pose[:direction] = 6 if value =~ /RIGHT/i
  883.     @pose[:direction] = 8 if value =~ /UP/i
  884.   end
  885.   #--------------------------------------------------------------------------
  886.   # *
  887.   #--------------------------------------------------------------------------
  888.   def set_targets(value)
  889.     case value
  890.     when /SELF/i
  891.       [self]
  892.     when /ACTOR ([^>,]+)/i
  893.       acotor = $game_actors[eval($1)]
  894.       target = $game_party.battle_members.include?(actor) ? [actor] : []
  895.     when /FRIEND ([^>,]+)/i
  896.       [$game_party.battle_members[eval($1)]].compact
  897.     when /ENEMY ([^>,]+)/i
  898.       [$game_troop.members[eval($1)]].compact
  899.     when /RANDOM ENEMY/i
  900.       battler.opponents_unit.members.random
  901.     when /RANDOM FRIEND/i
  902.       battler.firends_unit.members.random
  903.     when /ALL ENEMIES/i
  904.       battler.opponents_unit.members
  905.     when /ALL FRIENDS/i
  906.       battler.firends_unit.members
  907.     when /TARGETS/i
  908.       battler.action_targets.dup
  909.     when /USER/i
  910.       [battler]
  911.     else
  912.       nil
  913.     end
  914.   end
  915.   #--------------------------------------------------------------------------
  916.   # *
  917.   #--------------------------------------------------------------------------
  918.   def set_row(value)
  919.     pose = battler.sprite_value(make_symbol($1)) if value =~ /ROW (\w+)/i
  920.     pose = :direction if value =~ /ROW DIRECTION/i
  921.     pose = $1.to_i    if value =~ /ROW (\d+)/i
  922.     pose ? pose : 0
  923.   end
  924.   #--------------------------------------------------------------------------
  925.   # *
  926.   #--------------------------------------------------------------------------
  927.   def weapon_icon(index)
  928.     battler.weapons[index - 1] ? battler.weapons[index - 1].icon_index : nil
  929.   end
  930.   #--------------------------------------------------------------------------
  931.   # *
  932.   #--------------------------------------------------------------------------
  933.   def equip_list
  934.     @equips
  935.   end
  936.   #--------------------------------------------------------------------------
  937.   # *
  938.   #--------------------------------------------------------------------------
  939.   def armor_icon(index)
  940.     slot = battler.equip_slots[index]
  941.     return nil unless slot && slot != 0 && battler.equip_list[slot]
  942.     equip = battler.equip_list[slot]
  943.     equip.object ? equip.object.icon_index : nil
  944.   end
  945.   #--------------------------------------------------------------------------
  946.   # *
  947.   #--------------------------------------------------------------------------
  948.   def action_icon
  949.     current_item ? current_item.icon_index : 0
  950.   end
  951.   #--------------------------------------------------------------------------
  952.   # *
  953.   #--------------------------------------------------------------------------
  954.   def active?
  955.     @active
  956.   end
  957.   #--------------------------------------------------------------------------
  958.   # *
  959.   #--------------------------------------------------------------------------
  960.   def down?
  961.     @direction == 2
  962.   end
  963.   #--------------------------------------------------------------------------
  964.   # *
  965.   #--------------------------------------------------------------------------
  966.   def left?
  967.     @direction == 4
  968.   end
  969.   #--------------------------------------------------------------------------
  970.   # *
  971.   #--------------------------------------------------------------------------
  972.   def right?
  973.     @direction == 6
  974.   end
  975.   #--------------------------------------------------------------------------
  976.   # *
  977.   #--------------------------------------------------------------------------
  978.   def up?
  979.     @direction == 8
  980.   end
  981.   #--------------------------------------------------------------------------
  982.   # *
  983.   #--------------------------------------------------------------------------
  984.   def target_direction(x, y, current = nil)
  985.     position = current ? current : current_position
  986.     relative_x = position[:x] - x
  987.     relative_y = position[:y] - y
  988.     if relative_y.abs > relative_x.abs && !sideview
  989.       @direction = relative_y < 0 ? 2 : 8
  990.     elsif relative_x.abs >= relative_y.abs && !frontview
  991.       @direction = relative_x < 0 ? 6 : 4
  992.     end
  993.   end
  994.   #--------------------------------------------------------------------------
  995.   # *
  996.   #--------------------------------------------------------------------------
  997.   def position_fix
  998.     value =  16 if left?  || up?
  999.     value = -16 if right? || down?
  1000.     target_position[rand(2) == 0 ? :x : :y] += value
  1001.   end
  1002.   #--------------------------------------------------------------------------
  1003.   # *
  1004.   #--------------------------------------------------------------------------
  1005.   def sharing_position?
  1006.     units = $game_troop.members + $game_party.battle_members
  1007.     list  = units.select do |target|
  1008.       target != self && target.target_position == target_position
  1009.     end
  1010.     !list.empty?
  1011.   end
  1012.   #--------------------------------------------------------------------------
  1013.   # *
  1014.   #--------------------------------------------------------------------------
  1015.   def sideview
  1016.     $imported[:ve_actor_battlers] && VE_BATTLE_FORMATION == :side
  1017.   end
  1018.   #--------------------------------------------------------------------------
  1019.   # *
  1020.   #--------------------------------------------------------------------------
  1021.   def frontview
  1022.     $imported[:ve_actor_battlers] && VE_BATTLE_FORMATION == :front
  1023.   end
  1024.   #--------------------------------------------------------------------------
  1025.   # *
  1026.   #--------------------------------------------------------------------------
  1027.   def action_direction
  1028.     units = @action_targets
  1029.     target_x = units.collect {|member| member.current_position[:x] }.average
  1030.     target_y = units.collect {|member| member.current_position[:y] }.average
  1031.     target_direction(target_x, target_y)
  1032.   end
  1033.   #--------------------------------------------------------------------------
  1034.   # *
  1035.   #--------------------------------------------------------------------------
  1036.   def target_distance(symbol)
  1037.     @target_position[symbol] - @current_position[symbol]
  1038.   end
  1039.   #--------------------------------------------------------------------------
  1040.   # *
  1041.   #--------------------------------------------------------------------------
  1042.   def moving?
  1043.     @current_position != @target_position
  1044.   end
  1045.   #--------------------------------------------------------------------------
  1046.   # *
  1047.   #--------------------------------------------------------------------------
  1048.   def origin?
  1049.     @current_position[:x] != screen_x || @current_position[:y] != screen_y
  1050.   end
  1051.   #--------------------------------------------------------------------------
  1052.   # *
  1053.   #--------------------------------------------------------------------------
  1054.   def activate
  1055.     return unless current_action && current_action.item
  1056.     @active = true
  1057.     @active_pose = nil
  1058.     @action_targets = current_action.make_targets.compact.dup
  1059.     setup_immortals
  1060.   end
  1061.   #--------------------------------------------------------------------------
  1062.   # *
  1063.   #--------------------------------------------------------------------------
  1064.   def setup_immortals
  1065.     @action_targets.each {|target| immortals.push(target) unless target.dead? }
  1066.     immortals.uniq!
  1067.   end
  1068.   #--------------------------------------------------------------------------
  1069.   # *
  1070.   #--------------------------------------------------------------------------
  1071.   def deactivate
  1072.     @active = false
  1073.     @attack_flag = nil
  1074.     @result_flag = nil
  1075.     immortals = @immortals.dup
  1076.     @immortals.clear
  1077.     immortals.each {|member| member.refresh }
  1078.     @action_targets.clear
  1079.   end
  1080.   #--------------------------------------------------------------------------
  1081.   # *
  1082.   #--------------------------------------------------------------------------
  1083.   def action_pose(item)
  1084.     activate
  1085.     @current_item = item
  1086.     pose = set_action_pose(item)
  1087.     call_action_poses(pose, item)
  1088.   end
  1089.   #--------------------------------------------------------------------------
  1090.   # *
  1091.   #--------------------------------------------------------------------------
  1092.   def set_action_pose(item)
  1093.     [setup_pose_type(item), false, item]
  1094.   end
  1095.   #--------------------------------------------------------------------------
  1096.   # *
  1097.   #--------------------------------------------------------------------------
  1098.   def setup_pose_type(item)
  1099.     pose = weapons_pose("USE",   :use)
  1100.     pose = weapons_pose("ITEM",  :item)  if item.item?
  1101.     pose = weapons_pose("MAGIC", :magic) if item.magical?
  1102.     pose = weapons_pose("SKILL", :skill) if item.skill?
  1103.     pose = attack_pose if item_attack?(item)
  1104.     pose = :defend     if item_defend?(item)
  1105.     pose = custom_pose("ACTION", pose, item)
  1106.     pose
  1107.   end
  1108.   #--------------------------------------------------------------------------
  1109.   # *
  1110.   #--------------------------------------------------------------------------
  1111.   def item_attack?(item)
  1112.     item.skill? && item.id == attack_skill_id
  1113.   end
  1114.   #--------------------------------------------------------------------------
  1115.   # *
  1116.   #--------------------------------------------------------------------------
  1117.   def item_defend?(item)
  1118.     item.skill? && item.id == guard_skill_id
  1119.   end
  1120.   #--------------------------------------------------------------------------
  1121.   # *
  1122.   #--------------------------------------------------------------------------
  1123.   def attack_pose
  1124.     pose = weapons_pose("ATTACK", :attack)
  1125.     pose = weapons_pose("DUAL",   :dual_attack) if double_attack?
  1126.     pose
  1127.   end
  1128.   #--------------------------------------------------------------------------
  1129.   # *
  1130.   #--------------------------------------------------------------------------
  1131.   def weapons_pose(type, pose)
  1132.     valid = actor? ? weapons : []
  1133.     list  = valid.collect { |item| item.custom_pose(type) }.compact
  1134.     list.empty? || !pose_exist?(list.first) ? pose : list.first
  1135.   end
  1136.   #--------------------------------------------------------------------------
  1137.   # *
  1138.   #--------------------------------------------------------------------------
  1139.   def custom_pose(type, pose, item)
  1140.     note   = item ? item.note : ""
  1141.     custom = item.custom_pose(type)
  1142.     custom && pose_exist?(custom, note) ? custom : pose
  1143.   end
  1144.   #--------------------------------------------------------------------------
  1145.   # *
  1146.   #--------------------------------------------------------------------------
  1147.   def pose_exist?(pose, note = "")
  1148.     value  = "ACTION: #{make_string(pose)}"
  1149.     regexp = /<#{value}(?:(?: *, *[\w ]+)+)?>(?:[^<]|<[^\/])*<\/ACTION>/im
  1150.     get_all_poses(note) =~ regexp
  1151.   end
  1152.   #--------------------------------------------------------------------------
  1153.   # *
  1154.   #--------------------------------------------------------------------------
  1155.   def call_action_poses(pose, item)
  1156.     clear_idle_poses
  1157.     call_move_pose("ADVANCE", :advance, item) if need_move?(item)
  1158.     call_pose(*pose)
  1159.     call_pose(:inactive)
  1160.     call_custom_pose("RETREAT", :retreat, item)
  1161.   end
  1162.   #--------------------------------------------------------------------------
  1163.   # *
  1164.   #--------------------------------------------------------------------------
  1165.   def call_move_pose(type, pose, item)
  1166.     pose = weapons_pose(type, pose)
  1167.     pose = custom_pose(type, pose, item)
  1168.     call_pose(pose, false, item)
  1169.   end
  1170.   #--------------------------------------------------------------------------
  1171.   # *
  1172.   #--------------------------------------------------------------------------
  1173.   def call_custom_pose(type, pose, item)
  1174.     pose = custom_pose(type, pose, item)
  1175.     call_pose(pose, false, item)
  1176.   end
  1177.   #--------------------------------------------------------------------------
  1178.   # *
  1179.   #--------------------------------------------------------------------------
  1180.   def need_move?(item)
  1181.     return true  if item.note =~ /<ACTION MOVEMENT>/i
  1182.     return true  if item.skill? && item.physical?
  1183.     return true  if item.skill? && item.id == attack_skill_id
  1184.     return false
  1185.   end
  1186.   #--------------------------------------------------------------------------
  1187.   # *
  1188.   #--------------------------------------------------------------------------
  1189.   def call_damage_pose(item, user)
  1190.     call_pose(:hurt,     :clear, item, :skip) if hurt_pose?
  1191.     call_pose(:evade,    :clear, item, :skip) if @result.evaded
  1192.     call_pose(:critical, :clear, item, :skip) if @result.critical
  1193.   end
  1194.   #--------------------------------------------------------------------------
  1195.   # *
  1196.   #--------------------------------------------------------------------------
  1197.   def hurt_pose?
  1198.     @result.hit? && @result.hp_damage > 0 && !moving?
  1199.   end
  1200.   #--------------------------------------------------------------------------
  1201.   # *
  1202.   #--------------------------------------------------------------------------
  1203.   def set_active_pose
  1204.     return if (!current_action || !current_action.item) && !current_item
  1205.     item = current_action.item ? current_action.item : current_item
  1206.     pose = :ready      if sprite_value(:ready)
  1207.     pose = :item_cast  if item.item?     && sprite_value(:item_cast)
  1208.     pose = :magic_cast if item.magical?  && sprite_value(:magic_cast)
  1209.     pose = :skill_cast if item.physical? && sprite_value(:skill_cast)
  1210.     @active_pose = pose
  1211.   end
  1212.   #--------------------------------------------------------------------------
  1213.   # *
  1214.   #--------------------------------------------------------------------------
  1215.   def setup_counter(target)
  1216.     target.skip_pose unless [:inactive, :retreat].include?(target.pose_name)
  1217.     target.call_pose(:counter_on, :clear)
  1218.     @action_targets = [target]
  1219.     setup_immortals
  1220.     @current_item = $data_skills[attack_skill_id]
  1221.     pose = set_action_pose(@current_item)
  1222.     call_action_poses(pose, @current_item)
  1223.     call_pose(:counter_off)
  1224.   end
  1225.   #--------------------------------------------------------------------------
  1226.   # *
  1227.   #--------------------------------------------------------------------------
  1228.   def setup_reflect(item)
  1229.     skip_pose unless [:reflection, :inactive, :retreat].include?(pose_name)
  1230.     @action_targets = [self]
  1231.     setup_immortals
  1232.     @current_item = item
  1233.     pose = set_action_pose(item)
  1234.     call_pose(:reflection, true, item)
  1235.   end
  1236.   #--------------------------------------------------------------------------
  1237.   # *
  1238.   #--------------------------------------------------------------------------
  1239.   def setup_substitute(target)
  1240.     skip_pose unless [:substitution_on, :inactive, :retreat].include?(pose_name)
  1241.     @action_targets = [target]
  1242.     @substitution = true
  1243.     @current_position = target.current_position.dup
  1244.     @current_position[:x] += target.left? ? -16 : target.right? ? 16 : 0
  1245.     @current_position[:y] += target.up?   ? -16 : target.down?  ? 16 : 1
  1246.     @target_position = @current_position.dup
  1247.     call_pose(:substitution_off, true)
  1248.     call_pose(:substitution_on, true)
  1249.     sprite.update
  1250.   end
  1251.   #--------------------------------------------------------------------------
  1252.   # *
  1253.   #--------------------------------------------------------------------------
  1254.   def double_attack?
  1255.     actor? && dual_wield? && weapons.size > 1
  1256.   end
  1257.   #--------------------------------------------------------------------------
  1258.   # *
  1259.   #--------------------------------------------------------------------------
  1260.   def not_in_position?
  1261.     @current_position[:x] != screen_x || @current_position[:y] != screen_y
  1262.   end
  1263.   #--------------------------------------------------------------------------
  1264.   # *
  1265.   #--------------------------------------------------------------------------
  1266.   def state_pose?
  1267.     state_pose
  1268.   end
  1269.   #--------------------------------------------------------------------------
  1270.   # *
  1271.   #--------------------------------------------------------------------------
  1272.   def state_pose
  1273.     states.collect {|state| state.custom_pose("STATE") }.first
  1274.   end
  1275.   #--------------------------------------------------------------------------
  1276.   # *
  1277.   #--------------------------------------------------------------------------
  1278.   def reset_pose
  1279.     return unless $game_party.in_battle
  1280.     sprite.reset_pose
  1281.   end
  1282.   #--------------------------------------------------------------------------
  1283.   # * New method: frames
  1284.   #--------------------------------------------------------------------------
  1285.   def frames
  1286.     @character_name[/\[F(\d+)\]/i] ? $1.to_i : 3
  1287.   end
  1288.   #--------------------------------------------------------------------------
  1289.   # *
  1290.   #--------------------------------------------------------------------------
  1291.   def start_shake(power, speed, duration)
  1292.     @shake_power = power
  1293.     @shake_speed = speed
  1294.     @shake_duration = duration
  1295.   end
  1296.   #--------------------------------------------------------------------------
  1297.   # *
  1298.   #--------------------------------------------------------------------------
  1299.   def update_shake
  1300.     return unless shaking?
  1301.     delta  = (@shake_power * @shake_speed * @shake_direction) / 10.0
  1302.     clear  = @shake_duration <= 1 && @shake * (@shake + delta) < 0
  1303.     @shake = clear ? 0 : @shake + delta
  1304.     @shake_direction = -1 if @shake > @shake_power * 2
  1305.     @shake_direction = 1  if @shake < - @shake_power * 2
  1306.     @shake_duration -= 1
  1307.   end
  1308.   #--------------------------------------------------------------------------
  1309.   # *
  1310.   #--------------------------------------------------------------------------
  1311.   def update_freeze
  1312.     return if @freeze == 0 || !@freeze.numeric?
  1313.     @freeze -= 1
  1314.   end
  1315.   #--------------------------------------------------------------------------
  1316.   # *
  1317.   #--------------------------------------------------------------------------
  1318.   def shaking?
  1319.     @shake_duration > 0 || @shake != 0
  1320.   end
  1321.   #--------------------------------------------------------------------------
  1322.   # *
  1323.   #--------------------------------------------------------------------------
  1324.   def frozen?
  1325.     (@freeze.numeric? && @freeze > 0) || @freeze == :lock || unmovable?
  1326.   end
  1327.   #--------------------------------------------------------------------------
  1328.   # *
  1329.   #--------------------------------------------------------------------------
  1330.   def unmovable?
  1331.     get_all_notes =~ /<UNMOVEABLE>/i
  1332.   end
  1333. end

  1334. #==============================================================================
  1335. # ** Game_Actor
  1336. #------------------------------------------------------------------------------
  1337. #  This class handles actors. It's used within the Game_Actors class
  1338. # ($game_actors) and referenced by the Game_Party class ($game_party).
  1339. #==============================================================================

  1340. class Game_Actor < Game_Battler
  1341.   #--------------------------------------------------------------------------
  1342.   # *
  1343.   #--------------------------------------------------------------------------
  1344.   def perform_collapse_effect
  1345.     if $game_party.in_battle
  1346.       reset_pose
  1347.       case collapse_type
  1348.       when 0
  1349.         @sprite_effect_type = :collapse
  1350.         Sound.play_enemy_collapse
  1351.       when 1
  1352.         @sprite_effect_type = :boss_collapse
  1353.         Sound.play_boss_collapse1
  1354.       when 2
  1355.         @sprite_effect_type = :instant_collapse
  1356.       end
  1357.     end
  1358.   end
  1359.   #--------------------------------------------------------------------------
  1360.   # *
  1361.   #--------------------------------------------------------------------------
  1362.   def perform_damage_effect
  1363.     $game_troop.screen.start_shake(5, 5, 10) unless use_sprite?
  1364.     Sound.play_actor_damage
  1365.   end
  1366.   #--------------------------------------------------------------------------
  1367.   # *
  1368.   #--------------------------------------------------------------------------
  1369.   alias :param_plus_ve_animated_battle :param_plus
  1370.   def param_plus(param_id)
  1371.     if param_id > 1 && @attack_flag
  1372.       atk_equips.compact.inject(super) {|r, item| r += item.params[param_id] }
  1373.     else
  1374.       param_plus_ve_animated_battle(param_id)
  1375.     end
  1376.   end
  1377.   #--------------------------------------------------------------------------
  1378.   # *
  1379.   #--------------------------------------------------------------------------
  1380.   def atk_feature_objects
  1381.     list = @attack_flag ? atk_equips : equips.compact
  1382.     states + [actor] + [self.class] + list
  1383.   end
  1384.   #--------------------------------------------------------------------------
  1385.   # *
  1386.   #--------------------------------------------------------------------------
  1387.   def atk_all_features
  1388.     atk_feature_objects.inject([]) {|r, obj| r + obj.features }
  1389.   end
  1390.   #--------------------------------------------------------------------------
  1391.   # *
  1392.   #--------------------------------------------------------------------------
  1393.   def atk_features(code)
  1394.     atk_all_features.select {|ft| ft.code == code }
  1395.   end
  1396.   #--------------------------------------------------------------------------
  1397.   # *
  1398.   #--------------------------------------------------------------------------
  1399.   def atk_features_set(code)
  1400.     atk_features(code).inject([]) {|r, ft| r |= [ft.data_id] }
  1401.   end
  1402.   #--------------------------------------------------------------------------
  1403.   # *
  1404.   #--------------------------------------------------------------------------
  1405.   def atk_elements
  1406.     set = atk_features_set(FEATURE_ATK_ELEMENT)
  1407.     set |= [1] if weapons.compact.empty?
  1408.     return set
  1409.   end
  1410.   #--------------------------------------------------------------------------
  1411.   # *
  1412.   #--------------------------------------------------------------------------
  1413.   def atk_states
  1414.     atk_features_set(FEATURE_ATK_STATE)
  1415.   end
  1416.   #--------------------------------------------------------------------------
  1417.   # *
  1418.   #--------------------------------------------------------------------------
  1419.   def atk_equips
  1420.     ([weapons[@attack_flag - 1]] + armors).collect {|item| item }.compact
  1421.   end
  1422.   #--------------------------------------------------------------------------
  1423.   # *
  1424.   #--------------------------------------------------------------------------
  1425.   def default_direction
  1426.     units = opponents_unit.members
  1427.     x = units.collect {|member| member.screen_x }.average
  1428.     y = units.collect {|member| member.screen_y }.average
  1429.     target_direction(x, y, {x: screen_x, y: screen_y})
  1430.   end
  1431.   #--------------------------------------------------------------------------
  1432.   # *
  1433.   #--------------------------------------------------------------------------
  1434.   def screen_x
  1435.     return 0
  1436.   end
  1437.   #--------------------------------------------------------------------------
  1438.   # *
  1439.   #--------------------------------------------------------------------------
  1440.   def screen_y
  1441.     return 0
  1442.   end
  1443.   #--------------------------------------------------------------------------
  1444.   # *
  1445.   #--------------------------------------------------------------------------
  1446.   def character_hue
  1447.     hue
  1448.   end
  1449. end

  1450. #==============================================================================
  1451. # ** Game_Enemy
  1452. #------------------------------------------------------------------------------
  1453. #  This class handles enemy characters. It's used within the Game_Troop class
  1454. # ($game_troop).
  1455. #==============================================================================

  1456. class Game_Enemy < Game_Battler
  1457.   #--------------------------------------------------------------------------
  1458.   # *
  1459.   #--------------------------------------------------------------------------
  1460.   alias :perform_collapse_effect_ve_animated_battle :perform_collapse_effect
  1461.   def perform_collapse_effect
  1462.     reset_pose
  1463.     perform_collapse_effect_ve_animated_battle
  1464.   end
  1465.   #--------------------------------------------------------------------------
  1466.   # *
  1467.   #--------------------------------------------------------------------------
  1468.   def perform_damage_effect
  1469.     Sound.play_enemy_damage
  1470.   end
  1471.   #--------------------------------------------------------------------------
  1472.   # *
  1473.   #--------------------------------------------------------------------------
  1474.   def character_name
  1475.     @battler_name
  1476.   end
  1477.   #--------------------------------------------------------------------------
  1478.   # *
  1479.   #--------------------------------------------------------------------------
  1480.   def character_hue
  1481.     @battler_hue
  1482.   end
  1483.   #--------------------------------------------------------------------------
  1484.   # *
  1485.   #--------------------------------------------------------------------------
  1486.   def character_index
  1487.     0
  1488.   end
  1489.   #--------------------------------------------------------------------------
  1490.   # *
  1491.   #--------------------------------------------------------------------------
  1492.   def visual_items
  1493.     [default_part]
  1494.   end
  1495.   #--------------------------------------------------------------------------
  1496.   # *
  1497.   #--------------------------------------------------------------------------
  1498.   def default_part
  1499.     {name: character_name.dup, index1: character_index, index2: character_index,
  1500.      hue: character_hue, priority: 0}
  1501.   end
  1502.   #--------------------------------------------------------------------------
  1503.   # *
  1504.   #--------------------------------------------------------------------------
  1505.   def default_direction
  1506.     units = opponents_unit.battle_members
  1507.     x = units.collect {|member| member.screen_x }.average
  1508.     y = units.collect {|member| member.screen_y }.average
  1509.     target_direction(x, y, {x: screen_x, y: screen_y})
  1510.   end
  1511. end

  1512. #==============================================================================
  1513. # ** Game_Party
  1514. #------------------------------------------------------------------------------
  1515. #  This class handles the party. It includes information on amount of gold
  1516. # and items. The instance of this class is referenced by $game_party.
  1517. #==============================================================================

  1518. class Game_Party < Game_Unit
  1519.   #--------------------------------------------------------------------------
  1520.   # *
  1521.   #--------------------------------------------------------------------------
  1522.   def not_in_position?
  1523.     movable_members.any? {|member| member.not_in_position? }
  1524.   end
  1525.   #--------------------------------------------------------------------------
  1526.   # *
  1527.   #--------------------------------------------------------------------------
  1528.   def moving?
  1529.     movable_members.any? {|member| member.moving? }
  1530.   end
  1531. end

  1532. #==============================================================================
  1533. # ** Game_Troop
  1534. #------------------------------------------------------------------------------
  1535. #  This class handles enemy groups and battle-related data. Also performs
  1536. # battle events. The instance of this class is referenced by $game_troop.
  1537. #==============================================================================

  1538. class Game_Troop < Game_Unit
  1539.   #--------------------------------------------------------------------------
  1540.   # *
  1541.   #--------------------------------------------------------------------------
  1542.   attr_accessor :back_attack
  1543. end

  1544. #==============================================================================
  1545. # ** Sprite_Battler
  1546. #------------------------------------------------------------------------------
  1547. #  This sprite is used to display battlers. It observes a instance of the
  1548. # Game_Battler class and automatically changes sprite conditions.
  1549. #==============================================================================

  1550. class Sprite_Battler < Sprite_Base
  1551.   #--------------------------------------------------------------------------
  1552.   # *
  1553.   #--------------------------------------------------------------------------
  1554.   attr_accessor :battler
  1555.   #--------------------------------------------------------------------------
  1556.   # *
  1557.   #--------------------------------------------------------------------------
  1558.   alias :initialize_ve_animated_battle :initialize
  1559.   def initialize(viewport, battler = nil)
  1560.     initialize_ve_animated_battle(viewport, battler)
  1561.     init_variables
  1562.   end
  1563.   #--------------------------------------------------------------------------
  1564.   # *
  1565.   #--------------------------------------------------------------------------
  1566.   alias :update_effect_ve_animated_battle :update_effect
  1567.   def update_effect
  1568.     setup_collapse
  1569.     update_effect_ve_animated_battle
  1570.     update_pose
  1571.     update_pose_loop_anim if $imported[:ve_loop_animation]
  1572.   end
  1573.   #--------------------------------------------------------------------------
  1574.   # *
  1575.   #--------------------------------------------------------------------------
  1576.   alias :revert_to_normal_ve_animated_battle :revert_to_normal
  1577.   def revert_to_normal
  1578.     revert_to_normal_ve_animated_battle
  1579.     update_rect if bitmap
  1580.   end
  1581.   #--------------------------------------------------------------------------
  1582.   # *
  1583.   #--------------------------------------------------------------------------
  1584.   def setup_collapse
  1585.     if @battler.dead? && !@dead
  1586.       @battler.perform_collapse_effect
  1587.       @dead = true
  1588.     elsif @dead && !@battler.dead?
  1589.       @dead = false
  1590.     end
  1591.   end
  1592.   #--------------------------------------------------------------------------
  1593.   # *
  1594.   #--------------------------------------------------------------------------
  1595.   def update_bitmap
  1596.     setup_bitmap if graphic_changed?
  1597.   end
  1598.   #--------------------------------------------------------------------------
  1599.   # *
  1600.   #--------------------------------------------------------------------------
  1601.   def init_visibility
  1602.     @battler_visible = !@battler.hidden?
  1603.     self.opacity = 0 unless @battler_visible
  1604.   end
  1605.   #--------------------------------------------------------------------------
  1606.   # *
  1607.   #--------------------------------------------------------------------------
  1608.   def init_variables
  1609.     @frame = 0
  1610.     @sufix = ""
  1611.     @pose_sufix = ""
  1612.     @anim_sufix = VE_SPRITE_SUFIX
  1613.     @frame_width  = 0
  1614.     @frame_height = 0
  1615.     @pose_value   = {}
  1616.     @icon_list    = {}
  1617.     @throw_list   = []
  1618.     start_effect(:appear) if VE_BATTLE_INTRO_FADE && !@battler.hidden?
  1619.     @battler.clear_poses
  1620.     setup_positions
  1621.   end
  1622.   #--------------------------------------------------------------------------
  1623.   # *
  1624.   #--------------------------------------------------------------------------
  1625.   def subject
  1626.     @pose_battler ? @pose_battler : @battler
  1627.   end
  1628.   #--------------------------------------------------------------------------
  1629.   # *
  1630.   #--------------------------------------------------------------------------
  1631.   def sprite_value(value)
  1632.     @battler.sprite_value(value)
  1633.   end
  1634.   #--------------------------------------------------------------------------
  1635.   # *
  1636.   #--------------------------------------------------------------------------
  1637.   def graphic_changed?
  1638.     actor_name_change? || battler_name_change? || misc_change?
  1639.   end
  1640.   #--------------------------------------------------------------------------
  1641.   # *
  1642.   #--------------------------------------------------------------------------
  1643.   def actor_name_change?
  1644.     use_charset? && (@battler_name != @battler.character_name ||
  1645.     @battler_index != @battler.character_index ||
  1646.     @battler_hue   != @battler.character_hue)
  1647.   end
  1648.   #--------------------------------------------------------------------------
  1649.   # *
  1650.   #--------------------------------------------------------------------------
  1651.   def battler_name_change?
  1652.     !use_charset? && (@battler_name != @battler.battler_name ||
  1653.     @battler_hue  != @battler.battler_hue)
  1654.   end
  1655.   #--------------------------------------------------------------------------
  1656.   # *
  1657.   #--------------------------------------------------------------------------
  1658.   def misc_change?
  1659.     (visual_equip? && @visual_items != @battler.visual_items) ||
  1660.     @sufix != @battler.sufix || @direction != @battler.direction
  1661.   end
  1662.   #--------------------------------------------------------------------------
  1663.   # *
  1664.   #--------------------------------------------------------------------------
  1665.   def use_charset?
  1666.     sprite_value(:mode) == :charset
  1667.   end
  1668.   #--------------------------------------------------------------------------
  1669.   # *
  1670.   #--------------------------------------------------------------------------
  1671.   def visual_equip?
  1672.     $imported[:ve_visual_equip]
  1673.   end
  1674.   #--------------------------------------------------------------------------
  1675.   # *
  1676.   #--------------------------------------------------------------------------
  1677.   def setup_bitmap
  1678.     if use_charset?
  1679.       @battler_name  = @battler.character_name
  1680.       @battler_hue   = @battler.character_hue
  1681.       @battler_index = @battler.character_index
  1682.     else
  1683.       @battler_name  = @battler.battler_name
  1684.       @battler_hue   = @battler.battler_hue
  1685.     end
  1686.     @sufix        = @battler.sufix
  1687.     @direction    = @battler.direction
  1688.     @visual_items = @battler.visual_items.dup if visual_equip?
  1689.     init_bitmap
  1690.     init_frame
  1691.     init_visibility
  1692.   end
  1693.   #--------------------------------------------------------------------------
  1694.   # *
  1695.   #--------------------------------------------------------------------------
  1696.   def init_bitmap
  1697.     case sprite_value(:mode)
  1698.     when :charset
  1699.       if visual_equip?
  1700.         args = [@battler_name, @battler_hue, @visual_items, sufix]
  1701.         self.bitmap = Cache.character(*args)
  1702.       else
  1703.         self.bitmap = Cache.character(get_character_name, @battler_hue)
  1704.       end
  1705.     when :single
  1706.       self.bitmap = Cache.battler(get_battler_name, @battler_hue)
  1707.     when :sprite
  1708.       self.bitmap = Cache.battler(get_battler_name, @battler_hue)
  1709.     else
  1710.       self.bitmap = Cache.battler(@battler_name, @battler_hue)
  1711.     end
  1712.   end
  1713.   #--------------------------------------------------------------------------
  1714.   # *
  1715.   #--------------------------------------------------------------------------
  1716.   def sufix
  1717.     case sprite_value(:mode)
  1718.     when :charset then @sufix
  1719.     when :sprite  then @anim_sufix + @sufix
  1720.     else @sufix
  1721.     end
  1722.   end
  1723.   #--------------------------------------------------------------------------
  1724.   # *
  1725.   #--------------------------------------------------------------------------
  1726.   def get_battler_name
  1727.     name = @battler_name + sufix
  1728.     battler_exist?(name) ? name : @battler_name
  1729.   end
  1730.   #--------------------------------------------------------------------------
  1731.   # *
  1732.   #--------------------------------------------------------------------------
  1733.   def get_character_name
  1734.     name = @battler_name + sufix
  1735.     character_exist?(name) ? name : @battler_name
  1736.   end
  1737.   #--------------------------------------------------------------------------
  1738.   # *
  1739.   #--------------------------------------------------------------------------
  1740.   def init_frame
  1741.     @frame_width  = bitmap.width  / frame_number
  1742.     @frame_height = bitmap.height / row_number
  1743.   end
  1744.   #--------------------------------------------------------------------------
  1745.   # *
  1746.   #--------------------------------------------------------------------------
  1747.   def frame_number
  1748.     return @battler.frames     if single_char?
  1749.     return @battler.frames * 4 if multi_char?
  1750.     return 1 unless battler_exist?(@battler_name + sufix)
  1751.     return sprite_value(:frames) if sprite_value(:mode) == :sprite
  1752.     return 1
  1753.   end
  1754.   #--------------------------------------------------------------------------
  1755.   # *
  1756.   #--------------------------------------------------------------------------
  1757.   def row_number
  1758.     return 4 if single_char?
  1759.     return 8 if multi_char?
  1760.     return 1 unless battler_exist?(@battler_name + sufix)
  1761.     return sprite_value(:rows) if sprite_value(:mode) == :sprite
  1762.     return 1
  1763.   end
  1764.   #--------------------------------------------------------------------------
  1765.   # *
  1766.   #--------------------------------------------------------------------------
  1767.   def single_char?
  1768.     use_charset? && (single_normal? || single_visual?)
  1769.   end
  1770.   #--------------------------------------------------------------------------
  1771.   # *
  1772.   #--------------------------------------------------------------------------
  1773.   def multi_char?
  1774.     use_charset? && (multi_normal? || multi_visual?)
  1775.   end
  1776.   #--------------------------------------------------------------------------
  1777.   # *
  1778.   #--------------------------------------------------------------------------
  1779.   def single_normal?
  1780.     !visual_equip? && @battler_name[/^[!]?[$]./]
  1781.   end
  1782.   #--------------------------------------------------------------------------
  1783.   # *
  1784.   #--------------------------------------------------------------------------
  1785.   def multi_normal?
  1786.     !visual_equip? && !@battler_name[/^[!]?[$]./]
  1787.   end
  1788.   #--------------------------------------------------------------------------
  1789.   # *
  1790.   #--------------------------------------------------------------------------
  1791.   def single_visual?
  1792.     visual_equip? && !get_sign
  1793.   end
  1794.   #--------------------------------------------------------------------------
  1795.   # *
  1796.   #--------------------------------------------------------------------------
  1797.   def multi_visual?
  1798.     visual_equip? && get_sign
  1799.   end
  1800.   #--------------------------------------------------------------------------
  1801.   # *
  1802.   #--------------------------------------------------------------------------
  1803.   def get_sign
  1804.     @visual_items.any? {|part| !part[:name][/^[!]?[$]./] }
  1805.   end
  1806.   #--------------------------------------------------------------------------
  1807.   # *
  1808.   #--------------------------------------------------------------------------
  1809.   def update_origin
  1810.     update_rect if bitmap
  1811.     update_icon
  1812.     update_throw
  1813.   end
  1814.   #--------------------------------------------------------------------------
  1815.   # *
  1816.   #--------------------------------------------------------------------------
  1817.   def update_rect
  1818.     setup_frame
  1819.     setup_rect
  1820.     self.ox = @frame_width / 2
  1821.     self.oy = @frame_height
  1822.     self.mirror = pose_mirror
  1823.   end
  1824.   #--------------------------------------------------------------------------
  1825.   # *
  1826.   #--------------------------------------------------------------------------
  1827.   def pose_mirror
  1828.     mirror = sprite_value(:invert)
  1829.     return !mirror if right? && sprite_value(:mirror)
  1830.     return  mirror
  1831.   end
  1832.   #--------------------------------------------------------------------------
  1833.   # *
  1834.   #--------------------------------------------------------------------------
  1835.   def down?
  1836.     @battler.down?
  1837.   end
  1838.   #--------------------------------------------------------------------------
  1839.   # *
  1840.   #--------------------------------------------------------------------------
  1841.   def left?
  1842.     @battler.left?
  1843.   end
  1844.   #--------------------------------------------------------------------------
  1845.   # *
  1846.   #--------------------------------------------------------------------------
  1847.   def right?
  1848.     @battler.right?
  1849.   end
  1850.   #--------------------------------------------------------------------------
  1851.   # *
  1852.   #--------------------------------------------------------------------------
  1853.   def up?
  1854.     @battler.up?
  1855.   end
  1856.   #--------------------------------------------------------------------------
  1857.   # *
  1858.   #--------------------------------------------------------------------------
  1859.   def setup_frame
  1860.     return if @battler.timing.empty?
  1861.     value = @battler.timing
  1862.     value[:time] -= 1
  1863.     value[:time] = value[:wait] if value[:time] == 0
  1864.     return if value[:time] != value[:wait]
  1865.     max = value[:frame] == :all ? sprite_value(:frames) : value[:frame]
  1866.     @frame += 1
  1867.     if value[:loop]
  1868.       @battler.frame = returing_value(@frame, max - 1)
  1869.     else
  1870.       @frame %= max
  1871.       @battler.frame = value[:revert] ? max - 1 - @frame : @frame
  1872.       reset_frame if @frame >= max - 1 || @frame == 0
  1873.     end
  1874.   end
  1875.   #--------------------------------------------------------------------------
  1876.   # *
  1877.   #--------------------------------------------------------------------------
  1878.   def reset_frame
  1879.     @battler.timing = {}
  1880.     @frame = 0           
  1881.   end
  1882.   #--------------------------------------------------------------------------
  1883.   # *
  1884.   #--------------------------------------------------------------------------
  1885.   def setup_rect
  1886.     sign =  @battler_name[/^[$]./]
  1887.     if use_charset? && !sign
  1888.       index = @battler_index
  1889.       frame = (index % 4 * @battler.frames + @battler.frame) * @frame_width
  1890.       row   = (index / 4 * 4 + @battler.row) * @frame_height
  1891.     else
  1892.       frame = [[@battler.frame, 0].max, frame_number - 1].min * @frame_width
  1893.       row   = [[@battler.row,   0].max,   row_number - 1].min * @frame_height
  1894.     end
  1895.     self.src_rect.set(frame, row, @frame_width, @frame_height)
  1896.   end  
  1897.   #--------------------------------------------------------------------------
  1898.   # *
  1899.   #--------------------------------------------------------------------------
  1900.   def update_pose
  1901.     setup_pose
  1902.     update_next_pose
  1903.   end
  1904.   #--------------------------------------------------------------------------
  1905.   # *
  1906.   #--------------------------------------------------------------------------
  1907.   def update_next_pose
  1908.     next_pose unless @pose
  1909.     return if !@pose || !@pose[:type].is_a?(Symbol)
  1910.     update_pose_type
  1911.     next_pose unless @waiting
  1912.   end
  1913.   #--------------------------------------------------------------------------
  1914.   # *
  1915.   #--------------------------------------------------------------------------
  1916.   def setup_pose
  1917.     @current_pose = pose_list.first
  1918.     return unless @current_pose
  1919.     @battler.icon_list.clear if changed_pose?
  1920.     @frame  = 0 if changed_pose?
  1921.     battler = @current_pose[:battler]
  1922.     @pose_battler = battler unless battler == :skip
  1923.     @pose_value   = @current_pose[:value]
  1924.     @pose = @pose_value.first
  1925.   end
  1926.   #--------------------------------------------------------------------------
  1927.   # *
  1928.   #--------------------------------------------------------------------------
  1929.   def changed_pose?
  1930.     @pose_value != @current_pose[:value]
  1931.   end
  1932.   #--------------------------------------------------------------------------
  1933.   # *
  1934.   #--------------------------------------------------------------------------
  1935.   def pose_list
  1936.     @battler.pose_list
  1937.   end
  1938.   #--------------------------------------------------------------------------
  1939.   # *
  1940.   #--------------------------------------------------------------------------
  1941.   def update_pose_type
  1942.     @waiting = false
  1943.     return if @pose[:hit]  && @battler.result_flag != :hit
  1944.     return if @pose[:miss] && @battler.result_flag != :miss
  1945.     eval("update_pose_#{@pose[:type]}")  #rescue ""
  1946.   end
  1947.   #--------------------------------------------------------------------------
  1948.   # *
  1949.   #--------------------------------------------------------------------------
  1950.   def next_pose
  1951.     return unless @current_pose
  1952.     case @current_pose[:next]
  1953.     when :loop
  1954.       @pose_value.next_item
  1955.     when :reset
  1956.       @pose_value.shift
  1957.       reset_pose if @pose_value.empty?
  1958.     when Symbol
  1959.       @pose_value.shift
  1960.       @battler.call_pose(@current_pose[:next]) if @pose_value.empty?
  1961.     else
  1962.       last_value = @pose_value.shift
  1963.     end
  1964.     @pose_value.unshift(last_value) if @pose_value.empty? && pose_list.empty?
  1965.     @battler.pose_list.shift if @pose_value.empty?
  1966.   end
  1967.   #--------------------------------------------------------------------------
  1968.   # *
  1969.   #--------------------------------------------------------------------------
  1970.   def update_pose_wait
  1971.     case @pose[:time]
  1972.     when :animation
  1973.       @waiting = SceneManager.scene.spriteset.animation?
  1974.     when :action
  1975.       @waiting = SceneManager.scene.spriteset.action?(subject)
  1976.     when :movement
  1977.       @waiting = get_target.any? {|target| target.moving? }
  1978.     when :origin
  1979.       @waiting = get_target.any? {|target| target.origin? }
  1980.     when :counter
  1981.       @waiting = get_target.any? {|target| target.countered }
  1982.     when :substitution
  1983.       @waiting = get_target.any? {|target| target.substitution }
  1984.     when :tone
  1985.       @waiting = $game_troop.screen.tone_change?
  1986.     when :throw
  1987.       @waiting = throwing?
  1988.     else
  1989.       @pose[:time] -= 1
  1990.       @pose[:time] = @pose[:wait] if @pose[:time] == 0
  1991.       @waiting = @pose[:time] != @pose[:wait]
  1992.     end
  1993.   end
  1994.   #--------------------------------------------------------------------------
  1995.   # *
  1996.   #--------------------------------------------------------------------------
  1997.   def update_pose_clear
  1998.     battler.pose_list.clear
  1999.   end
  2000.   #--------------------------------------------------------------------------
  2001.   # *
  2002.   #--------------------------------------------------------------------------
  2003.   def update_pose_action
  2004.     get_target.each do |target|
  2005.       target.clear_idle_poses
  2006.       target.call_pose(@pose[:action], :clear, @battler.current_item, @battler)
  2007.     end
  2008.   end
  2009.   #--------------------------------------------------------------------------
  2010.   # *
  2011.   #--------------------------------------------------------------------------
  2012.   def update_pose_anim
  2013.     subject.targets = get_target
  2014.     subject.call_anim = true
  2015.     subject.animation = @pose[:anim]
  2016.   end
  2017.   #--------------------------------------------------------------------------
  2018.   # *
  2019.   #--------------------------------------------------------------------------
  2020.   def update_pose_effect
  2021.     subject.call_effect = true
  2022.     subject.attack_flag = @pose[:weapon]
  2023.     subject.damage_flag = @pose[:damage]
  2024.     subject.target_flag = @pose[:target] ? @pose[:target] : subject.targets
  2025.   end
  2026.   #--------------------------------------------------------------------------
  2027.   # *
  2028.   #--------------------------------------------------------------------------
  2029.   def update_pose_loop
  2030.     get_target.each {|target| target.pose_loop_anim = @pose[:loop_anim] }
  2031.   end
  2032.   #--------------------------------------------------------------------------
  2033.   # *
  2034.   #--------------------------------------------------------------------------
  2035.   def update_pose_reset
  2036.     @battler.actions[0] = @battler.previous_action if @pose[:action]
  2037.     reset_pose if @pose[:pose]
  2038.   end
  2039.   #--------------------------------------------------------------------------
  2040.   # *
  2041.   #--------------------------------------------------------------------------
  2042.   def update_pose_plane
  2043.     if @pose[:delete]
  2044.       SceneManager.scene.spriteset.delete_plane(@pose[:duration])
  2045.     elsif @pose[:list]
  2046.       SceneManager.scene.spriteset.action_plane(*@pose[:list])
  2047.     end
  2048.   end
  2049.   #--------------------------------------------------------------------------
  2050.   # *
  2051.   #--------------------------------------------------------------------------
  2052.   def update_pose_sound
  2053.     se = RPG::SE.new(@pose[:name], @pose[:volume], @pose[:pitch])
  2054.     se.play
  2055.   end
  2056.   #--------------------------------------------------------------------------
  2057.   # *
  2058.   #--------------------------------------------------------------------------
  2059.   def update_pose_pose
  2060.     get_target.each do |target|
  2061.       target.row    = @pose[:row] - 1           if @pose[:row].is_a?(Numeric)
  2062.       target.row    = target.direction / 2  - 1 if @pose[:row].is_a?(Symbol)
  2063.       target.sufix  = @pose[:sufix]
  2064.       target.angle  = @pose[:angle]
  2065.       target.spin   = @pose[:spin]
  2066.       target.x_adj  = @pose[:x]
  2067.       target.y_adj  = @pose[:y]
  2068.       target.timing = @pose[:pose]
  2069.       target.frame  = @pose[:frame] - 1
  2070.       target.frame  %= target.sprite_value(:frames)
  2071.     end
  2072.   end
  2073.   #--------------------------------------------------------------------------
  2074.   # *
  2075.   #--------------------------------------------------------------------------
  2076.   def update_pose_move
  2077.     get_target.each do |target|
  2078.       target.teleport = @pose[:teleport]
  2079.       setup_target_position(target)
  2080.       target.target_position[:x] += target.left? ? @pose[:x] : -@pose[:x]
  2081.       target.target_position[:y] += target.down? ? @pose[:y] : -@pose[:y]
  2082.       target.target_position[:h] += @pose[:h]
  2083.       target.move_speed = @pose[:speed]
  2084.     end
  2085.   end
  2086.   #--------------------------------------------------------------------------
  2087.   # *
  2088.   #--------------------------------------------------------------------------
  2089.   def update_pose_counter
  2090.     get_target.each {|target| target.countered = @pose[:counter] }
  2091.   end
  2092.   #--------------------------------------------------------------------------
  2093.   # *
  2094.   #--------------------------------------------------------------------------
  2095.   def update_pose_substitution
  2096.     get_target.each {|target| target.substitution = @pose[:substitution] }
  2097.   end
  2098.   #--------------------------------------------------------------------------
  2099.   # *
  2100.   #--------------------------------------------------------------------------
  2101.   def update_pose_jump
  2102.     get_target.each do |target|
  2103.       if @pose[:move]
  2104.         x_plus = (target.target_distance(:x) / 32.0).abs
  2105.         y_plus = (target.target_distance(:y) / 32.0).abs
  2106.         speed = Math.sqrt((x_plus ** 2) + (y_plus ** 2)) / @battler.move_speed
  2107.         target.jumping[:speed] = @pose[:height] * 5.0 / [speed, 1].max
  2108.       else
  2109.         target.jumping[:speed] = @pose[:speed]
  2110.       end
  2111.       target.jumping[:height] = @pose[:height]
  2112.       target.jumping[:count]  = target.jumping[:height] * 2  
  2113.     end   
  2114.   end
  2115.   #--------------------------------------------------------------------------
  2116.   # *
  2117.   #--------------------------------------------------------------------------
  2118.   def update_pose_inactive
  2119.     subject.deactivate
  2120.   end
  2121.   #--------------------------------------------------------------------------
  2122.   # *
  2123.   #--------------------------------------------------------------------------
  2124.   def update_pose_direction
  2125.     dir = [subject.screen_x, subject.screen_y]
  2126.     subject.target_direction(*dir) if @pose[:return]
  2127.     subject.action_direction       if @pose[:targets]
  2128.     subject.direction = @pose[:direction] if @pose[:direction]
  2129.   end
  2130.   #--------------------------------------------------------------------------
  2131.   # *
  2132.   #--------------------------------------------------------------------------
  2133.   def update_pose_icon
  2134.     get_target.each do |target|
  2135.       if @pose[:delete]
  2136.         target.icon_list.delete(@pose[:index])
  2137.       else
  2138.         target.icon_list[@pose[:index]] = @pose.dup
  2139.       end
  2140.       target.sprite.update_icon
  2141.     end
  2142.   end
  2143.   #--------------------------------------------------------------------------
  2144.   # *
  2145.   #--------------------------------------------------------------------------
  2146.   def update_pose_picture
  2147.     if @pose[:show]
  2148.       $game_troop.screen.pictures[@pose[:id]].show(*@pose[:show])
  2149.     elsif @pose[:move]
  2150.       $game_troop.screen.pictures[@pose[:id]].move(*@pose[:move])
  2151.     elsif @pose[:delete]
  2152.      $game_troop.screen.pictures[@pose[:id]].erase
  2153.     end
  2154.   end
  2155.   #--------------------------------------------------------------------------
  2156.   # *
  2157.   #--------------------------------------------------------------------------
  2158.   def update_pose_throw
  2159.     get_target.each do |target|
  2160.       value = @pose.dup
  2161.       value[:user] = subject.sprite
  2162.       target.throw_list.push(value.dup)
  2163.       target.sprite.update_throw
  2164.     end   
  2165.   end
  2166.   #--------------------------------------------------------------------------
  2167.   # *
  2168.   #--------------------------------------------------------------------------
  2169.   def update_pose_shake
  2170.     if @pose[:screen]
  2171.       $game_troop.screen.start_shake(*@pose[:shake])
  2172.     else
  2173.       get_target.each {|target| target.start_shake(*@pose[:shake]) }
  2174.     end
  2175.   end
  2176.   #--------------------------------------------------------------------------
  2177.   # *
  2178.   #--------------------------------------------------------------------------
  2179.   def update_pose_flash
  2180.     if @pose[:screen]
  2181.       $game_troop.screen.start_flash(*@pose[:flash])
  2182.     else
  2183.       get_target.each {|target| target.sprite.flash(*@pose[:flash]) }
  2184.     end
  2185.   end
  2186.   #--------------------------------------------------------------------------
  2187.   # *
  2188.   #--------------------------------------------------------------------------
  2189.   def update_pose_movie
  2190.     Graphics.play_movie('Movies/' + @pose[:name]) if @pose[:name] != ""
  2191.     update_pose_tone
  2192.   end
  2193.   #--------------------------------------------------------------------------
  2194.   # *
  2195.   #--------------------------------------------------------------------------
  2196.   def update_pose_tone
  2197.     eval("update_#{@pose[:priority]}_tone")
  2198.   end
  2199.   #--------------------------------------------------------------------------
  2200.   # *
  2201.   #--------------------------------------------------------------------------
  2202.   def update_low_tone
  2203.     screen = $game_troop.screen
  2204.     screen.old_low_tone = screen.low_tone.dup unless screen.old_low_tone
  2205.     tone = @pose[:clear] ? screen.old_low_tone : @pose[:tone]
  2206.     $game_troop.screen.old_low_tone = nil if @pose[:clear]
  2207.     $game_troop.screen.start_low_tone_change(tone, @pose[:duration])
  2208.   end
  2209.   #--------------------------------------------------------------------------
  2210.   # *
  2211.   #--------------------------------------------------------------------------
  2212.   def update_normal_tone
  2213.     screen = $game_troop.screen
  2214.     screen.old_tone = screen.tone.dup unless screen.old_tone
  2215.     tone = @pose[:clear] ? $game_troop.screen.old_tone : @pose[:tone]
  2216.     $game_troop.screen.old_tone = nil if @pose[:clear]
  2217.     $game_troop.screen.start_tone_change(tone, @pose[:duration])
  2218.   end
  2219.   #--------------------------------------------------------------------------
  2220.   # *
  2221.   #--------------------------------------------------------------------------  
  2222.   def update_high_tone
  2223.     screen = $game_troop.screen
  2224.     screen.old_high_tone = screen.high_tone.dup unless screen.old_high_tone
  2225.     tone = @pose[:clear] ? screen.old_high_tone : @pose[:tone]
  2226.     $game_troop.screen.old_high_tone = nil if @pose[:clear]
  2227.     $game_troop.screen.start_high_tone_change(tone, @pose[:duration])
  2228.   end
  2229.   #--------------------------------------------------------------------------
  2230.   # *
  2231.   #--------------------------------------------------------------------------
  2232.   def setup_target_position(target)
  2233.     return unless @battler.use_sprite?
  2234.     if @pose[:value] == :move_to
  2235.       setup_move_to_target_position(target)
  2236.     elsif @pose[:value] == :step_foward
  2237.       setup_step_foward_position(target)
  2238.     elsif @pose[:value] == :step_backward
  2239.       setup_step_backward_position(target)
  2240.     elsif @pose[:value] == :escape
  2241.       setup_escape_position(target)
  2242.     elsif @pose[:value] == :retreat
  2243.       setup_retreat_position(target)
  2244.     end
  2245.     target.position_fix while target.sharing_position?
  2246.     target.target_position = target.current_position.dup if target.unmovable?
  2247.   end
  2248.   #--------------------------------------------------------------------------
  2249.   # *
  2250.   #--------------------------------------------------------------------------
  2251.   def setup_move_to_target_position(target)
  2252.     targets = @pose[:targets].select {|member| member.use_sprite? }
  2253.     return if targets.empty?
  2254.     return @waiting = true if targets.any? {|member| member.moving?}
  2255.     x = targets.collect {|member| member.current_position[:x]}.average
  2256.     y = targets.collect {|member| member.current_position[:y]}.average
  2257.     target.target_direction(x, y)
  2258.     y -= 32 if down?
  2259.     x += 32 if left?
  2260.     x -= 32 if right?
  2261.     y += 32 if up?
  2262.     target.target_position[:x] = x
  2263.     target.target_position[:y] = y
  2264.   end
  2265.   #--------------------------------------------------------------------------
  2266.   # *
  2267.   #--------------------------------------------------------------------------
  2268.   def setup_step_foward_position(target)
  2269.     target.target_position[:y] += 48 if down?
  2270.     target.target_position[:x] -= 48 if left?
  2271.     target.target_position[:x] += 48 if right?
  2272.     target.target_position[:y] -= 48 if up?
  2273.   end
  2274.   #--------------------------------------------------------------------------
  2275.   # *
  2276.   #--------------------------------------------------------------------------
  2277.   def setup_step_backward_position(target)
  2278.     target.target_position[:y] -= 48 if down?
  2279.     target.target_position[:x] += 48 if left?
  2280.     target.target_position[:x] -= 48 if right?
  2281.     target.target_position[:y] += 48 if up?
  2282.   end
  2283.   #--------------------------------------------------------------------------
  2284.   # *
  2285.   #--------------------------------------------------------------------------
  2286.   def setup_escape_position(target)
  2287.     target.target_position[:y] -= 240 if down?
  2288.     target.target_position[:x] += 240 if left?
  2289.     target.target_position[:x] -= 240 if right?
  2290.     target.target_position[:y] += 240 if up?
  2291.     position = target.target_position
  2292.     target.target_direction(position[:x], position[:y])
  2293.   end
  2294.   #--------------------------------------------------------------------------
  2295.   # *
  2296.   #--------------------------------------------------------------------------
  2297.   def setup_retreat_position(target)
  2298.     return if target.target_position[:x] == target.screen_x &&
  2299.               target.target_position[:y] == target.screen_y
  2300.     target.target_position[:x] = target.screen_x
  2301.     target.target_position[:y] = target.screen_y
  2302.     position = target.target_position
  2303.     target.target_direction(position[:x], position[:y])
  2304.   end  
  2305.   #--------------------------------------------------------------------------
  2306.   # *
  2307.   #--------------------------------------------------------------------------
  2308.   def reset_pose
  2309.     idle_pose = @battler.pose_name
  2310.     next_pose = get_idle_pose
  2311.     @frame = 0
  2312.     @battler.default_direction
  2313.     @battler.clear_idle_poses
  2314.     @battler.call_pose(next_pose)
  2315.     setup_pose
  2316.   end
  2317.   #--------------------------------------------------------------------------
  2318.   # *
  2319.   #--------------------------------------------------------------------------
  2320.   def get_idle_pose
  2321.     pose = :idle
  2322.     pose = :danger if @battler.danger?
  2323.     pose = @battler.state_pose  if @battler.state_pose?
  2324.     pose = :guard  if @battler.guard?
  2325.     pose = @battler.active_pose if @battler.active_pose
  2326.     pose = :dead   if @battler.dead?
  2327.     pose
  2328.   end
  2329.   #--------------------------------------------------------------------------
  2330.   # *
  2331.   #--------------------------------------------------------------------------
  2332.   def get_target
  2333.     @pose[:target] ? @pose[:target] : [subject]
  2334.   end
  2335.   #--------------------------------------------------------------------------
  2336.   # *
  2337.   #--------------------------------------------------------------------------
  2338.   def setup_positions
  2339.     positions = {x: @battler.screen_x, y: @battler.screen_y, h: 0, j: 0}
  2340.     @battler.target_position  = positions.dup
  2341.     @battler.current_position = positions.dup
  2342.     @battler.default_position = positions.dup
  2343.     @battler.jumping = {count: 0, height: 0, speed: 10}
  2344.     reset_pose
  2345.   end
  2346.   #--------------------------------------------------------------------------
  2347.   # *
  2348.   #--------------------------------------------------------------------------
  2349.   def position
  2350.     @battler.current_position
  2351.   end
  2352.   #--------------------------------------------------------------------------
  2353.   # *
  2354.   #--------------------------------------------------------------------------
  2355.   def update_position
  2356.     update_misc
  2357.     update_movement
  2358.     update_jumping
  2359.     self.x = position[:x] + adjust_x
  2360.     self.y = position[:y] + adjust_y - position[:h] - position[:j]
  2361.     self.z = position[:y] + (@battler.active? ? 2 : 1)
  2362.     self.angle  = @battler.angle if angle != @battler.angle
  2363.     self.angle += @battler.spin
  2364.   end
  2365.   #--------------------------------------------------------------------------
  2366.   # *
  2367.   #--------------------------------------------------------------------------
  2368.   def update_misc
  2369.     @battler.update_shake
  2370.     @battler.update_freeze
  2371.   end
  2372.   #--------------------------------------------------------------------------
  2373.   # *
  2374.   #--------------------------------------------------------------------------
  2375.   def adjust_x
  2376.     @battler.x_adj + [1, -1].random * rand(@battler.shake + 1)
  2377.   end
  2378.   #--------------------------------------------------------------------------
  2379.   # *
  2380.   #--------------------------------------------------------------------------
  2381.   def adjust_y
  2382.     @battler.y_adj + [1, -1].random * rand(@battler.shake + 1)
  2383.   end
  2384.   #--------------------------------------------------------------------------
  2385.   # *
  2386.   #--------------------------------------------------------------------------
  2387.   def update_movement
  2388.     return if @battler.frozen? || !@battler.moving?
  2389.     @battler.teleport ? update_teleport_movement : update_normal_movement
  2390.   end
  2391.   #--------------------------------------------------------------------------
  2392.   # *
  2393.   #--------------------------------------------------------------------------
  2394.   def update_teleport_movement
  2395.     @battler.current_position[:x] = @battler.target_position[:x]
  2396.     @battler.current_position[:y] = @battler.target_position[:y]
  2397.     @battler.current_position[:h] = [@battler.target_position[:h], 0].max
  2398.     @battler.teleport = false
  2399.   end
  2400.   #--------------------------------------------------------------------------
  2401.   # *
  2402.   #--------------------------------------------------------------------------
  2403.   def update_normal_movement
  2404.     distance = set_distance
  2405.     move     = {x: 1.0, y: 1.0, h: 1.0}
  2406.     if distance[:x].abs < distance[:y].abs
  2407.       move[:x] = 1.0 / (distance[:y].abs.to_f / distance[:x].abs)
  2408.     elsif distance[:y].abs < distance[:x].abs
  2409.       move[:y] = 1.0 / (distance[:x].abs.to_f / distance[:y].abs)
  2410.     elsif distance[:h].abs < distance[:x].abs
  2411.       move[:h] = 1.0 / (distance[:x].abs.to_f / distance[:h].abs)
  2412.     end
  2413.     speed = set_speed(distance)
  2414.     x = move[:x] * speed[:x]
  2415.     y = move[:y] * speed[:y]
  2416.     h = move[:h] * speed[:h]
  2417.     set_movement(x, y, h)
  2418.   end
  2419.   #--------------------------------------------------------------------------
  2420.   # *
  2421.   #--------------------------------------------------------------------------
  2422.   def set_distance
  2423.     x = @battler.target_distance(:x)
  2424.     y = @battler.target_distance(:y)
  2425.     h = @battler.target_distance(:h)
  2426.     {x: x, y: y, h: h}
  2427.   end
  2428.   #--------------------------------------------------------------------------
  2429.   # *
  2430.   #--------------------------------------------------------------------------
  2431.   def set_speed(distance)
  2432.     move_speed = @battler.move_speed
  2433.     x = move_speed * (distance[:x] == 0 ? 0 : (distance[:x] > 0 ? 8 : -8))
  2434.     y = move_speed * (distance[:y] == 0 ? 0 : (distance[:y] > 0 ? 8 : -8))
  2435.     h = move_speed * (distance[:h] == 0 ? 0 : (distance[:h] > 0 ? 8 : -8))
  2436.     {x: x, y: y, h: h}
  2437.   end
  2438.   #--------------------------------------------------------------------------
  2439.   # *
  2440.   #--------------------------------------------------------------------------
  2441.   def set_movement(x, y, h)
  2442.     target  = @battler.target_position
  2443.     current = @battler.current_position
  2444.     current[:x] += x
  2445.     current[:y] += y
  2446.     current[:h] += h
  2447.     current[:x] = target[:x] if in_distance?(current[:x], target[:x], x)
  2448.     current[:y] = target[:y] if in_distance?(current[:y], target[:y], y)
  2449.     current[:h] = target[:h] if in_distance?(current[:h], target[:h], h)
  2450.   end
  2451.   #--------------------------------------------------------------------------
  2452.   # *
  2453.   #--------------------------------------------------------------------------
  2454.   def in_distance?(x, y, z)
  2455.     x.between?(y - z - 1, y + z + 1)
  2456.   end
  2457.   #--------------------------------------------------------------------------
  2458.   # *
  2459.   #--------------------------------------------------------------------------
  2460.   def update_jumping
  2461.     return if @battler.jumping[:count] == 0 || @battler.frozen?
  2462.     jump = @battler.jumping
  2463.     jump[:count] = [jump[:count] - (1 * jump[:speed] / 10.0), 0].max.to_f
  2464.     count = jump[:count]
  2465.     speed = jump[:speed]
  2466.     peak  = jump[:height]
  2467.     result = (peak ** 2 - (count - peak).abs ** 2) / 2
  2468.     @battler.current_position[:j] = [result, 0].max
  2469.   end
  2470.   #--------------------------------------------------------------------------
  2471.   # *
  2472.   #--------------------------------------------------------------------------
  2473.   def update_icon
  2474.     @battler.icon_list.each do |key, value|
  2475.       icon = @icon_list[key]
  2476.       @icon_list[key] = Sprite_Icon.new(self, value) if !icon
  2477.       icon.refresh       if icon && value[:icon] != icon.icon
  2478.       icon.value = value if icon && icon.value != value
  2479.     end
  2480.     @icon_list.each do |key, value|
  2481.       value.update
  2482.       delete_icon(key) if value && !@battler.icon_list[key]
  2483.     end
  2484.   end
  2485.   #--------------------------------------------------------------------------
  2486.   # *
  2487.   #--------------------------------------------------------------------------
  2488.   def update_throw
  2489.     @battler.throw_list.each do |value|
  2490.       @throw_list.push(Sprite_Throw.new(self, value.dup))
  2491.       @battler.throw_list.delete(value)
  2492.     end
  2493.     @throw_list.each_with_index do |value, index|
  2494.       value.update
  2495.       delete_throw(index) if value.disposing?
  2496.     end
  2497.     @throw_list.compact!
  2498.   end
  2499.   #--------------------------------------------------------------------------
  2500.   # *
  2501.   #--------------------------------------------------------------------------
  2502.   def delete_icon(key)
  2503.     @icon_list[key].dispose
  2504.     @icon_list.delete(key)
  2505.   end
  2506.   #--------------------------------------------------------------------------
  2507.   # *
  2508.   #--------------------------------------------------------------------------
  2509.   def delete_throw(index)
  2510.     @throw_list[index].dispose
  2511.     @throw_list.delete_at(index)
  2512.   end
  2513.   #--------------------------------------------------------------------------
  2514.   # *
  2515.   #--------------------------------------------------------------------------
  2516.   def throwing?
  2517.     !@throw_list.empty?
  2518.   end
  2519.   #--------------------------------------------------------------------------
  2520.   # *
  2521.   #--------------------------------------------------------------------------
  2522.   def update_pose_loop_anim
  2523.     if @battler.pose_loop_anim && !loop_anim?(:pose_anim)
  2524.       @pose_name_list = @battler.pose_name_list.first
  2525.       animation = {type: :pose_anim, anim: @battler.pose_loop_anim, loop: 1}     
  2526.       add_loop_animation(animation)
  2527.     end
  2528.     if @battler.pose_loop_anim && loop_anim?(:pose_anim) &&
  2529.        @pose_name_list != @battler.pose_name_list.first
  2530.       @pose_loop_anim = nil
  2531.       @battler.pose_loop_anim = nil
  2532.       end_loop_anim(:pose_anim)
  2533.     end
  2534.   end
  2535. end

  2536. #==============================================================================
  2537. # ** Spriteset_Battle
  2538. #------------------------------------------------------------------------------
  2539. #  This class brings together battle screen sprites. It's used within the
  2540. # Scene_Battle class.
  2541. #==============================================================================

  2542. class Spriteset_Battle
  2543.   #--------------------------------------------------------------------------
  2544.   # *
  2545.   #--------------------------------------------------------------------------
  2546.   def create_actors
  2547.     @actor_sprites = $game_party.battle_members.reverse.collect do |actor|
  2548.       Sprite_Battler.new(@viewport1, actor)
  2549.     end
  2550.     @actors_party = $game_party.battle_members.dup
  2551.   end
  2552.   #--------------------------------------------------------------------------
  2553.   # *
  2554.   #--------------------------------------------------------------------------
  2555.   alias :initialize_ve_animated_battle :initialize
  2556.   def initialize
  2557.     init_action_plane
  2558.     initialize_ve_animated_battle
  2559.   end
  2560.   #--------------------------------------------------------------------------
  2561.   # *
  2562.   #--------------------------------------------------------------------------
  2563.   alias :update_ve_animated_battle :update
  2564.   def update
  2565.     update_ve_animated_battle
  2566.     update_action_plane
  2567.   end
  2568.   #--------------------------------------------------------------------------
  2569.   # *
  2570.   #--------------------------------------------------------------------------
  2571.   alias :dispose_ve_animated_battle :dispose
  2572.   def dispose
  2573.     dispose_ve_animated_battle
  2574.     dispose_action_plane
  2575.   end
  2576.   #--------------------------------------------------------------------------
  2577.   # *
  2578.   #--------------------------------------------------------------------------
  2579.   alias :create_pictures_ve_animated_battle :create_pictures
  2580.   def create_pictures
  2581.     battler_sprites.each {|battler| battler.setup_positions }
  2582.     create_pictures_ve_animated_battle
  2583.   end
  2584.   #--------------------------------------------------------------------------
  2585.   # *
  2586.   #--------------------------------------------------------------------------
  2587.   alias :create_viewports_ve_animated_battle :create_viewports
  2588.   def create_viewports
  2589.     create_viewports_ve_animated_battle
  2590.     @viewport4 = Viewport.new
  2591.     @viewport4.z = 200
  2592.   end
  2593.   #--------------------------------------------------------------------------
  2594.   # *
  2595.   #--------------------------------------------------------------------------
  2596.   alias :update_viewports_ve_animated_battle :update_viewports
  2597.   def update_viewports
  2598.     update_viewports_ve_animated_battle
  2599.     @viewport1.ox = [1, -1].random * rand($game_troop.screen.shake)
  2600.     @viewport1.oy = [1, -1].random * rand($game_troop.screen.shake)
  2601.     @back1_sprite.tone.set($game_troop.screen.low_tone)
  2602.     @back2_sprite.tone.set($game_troop.screen.low_tone)
  2603.     @viewport4.tone.set($game_troop.screen.high_tone)
  2604.   end
  2605.   #--------------------------------------------------------------------------
  2606.   # *
  2607.   #--------------------------------------------------------------------------
  2608.   def action?(subject)
  2609.     battler_sprites.compact.any? do |sprite|
  2610.       sprite.subject == subject && sprite.battler != subject
  2611.     end
  2612.   end
  2613.   #--------------------------------------------------------------------------
  2614.   # *
  2615.   #--------------------------------------------------------------------------
  2616.   def init_action_plane
  2617.     @action_plane = Action_Plane.new(@viewport1)
  2618.   end
  2619.   #--------------------------------------------------------------------------
  2620.   # *
  2621.   #--------------------------------------------------------------------------
  2622.   def update_action_plane
  2623.     @action_plane.update
  2624.   end
  2625.   #--------------------------------------------------------------------------
  2626.   # *
  2627.   #--------------------------------------------------------------------------
  2628.   def dispose_action_plane
  2629.     @action_plane.dispose
  2630.   end
  2631.   #--------------------------------------------------------------------------
  2632.   # *
  2633.   #--------------------------------------------------------------------------
  2634.   def action_plane(name, x, y, z, zoom_x, zoom_y, opacity, blend, duration)
  2635.     @action_plane.setup(name, x, y, z, zoom_x, zoom_y, opacity, blend, duration)
  2636.   end
  2637.   #--------------------------------------------------------------------------
  2638.   # *
  2639.   #--------------------------------------------------------------------------
  2640.   def delete_plane(duration)
  2641.     @action_plane.delete(duration)
  2642.   end
  2643. end

  2644. #==============================================================================
  2645. # ** Window_BattleLog
  2646. #------------------------------------------------------------------------------
  2647. #  This window shows the battle progress. Do not show the window frame.
  2648. #==============================================================================

  2649. class Window_BattleLog < Window_Selectable
  2650.   #--------------------------------------------------------------------------
  2651.   # *
  2652.   #--------------------------------------------------------------------------
  2653.   def display_added_states(target)
  2654.     target.result.added_state_objects.each do |state|
  2655.       state_msg = target.actor? ? state.message1 : state.message2
  2656.       next if state_msg.empty?
  2657.       replace_text(target.name + state_msg)
  2658.       wait
  2659.       wait_for_effect
  2660.     end
  2661.   end
  2662.   #--------------------------------------------------------------------------
  2663.   # *
  2664.   #--------------------------------------------------------------------------
  2665.   def display_counter(target, item)
  2666.     Sound.play_evasion
  2667.     add_text(sprintf(Vocab::CounterAttack, target.name))
  2668.   end
  2669.   #--------------------------------------------------------------------------
  2670.   # *
  2671.   #--------------------------------------------------------------------------
  2672.   def display_reflection(target, item)
  2673.     Sound.play_reflection
  2674.     add_text(sprintf(Vocab::MagicReflection, target.name))
  2675.   end
  2676.   #--------------------------------------------------------------------------
  2677.   # *
  2678.   #--------------------------------------------------------------------------
  2679.   def display_substitute(substitute, target)
  2680.     add_text(sprintf(Vocab::Substitute, substitute.name, target.name))
  2681.   end
  2682. end


  2683. #==============================================================================
  2684. # ** Scene_Battle
  2685. #------------------------------------------------------------------------------
  2686. #  This class performs battle screen processing.
  2687. #==============================================================================

  2688. class Scene_Battle < Scene_Base
  2689.   #--------------------------------------------------------------------------
  2690.   # *
  2691.   #--------------------------------------------------------------------------
  2692.   def abs_wait_short
  2693.   end
  2694.   #--------------------------------------------------------------------------
  2695.   # *
  2696.   #--------------------------------------------------------------------------
  2697.   def wait_for_animation
  2698.     update_for_wait
  2699.   end
  2700.   #--------------------------------------------------------------------------
  2701.   # *
  2702.   #--------------------------------------------------------------------------
  2703.   def wait_for_effect
  2704.     update_for_wait
  2705.   end
  2706.   #--------------------------------------------------------------------------
  2707.   # *
  2708.   #--------------------------------------------------------------------------
  2709.   def process_action
  2710.     return if scene_changing? || active?
  2711.     if next_subject?
  2712.       @subject = BattleManager.next_subject
  2713.       @subject.activate if @subject
  2714.     end
  2715.     return turn_end unless @subject
  2716.     return process_action_end if !@subject.active && !@subject.current_action
  2717.     if @subject.current_action
  2718.       @subject.current_action.prepare
  2719.       if @subject.current_action.valid?
  2720.         @status_window.open
  2721.         execute_action
  2722.       end
  2723.       @subject.remove_current_action
  2724.     end
  2725.   end
  2726.   #--------------------------------------------------------------------------
  2727.   # *
  2728.   #--------------------------------------------------------------------------
  2729.   def show_animation(targets, animation_id)
  2730.     if animation_id < 0
  2731.       show_animated_attack_animation(targets)
  2732.     else
  2733.       show_normal_animation(targets, animation_id)
  2734.     end
  2735.     wait_for_animation
  2736.   end
  2737.   #--------------------------------------------------------------------------
  2738.   # *
  2739.   #--------------------------------------------------------------------------
  2740.   def invoke_counter_attack(target, item)
  2741.     target.setup_counter(@subject)
  2742.     @counter_flag.push(target)
  2743.   end
  2744.   #--------------------------------------------------------------------------
  2745.   # *
  2746.   #--------------------------------------------------------------------------
  2747.   def invoke_magic_reflection(target, item)
  2748.     @subject.setup_reflect(item)
  2749.     @reflect_flag.push(target)
  2750.   end
  2751.   #--------------------------------------------------------------------------
  2752.   # * Alias method: apply_substitute
  2753.   #--------------------------------------------------------------------------
  2754.   def apply_substitute(target, item)
  2755.     if check_substitute(target, item)
  2756.       substitute = target.friends_unit.substitute_battler
  2757.       if substitute && target != substitute
  2758.         @substitution = {target: target, substitute: substitute}
  2759.         substitute.setup_substitute(target)
  2760.         return substitute
  2761.       end
  2762.     end
  2763.     target
  2764.   end
  2765.   #--------------------------------------------------------------------------
  2766.   # *
  2767.   #--------------------------------------------------------------------------
  2768.   alias :create_spriteset_ve_animated_battle :create_spriteset
  2769.   def create_spriteset
  2770.     create_spriteset_ve_animated_battle
  2771.     members = $game_party.movable_members
  2772.     members.each {|member| member.call_pose(:intro, :clear) }
  2773.     2.times { @spriteset.update }
  2774.   end
  2775.   #--------------------------------------------------------------------------
  2776.   # *
  2777.   #--------------------------------------------------------------------------
  2778.   alias :update_basic_ve_animated_battle :update_basic
  2779.   def update_basic
  2780.     update_basic_ve_animated_battle
  2781.     update_sprite_action
  2782.   end
  2783.   #--------------------------------------------------------------------------
  2784.   # *
  2785.   #--------------------------------------------------------------------------
  2786.   alias :turn_end_ve_animated_battle :turn_end
  2787.   def turn_end
  2788.     turn_end_ve_animated_battle
  2789.     @spriteset.battler_sprites.each {|sprite| sprite.reset_pose }
  2790.   end
  2791.   #--------------------------------------------------------------------------
  2792.   # *
  2793.   #--------------------------------------------------------------------------
  2794.   alias :next_command_ve_animated_battle :next_command
  2795.   def next_command
  2796.     BattleManager.set_active_pose
  2797.     next_command_ve_animated_battle
  2798.   end
  2799.   #--------------------------------------------------------------------------
  2800.   # *
  2801.   #--------------------------------------------------------------------------
  2802.   alias :prior_command_ve_animated_battle :prior_command
  2803.   def prior_command
  2804.     prior_command_ve_animated_battle
  2805.     BattleManager.clear_active_pose
  2806.   end
  2807.   #--------------------------------------------------------------------------
  2808.   # *
  2809.   #--------------------------------------------------------------------------
  2810.   def show_animated_attack_animation(targets)
  2811.     if @subject.actor? || $imported[:ve_actor_battlers]
  2812.       show_normal_animation(targets, @subject.atk_animation_id1, false)
  2813.     else
  2814.       Sound.play_enemy_attack
  2815.       abs_wait_short
  2816.     end
  2817.   end
  2818.   #--------------------------------------------------------------------------
  2819.   # *
  2820.   #--------------------------------------------------------------------------
  2821.   def next_subject?
  2822.     !@subject || !@subject.active?
  2823.   end
  2824.   #--------------------------------------------------------------------------
  2825.   # *
  2826.   #--------------------------------------------------------------------------
  2827.   def active?
  2828.     members = $game_troop.members + $game_party.battle_members
  2829.     members.any? {|member| member.active? }
  2830.   end
  2831.   #--------------------------------------------------------------------------
  2832.   # *
  2833.   #--------------------------------------------------------------------------
  2834.   def execute_action
  2835.     use_item
  2836.     @log_window.wait_and_clear
  2837.   end
  2838.   #--------------------------------------------------------------------------
  2839.   # *
  2840.   #--------------------------------------------------------------------------
  2841.   def use_item
  2842.     item = @subject.current_action.item
  2843.     @log_window.display_use_item(@subject, item)
  2844.     @subject.action_pose(item)
  2845.     @subject.use_item(item)
  2846.     refresh_status
  2847.   end
  2848.   #--------------------------------------------------------------------------
  2849.   # *
  2850.   #--------------------------------------------------------------------------
  2851.   def update_sprite_action
  2852.     @old_subject = @subject
  2853.     battlers = $game_party.battle_members + $game_troop.members
  2854.     battlers.each do |subject|
  2855.       @subject = subject
  2856.       call_animation if @subject.call_anim
  2857.       call_effect    if @subject.call_effect
  2858.     end
  2859.     @subject = @old_subject
  2860.   end
  2861.   #--------------------------------------------------------------------------
  2862.   # *
  2863.   #--------------------------------------------------------------------------
  2864.   def call_animation
  2865.     @subject.call_anim = false
  2866.     animation = @subject.animation
  2867.     @subject.animation = 0
  2868.     show_animation(@subject.targets, animation)
  2869.   end
  2870.   #--------------------------------------------------------------------------
  2871.   # *
  2872.   #--------------------------------------------------------------------------
  2873.   def call_effect
  2874.     @counter_flag = []
  2875.     @reflect_flag = []
  2876.     @substitution = nil
  2877.     @subject.call_effect = false
  2878.     targets = @subject.target_flag ? @subject.target_flag : @subject.targets
  2879.     item    = @subject.current_item
  2880.     targets.each {|target| item.repeats.times { invoke_item(target, item) } }
  2881.     @counter_flag.each {|target| @log_window.display_counter(target, item) }
  2882.     @reflect_flag.each {|target| @log_window.display_reflection(target, item) }
  2883.     if @substitution
  2884.       substitute = @substitution[:substitute]
  2885.       target     = @substitution[:target]
  2886.       @log_window.display_substitute(substitute, target)
  2887.     end
  2888.   end
  2889. end

  2890. #==============================================================================
  2891. # ** Sprite_Object
  2892. #------------------------------------------------------------------------------
  2893. #  This the base sprite used to display icons and throw animations.
  2894. #==============================================================================

  2895. class Sprite_Object < Sprite_Base
  2896.   #--------------------------------------------------------------------------
  2897.   # *
  2898.   #--------------------------------------------------------------------------
  2899.   attr_accessor :value
  2900.   #--------------------------------------------------------------------------
  2901.   # *
  2902.   #--------------------------------------------------------------------------
  2903.   def initialize(viewport)
  2904.     super(viewport)
  2905.     @right    = @battler.right?
  2906.     @up       = @battler.up?
  2907.     @spin     = 0
  2908.     @zooming  = 0
  2909.     @fade_in  = 0
  2910.     @fade_out = 0
  2911.     self.zoom_x = value[:izm]
  2912.     self.zoom_y = value[:izm]
  2913.   end
  2914.   #--------------------------------------------------------------------------
  2915.   # *
  2916.   #--------------------------------------------------------------------------
  2917.   def update
  2918.     super
  2919.     update_position
  2920.     update_opacity
  2921.     update_angle
  2922.     update_zoom
  2923.   end
  2924.   #--------------------------------------------------------------------------
  2925.   # *
  2926.   #--------------------------------------------------------------------------
  2927.   def update_opacity
  2928.     if value[:fin] > 0
  2929.       @fade_in += 1
  2930.       self.opacity = [@fade_in * value[:fin], value[:o]].min
  2931.     elsif value[:fout] > 0
  2932.       @fade_out += 1
  2933.       self.opacity = [value[:o] - @fade_out * value[:fin], 0].max
  2934.     else
  2935.       self.opacity =  value[:o]
  2936.     end
  2937.   end
  2938.   #--------------------------------------------------------------------------
  2939.   # *
  2940.   #--------------------------------------------------------------------------
  2941.   def update_angle
  2942.     @spin += 1 if Graphics.frame_count % 2 == 0
  2943.     self.angle  = value[:a] + value[:spin] * @spin
  2944.     self.angle *= -1 if @right || @up
  2945.   end
  2946.   #--------------------------------------------------------------------------
  2947.   # *
  2948.   #--------------------------------------------------------------------------
  2949.   def update_zoom
  2950.     if self.zoom_x < value[:ezm]
  2951.       @zooming += 1
  2952.       self.zoom_x = [value[:izm] + @zooming * value[:szm], value[:ezm]].min
  2953.       self.zoom_y = [value[:izm] + @zooming * value[:szm], value[:ezm]].min
  2954.     elsif self.zoom_x > value[:ezm]
  2955.       @zooming += 1
  2956.       self.zoom_x = [value[:izm] - @zooming * value[:szm], value[:ezm]].max
  2957.       self.zoom_y = [value[:izm] - @zooming * value[:szm], value[:ezm]].max
  2958.     end
  2959.   end
  2960.   #--------------------------------------------------------------------------
  2961.   # *
  2962.   #--------------------------------------------------------------------------
  2963.   def icon
  2964.     value[:icon]
  2965.   end
  2966.   #--------------------------------------------------------------------------
  2967.   # *
  2968.   #--------------------------------------------------------------------------
  2969.   def icon_changed?
  2970.     @icon_value != (value[:image] ?  value[:image] : icon)
  2971.   end
  2972.   #--------------------------------------------------------------------------
  2973.   # *
  2974.   #--------------------------------------------------------------------------
  2975.   def setup_icon
  2976.     p @icon_value if self.is_a?(Sprite_Throw)
  2977.     @icon_value = value[:image] ?  value[:image].dup : icon
  2978.     if value[:image]
  2979.       self.bitmap = Cache.picture(value[:image])
  2980.       self.src_rect.set(0, 0, bitmap.width, bitmap.height)
  2981.       self.ox = bitmap.width  / 2
  2982.       self.oy = bitmap.height / 2
  2983.     else
  2984.       self.bitmap = Cache.system("Iconset")
  2985.       self.src_rect.set(icon % 16 * 24, icon / 16 * 24, 24, 24)
  2986.       self.ox = 12
  2987.       self.oy = 12
  2988.     end
  2989.   end  
  2990. end

  2991. #==============================================================================
  2992. # ** Sprite_Icon
  2993. #------------------------------------------------------------------------------
  2994. #  This sprite is used to display icons.
  2995. #==============================================================================

  2996. class Sprite_Icon < Sprite_Object
  2997.   #--------------------------------------------------------------------------
  2998.   # *
  2999.   #--------------------------------------------------------------------------
  3000.   def initialize(battler, value)
  3001.     @battler = battler
  3002.     @value   = value.dup
  3003.     super(battler.viewport)
  3004.     setup_icon
  3005.   end
  3006.   #--------------------------------------------------------------------------
  3007.   # *
  3008.   #--------------------------------------------------------------------------
  3009.   def update_position
  3010.     setup_icon if icon_changed?
  3011.     self.x = pos[:x] + (@right ? -add_x : add_x)
  3012.     self.y = pos[:y] + (@up    ? -add_y : add_y)
  3013.     self.z = pos[:y] + value[:z] + 3
  3014.     self.mirror = @right || @up
  3015.   end
  3016.   #--------------------------------------------------------------------------
  3017.   # *
  3018.   #--------------------------------------------------------------------------
  3019.   def add_x
  3020.     value[:x] - @battler.ox / 2
  3021.   end
  3022.   #--------------------------------------------------------------------------
  3023.   # *
  3024.   #--------------------------------------------------------------------------
  3025.   def add_y
  3026.     value[:y] - pos[:h] - pos[:j] - @battler.oy / 2
  3027.   end
  3028.   #--------------------------------------------------------------------------
  3029.   # *
  3030.   #--------------------------------------------------------------------------
  3031.   def pos
  3032.     @battler.position
  3033.   end
  3034. end

  3035. #==============================================================================
  3036. # ** Sprite_Throw
  3037. #------------------------------------------------------------------------------
  3038. #  This sprite is used to display throw animations.
  3039. #==============================================================================

  3040. class Sprite_Throw < Sprite_Object
  3041.   #--------------------------------------------------------------------------
  3042.   # *
  3043.   #--------------------------------------------------------------------------
  3044.   def initialize(target, settings)
  3045.     @battler = settings[:user]
  3046.     @target  = target
  3047.     @value   = settings.dup
  3048.     super(target.viewport)
  3049.     setup_throw
  3050.   end
  3051.   #--------------------------------------------------------------------------
  3052.   # *
  3053.   #--------------------------------------------------------------------------
  3054.   def setup_throw
  3055.     set_initial_position
  3056.     setup_arc
  3057.     setup_icon
  3058.     setup_animation if $imported[:ve_loop_animation] && value[:anim]
  3059.   end
  3060.   #--------------------------------------------------------------------------
  3061.   # *
  3062.   #--------------------------------------------------------------------------
  3063.   def set_initial_position
  3064.     if value[:return]
  3065.       @current_position = @target.position.dup
  3066.       @target_position  = @battler.position.dup
  3067.       init_ox = @target.right?  ? -value[:init_x] : value[:init_x]
  3068.       init_oy = @target.up?     ? -value[:init_y] : value[:init_y]
  3069.       end_ox  = @battler.right? ? -value[:end_x]  : value[:end_x]
  3070.       end_oy  = @battler.up?    ? -value[:end_y]  : value[:end_y]
  3071.     else
  3072.       @current_position = @battler.position.dup
  3073.       @target_position  = @target.position.dup
  3074.       init_ox = @battler.right? ? -value[:init_x] : value[:init_x]
  3075.       init_oy = @battler.up?    ? -value[:init_x] : value[:init_x]
  3076.       end_ox  = @target.right?  ? -value[:end_x]  : value[:end_x]
  3077.       end_oy  = @target.up?     ? -value[:end_y]  : value[:end_y]
  3078.     end
  3079.     @current_position[:x] += value[:init_x] + init_ox
  3080.     @current_position[:y] += value[:init_y] + init_oy
  3081.     @target_position[:x]  += value[:end_x]  + end_ox
  3082.     @target_position[:y]  += value[:end_y]  + end_oy
  3083.     @initial_position = @current_position.dup
  3084.   end
  3085.   #--------------------------------------------------------------------------
  3086.   # *
  3087.   #--------------------------------------------------------------------------
  3088.   def setup_arc
  3089.     @arc = {}
  3090.     x_plus = (target_distance(:x) / 32.0).abs
  3091.     y_plus = (target_distance(:y) / 32.0).abs
  3092.     speed = Math.sqrt((x_plus ** 2) + (y_plus ** 2)) / value[:speed]
  3093.     @arc[:speed]  = value[:arc] * 5.0 / [speed, 1].max
  3094.     @arc[:height] = value[:arc]
  3095.     @arc[:count]  = value[:arc] * 2
  3096.     @current_position[:a] = 0
  3097.   end
  3098.   #--------------------------------------------------------------------------
  3099.   # *
  3100.   #--------------------------------------------------------------------------
  3101.   def setup_icon
  3102.     super
  3103.     self.angle = value[:a]
  3104.   end
  3105.   #--------------------------------------------------------------------------
  3106.   # *
  3107.   #--------------------------------------------------------------------------
  3108.   def setup_animation
  3109.     animation = {type: :throw, anim: value[:anim], loop: 1}
  3110.     add_loop_animation(animation)
  3111.   end
  3112.   #--------------------------------------------------------------------------
  3113.   # *
  3114.   #--------------------------------------------------------------------------
  3115.   def update
  3116.     super
  3117.     update_move
  3118.     update_arc
  3119.   end
  3120.   #--------------------------------------------------------------------------
  3121.   # *
  3122.   #--------------------------------------------------------------------------
  3123.   def update_move
  3124.     distance = set_distance
  3125.     move     = {x: 1.0, y: 1.0}
  3126.     if distance[:x].abs < distance[:y].abs
  3127.       move[:x] = 1.0 / (distance[:y].abs.to_f / distance[:x].abs)
  3128.     elsif distance[:y].abs < distance[:x].abs
  3129.       move[:y] = 1.0 / (distance[:x].abs.to_f / distance[:y].abs)
  3130.     end
  3131.     speed = set_speed(distance)
  3132.     x = move[:x] * speed[:x]
  3133.     y = move[:y] * speed[:y]
  3134.     set_movement(x, y)
  3135.   end
  3136.   #--------------------------------------------------------------------------
  3137.   # *
  3138.   #--------------------------------------------------------------------------
  3139.   def set_distance
  3140.     {x: target_distance(:x), y: target_distance(:y)}
  3141.   end
  3142.   #--------------------------------------------------------------------------
  3143.   # *
  3144.   #--------------------------------------------------------------------------
  3145.   def target_distance(symbol)
  3146.     @target_position[symbol] - @current_position[symbol]
  3147.   end
  3148.   #--------------------------------------------------------------------------
  3149.   # *
  3150.   #--------------------------------------------------------------------------
  3151.   def set_speed(distance)
  3152.     x = value[:speed] * (distance[:x] == 0 ? 0 : (distance[:x] > 0 ? 8 : -8))
  3153.     y = value[:speed] * (distance[:y] == 0 ? 0 : (distance[:y] > 0 ? 8 : -8))
  3154.     {x: x, y: y}
  3155.   end
  3156.   #--------------------------------------------------------------------------
  3157.   # *
  3158.   #--------------------------------------------------------------------------
  3159.   def set_movement(x, y)
  3160.     target  = @target_position
  3161.     current = @current_position
  3162.     current[:x] += x
  3163.     current[:y] += y
  3164.     current[:x] = target[:x] if in_distance?(current[:x], target[:x], x)
  3165.     current[:y] = target[:y] if in_distance?(current[:y], target[:y], y)
  3166.   end
  3167.   #--------------------------------------------------------------------------
  3168.   # *
  3169.   #--------------------------------------------------------------------------
  3170.   def in_distance?(x, y, z)
  3171.     x.between?(y - z - 1, y + z + 1)
  3172.   end
  3173.   #--------------------------------------------------------------------------
  3174.   # *
  3175.   #--------------------------------------------------------------------------
  3176.   def update_arc
  3177.     return if @arc[:count] == 0
  3178.     @arc[:count] = [@arc[:count] - (1 * @arc[:speed] / 10.0), 0].max.to_f
  3179.     count = @arc[:count]
  3180.     speed = @arc[:speed]
  3181.     peak  = @arc[:height]   
  3182.     result = (peak ** 2 - (count - peak).abs ** 2) / 2
  3183.     @current_position[:a] = value[:revert] ? -result : result
  3184.   end
  3185.   #--------------------------------------------------------------------------
  3186.   # *
  3187.   #--------------------------------------------------------------------------
  3188.   def update_position
  3189.     setup_icon if icon_changed?
  3190.     self.x = position[:x]
  3191.     self.y = position[:y] - position[:h] - position[:a]
  3192.     self.z = position[:y] + value[:z] + 4
  3193.     self.ox = 12
  3194.     self.oy = 12
  3195.     self.mirror = @right || @up
  3196.   end
  3197.   #--------------------------------------------------------------------------
  3198.   # *
  3199.   #--------------------------------------------------------------------------
  3200.   def position
  3201.     @current_position
  3202.   end
  3203.   #--------------------------------------------------------------------------
  3204.   # *
  3205.   #--------------------------------------------------------------------------
  3206.   def target
  3207.     @target_position
  3208.   end
  3209.   #--------------------------------------------------------------------------
  3210.   # *
  3211.   #--------------------------------------------------------------------------
  3212.   def disposing?
  3213.     position[:x] == target[:x] && position[:y] == target[:y]
  3214.   end
  3215. end

  3216. #==============================================================================
  3217. # ** Action_Plane
  3218. #------------------------------------------------------------------------------
  3219. #  
  3220. #==============================================================================

  3221. class Action_Plane < Plane
  3222.   #--------------------------------------------------------------------------
  3223.   # *
  3224.   #--------------------------------------------------------------------------
  3225.   def initialize(viewport)
  3226.     super(viewport)
  3227.     @settings = {x: 0, y: 0, opacity: 0, zoom_x: 1.0, zoom_y: 1.0}
  3228.     @duration = 1
  3229.   end
  3230.   #--------------------------------------------------------------------------
  3231.   # * dispose
  3232.   #--------------------------------------------------------------------------
  3233.   def dispose
  3234.     bitmap.dispose if bitmap
  3235.     super
  3236.   end
  3237.   #--------------------------------------------------------------------------
  3238.   # *
  3239.   #--------------------------------------------------------------------------
  3240.   def setup(name, x, y, z, zoom_x, zoom_y, opacity, blend, duration)
  3241.     self.bitmap = Cache.picture(name)
  3242.     self.z = z
  3243.     @settings[:x] = x
  3244.     @settings[:y] = y
  3245.     @settings[:zoom_x]  = zoom_x / 100.0
  3246.     @settings[:zoom_y]  = zoom_y / 100.0
  3247.     @settings[:opacity] = opacity
  3248.     @blend_type = blend
  3249.     @delete     = false
  3250.     @duration   = [duration, 1].max
  3251.   end
  3252.   #--------------------------------------------------------------------------
  3253.   # *
  3254.   #--------------------------------------------------------------------------
  3255.   def delete(duration = 60)
  3256.     @settings[:opacity] = 0
  3257.     @duration = [duration, 1].max
  3258.     @delete   = true
  3259.   end
  3260.   #--------------------------------------------------------------------------
  3261.   # *
  3262.   #--------------------------------------------------------------------------
  3263.   def value
  3264.     @settings
  3265.   end
  3266.   #--------------------------------------------------------------------------
  3267.   # *
  3268.   #--------------------------------------------------------------------------
  3269.   def update
  3270.     update_position
  3271.     update_opacity
  3272.     update_zoom
  3273.     update_delete
  3274.     @duration -= 1 if @duration > 0
  3275.   end
  3276.   #--------------------------------------------------------------------------
  3277.   # *
  3278.   #--------------------------------------------------------------------------
  3279.   def update_position
  3280.     self.ox += value[:x]
  3281.     self.oy += value[:y]
  3282.   end
  3283.   #--------------------------------------------------------------------------
  3284.   # *
  3285.   #--------------------------------------------------------------------------
  3286.   def update_opacity
  3287.     return if @duration == 0
  3288.     d = @duration
  3289.     self.opacity = (self.opacity * (d - 1) + value[:opacity]) / d
  3290.   end
  3291.   #--------------------------------------------------------------------------
  3292.   # *
  3293.   #--------------------------------------------------------------------------
  3294.   def update_zoom
  3295.     return if @duration == 0
  3296.     d = @duration
  3297.     self.zoom_x = (self.zoom_x * (d - 1) + value[:zoom_x]) / d
  3298.     self.zoom_y = (self.zoom_y * (d - 1) + value[:zoom_y]) / d
  3299.   end
  3300.   #--------------------------------------------------------------------------
  3301.   # *
  3302.   #--------------------------------------------------------------------------
  3303.   def update_delete
  3304.     return if !@delete || @duration > 0
  3305.     self.bitmap.dispose
  3306.     self.bitmap = nil
  3307.     @settings   = {x: 0, y: 0, opacity: 0, zoom_x: 100.0, zoon_y: 100.0}
  3308.     @blend_type = 0
  3309.     @delete = false
  3310.   end
  3311. end
复制代码
捕获.PNG

Project3.7z

517.11 KB, 下载次数: 41

最佳答案

查看完整内容

按楼主要求试伤害在动画结束后显示。 但是仅仅调了伤害显示,敌人还是会在刚开始显示动画就挂掉。 有问题的继续问我好了。
梦石
0
星屑
75
在线时间
435 小时
注册时间
2012-7-31
回帖
744
发表于 2013-7-17 20:38:13 | 显示全部楼层
按楼主要求试伤害在动画结束后显示。
但是仅仅调了伤害显示,敌人还是会在刚开始显示动画就挂掉。
有问题的继续问我好了。 Project3.rar (536.48 KB, 下载次数: 33)

评分

参与人数 1梦石 +1 收起 理由
Mic_洛洛 + 1 认可答案

查看全部评分

回复

使用道具 举报

矿工

梦石
0
星屑
134
在线时间
898 小时
注册时间
2012-10-5
回帖
1303
发表于 2013-7-17 20:52:19 | 显示全部楼层
等待几帧后伤害,把本身的伤害公式删去,利用公共事件。
呃,发糖贴好冷清呀!
回复

使用道具 举报

梦石
0
星屑
50
在线时间
14 小时
注册时间
2012-7-30
回帖
24
发表于 2013-7-17 21:02:57 | 显示全部楼层
哇,哪来的战斗图,这么好。是什么战斗系统
回复

使用道具 举报

梦石
0
星屑
50
在线时间
82 小时
注册时间
2013-3-17
回帖
49
 楼主| 发表于 2013-7-17 21:07:46 | 显示全部楼层
1332535 发表于 2013-7-17 21:02
哇,哪来的战斗图,这么好。是什么战斗系统

VE Animated Battle
回复

使用道具 举报

梦石
0
星屑
50
在线时间
82 小时
注册时间
2013-3-17
回帖
49
 楼主| 发表于 2013-7-17 21:08:35 | 显示全部楼层
876加几 发表于 2013-7-17 20:52
等待几帧后伤害,把本身的伤害公式删去,利用公共事件。

强制战斗指令?
回复

使用道具 举报

矿工

梦石
0
星屑
134
在线时间
898 小时
注册时间
2012-10-5
回帖
1303
发表于 2013-7-17 21:57:46 | 显示全部楼层
chengzhuo5 发表于 2013-7-17 21:08
强制战斗指令?

各种条件分歧,如实在不会搜RMVA脚本库。
若搜不到只有搜外国网站了。
呃,发糖贴好冷清呀!
回复

使用道具 举报

梦石
0
星屑
50
在线时间
82 小时
注册时间
2013-3-17
回帖
49
 楼主| 发表于 2013-7-18 00:09:02 来自手机 | 显示全部楼层
876加几 发表于 2013-7-17 21:57  各种条件分歧,如实在不会搜RMVA脚本库。  若搜不到只有搜外国网站了。

难道就不能改原脚本么?
回复

使用道具 举报

梦石
0
星屑
75
在线时间
91 小时
注册时间
2013-7-7
回帖
37
发表于 2013-7-18 03:17:37 | 显示全部楼层
chengzhuo5 发表于 2013-7-18 00:09
难道就不能改原脚本么?

   你脚本问题把 我这怎么弄都是在最后显示伤害阿


玩竖版的话 你这是英文的 而且你看得懂  建议你去换另一个版本

那个版本很唯美        就是忘记叫什么了。

回复

使用道具 举报

矿工

梦石
0
星屑
134
在线时间
898 小时
注册时间
2012-10-5
回帖
1303
发表于 2013-7-18 08:52:24 | 显示全部楼层
chengzhuo5 发表于 2013-7-18 00:09
难道就不能改原脚本么?

可以呀,你看看哪里出错了,就来改改,并看看原版战斗是如何防止动画未结束就伤害的。
呃,发糖贴好冷清呀!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部