设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3043|回复: 12
打印 上一主题 下一主题

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
82 小时
注册时间
2013-3-17
帖子
63
跳转到指定楼层
1
发表于 2013-7-17 20:38:12 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1星屑
如题,脚本见范例。艾利克的“111”技能动画为陨石,但是动画刚刚播放就造成伤害(见图)。请问如何等到动画放完后再造成伤害??
可能相关的脚本
RUBY 代码复制
  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. #==============================================================================
  22. # ** Victor Engine
  23. #------------------------------------------------------------------------------
  24. #   Setting module for the Victor Engine
  25. #==============================================================================
  26.  
  27. $imported[:ve_animated_battle] = true
  28.  
  29. #==============================================================================
  30. # ** Object
  31. #------------------------------------------------------------------------------
  32. #  This class is the superclass of all other classes.
  33. #==============================================================================
  34.  
  35. class Object
  36.   #--------------------------------------------------------------------------
  37.   # *
  38.   #--------------------------------------------------------------------------
  39.   def custom_pose(type)
  40.     note =~ /<#{type.upcase} POSE: (\w[\w ]+)>/i ? make_symbol($1) : nil
  41.   end
  42. end
  43.  
  44. #==============================================================================
  45. # ** BattleManager
  46. #------------------------------------------------------------------------------
  47. #  This module handles the battle processing
  48. #==============================================================================
  49.  
  50. class << BattleManager
  51.   #--------------------------------------------------------------------------
  52.   # *
  53.   #--------------------------------------------------------------------------
  54.   attr_accessor :old_tone
  55.   #--------------------------------------------------------------------------
  56.   # *
  57.   #--------------------------------------------------------------------------
  58.   alias :init_members_ve_animated_battle :init_members
  59.   def init_members
  60.     $game_party.members.each {|member| member.clear_poses }
  61.     init_members_ve_animated_battle
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # *
  65.   #--------------------------------------------------------------------------
  66.   alias :battle_end_ve_animated_battle :battle_end
  67.   def battle_end(result)
  68.     $game_party.members.each {|member| member.clear_poses }
  69.     battle_end_ve_animated_battle(result)
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # *
  73.   #--------------------------------------------------------------------------
  74.   alias :process_victory_ve_animated_battle :process_victory
  75.   def process_victory
  76.     process_victory_pose
  77.     process_victory_ve_animated_battle
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # *
  81.   #--------------------------------------------------------------------------
  82.   alias :process_escape_ve_animated_battle :process_escape
  83.   def process_escape
  84.     @escaping = true
  85.     success   = process_escape_ve_animated_battle
  86.     @escaping = false
  87.     return success
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # *
  91.   #--------------------------------------------------------------------------
  92.   alias :process_abort_ve_animated_battle :process_abort
  93.   def process_abort
  94.     process_escape_pose if @escaping
  95.     process_abort_ve_animated_battle
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # *
  99.   #--------------------------------------------------------------------------
  100.   def process_victory_pose
  101.     SceneManager.scene.update_basic while $game_party.not_in_position?
  102.     $game_party.movable_members.each do |member|
  103.       member.clear_idle_poses
  104.       member.call_pose(:victory)
  105.     end
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # *
  109.   #--------------------------------------------------------------------------
  110.   def process_escape_pose
  111.     $game_party.movable_members.each do |member|
  112.       member.clear_idle_poses
  113.       member.call_pose(:escape)
  114.     end
  115.     5.times { SceneManager.scene.update_basic }
  116.     SceneManager.scene.update_basic while $game_party.moving?
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # *
  120.   #--------------------------------------------------------------------------
  121.   def set_active_pose
  122.     return unless actor
  123.     actor.set_active_pose
  124.     actor.reset_pose
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # *
  128.   #--------------------------------------------------------------------------
  129.   def clear_active_pose
  130.     return unless actor
  131.     actor.active_pose = nil
  132.     actor.reset_pose
  133.   end
  134. end
  135.  
  136. #==============================================================================
  137. # ** Game_Screen
  138. #------------------------------------------------------------------------------
  139. #  This class handles screen maintenance data, such as change in color tone,
  140. # flashes, etc. It's used within the Game_Map and Game_Troop classes.
  141. #==============================================================================
  142.  
  143. class Game_Screen
  144.   #--------------------------------------------------------------------------
  145.   # *
  146.   #--------------------------------------------------------------------------
  147.   attr_reader   :low_tone
  148.   attr_reader   :high_tone
  149.   attr_accessor :old_tone
  150.   attr_accessor :old_low_tone
  151.   attr_accessor :old_high_tone
  152.   #--------------------------------------------------------------------------
  153.   # *
  154.   #--------------------------------------------------------------------------
  155.   alias :clear_tone_ve_animated_battle :clear_tone
  156.   def clear_tone
  157.     clear_tone_ve_animated_battle
  158.     @low_tone  = Tone.new
  159.     @high_tone = Tone.new
  160.     @low_tone_target  = Tone.new
  161.     @high_tone_target = Tone.new
  162.     @low_tone_duration  = 0
  163.     @high_tone_duration = 0
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # *
  167.   #--------------------------------------------------------------------------
  168.   alias :update_ve_animated_battle :update
  169.   def update
  170.     update_ve_animated_battle
  171.     low_update_tone
  172.     high_update_tone
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # *
  176.   #--------------------------------------------------------------------------
  177.   def start_low_tone_change(tone, duration)
  178.     @low_tone_target = tone.clone
  179.     @low_tone_duration = duration
  180.     @low_tone = @low_tone_target.clone if @low_tone_duration == 0
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # *
  184.   #--------------------------------------------------------------------------
  185.   def start_high_tone_change(tone, duration)
  186.     @high_tone_target = tone.clone
  187.     @high_tone_duration = duration
  188.     @high_tone = @high_tone_target.clone if @high_tone_duration == 0
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   # *
  192.   #--------------------------------------------------------------------------
  193.   def low_update_tone
  194.     if @low_tone_duration > 0
  195.       d    = @low_tone_duration
  196.       tone = @low_tone_target
  197.       @low_tone.red   = (@low_tone.red   * (d - 1) + tone.red)   / d
  198.       @low_tone.green = (@low_tone.green * (d - 1) + tone.green) / d
  199.       @low_tone.blue  = (@low_tone.blue  * (d - 1) + tone.blue)  / d
  200.       @low_tone.gray  = (@low_tone.gray  * (d - 1) + tone.gray)  / d
  201.       @low_tone_duration -= 1
  202.     end
  203.   end  
  204.   #--------------------------------------------------------------------------
  205.   # *
  206.   #--------------------------------------------------------------------------
  207.   def high_update_tone
  208.     if @high_tone_duration > 0
  209.       d    = @high_tone_duration
  210.       tone = @high_tone_target
  211.       @high_tone.red   = (@high_tone.red   * (d - 1) + tone.red)   / d
  212.       @high_tone.green = (@high_tone.green * (d - 1) + tone.green) / d
  213.       @high_tone.blue  = (@high_tone.blue  * (d - 1) + tone.blue)  / d
  214.       @high_tone.gray  = (@high_tone.gray  * (d - 1) + tone.gray)  / d
  215.       @high_tone_duration -= 1
  216.     end
  217.   end
  218.   #--------------------------------------------------------------------------
  219.   # * New method: tone_change?
  220.   #--------------------------------------------------------------------------
  221.   def tone_change?
  222.     @tone_duration > 0 || @low_tone_duration > 0 || @high_tone_duration > 0
  223.   end
  224. end
  225.  
  226. #==============================================================================
  227. # ** Game_ActionResult
  228. #------------------------------------------------------------------------------
  229. #  This class handles the results of actions. This class is used within the
  230. # Game_Battler class.
  231. #==============================================================================
  232.  
  233. class Game_ActionResult
  234.   #--------------------------------------------------------------------------
  235.   # * New method: damage_value_adjust
  236.   #--------------------------------------------------------------------------
  237.   def damage_value_adjust(value, item)
  238.     @hp_damage *= value
  239.     @mp_damage *= value
  240.     @hp_damage = @hp_damage.to_i
  241.     @mp_damage = [@battler.mp, @mp_damage.to_i].min
  242.     @hp_drain = @hp_damage if item.damage.drain?
  243.     @mp_drain = @mp_damage if item.damage.drain?
  244.     @hp_drain = [@battler.hp, @hp_drain].min
  245.   end
  246. end
  247.  
  248. #==============================================================================
  249. # ** Game_Battler
  250. #------------------------------------------------------------------------------
  251. #  This class deals with battlers. It's used as a superclass of the Game_Actor
  252. # and Game_Enemy classes.
  253. #==============================================================================
  254.  
  255. class Game_Battler < Game_BattlerBase
  256.   #--------------------------------------------------------------------------
  257.   # *
  258.   #--------------------------------------------------------------------------
  259.   attr_accessor :row
  260.   attr_accessor :frame
  261.   attr_accessor :timing
  262.   attr_accessor :freeze
  263.  
  264.   attr_accessor :direction
  265.   attr_accessor :move_speed
  266.   attr_accessor :jumping
  267.   attr_accessor :shake
  268.  
  269.   attr_accessor :pose_list
  270.  
  271.   attr_accessor :immortals
  272.  
  273.   attr_accessor :attack_flag
  274.   attr_accessor :damage_flag
  275.   attr_accessor :result_flag
  276.   attr_accessor :target_flag
  277.  
  278.   attr_accessor :spin
  279.   attr_accessor :angle
  280.   attr_accessor :sufix
  281.   attr_accessor :active
  282.   attr_accessor :targets
  283.   attr_accessor :teleport
  284.   attr_accessor :x_adj
  285.   attr_accessor :y_adj
  286.  
  287.   attr_accessor :call_anim
  288.   attr_accessor :call_effect
  289.   attr_accessor :animation
  290.   attr_accessor :countered
  291.   attr_accessor :substitution
  292.  
  293.   attr_accessor :action_targets
  294.   attr_accessor :active_pose
  295.   attr_accessor :pose_loop_anim
  296.  
  297.   attr_accessor :previous_action
  298.  
  299.   attr_accessor :icon_list
  300.   attr_accessor :throw_list
  301.  
  302.   attr_accessor :current_item
  303.  
  304.   attr_accessor :target_position
  305.   attr_accessor :current_position
  306.   attr_accessor :default_position
  307.  
  308.   #--------------------------------------------------------------------------
  309.   # *
  310.   #--------------------------------------------------------------------------
  311.   alias :initialize_ve_animated_battle :initialize
  312.   def initialize
  313.     init_anim_battlers_variables
  314.     initialize_ve_animated_battle
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # *
  318.   #--------------------------------------------------------------------------
  319.   alias :item_apply_ve_animated_battle :item_apply
  320.   def item_apply(user, item)
  321.     item_apply_ve_animated_battle(user, item)
  322.     call_damage_pose(item, user) if movable?
  323.     [url=home.php?mod=space&uid=131733]@substitution[/url]    = false
  324.     user.result_flag = @result.hit? ? :hit : :miss
  325.   end
  326.   #--------------------------------------------------------------------------
  327.   # * Alias method: make_damage_value
  328.   #--------------------------------------------------------------------------
  329.   alias :make_damage_value_ve_animated_battle :make_damage_value
  330.   def make_damage_value(user, item)
  331.     make_damage_value_ve_animated_battle(user, item)
  332.     @result.damage_value_adjust(user.damage_flag, item) if user.damage_flag
  333.   end
  334.   #--------------------------------------------------------------------------
  335.   # *
  336.   #--------------------------------------------------------------------------
  337.   alias :regenerate_hp_ve_animated_battle :regenerate_hp
  338.   def regenerate_hp
  339.     regenerate_hp_ve_animated_battle
  340.     call_pose(:hurt, :clear) if @result.hp_damage > 0 && movable?
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # *
  344.   #--------------------------------------------------------------------------
  345.   def dead?
  346.     super && !immortal?
  347.   end
  348.   #--------------------------------------------------------------------------
  349.   # *
  350.   #--------------------------------------------------------------------------
  351.   def refresh
  352.     state_resist_set.each {|state_id| erase_state(state_id) }
  353.     @hp = [[@hp, mhp].min, 0].max
  354.     @mp = [[@mp, mmp].min, 0].max
  355.     die if [url=home.php?mod=space&uid=90807]@Dying[/url] && !immortal?
  356.     return if @dying
  357.     valid = @hp == 0 && !immortal?
  358.     valid ? add_state(death_state_id) : remove_state(death_state_id)
  359.     reset_pose
  360.   end
  361.   #--------------------------------------------------------------------------
  362.   # *
  363.   #--------------------------------------------------------------------------
  364.   def immortal?
  365.     return false unless $game_party.in_battle
  366.     members = $game_troop.members + $game_party.battle_members
  367.     members.any? {|member| member.immortals.include?(self) }
  368.   end
  369.   #--------------------------------------------------------------------------
  370.   # *
  371.   #--------------------------------------------------------------------------
  372.   alias :die_ve_animated_battle :die
  373.   def die
  374.     return @dying = true if immortal?
  375.     call_pose(:die, :clear)
  376.     @dying = false
  377.     die_ve_animated_battle
  378.   end
  379.   #--------------------------------------------------------------------------
  380.   # *
  381.   #--------------------------------------------------------------------------
  382.   alias :revive_ve_animated_battle :revive
  383.   def revive
  384.     call_pose(:revive, :clear)
  385.     revive_ve_animated_battle
  386.   end
  387.   #--------------------------------------------------------------------------
  388.   # *
  389.   #--------------------------------------------------------------------------
  390.   def init_anim_battlers_variables
  391.     clear_poses
  392.   end
  393.   #--------------------------------------------------------------------------
  394.   # *
  395.   #--------------------------------------------------------------------------
  396.   def clear_poses
  397.     @sufix = ""
  398.     @row   = 0
  399.     @frame = 0
  400.     [url=home.php?mod=space&uid=124954]@Angle[/url] = 0
  401.     @spin  = 0
  402.     @x_adj = 0
  403.     @y_adj = 0
  404.     @direction  = 2
  405.     @move_speed = 1.0
  406.     @pose_list  = []
  407.     @targets    = []
  408.     @immortals  = []
  409.     @throw_list = []
  410.     @icon_list  = {}
  411.     @timing     = {}
  412.     @action_targets = []
  413.     clear_shake
  414.     clear_position
  415.   end
  416.   #--------------------------------------------------------------------------
  417.   # *
  418.   #--------------------------------------------------------------------------
  419.   def clear_shake
  420.     @shake_power = 0
  421.     @shake_speed = 0
  422.     @shake_duration = 0
  423.     @shake_direction = 1
  424.     @shake = 0
  425.   end
  426.   #--------------------------------------------------------------------------
  427.   # *
  428.   #--------------------------------------------------------------------------
  429.   def clear_position
  430.     @target_position  = {x: 0, y: 0, h: 0, j: 0}
  431.     @current_position = {x: 0, y: 0, h: 0, j: 0}
  432.     @default_position = {x: 0, y: 0, h: 0, j: 0}
  433.   end
  434.   #--------------------------------------------------------------------------
  435.   # *
  436.   #--------------------------------------------------------------------------
  437.   def call_pose(symbol, insert = nil, item = nil, battler = nil)
  438.     skip_pose if insert == :clear && pose_name_list.first == symbol
  439.     pose  = make_string(symbol)
  440.     note  = item ? item.note : ""
  441.     notes = get_all_poses(note)
  442.     code  = "ACTION: #{pose}((?: *, *[\\w ]+)+)?"
  443.     setup_pose(symbol, notes, code, insert, battler)
  444.   end
  445.   #--------------------------------------------------------------------------
  446.   # *
  447.   #--------------------------------------------------------------------------
  448.   def get_all_poses(note = "")
  449.     note + get_all_notes + battler_settings + default_settings
  450.   end
  451.   #--------------------------------------------------------------------------
  452.   # *
  453.   #--------------------------------------------------------------------------
  454.   def default_settings
  455.     VE_DEFAULT_ACTION
  456.   end
  457.   #--------------------------------------------------------------------------
  458.   # *
  459.   #--------------------------------------------------------------------------
  460.   def battler_settings
  461.     VE_ACTION_SETTINGS[battler_mode] ? VE_ACTION_SETTINGS[battler_mode] : ""
  462.   end
  463.   #--------------------------------------------------------------------------
  464.   # *
  465.   #--------------------------------------------------------------------------
  466.   def battler_mode
  467.     sprite_value(:action)
  468.   end
  469.   #--------------------------------------------------------------------------
  470.   # *
  471.   #--------------------------------------------------------------------------
  472.   def sprite_value(value)
  473.     sprite_settings[value] ? sprite_settings[value] : VE_DEFAULT_SPRITE[value]
  474.   end
  475.   #--------------------------------------------------------------------------
  476.   # *
  477.   #--------------------------------------------------------------------------
  478.   def sprite_settings
  479.     VE_SPRITE_SETTINGS[@battler_name] ? VE_SPRITE_SETTINGS[@battler_name] :
  480.     VE_DEFAULT_SPRITE
  481.   end
  482.   #--------------------------------------------------------------------------
  483.   # *
  484.   #--------------------------------------------------------------------------
  485.   def setup_pose(pose, notes, code, insert, battler)
  486.     regexp = /<#{code}>((?:[^<]|<[^\/])*)<\/ACTION>/im
  487.     if notes.gsub(/\r\n/i, "") =~ regexp
  488.       time, last = get_values($1)
  489.       value = setup_value($2, battler == :skip ? nil : battler)
  490.       return if value.empty?
  491.       time.times do
  492.         list = {pose: pose, next: last, value: value.dup, battler: battler}
  493.         insert ? @pose_list.unshift(list) : @pose_list.push(list)
  494.       end
  495.     end
  496.   end
  497.   #--------------------------------------------------------------------------
  498.   # *
  499.   #--------------------------------------------------------------------------
  500.   def pose_name_list
  501.     @pose_list.collect {|pose| pose[:pose]}
  502.   end
  503.   #--------------------------------------------------------------------------
  504.   # *
  505.   #--------------------------------------------------------------------------
  506.   def pose_name
  507.     pose_name_list.first
  508.   end
  509.   #--------------------------------------------------------------------------
  510.   # *
  511.   #--------------------------------------------------------------------------
  512.   def skip_pose
  513.     @current_pose = pose_name
  514.     @pose_list.shift while @current_pose == pose_name && !@pose_list.empty?
  515.   end
  516.   #--------------------------------------------------------------------------
  517.   # *
  518.   #--------------------------------------------------------------------------
  519.   def get_values(value)
  520.     if value
  521.       time = value =~ /([^,]+) TIMES/i ? [eval($1), 1].max : 1
  522.       last = value =~ /(\w[\w ]+)/i    ? make_symbol($1)   : nil
  523.       [time, last]
  524.     else
  525.       [1, nil]
  526.     end
  527.   end
  528.   #--------------------------------------------------------------------------
  529.   # *
  530.   #--------------------------------------------------------------------------
  531.   def clear_idle_poses
  532.     @pose_list.delete_if {|pose| idle_pose?(pose[:pose]) }
  533.   end
  534.   #--------------------------------------------------------------------------
  535.   # *
  536.   #--------------------------------------------------------------------------
  537.   def battler
  538.     @pose[:battler] ? @pose[:battler] : self
  539.   end
  540.   #--------------------------------------------------------------------------
  541.   # *
  542.   #--------------------------------------------------------------------------
  543.   def idle_pose?(pose)
  544.     idle_pose_list.include?(pose.downcase.to_sym)
  545.   end
  546.   #--------------------------------------------------------------------------
  547.   # *
  548.   #--------------------------------------------------------------------------
  549.   def idle_pose_list
  550.     [:idle, :guard, :danger, :dead, :item_cast, :magic_cast, :skill_cast,
  551.      :default_cast] + states_pose
  552.   end
  553.   #--------------------------------------------------------------------------
  554.   # *
  555.   #--------------------------------------------------------------------------
  556.   def states_pose
  557.     $data_states.compact.collect {|state| state.custom_pose("STATE") }.compact
  558.   end
  559.   #--------------------------------------------------------------------------
  560.   # *
  561.   #--------------------------------------------------------------------------
  562.   def setup_value(settings, battler)
  563.     values = []
  564.     settings.scan(/(\w+)(?:: ([^;]+)[;\n\r])?/i) do |type, value|
  565.       values.push(set_pose_value(type, value ? value : '', battler))
  566.     end
  567.     values
  568.   end
  569.   #--------------------------------------------------------------------------
  570.   # *
  571.   #--------------------------------------------------------------------------
  572.   def set_pose_value(type, value, battler)
  573.     @pose = {}
  574.     @pose[:battler] = battler
  575.     @pose[:type] = make_symbol(type)
  576.     @pose[:hit]  = value =~ /HIT ONLY/i  ? true : false
  577.     @pose[:miss] = value =~ /MISS ONLY/i ? true : false
  578.     set_pose_setting("#{type} #{value}")
  579.     @pose
  580.   end
  581.   #--------------------------------------------------------------------------
  582.   # *
  583.   #--------------------------------------------------------------------------
  584.   def set_pose_setting(value)
  585.     case value
  586.     when /^POSE (.*)/i then set_pose($1)
  587.     when /^WAIT (.*)/i then set_wait($1)
  588.     when /^MOVE (.*)/i then set_move($1)
  589.     when /^JUMP (.*)/i then set_jump($1)
  590.     when /^ANIM (.*)/i then set_anim($1)
  591.     when /^ICON (.*)/i then set_icon($1)
  592.     when /^LOOP (.*)/i then set_loop($1)
  593.     when /^TONE (.*)/i then set_tone($1)
  594.     when /^THROW (.*)/i then set_throw($1)
  595.     when /^SOUND (.*)/i then set_sound($1)
  596.     when /^PLANE (.*)/i then set_plane($1)
  597.     when /^FLASH (.*)/i then set_flash($1)
  598.     when /^SHAKE (.*)/i then set_shake($1)
  599.     when /^MOVIE (.*)/i then set_movie($1)
  600.     when /^ACTION (.*)/i then set_action($1)
  601.     when /^FREEZE (.*)/i then set_freeze($1)
  602.     when /^EFFECT (.*)/i then set_effect($1)
  603.     when /^PICTURE (.*)/i then set_picture($1)
  604.     when /^COUNTER (.*)/i then set_counter($1)
  605.     when /^DIRECTION (.*)/i then set_direction($1)
  606.     end
  607.   end
  608.   #--------------------------------------------------------------------------
  609.   # *
  610.   #--------------------------------------------------------------------------
  611.   def set_pose(value)
  612.     @pose[:target] = set_targets(value)
  613.     @pose[:row]    = battler.set_row(value)
  614.     @pose[:angle]  = value =~ /ANGLE ([+-]?\d+)/i  ? $1.to_i : 0
  615.     @pose[:spin]   = value =~ /SPIN ([+-]?\d+)/i   ? $1.to_i : 0
  616.     @pose[:sufix]  = value =~ /SUFIX ([\[\]\w]+)/i ? $1.to_s : ""
  617.     @pose[:x] = value =~ /X ([+-]?\d+)/i   ? $1.to_i : 0
  618.     @pose[:y] = value =~ /Y ([+-]?\d+)/i   ? $1.to_i : 0
  619.     if value =~ /(\d+|ALL) FRAMES?/i
  620.       w = [value =~ /WAIT (\d+)/i ? $1.to_i : 1, 1].max
  621.       m = /(\d+) FRAMES/i ? $1.to_i : :all
  622.       l = value =~ /RETURN/i ? true : false
  623.       r = value =~ /REVERT/i ? true : false
  624.       @pose[:frame] = value =~ /FRAME (\d+)/i ? $1.to_i : 1
  625.       @pose[:pose]  = {wait: w, time: w, frame: m, loop: l, revert: r}
  626.     else
  627.       @pose[:pose]  = {}
  628.       @pose[:frame] = value =~ /FRAME (\d+)/i ? $1.to_i : 1
  629.     end
  630.   end
  631.   #--------------------------------------------------------------------------
  632.   # *
  633.   #--------------------------------------------------------------------------
  634.   def set_wait(value)
  635.     @pose[:target] = set_targets(value)
  636.     case value
  637.     when /(\d+)/i
  638.       @pose[:time] = $1.to_i
  639.       @pose[:wait] = $1.to_i
  640.     when /(ACTION|ANIMATION|MOVEMENT|ORIGIN|THROW|COUNTER|SUBSTITUTION|TONE)/i
  641.       @pose[:time] = make_symbol($1)
  642.       @pose[:wait] = make_symbol($1)
  643.     end
  644.   end
  645.   #--------------------------------------------------------------------------
  646.   # *
  647.   #--------------------------------------------------------------------------
  648.   def set_move(value)
  649.     regexp = /(MOVE TO|STEP FOWARD|STEP BACKWARD|RETREAT|ESCAPE)/i
  650.     @pose[:value]  = make_symbol($1) if value =~ regexp
  651.     @pose[:target] = battler.set_targets(value)
  652.     @pose[:x]      = value =~ /X ([+-]?\d+)/i ? $1.to_i : 0
  653.     @pose[:y]      = value =~ /Y ([+-]?\d+)/i ? $1.to_i : 0
  654.     @pose[:h]      = value =~ /HEIGHT (\d+)/i ? $1.to_i : 0
  655.     @pose[:speed]  = value =~ /SPEED (\d+)/i  ? $1.to_i / 10.0 : 1.0
  656.     @pose[:targets]  = @action_targets if @pose[:value] == :move_to
  657.     @pose[:teleport] = value =~ /TELEPORT/i
  658.   end
  659.   #--------------------------------------------------------------------------
  660.   # *
  661.   #--------------------------------------------------------------------------
  662.   def set_jump(value)
  663.     @pose[:target] = set_targets(value)
  664.     @pose[:move]   = value =~ /MOVE/i
  665.     @pose[:height] = value =~ /HEIGHT (\d+)/i ? [$1.to_i, 1].max : 5
  666.     @pose[:speed]  = value =~ /SPEED (\d+)/i  ? [$1.to_i, 1].max : 10
  667.   end
  668.   #--------------------------------------------------------------------------
  669.   # *
  670.   #--------------------------------------------------------------------------
  671.   def set_action(value)
  672.     @pose[:target] = set_targets(value)
  673.     value.scan(/(\w[\w ]+)/) do
  674.       not_action = ['target','actor','friend','enemy', 'user','self']
  675.       next if not_action.include?($1.downcase)
  676.       @pose[:action] = make_symbol($1)
  677.     end
  678.   end
  679.   #--------------------------------------------------------------------------
  680.   # *
  681.   #--------------------------------------------------------------------------
  682.   def set_freeze(value)
  683.     @pose[:target]   = set_targets(value)
  684.     @pose[:duration] = value =~ /DURATION (\d+)/i ? [$1.to_i, 1].max : 1
  685.   end
  686.   #--------------------------------------------------------------------------
  687.   # *
  688.   #--------------------------------------------------------------------------
  689.   def set_sound(value)
  690.     @pose[:name]   = value =~ /NAME #{get_filename}/i ? $1 : ""
  691.     @pose[:volume] = value =~ /VOLUME (\d+)/i ? $1.to_i : 100
  692.     @pose[:pitch]  = value =~ /PITCH (\d+)/i  ? $1.to_i : 100
  693.   end
  694.   #--------------------------------------------------------------------------
  695.   # *
  696.   #--------------------------------------------------------------------------
  697.   def set_anim(value)
  698.     @pose[:target] = set_targets(value)
  699.     item = current_item ? current_item : nil
  700.     case value
  701.     when /CAST/i
  702.       cast = item && $imported[:ve_cast_animation]
  703.       anim = cast ? battler.cast_animation_id(item) : 0
  704.       @pose[:anim] = anim
  705.     when /EFFECT/i
  706.       @pose[:anim] = item ? item.animation_id : 0
  707.     when /ID (\d+)/i
  708.       @pose[:anim] = $1.to_i
  709.     when /WEAPON *(\d+)?/i
  710.       @pose[:anim] = battler.atk_animation_id1
  711.       @pose[:anim] = battler.atk_animation_id2 if $1 && $1.to_i == 2
  712.     else
  713.       @pose[:anim] = 0
  714.     end
  715.   end
  716.   #--------------------------------------------------------------------------
  717.   # *
  718.   #--------------------------------------------------------------------------
  719.   def set_icon(value)
  720.     @pose[:target] = set_targets(value)
  721.     @pose[:index]  = value =~ /INDEX ([+-]?\d+)/i      ? $1.to_i : 0
  722.     @pose[:image]  = value =~ /IMAGE #{get_filename}/i ? $1.to_s : nil
  723.     @pose[:delete] = value =~ /DELETE/i ? true : false
  724.     return if @pose[:delete]
  725.     set_action_icon(value)
  726.     @pose[:x] = value =~ /X ([+-]?\d+)/i  ? $1.to_i : 0
  727.     @pose[:y] = value =~ /Y ([+-]?\d+)/i  ? $1.to_i : 0
  728.     @pose[:z] = value =~ /Z ([+-]?\d+)/i  ? $1.to_i : -1
  729.     @pose[:a] = value =~ /ANGLE ([+-]?\d+)/i   ? $1.to_i : 0
  730.     @pose[:o] = value =~ /OPACITY (\d+)/i      ? $1.to_i : 255
  731.     @pose[:spin] = value =~ /SPIN ([+-]\d+)/i  ? $1.to_i : 0
  732.     @pose[:fin]  = value =~ /FADE IN (\d+)/i   ? $1.to_i : 0
  733.     @pose[:fout] = value =~ /FADE OUT (\d+)/i  ? $1.to_i : 0
  734.     @pose[:izm]  = value =~ /INIT ZOOM (\d+)/i ? $1.to_i / 100.0 : 1.0
  735.     @pose[:ezm]  = value =~ /END ZOOM (\d+)/i  ? $1.to_i / 100.0 : 1.0
  736.     @pose[:szm]  = value =~ /ZOOM SPD (\d+)/i  ? $1.to_i / 100.0 : 0.1
  737.   end
  738.   #--------------------------------------------------------------------------
  739.   # *
  740.   #--------------------------------------------------------------------------
  741.   def set_picture(value)
  742.     @pose[:id] = value =~ /ID (\d+)/i ? [$1.to_i, 1].max : 1
  743.     @pose[:delete] = value =~ /DELETE/i ? true : false
  744.     return if @pose[:delete]
  745.     name = value =~ /NAME #{get_filename}/i ? $1.to_s : ""
  746.     orig = value =~ /ORIGIN CENTER/i ? 1 : 0
  747.     x    = value =~ /POS X ([+-]?\d+)/i ? $1.to_i : 0
  748.     y    = value =~ /POS Y ([+-]?\d+)/i ? $1.to_i : 0
  749.     zoom_x  = value =~ /ZOOM X ([+-]?\d+)/i ? $1.to_i : 100.0
  750.     zoom_y  = value =~ /ZOOM X ([+-]?\d+)/i ? $1.to_i : 100.0
  751.     opacity = value =~ /OPACITY (\d+)/i     ? $1.to_i : 255
  752.     blend   = value =~ /BLEND ([+-]\d+)/i   ? $1.to_i : 0
  753.     duration = value =~ /DURATION (\d+)/i    ? $1.to_i : 0
  754.     if value =~ /SHOW/i
  755.       @pose[:show] = [name, orig, x, y, zoom_x, zoom_y, opacity, blend]
  756.     elsif value =~ /MOVE/i
  757.       @pose[:move] = [orig, x, y, zoom_x, zoom_y, opacity, blend, duration]
  758.     end
  759.   end
  760.   #--------------------------------------------------------------------------
  761.   # *
  762.   #--------------------------------------------------------------------------
  763.   def set_plane(value)
  764.     @pose[:delete]   = value =~ /DELETE/i ? true : false
  765.     @pose[:duration] = value =~ /DURATION (\d+)/i ? $1.to_i : 0
  766.     return if @pose[:delete]
  767.     name = value =~ /NAME #{get_filename}/i ? $1.to_s : ""
  768.     x    = value =~ /MOVE X ([+-]?\d+)/i ? $1.to_i : 0
  769.     y    = value =~ /MOVE Y ([+-]?\d+)/i ? $1.to_i : 0
  770.     z    = value =~ /Z ([+-]?\d+)/i      ? $1.to_i : 100
  771.     zoom_x  = value =~ /ZOOM X ([+-]?\d+)/i ? $1.to_i : 100.0
  772.     zoom_y  = value =~ /ZOOM X ([+-]?\d+)/i ? $1.to_i : 100.0
  773.     opacity = value =~ /OPACITY (\d+)/i     ? $1.to_i : 160
  774.     blend   = value =~ /BLEND ([+-]\d+)/i   ? $1.to_i : 0
  775.     duration = @pose[:duration]
  776.     @pose[:list] = [name, x, y, z, zoom_x, zoom_y, opacity, blend, duration]
  777.   end
  778.   #--------------------------------------------------------------------------
  779.   # *
  780.   #--------------------------------------------------------------------------
  781.   def set_throw(value)
  782.     @pose[:target] = set_targets(value)
  783.     @pose[:image]  = value =~ /IMAGE #{get_filename}/i ? $1.to_s : nil
  784.     set_action_icon(value)
  785.     @pose[:revert] = value =~ /REVERT/i
  786.     @pose[:return] = value =~ /RETURN/i
  787.     @pose[:init_x] = value =~ /INIT X ([+-]?\d+)/i ? $1.to_i : 0
  788.     @pose[:init_y] = value =~ /INIT Y ([+-]?\d+)/i ? $1.to_i : 0
  789.     @pose[:end_x]  = value =~ /END X ([+-]?\d+)/i  ? $1.to_i : 0
  790.     @pose[:end_y]  = value =~ /END Y ([+-]?\d+)/i  ? $1.to_i : 0
  791.     @pose[:anim]   = value =~ /ANIM (\d+)/i    ? $1.to_i : nil
  792.     @pose[:arc]    = value =~ /ARC (\d+)/i     ? $1.to_i : 0
  793.     @pose[:speed]  = value =~ /SPEED (\d+)/i   ? $1.to_i / 10.0 : 1.0
  794.     @pose[:spin] = value =~ /SPIN ([+-]\d+)/i  ? $1.to_i : 0
  795.     @pose[:fin]  = value =~ /FADE IN (\d+)/i   ? $1.to_i : 0
  796.     @pose[:fout] = value =~ /FADE OUT (\d+)/i  ? $1.to_i : 0
  797.     @pose[:izm]  = value =~ /INIT ZOOM (\d+)/i ? $1.to_i / 100.0 : 1.0
  798.     @pose[:ezm]  = value =~ /END ZOOM (\d+)/i  ? $1.to_i / 100.0 : 1.0
  799.     @pose[:szm]  = value =~ /ZOOM SPD (\d+)/i  ? $1.to_i / 100.0 : 0.1
  800.     @pose[:z] = value =~ /Z ([+-]?\d+)/i  ? $1.to_i : 0
  801.     @pose[:o] = value =~ /OPACITY (\d+)/i ? $1.to_i : 255
  802.     @pose[:a] = value =~ /ANGLE (\d+)/i   ? $1.to_i : 0
  803.   end
  804.   #--------------------------------------------------------------------------
  805.   # *
  806.   #--------------------------------------------------------------------------
  807.   def set_action_icon(value)
  808.     icon = weapon_icon($1.to_i) if value =~ /WEAPON (\d+)/i && battler.actor?
  809.     icon = armor_icon($1.to_i)  if value =~ /ARMOR (\d+)/i  && battler.actor?
  810.     icon = armor_icon(1)        if value =~ /SHIELD/i       && battler.actor?
  811.     icon = action_icon if value =~ /ACTION/i
  812.     icon = $1.to_i     if value =~ /ICON (\d+)/i
  813.     @pose[:icon] = icon ? icon : 0
  814.   end
  815.   #--------------------------------------------------------------------------
  816.   # *
  817.   #--------------------------------------------------------------------------
  818.   def set_shake(value)
  819.     @pose[:target] = set_targets(value)
  820.     @pose[:screen] = value =~ /SCREEN/i ? true : false
  821.     power = value =~ /POWER (\d+)/i ? [$1.to_i, 2].max : 5
  822.     speed = value =~ /SPEED (\d+)/i ? [$1.to_i, 2].max : 5
  823.     duration = value =~ /DURATION (\d+)/i ? [$1.to_i, 1].max : 10
  824.     @pose[:shake] = [power / 2.0, speed / 2.0, duration]
  825.   end
  826.   #--------------------------------------------------------------------------
  827.   # *
  828.   #--------------------------------------------------------------------------
  829.   def set_movie(value)
  830.     @pose[:name] = value =~ /NAME #{get_filename}/i ? $1.to_s : ""
  831.     set_tone(value)
  832.   end
  833.   #--------------------------------------------------------------------------
  834.   # *
  835.   #--------------------------------------------------------------------------
  836.   def set_tone(value)
  837.     r = value =~ /RED ([+-]?\d+)/i   ? $1.to_i : 0
  838.     g = value =~ /GREEN ([+-]?\d+)/i ? $1.to_i : 0
  839.     b = value =~ /BLUE ([+-]?\d+)/i  ? $1.to_i : 0
  840.     a = value =~ /GRAY ([+-]?\d+)/i  ? $1.to_i : 0
  841.     tone  = [r, g, b, a]
  842.     tone  = [ 255,  255,  255, 0] if value =~ /WHITE/i
  843.     tone  = [-255, -255, -255, 0] if value =~ /BLACK/i
  844.     @pose[:tone]  = Tone.new(*tone)
  845.     @pose[:clear] = true if value =~ /CLEAR/i
  846.     @pose[:duration] = value =~ /DURATION (\d+)/i ? $1.to_i : 0
  847.     @pose[:priority] = :normal
  848.     @pose[:priority] = :high if value =~ /HIGH PRIORITY/i
  849.     @pose[:priority] = :low  if value =~ /LOW PRIORITY/i
  850.   end
  851.   #--------------------------------------------------------------------------
  852.   # *
  853.   #--------------------------------------------------------------------------
  854.   def set_flash(value)
  855.     @pose[:target] = set_targets(value)
  856.     @pose[:screen] = value =~ /SCREEN/i ? true : false
  857.     r = value =~ /RED (\d+)/i   ? $1.to_i : 255
  858.     g = value =~ /GREEN (\d+)/i ? $1.to_i : 255
  859.     b = value =~ /BLUE (\d+)/i  ? $1.to_i : 255
  860.     a = value =~ /ALPHA (\d+)/i ? $1.to_i : 160
  861.     duration = value =~ /DURATION (\d+)/i ? [$1.to_i, 1].max : 10
  862.     @pose[:flash] = [Color.new(r, g, b, a), duration]
  863.   end
  864.   #--------------------------------------------------------------------------
  865.   # *
  866.   #--------------------------------------------------------------------------
  867.   def set_loop(value)
  868.     @pose[:target]    = set_targets(value)
  869.     @pose[:loop_anim] = value =~ /ANIM (\d+)/i ? $1.to_i : 0
  870.   end
  871.   #--------------------------------------------------------------------------
  872.   # *
  873.   #--------------------------------------------------------------------------
  874.   def set_effect(value)
  875.     @pose[:target] = set_targets(value)
  876.     @pose[:damage] = $1.to_i / 100.0  if value =~ /(\d+)%/i
  877.     @pose[:weapon] = [$1.to_i, 1].max if value =~ /WEAPON (\d+)/i
  878.   end
  879.   #--------------------------------------------------------------------------
  880.   # *
  881.   #--------------------------------------------------------------------------
  882.   def set_counter(value)
  883.     @pose[:target]  = set_targets(value)
  884.     @pose[:counter] = true  if value =~ /ON/i
  885.     @pose[:counter] = false if value =~ /OFF/i
  886.   end
  887.   #--------------------------------------------------------------------------
  888.   # *
  889.   #--------------------------------------------------------------------------
  890.   def set_direction(value)
  891.     @pose[:targets]   = true if value =~ /TARGETS/i
  892.     @pose[:return]    = true if value =~ /RETURN/i
  893.     @pose[:direction] = 2 if value =~ /DOWN/i
  894.     @pose[:direction] = 4 if value =~ /LEFT/i
  895.     @pose[:direction] = 6 if value =~ /RIGHT/i
  896.     @pose[:direction] = 8 if value =~ /UP/i
  897.   end
  898.   #--------------------------------------------------------------------------
  899.   # *
  900.   #--------------------------------------------------------------------------
  901.   def set_targets(value)
  902.     case value
  903.     when /SELF/i
  904.       [self]
  905.     when /ACTOR ([^>,]+)/i
  906.       acotor = $game_actors[eval($1)]
  907.       target = $game_party.battle_members.include?(actor) ? [actor] : []
  908.     when /FRIEND ([^>,]+)/i
  909.       [$game_party.battle_members[eval($1)]].compact
  910.     when /ENEMY ([^>,]+)/i
  911.       [$game_troop.members[eval($1)]].compact
  912.     when /RANDOM ENEMY/i
  913.       battler.opponents_unit.members.random
  914.     when /RANDOM FRIEND/i
  915.       battler.firends_unit.members.random
  916.     when /ALL ENEMIES/i
  917.       battler.opponents_unit.members
  918.     when /ALL FRIENDS/i
  919.       battler.firends_unit.members
  920.     when /TARGETS/i
  921.       battler.action_targets.dup
  922.     when /USER/i
  923.       [battler]
  924.     else
  925.       nil
  926.     end
  927.   end
  928.   #--------------------------------------------------------------------------
  929.   # *
  930.   #--------------------------------------------------------------------------
  931.   def set_row(value)
  932.     pose = battler.sprite_value(make_symbol($1)) if value =~ /ROW (\w+)/i
  933.     pose = :direction if value =~ /ROW DIRECTION/i
  934.     pose = $1.to_i    if value =~ /ROW (\d+)/i
  935.     pose ? pose : 0
  936.   end
  937.   #--------------------------------------------------------------------------
  938.   # *
  939.   #--------------------------------------------------------------------------
  940.   def weapon_icon(index)
  941.     battler.weapons[index - 1] ? battler.weapons[index - 1].icon_index : nil
  942.   end
  943.   #--------------------------------------------------------------------------
  944.   # *
  945.   #--------------------------------------------------------------------------
  946.   def equip_list
  947.     @equips
  948.   end
  949.   #--------------------------------------------------------------------------
  950.   # *
  951.   #--------------------------------------------------------------------------
  952.   def armor_icon(index)
  953.     slot = battler.equip_slots[index]
  954.     return nil unless slot && slot != 0 && battler.equip_list[slot]
  955.     equip = battler.equip_list[slot]
  956.     equip.object ? equip.object.icon_index : nil
  957.   end
  958.   #--------------------------------------------------------------------------
  959.   # *
  960.   #--------------------------------------------------------------------------
  961.   def action_icon
  962.     current_item ? current_item.icon_index : 0
  963.   end
  964.   #--------------------------------------------------------------------------
  965.   # *
  966.   #--------------------------------------------------------------------------
  967.   def active?
  968.     @active
  969.   end
  970.   #--------------------------------------------------------------------------
  971.   # *
  972.   #--------------------------------------------------------------------------
  973.   def down?
  974.     @direction == 2
  975.   end
  976.   #--------------------------------------------------------------------------
  977.   # *
  978.   #--------------------------------------------------------------------------
  979.   def left?
  980.     @direction == 4
  981.   end
  982.   #--------------------------------------------------------------------------
  983.   # *
  984.   #--------------------------------------------------------------------------
  985.   def right?
  986.     @direction == 6
  987.   end
  988.   #--------------------------------------------------------------------------
  989.   # *
  990.   #--------------------------------------------------------------------------
  991.   def up?
  992.     @direction == 8
  993.   end
  994.   #--------------------------------------------------------------------------
  995.   # *
  996.   #--------------------------------------------------------------------------
  997.   def target_direction(x, y, current = nil)
  998.     position = current ? current : current_position
  999.     relative_x = position[:x] - x
  1000.     relative_y = position[:y] - y
  1001.     if relative_y.abs > relative_x.abs && !sideview
  1002.       @direction = relative_y < 0 ? 2 : 8
  1003.     elsif relative_x.abs >= relative_y.abs && !frontview
  1004.       @direction = relative_x < 0 ? 6 : 4
  1005.     end
  1006.   end
  1007.   #--------------------------------------------------------------------------
  1008.   # *
  1009.   #--------------------------------------------------------------------------
  1010.   def position_fix
  1011.     value =  16 if left?  || up?
  1012.     value = -16 if right? || down?
  1013.     target_position[rand(2) == 0 ? :x : :y] += value
  1014.   end
  1015.   #--------------------------------------------------------------------------
  1016.   # *
  1017.   #--------------------------------------------------------------------------
  1018.   def sharing_position?
  1019.     units = $game_troop.members + $game_party.battle_members
  1020.     list  = units.select do |target|
  1021.       target != self && target.target_position == target_position
  1022.     end
  1023.     !list.empty?
  1024.   end
  1025.   #--------------------------------------------------------------------------
  1026.   # *
  1027.   #--------------------------------------------------------------------------
  1028.   def sideview
  1029.     $imported[:ve_actor_battlers] && VE_BATTLE_FORMATION == :side
  1030.   end
  1031.   #--------------------------------------------------------------------------
  1032.   # *
  1033.   #--------------------------------------------------------------------------
  1034.   def frontview
  1035.     $imported[:ve_actor_battlers] && VE_BATTLE_FORMATION == :front
  1036.   end
  1037.   #--------------------------------------------------------------------------
  1038.   # *
  1039.   #--------------------------------------------------------------------------
  1040.   def action_direction
  1041.     units = @action_targets
  1042.     target_x = units.collect {|member| member.current_position[:x] }.average
  1043.     target_y = units.collect {|member| member.current_position[:y] }.average
  1044.     target_direction(target_x, target_y)
  1045.   end
  1046.   #--------------------------------------------------------------------------
  1047.   # *
  1048.   #--------------------------------------------------------------------------
  1049.   def target_distance(symbol)
  1050.     @target_position[symbol] - @current_position[symbol]
  1051.   end
  1052.   #--------------------------------------------------------------------------
  1053.   # *
  1054.   #--------------------------------------------------------------------------
  1055.   def moving?
  1056.     @current_position != @target_position
  1057.   end
  1058.   #--------------------------------------------------------------------------
  1059.   # *
  1060.   #--------------------------------------------------------------------------
  1061.   def origin?
  1062.     @current_position[:x] != screen_x || @current_position[:y] != screen_y
  1063.   end
  1064.   #--------------------------------------------------------------------------
  1065.   # *
  1066.   #--------------------------------------------------------------------------
  1067.   def activate
  1068.     return unless current_action && current_action.item
  1069.     @active = true
  1070.     @active_pose = nil
  1071.     @action_targets = current_action.make_targets.compact.dup
  1072.     setup_immortals
  1073.   end
  1074.   #--------------------------------------------------------------------------
  1075.   # *
  1076.   #--------------------------------------------------------------------------
  1077.   def setup_immortals
  1078.     @action_targets.each {|target| immortals.push(target) unless target.dead? }
  1079.     immortals.uniq!
  1080.   end
  1081.   #--------------------------------------------------------------------------
  1082.   # *
  1083.   #--------------------------------------------------------------------------
  1084.   def deactivate
  1085.     @active = false
  1086.     @attack_flag = nil
  1087.     @result_flag = nil
  1088.     immortals = @immortals.dup
  1089.     @immortals.clear
  1090.     immortals.each {|member| member.refresh }
  1091.     @action_targets.clear
  1092.   end
  1093.   #--------------------------------------------------------------------------
  1094.   # *
  1095.   #--------------------------------------------------------------------------
  1096.   def action_pose(item)
  1097.     activate
  1098.     @current_item = item
  1099.     pose = set_action_pose(item)
  1100.     call_action_poses(pose, item)
  1101.   end
  1102.   #--------------------------------------------------------------------------
  1103.   # *
  1104.   #--------------------------------------------------------------------------
  1105.   def set_action_pose(item)
  1106.     [setup_pose_type(item), false, item]
  1107.   end
  1108.   #--------------------------------------------------------------------------
  1109.   # *
  1110.   #--------------------------------------------------------------------------
  1111.   def setup_pose_type(item)
  1112.     pose = weapons_pose("USE",   :use)
  1113.     pose = weapons_pose("ITEM",  :item)  if item.item?
  1114.     pose = weapons_pose("MAGIC", :magic) if item.magical?
  1115.     pose = weapons_pose("SKILL", :skill) if item.skill?
  1116.     pose = attack_pose if item_attack?(item)
  1117.     pose = :defend     if item_defend?(item)
  1118.     pose = custom_pose("ACTION", pose, item)
  1119.     pose
  1120.   end
  1121.   #--------------------------------------------------------------------------
  1122.   # *
  1123.   #--------------------------------------------------------------------------
  1124.   def item_attack?(item)
  1125.     item.skill? && item.id == attack_skill_id
  1126.   end
  1127.   #--------------------------------------------------------------------------
  1128.   # *
  1129.   #--------------------------------------------------------------------------
  1130.   def item_defend?(item)
  1131.     item.skill? && item.id == guard_skill_id
  1132.   end
  1133.   #--------------------------------------------------------------------------
  1134.   # *
  1135.   #--------------------------------------------------------------------------
  1136.   def attack_pose
  1137.     pose = weapons_pose("ATTACK", :attack)
  1138.     pose = weapons_pose("DUAL",   :dual_attack) if double_attack?
  1139.     pose
  1140.   end
  1141.   #--------------------------------------------------------------------------
  1142.   # *
  1143.   #--------------------------------------------------------------------------
  1144.   def weapons_pose(type, pose)
  1145.     valid = actor? ? weapons : []
  1146.     list  = valid.collect { |item| item.custom_pose(type) }.compact
  1147.     list.empty? || !pose_exist?(list.first) ? pose : list.first
  1148.   end
  1149.   #--------------------------------------------------------------------------
  1150.   # *
  1151.   #--------------------------------------------------------------------------
  1152.   def custom_pose(type, pose, item)
  1153.     note   = item ? item.note : ""
  1154.     custom = item.custom_pose(type)
  1155.     custom && pose_exist?(custom, note) ? custom : pose
  1156.   end
  1157.   #--------------------------------------------------------------------------
  1158.   # *
  1159.   #--------------------------------------------------------------------------
  1160.   def pose_exist?(pose, note = "")
  1161.     value  = "ACTION: #{make_string(pose)}"
  1162.     regexp = /<#{value}(?:(?: *, *[\w ]+)+)?>(?:[^<]|<[^\/])*<\/ACTION>/im
  1163.     get_all_poses(note) =~ regexp
  1164.   end
  1165.   #--------------------------------------------------------------------------
  1166.   # *
  1167.   #--------------------------------------------------------------------------
  1168.   def call_action_poses(pose, item)
  1169.     clear_idle_poses
  1170.     call_move_pose("ADVANCE", :advance, item) if need_move?(item)
  1171.     call_pose(*pose)
  1172.     call_pose(:inactive)
  1173.     call_custom_pose("RETREAT", :retreat, item)
  1174.   end
  1175.   #--------------------------------------------------------------------------
  1176.   # *
  1177.   #--------------------------------------------------------------------------
  1178.   def call_move_pose(type, pose, item)
  1179.     pose = weapons_pose(type, pose)
  1180.     pose = custom_pose(type, pose, item)
  1181.     call_pose(pose, false, item)
  1182.   end
  1183.   #--------------------------------------------------------------------------
  1184.   # *
  1185.   #--------------------------------------------------------------------------
  1186.   def call_custom_pose(type, pose, item)
  1187.     pose = custom_pose(type, pose, item)
  1188.     call_pose(pose, false, item)
  1189.   end
  1190.   #--------------------------------------------------------------------------
  1191.   # *
  1192.   #--------------------------------------------------------------------------
  1193.   def need_move?(item)
  1194.     return true  if item.note =~ /<ACTION MOVEMENT>/i
  1195.     return true  if item.skill? && item.physical?
  1196.     return true  if item.skill? && item.id == attack_skill_id
  1197.     return false
  1198.   end
  1199.   #--------------------------------------------------------------------------
  1200.   # *
  1201.   #--------------------------------------------------------------------------
  1202.   def call_damage_pose(item, user)
  1203.     call_pose(:hurt,     :clear, item, :skip) if hurt_pose?
  1204.     call_pose(:evade,    :clear, item, :skip) if @result.evaded
  1205.     call_pose(:critical, :clear, item, :skip) if @result.critical
  1206.   end
  1207.   #--------------------------------------------------------------------------
  1208.   # *
  1209.   #--------------------------------------------------------------------------
  1210.   def hurt_pose?
  1211.     @result.hit? && @result.hp_damage > 0 && !moving?
  1212.   end
  1213.   #--------------------------------------------------------------------------
  1214.   # *
  1215.   #--------------------------------------------------------------------------
  1216.   def set_active_pose
  1217.     return if (!current_action || !current_action.item) && !current_item
  1218.     item = current_action.item ? current_action.item : current_item
  1219.     pose = :ready      if sprite_value(:ready)
  1220.     pose = :item_cast  if item.item?     && sprite_value(:item_cast)
  1221.     pose = :magic_cast if item.magical?  && sprite_value(:magic_cast)
  1222.     pose = :skill_cast if item.physical? && sprite_value(:skill_cast)
  1223.     @active_pose = pose
  1224.   end
  1225.   #--------------------------------------------------------------------------
  1226.   # *
  1227.   #--------------------------------------------------------------------------
  1228.   def setup_counter(target)
  1229.     target.skip_pose unless [:inactive, :retreat].include?(target.pose_name)
  1230.     target.call_pose(:counter_on, :clear)
  1231.     @action_targets = [target]
  1232.     setup_immortals
  1233.     @current_item = $data_skills[attack_skill_id]
  1234.     pose = set_action_pose(@current_item)
  1235.     call_action_poses(pose, @current_item)
  1236.     call_pose(:counter_off)
  1237.   end
  1238.   #--------------------------------------------------------------------------
  1239.   # *
  1240.   #--------------------------------------------------------------------------
  1241.   def setup_reflect(item)
  1242.     skip_pose unless [:reflection, :inactive, :retreat].include?(pose_name)
  1243.     @action_targets = [self]
  1244.     setup_immortals
  1245.     @current_item = item
  1246.     pose = set_action_pose(item)
  1247.     call_pose(:reflection, true, item)
  1248.   end
  1249.   #--------------------------------------------------------------------------
  1250.   # *
  1251.   #--------------------------------------------------------------------------
  1252.   def setup_substitute(target)
  1253.     skip_pose unless [:substitution_on, :inactive, :retreat].include?(pose_name)
  1254.     @action_targets = [target]
  1255.     @substitution = true
  1256.     @current_position = target.current_position.dup
  1257.     @current_position[:x] += target.left? ? -16 : target.right? ? 16 : 0
  1258.     @current_position[:y] += target.up?   ? -16 : target.down?  ? 16 : 1
  1259.     @target_position = @current_position.dup
  1260.     call_pose(:substitution_off, true)
  1261.     call_pose(:substitution_on, true)
  1262.     sprite.update
  1263.   end
  1264.   #--------------------------------------------------------------------------
  1265.   # *
  1266.   #--------------------------------------------------------------------------
  1267.   def double_attack?
  1268.     actor? && dual_wield? && weapons.size > 1
  1269.   end
  1270.   #--------------------------------------------------------------------------
  1271.   # *
  1272.   #--------------------------------------------------------------------------
  1273.   def not_in_position?
  1274.     @current_position[:x] != screen_x || @current_position[:y] != screen_y
  1275.   end
  1276.   #--------------------------------------------------------------------------
  1277.   # *
  1278.   #--------------------------------------------------------------------------
  1279.   def state_pose?
  1280.     state_pose
  1281.   end
  1282.   #--------------------------------------------------------------------------
  1283.   # *
  1284.   #--------------------------------------------------------------------------
  1285.   def state_pose
  1286.     states.collect {|state| state.custom_pose("STATE") }.first
  1287.   end
  1288.   #--------------------------------------------------------------------------
  1289.   # *
  1290.   #--------------------------------------------------------------------------
  1291.   def reset_pose
  1292.     return unless $game_party.in_battle
  1293.     sprite.reset_pose
  1294.   end
  1295.   #--------------------------------------------------------------------------
  1296.   # * New method: frames
  1297.   #--------------------------------------------------------------------------
  1298.   def frames
  1299.     @character_name[/\[F(\d+)\]/i] ? $1.to_i : 3
  1300.   end
  1301.   #--------------------------------------------------------------------------
  1302.   # *
  1303.   #--------------------------------------------------------------------------
  1304.   def start_shake(power, speed, duration)
  1305.     @shake_power = power
  1306.     @shake_speed = speed
  1307.     @shake_duration = duration
  1308.   end
  1309.   #--------------------------------------------------------------------------
  1310.   # *
  1311.   #--------------------------------------------------------------------------
  1312.   def update_shake
  1313.     return unless shaking?
  1314.     delta  = (@shake_power * @shake_speed * @shake_direction) / 10.0
  1315.     clear  = @shake_duration <= 1 && @shake * (@shake + delta) < 0
  1316.     @shake = clear ? 0 : @shake + delta
  1317.     @shake_direction = -1 if @shake > @shake_power * 2
  1318.     @shake_direction = 1  if @shake < - @shake_power * 2
  1319.     @shake_duration -= 1
  1320.   end
  1321.   #--------------------------------------------------------------------------
  1322.   # *
  1323.   #--------------------------------------------------------------------------
  1324.   def update_freeze
  1325.     return if @freeze == 0 || !@freeze.numeric?
  1326.     @freeze -= 1
  1327.   end
  1328.   #--------------------------------------------------------------------------
  1329.   # *
  1330.   #--------------------------------------------------------------------------
  1331.   def shaking?
  1332.     @shake_duration > 0 || @shake != 0
  1333.   end
  1334.   #--------------------------------------------------------------------------
  1335.   # *
  1336.   #--------------------------------------------------------------------------
  1337.   def frozen?
  1338.     (@freeze.numeric? && @freeze > 0) || @freeze == :lock || unmovable?
  1339.   end
  1340.   #--------------------------------------------------------------------------
  1341.   # *
  1342.   #--------------------------------------------------------------------------
  1343.   def unmovable?
  1344.     get_all_notes =~ /<UNMOVEABLE>/i
  1345.   end
  1346. end
  1347.  
  1348. #==============================================================================
  1349. # ** Game_Actor
  1350. #------------------------------------------------------------------------------
  1351. #  This class handles actors. It's used within the Game_Actors class
  1352. # ($game_actors) and referenced by the Game_Party class ($game_party).
  1353. #==============================================================================
  1354.  
  1355. class Game_Actor < Game_Battler
  1356.   #--------------------------------------------------------------------------
  1357.   # *
  1358.   #--------------------------------------------------------------------------
  1359.   def perform_collapse_effect
  1360.     if $game_party.in_battle
  1361.       reset_pose
  1362.       case collapse_type
  1363.       when 0
  1364.         @sprite_effect_type = :collapse
  1365.         Sound.play_enemy_collapse
  1366.       when 1
  1367.         @sprite_effect_type = :boss_collapse
  1368.         Sound.play_boss_collapse1
  1369.       when 2
  1370.         @sprite_effect_type = :instant_collapse
  1371.       end
  1372.     end
  1373.   end
  1374.   #--------------------------------------------------------------------------
  1375.   # *
  1376.   #--------------------------------------------------------------------------
  1377.   def perform_damage_effect
  1378.     $game_troop.screen.start_shake(5, 5, 10) unless use_sprite?
  1379.     Sound.play_actor_damage
  1380.   end
  1381.   #--------------------------------------------------------------------------
  1382.   # *
  1383.   #--------------------------------------------------------------------------
  1384.   alias :param_plus_ve_animated_battle :param_plus
  1385.   def param_plus(param_id)
  1386.     if param_id > 1 && @attack_flag
  1387.       atk_equips.compact.inject(super) {|r, item| r += item.params[param_id] }
  1388.     else
  1389.       param_plus_ve_animated_battle(param_id)
  1390.     end
  1391.   end
  1392.   #--------------------------------------------------------------------------
  1393.   # *
  1394.   #--------------------------------------------------------------------------
  1395.   def atk_feature_objects
  1396.     list = @attack_flag ? atk_equips : equips.compact
  1397.     states + [actor] + [self.class] + list
  1398.   end
  1399.   #--------------------------------------------------------------------------
  1400.   # *
  1401.   #--------------------------------------------------------------------------
  1402.   def atk_all_features
  1403.     atk_feature_objects.inject([]) {|r, obj| r + obj.features }
  1404.   end
  1405.   #--------------------------------------------------------------------------
  1406.   # *
  1407.   #--------------------------------------------------------------------------
  1408.   def atk_features(code)
  1409.     atk_all_features.select {|ft| ft.code == code }
  1410.   end
  1411.   #--------------------------------------------------------------------------
  1412.   # *
  1413.   #--------------------------------------------------------------------------
  1414.   def atk_features_set(code)
  1415.     atk_features(code).inject([]) {|r, ft| r |= [ft.data_id] }
  1416.   end
  1417.   #--------------------------------------------------------------------------
  1418.   # *
  1419.   #--------------------------------------------------------------------------
  1420.   def atk_elements
  1421.     set = atk_features_set(FEATURE_ATK_ELEMENT)
  1422.     set |= [1] if weapons.compact.empty?
  1423.     return set
  1424.   end
  1425.   #--------------------------------------------------------------------------
  1426.   # *
  1427.   #--------------------------------------------------------------------------
  1428.   def atk_states
  1429.     atk_features_set(FEATURE_ATK_STATE)
  1430.   end
  1431.   #--------------------------------------------------------------------------
  1432.   # *
  1433.   #--------------------------------------------------------------------------
  1434.   def atk_equips
  1435.     ([weapons[@attack_flag - 1]] + armors).collect {|item| item }.compact
  1436.   end
  1437.   #--------------------------------------------------------------------------
  1438.   # *
  1439.   #--------------------------------------------------------------------------
  1440.   def default_direction
  1441.     units = opponents_unit.members
  1442.     x = units.collect {|member| member.screen_x }.average
  1443.     y = units.collect {|member| member.screen_y }.average
  1444.     target_direction(x, y, {x: screen_x, y: screen_y})
  1445.   end
  1446.   #--------------------------------------------------------------------------
  1447.   # *
  1448.   #--------------------------------------------------------------------------
  1449.   def screen_x
  1450.     return 0
  1451.   end
  1452.   #--------------------------------------------------------------------------
  1453.   # *
  1454.   #--------------------------------------------------------------------------
  1455.   def screen_y
  1456.     return 0
  1457.   end
  1458.   #--------------------------------------------------------------------------
  1459.   # *
  1460.   #--------------------------------------------------------------------------
  1461.   def character_hue
  1462.     hue
  1463.   end
  1464. end
  1465.  
  1466. #==============================================================================
  1467. # ** Game_Enemy
  1468. #------------------------------------------------------------------------------
  1469. #  This class handles enemy characters. It's used within the Game_Troop class
  1470. # ($game_troop).
  1471. #==============================================================================
  1472.  
  1473. class Game_Enemy < Game_Battler
  1474.   #--------------------------------------------------------------------------
  1475.   # *
  1476.   #--------------------------------------------------------------------------
  1477.   alias :perform_collapse_effect_ve_animated_battle :perform_collapse_effect
  1478.   def perform_collapse_effect
  1479.     reset_pose
  1480.     perform_collapse_effect_ve_animated_battle
  1481.   end
  1482.   #--------------------------------------------------------------------------
  1483.   # *
  1484.   #--------------------------------------------------------------------------
  1485.   def perform_damage_effect
  1486.     Sound.play_enemy_damage
  1487.   end
  1488.   #--------------------------------------------------------------------------
  1489.   # *
  1490.   #--------------------------------------------------------------------------
  1491.   def character_name
  1492.     @battler_name
  1493.   end
  1494.   #--------------------------------------------------------------------------
  1495.   # *
  1496.   #--------------------------------------------------------------------------
  1497.   def character_hue
  1498.     @battler_hue
  1499.   end
  1500.   #--------------------------------------------------------------------------
  1501.   # *
  1502.   #--------------------------------------------------------------------------
  1503.   def character_index
  1504.     0
  1505.   end
  1506.   #--------------------------------------------------------------------------
  1507.   # *
  1508.   #--------------------------------------------------------------------------
  1509.   def visual_items
  1510.     [default_part]
  1511.   end
  1512.   #--------------------------------------------------------------------------
  1513.   # *
  1514.   #--------------------------------------------------------------------------
  1515.   def default_part
  1516.     {name: character_name.dup, index1: character_index, index2: character_index,
  1517.      hue: character_hue, priority: 0}
  1518.   end
  1519.   #--------------------------------------------------------------------------
  1520.   # *
  1521.   #--------------------------------------------------------------------------
  1522.   def default_direction
  1523.     units = opponents_unit.battle_members
  1524.     x = units.collect {|member| member.screen_x }.average
  1525.     y = units.collect {|member| member.screen_y }.average
  1526.     target_direction(x, y, {x: screen_x, y: screen_y})
  1527.   end
  1528. end
  1529.  
  1530. #==============================================================================
  1531. # ** Game_Party
  1532. #------------------------------------------------------------------------------
  1533. #  This class handles the party. It includes information on amount of gold
  1534. # and items. The instance of this class is referenced by $game_party.
  1535. #==============================================================================
  1536.  
  1537. class Game_Party < Game_Unit
  1538.   #--------------------------------------------------------------------------
  1539.   # *
  1540.   #--------------------------------------------------------------------------
  1541.   def not_in_position?
  1542.     movable_members.any? {|member| member.not_in_position? }
  1543.   end
  1544.   #--------------------------------------------------------------------------
  1545.   # *
  1546.   #--------------------------------------------------------------------------
  1547.   def moving?
  1548.     movable_members.any? {|member| member.moving? }
  1549.   end
  1550. end
  1551.  
  1552. #==============================================================================
  1553. # ** Game_Troop
  1554. #------------------------------------------------------------------------------
  1555. #  This class handles enemy groups and battle-related data. Also performs
  1556. # battle events. The instance of this class is referenced by $game_troop.
  1557. #==============================================================================
  1558.  
  1559. class Game_Troop < Game_Unit
  1560.   #--------------------------------------------------------------------------
  1561.   # *
  1562.   #--------------------------------------------------------------------------
  1563.   attr_accessor :back_attack
  1564. end
  1565.  
  1566. #==============================================================================
  1567. # ** Sprite_Battler
  1568. #------------------------------------------------------------------------------
  1569. #  This sprite is used to display battlers. It observes a instance of the
  1570. # Game_Battler class and automatically changes sprite conditions.
  1571. #==============================================================================
  1572.  
  1573. class Sprite_Battler < Sprite_Base
  1574.   #--------------------------------------------------------------------------
  1575.   # *
  1576.   #--------------------------------------------------------------------------
  1577.   attr_accessor :battler
  1578.   #--------------------------------------------------------------------------
  1579.   # *
  1580.   #--------------------------------------------------------------------------
  1581.   alias :initialize_ve_animated_battle :initialize
  1582.   def initialize(viewport, battler = nil)
  1583.     initialize_ve_animated_battle(viewport, battler)
  1584.     init_variables
  1585.   end
  1586.   #--------------------------------------------------------------------------
  1587.   # *
  1588.   #--------------------------------------------------------------------------
  1589.   alias :update_effect_ve_animated_battle :update_effect
  1590.   def update_effect
  1591.     setup_collapse
  1592.     update_effect_ve_animated_battle
  1593.     update_pose
  1594.     update_pose_loop_anim if $imported[:ve_loop_animation]
  1595.   end
  1596.   #--------------------------------------------------------------------------
  1597.   # *
  1598.   #--------------------------------------------------------------------------
  1599.   alias :revert_to_normal_ve_animated_battle :revert_to_normal
  1600.   def revert_to_normal
  1601.     revert_to_normal_ve_animated_battle
  1602.     update_rect if bitmap
  1603.   end
  1604.   #--------------------------------------------------------------------------
  1605.   # *
  1606.   #--------------------------------------------------------------------------
  1607.   def setup_collapse
  1608.     if @battler.dead? && !@dead
  1609.       @battler.perform_collapse_effect
  1610.       @dead = true
  1611.     elsif @dead && !@battler.dead?
  1612.       @dead = false
  1613.     end
  1614.   end
  1615.   #--------------------------------------------------------------------------
  1616.   # *
  1617.   #--------------------------------------------------------------------------
  1618.   def update_bitmap
  1619.     setup_bitmap if graphic_changed?
  1620.   end
  1621.   #--------------------------------------------------------------------------
  1622.   # *
  1623.   #--------------------------------------------------------------------------
  1624.   def init_visibility
  1625.     @battler_visible = !@battler.hidden?
  1626.     self.opacity = 0 unless @battler_visible
  1627.   end
  1628.   #--------------------------------------------------------------------------
  1629.   # *
  1630.   #--------------------------------------------------------------------------
  1631.   def init_variables
  1632.     @frame = 0
  1633.     @sufix = ""
  1634.     @pose_sufix = ""
  1635.     @anim_sufix = VE_SPRITE_SUFIX
  1636.     @frame_width  = 0
  1637.     @frame_height = 0
  1638.     @pose_value   = {}
  1639.     @icon_list    = {}
  1640.     @throw_list   = []
  1641.     start_effect(:appear) if VE_BATTLE_INTRO_FADE && !@battler.hidden?
  1642.     @battler.clear_poses
  1643.     setup_positions
  1644.   end
  1645.   #--------------------------------------------------------------------------
  1646.   # *
  1647.   #--------------------------------------------------------------------------
  1648.   def subject
  1649.     @pose_battler ? @pose_battler : @battler
  1650.   end
  1651.   #--------------------------------------------------------------------------
  1652.   # *
  1653.   #--------------------------------------------------------------------------
  1654.   def sprite_value(value)
  1655.     @battler.sprite_value(value)
  1656.   end
  1657.   #--------------------------------------------------------------------------
  1658.   # *
  1659.   #--------------------------------------------------------------------------
  1660.   def graphic_changed?
  1661.     actor_name_change? || battler_name_change? || misc_change?
  1662.   end
  1663.   #--------------------------------------------------------------------------
  1664.   # *
  1665.   #--------------------------------------------------------------------------
  1666.   def actor_name_change?
  1667.     use_charset? && (@battler_name != @battler.character_name ||
  1668.     @battler_index != @battler.character_index ||
  1669.     @battler_hue   != @battler.character_hue)
  1670.   end
  1671.   #--------------------------------------------------------------------------
  1672.   # *
  1673.   #--------------------------------------------------------------------------
  1674.   def battler_name_change?
  1675.     !use_charset? && (@battler_name != @battler.battler_name ||
  1676.     @battler_hue  != @battler.battler_hue)
  1677.   end
  1678.   #--------------------------------------------------------------------------
  1679.   # *
  1680.   #--------------------------------------------------------------------------
  1681.   def misc_change?
  1682.     (visual_equip? && @visual_items != @battler.visual_items) ||
  1683.     @sufix != @battler.sufix || @direction != @battler.direction
  1684.   end
  1685.   #--------------------------------------------------------------------------
  1686.   # *
  1687.   #--------------------------------------------------------------------------
  1688.   def use_charset?
  1689.     sprite_value(:mode) == :charset
  1690.   end
  1691.   #--------------------------------------------------------------------------
  1692.   # *
  1693.   #--------------------------------------------------------------------------
  1694.   def visual_equip?
  1695.     $imported[:ve_visual_equip]
  1696.   end
  1697.   #--------------------------------------------------------------------------
  1698.   # *
  1699.   #--------------------------------------------------------------------------
  1700.   def setup_bitmap
  1701.     if use_charset?
  1702.       @battler_name  = @battler.character_name
  1703.       @battler_hue   = @battler.character_hue
  1704.       @battler_index = @battler.character_index
  1705.     else
  1706.       @battler_name  = @battler.battler_name
  1707.       @battler_hue   = @battler.battler_hue
  1708.     end
  1709.     @sufix        = @battler.sufix
  1710.     @direction    = @battler.direction
  1711.     @visual_items = @battler.visual_items.dup if visual_equip?
  1712.     init_bitmap
  1713.     init_frame
  1714.     init_visibility
  1715.   end
  1716.   #--------------------------------------------------------------------------
  1717.   # *
  1718.   #--------------------------------------------------------------------------
  1719.   def init_bitmap
  1720.     case sprite_value(:mode)
  1721.     when :charset
  1722.       if visual_equip?
  1723.         args = [@battler_name, @battler_hue, @visual_items, sufix]
  1724.         self.bitmap = Cache.character(*args)
  1725.       else
  1726.         self.bitmap = Cache.character(get_character_name, @battler_hue)
  1727.       end
  1728.     when :single
  1729.       self.bitmap = Cache.battler(get_battler_name, @battler_hue)
  1730.     when :sprite
  1731.       self.bitmap = Cache.battler(get_battler_name, @battler_hue)
  1732.     else
  1733.       self.bitmap = Cache.battler(@battler_name, @battler_hue)
  1734.     end
  1735.   end
  1736.   #--------------------------------------------------------------------------
  1737.   # *
  1738.   #--------------------------------------------------------------------------
  1739.   def sufix
  1740.     case sprite_value(:mode)
  1741.     when :charset then @sufix
  1742.     when :sprite  then @anim_sufix + @sufix
  1743.     else @sufix
  1744.     end
  1745.   end
  1746.   #--------------------------------------------------------------------------
  1747.   # *
  1748.   #--------------------------------------------------------------------------
  1749.   def get_battler_name
  1750.     name = @battler_name + sufix
  1751.     battler_exist?(name) ? name : @battler_name
  1752.   end
  1753.   #--------------------------------------------------------------------------
  1754.   # *
  1755.   #--------------------------------------------------------------------------
  1756.   def get_character_name
  1757.     name = @battler_name + sufix
  1758.     character_exist?(name) ? name : @battler_name
  1759.   end
  1760.   #--------------------------------------------------------------------------
  1761.   # *
  1762.   #--------------------------------------------------------------------------
  1763.   def init_frame
  1764.     @frame_width  = bitmap.width  / frame_number
  1765.     @frame_height = bitmap.height / row_number
  1766.   end
  1767.   #--------------------------------------------------------------------------
  1768.   # *
  1769.   #--------------------------------------------------------------------------
  1770.   def frame_number
  1771.     return @battler.frames     if single_char?
  1772.     return @battler.frames * 4 if multi_char?
  1773.     return 1 unless battler_exist?(@battler_name + sufix)
  1774.     return sprite_value(:frames) if sprite_value(:mode) == :sprite
  1775.     return 1
  1776.   end
  1777.   #--------------------------------------------------------------------------
  1778.   # *
  1779.   #--------------------------------------------------------------------------
  1780.   def row_number
  1781.     return 4 if single_char?
  1782.     return 8 if multi_char?
  1783.     return 1 unless battler_exist?(@battler_name + sufix)
  1784.     return sprite_value(:rows) if sprite_value(:mode) == :sprite
  1785.     return 1
  1786.   end
  1787.   #--------------------------------------------------------------------------
  1788.   # *
  1789.   #--------------------------------------------------------------------------
  1790.   def single_char?
  1791.     use_charset? && (single_normal? || single_visual?)
  1792.   end
  1793.   #--------------------------------------------------------------------------
  1794.   # *
  1795.   #--------------------------------------------------------------------------
  1796.   def multi_char?
  1797.     use_charset? && (multi_normal? || multi_visual?)
  1798.   end
  1799.   #--------------------------------------------------------------------------
  1800.   # *
  1801.   #--------------------------------------------------------------------------
  1802.   def single_normal?
  1803.     !visual_equip? && @battler_name[/^[!]?[$]./]
  1804.   end
  1805.   #--------------------------------------------------------------------------
  1806.   # *
  1807.   #--------------------------------------------------------------------------
  1808.   def multi_normal?
  1809.     !visual_equip? && !@battler_name[/^[!]?[$]./]
  1810.   end
  1811.   #--------------------------------------------------------------------------
  1812.   # *
  1813.   #--------------------------------------------------------------------------
  1814.   def single_visual?
  1815.     visual_equip? && !get_sign
  1816.   end
  1817.   #--------------------------------------------------------------------------
  1818.   # *
  1819.   #--------------------------------------------------------------------------
  1820.   def multi_visual?
  1821.     visual_equip? && get_sign
  1822.   end
  1823.   #--------------------------------------------------------------------------
  1824.   # *
  1825.   #--------------------------------------------------------------------------
  1826.   def get_sign
  1827.     @visual_items.any? {|part| !part[:name][/^[!]?[$]./] }
  1828.   end
  1829.   #--------------------------------------------------------------------------
  1830.   # *
  1831.   #--------------------------------------------------------------------------
  1832.   def update_origin
  1833.     update_rect if bitmap
  1834.     update_icon
  1835.     update_throw
  1836.   end
  1837.   #--------------------------------------------------------------------------
  1838.   # *
  1839.   #--------------------------------------------------------------------------
  1840.   def update_rect
  1841.     setup_frame
  1842.     setup_rect
  1843.     self.ox = @frame_width / 2
  1844.     self.oy = @frame_height
  1845.     self.mirror = pose_mirror
  1846.   end
  1847.   #--------------------------------------------------------------------------
  1848.   # *
  1849.   #--------------------------------------------------------------------------
  1850.   def pose_mirror
  1851.     mirror = sprite_value(:invert)
  1852.     return !mirror if right? && sprite_value(:mirror)
  1853.     return  mirror
  1854.   end
  1855.   #--------------------------------------------------------------------------
  1856.   # *
  1857.   #--------------------------------------------------------------------------
  1858.   def down?
  1859.     @battler.down?
  1860.   end
  1861.   #--------------------------------------------------------------------------
  1862.   # *
  1863.   #--------------------------------------------------------------------------
  1864.   def left?
  1865.     @battler.left?
  1866.   end
  1867.   #--------------------------------------------------------------------------
  1868.   # *
  1869.   #--------------------------------------------------------------------------
  1870.   def right?
  1871.     @battler.right?
  1872.   end
  1873.   #--------------------------------------------------------------------------
  1874.   # *
  1875.   #--------------------------------------------------------------------------
  1876.   def up?
  1877.     @battler.up?
  1878.   end
  1879.   #--------------------------------------------------------------------------
  1880.   # *
  1881.   #--------------------------------------------------------------------------
  1882.   def setup_frame
  1883.     return if @battler.timing.empty?
  1884.     value = @battler.timing
  1885.     value[:time] -= 1
  1886.     value[:time] = value[:wait] if value[:time] == 0
  1887.     return if value[:time] != value[:wait]
  1888.     max = value[:frame] == :all ? sprite_value(:frames) : value[:frame]
  1889.     @frame += 1
  1890.     if value[:loop]
  1891.       @battler.frame = returing_value(@frame, max - 1)
  1892.     else
  1893.       @frame %= max
  1894.       @battler.frame = value[:revert] ? max - 1 - @frame : @frame
  1895.       reset_frame if @frame >= max - 1 || @frame == 0
  1896.     end
  1897.   end
  1898.   #--------------------------------------------------------------------------
  1899.   # *
  1900.   #--------------------------------------------------------------------------
  1901.   def reset_frame
  1902.     @battler.timing = {}
  1903.     @frame = 0           
  1904.   end
  1905.   #--------------------------------------------------------------------------
  1906.   # *
  1907.   #--------------------------------------------------------------------------
  1908.   def setup_rect
  1909.     sign =  @battler_name[/^[$]./]
  1910.     if use_charset? && !sign
  1911.       index = @battler_index
  1912.       frame = (index % 4 * @battler.frames + @battler.frame) * @frame_width
  1913.       row   = (index / 4 * 4 + @battler.row) * @frame_height
  1914.     else
  1915.       frame = [[@battler.frame, 0].max, frame_number - 1].min * @frame_width
  1916.       row   = [[@battler.row,   0].max,   row_number - 1].min * @frame_height
  1917.     end
  1918.     self.src_rect.set(frame, row, @frame_width, @frame_height)
  1919.   end  
  1920.   #--------------------------------------------------------------------------
  1921.   # *
  1922.   #--------------------------------------------------------------------------
  1923.   def update_pose
  1924.     setup_pose
  1925.     update_next_pose
  1926.   end
  1927.   #--------------------------------------------------------------------------
  1928.   # *
  1929.   #--------------------------------------------------------------------------
  1930.   def update_next_pose
  1931.     next_pose unless @pose
  1932.     return if !@pose || !@pose[:type].is_a?(Symbol)
  1933.     update_pose_type
  1934.     next_pose unless @waiting
  1935.   end
  1936.   #--------------------------------------------------------------------------
  1937.   # *
  1938.   #--------------------------------------------------------------------------
  1939.   def setup_pose
  1940.     @current_pose = pose_list.first
  1941.     return unless @current_pose
  1942.     @battler.icon_list.clear if changed_pose?
  1943.     @frame  = 0 if changed_pose?
  1944.     battler = @current_pose[:battler]
  1945.     @pose_battler = battler unless battler == :skip
  1946.     @pose_value   = @current_pose[:value]
  1947.     @pose = @pose_value.first
  1948.   end
  1949.   #--------------------------------------------------------------------------
  1950.   # *
  1951.   #--------------------------------------------------------------------------
  1952.   def changed_pose?
  1953.     @pose_value != @current_pose[:value]
  1954.   end
  1955.   #--------------------------------------------------------------------------
  1956.   # *
  1957.   #--------------------------------------------------------------------------
  1958.   def pose_list
  1959.     @battler.pose_list
  1960.   end
  1961.   #--------------------------------------------------------------------------
  1962.   # *
  1963.   #--------------------------------------------------------------------------
  1964.   def update_pose_type
  1965.     @waiting = false
  1966.     return if @pose[:hit]  && @battler.result_flag != :hit
  1967.     return if @pose[:miss] && @battler.result_flag != :miss
  1968.     eval("update_pose_#{@pose[:type]}")  #rescue ""
  1969.   end
  1970.   #--------------------------------------------------------------------------
  1971.   # *
  1972.   #--------------------------------------------------------------------------
  1973.   def next_pose
  1974.     return unless @current_pose
  1975.     case @current_pose[:next]
  1976.     when :loop
  1977.       @pose_value.next_item
  1978.     when :reset
  1979.       @pose_value.shift
  1980.       reset_pose if @pose_value.empty?
  1981.     when Symbol
  1982.       @pose_value.shift
  1983.       @battler.call_pose(@current_pose[:next]) if @pose_value.empty?
  1984.     else
  1985.       last_value = @pose_value.shift
  1986.     end
  1987.     @pose_value.unshift(last_value) if @pose_value.empty? && pose_list.empty?
  1988.     @battler.pose_list.shift if @pose_value.empty?
  1989.   end
  1990.   #--------------------------------------------------------------------------
  1991.   # *
  1992.   #--------------------------------------------------------------------------
  1993.   def update_pose_wait
  1994.     case @pose[:time]
  1995.     when :animation
  1996.       @waiting = SceneManager.scene.spriteset.animation?
  1997.     when :action
  1998.       @waiting = SceneManager.scene.spriteset.action?(subject)
  1999.     when :movement
  2000.       @waiting = get_target.any? {|target| target.moving? }
  2001.     when :origin
  2002.       @waiting = get_target.any? {|target| target.origin? }
  2003.     when :counter
  2004.       @waiting = get_target.any? {|target| target.countered }
  2005.     when :substitution
  2006.       @waiting = get_target.any? {|target| target.substitution }
  2007.     when :tone
  2008.       @waiting = $game_troop.screen.tone_change?
  2009.     when :throw
  2010.       @waiting = throwing?
  2011.     else
  2012.       @pose[:time] -= 1
  2013.       @pose[:time] = @pose[:wait] if @pose[:time] == 0
  2014.       @waiting = @pose[:time] != @pose[:wait]
  2015.     end
  2016.   end
  2017.   #--------------------------------------------------------------------------
  2018.   # *
  2019.   #--------------------------------------------------------------------------
  2020.   def update_pose_clear
  2021.     battler.pose_list.clear
  2022.   end
  2023.   #--------------------------------------------------------------------------
  2024.   # *
  2025.   #--------------------------------------------------------------------------
  2026.   def update_pose_action
  2027.     get_target.each do |target|
  2028.       target.clear_idle_poses
  2029.       target.call_pose(@pose[:action], :clear, @battler.current_item, @battler)
  2030.     end
  2031.   end
  2032.   #--------------------------------------------------------------------------
  2033.   # *
  2034.   #--------------------------------------------------------------------------
  2035.   def update_pose_anim
  2036.     subject.targets = get_target
  2037.     subject.call_anim = true
  2038.     subject.animation = @pose[:anim]
  2039.   end
  2040.   #--------------------------------------------------------------------------
  2041.   # *
  2042.   #--------------------------------------------------------------------------
  2043.   def update_pose_effect
  2044.     subject.call_effect = true
  2045.     subject.attack_flag = @pose[:weapon]
  2046.     subject.damage_flag = @pose[:damage]
  2047.     subject.target_flag = @pose[:target] ? @pose[:target] : subject.targets
  2048.   end
  2049.   #--------------------------------------------------------------------------
  2050.   # *
  2051.   #--------------------------------------------------------------------------
  2052.   def update_pose_loop
  2053.     get_target.each {|target| target.pose_loop_anim = @pose[:loop_anim] }
  2054.   end
  2055.   #--------------------------------------------------------------------------
  2056.   # *
  2057.   #--------------------------------------------------------------------------
  2058.   def update_pose_reset
  2059.     @battler.actions[0] = @battler.previous_action if @pose[:action]
  2060.     reset_pose if @pose[:pose]
  2061.   end
  2062.   #--------------------------------------------------------------------------
  2063.   # *
  2064.   #--------------------------------------------------------------------------
  2065.   def update_pose_plane
  2066.     if @pose[:delete]
  2067.       SceneManager.scene.spriteset.delete_plane(@pose[:duration])
  2068.     elsif @pose[:list]
  2069.       SceneManager.scene.spriteset.action_plane(*@pose[:list])
  2070.     end
  2071.   end
  2072.   #--------------------------------------------------------------------------
  2073.   # *
  2074.   #--------------------------------------------------------------------------
  2075.   def update_pose_sound
  2076.     se = RPG::SE.new(@pose[:name], @pose[:volume], @pose[:pitch])
  2077.     se.play
  2078.   end
  2079.   #--------------------------------------------------------------------------
  2080.   # *
  2081.   #--------------------------------------------------------------------------
  2082.   def update_pose_pose
  2083.     get_target.each do |target|
  2084.       target.row    = @pose[:row] - 1           if @pose[:row].is_a?(Numeric)
  2085.       target.row    = target.direction / 2  - 1 if @pose[:row].is_a?(Symbol)
  2086.       target.sufix  = @pose[:sufix]
  2087.       target.angle  = @pose[:angle]
  2088.       target.spin   = @pose[:spin]
  2089.       target.x_adj  = @pose[:x]
  2090.       target.y_adj  = @pose[:y]
  2091.       target.timing = @pose[:pose]
  2092.       target.frame  = @pose[:frame] - 1
  2093.       target.frame  %= target.sprite_value(:frames)
  2094.     end
  2095.   end
  2096.   #--------------------------------------------------------------------------
  2097.   # *
  2098.   #--------------------------------------------------------------------------
  2099.   def update_pose_move
  2100.     get_target.each do |target|
  2101.       target.teleport = @pose[:teleport]
  2102.       setup_target_position(target)
  2103.       target.target_position[:x] += target.left? ? @pose[:x] : -@pose[:x]
  2104.       target.target_position[:y] += target.down? ? @pose[:y] : -@pose[:y]
  2105.       target.target_position[:h] += @pose[:h]
  2106.       target.move_speed = @pose[:speed]
  2107.     end
  2108.   end
  2109.   #--------------------------------------------------------------------------
  2110.   # *
  2111.   #--------------------------------------------------------------------------
  2112.   def update_pose_counter
  2113.     get_target.each {|target| target.countered = @pose[:counter] }
  2114.   end
  2115.   #--------------------------------------------------------------------------
  2116.   # *
  2117.   #--------------------------------------------------------------------------
  2118.   def update_pose_substitution
  2119.     get_target.each {|target| target.substitution = @pose[:substitution] }
  2120.   end
  2121.   #--------------------------------------------------------------------------
  2122.   # *
  2123.   #--------------------------------------------------------------------------
  2124.   def update_pose_jump
  2125.     get_target.each do |target|
  2126.       if @pose[:move]
  2127.         x_plus = (target.target_distance(:x) / 32.0).abs
  2128.         y_plus = (target.target_distance(:y) / 32.0).abs
  2129.         speed = Math.sqrt((x_plus ** 2) + (y_plus ** 2)) / @battler.move_speed
  2130.         target.jumping[:speed] = @pose[:height] * 5.0 / [speed, 1].max
  2131.       else
  2132.         target.jumping[:speed] = @pose[:speed]
  2133.       end
  2134.       target.jumping[:height] = @pose[:height]
  2135.       target.jumping[:count]  = target.jumping[:height] * 2  
  2136.     end   
  2137.   end
  2138.   #--------------------------------------------------------------------------
  2139.   # *
  2140.   #--------------------------------------------------------------------------
  2141.   def update_pose_inactive
  2142.     subject.deactivate
  2143.   end
  2144.   #--------------------------------------------------------------------------
  2145.   # *
  2146.   #--------------------------------------------------------------------------
  2147.   def update_pose_direction
  2148.     dir = [subject.screen_x, subject.screen_y]
  2149.     subject.target_direction(*dir) if @pose[:return]
  2150.     subject.action_direction       if @pose[:targets]
  2151.     subject.direction = @pose[:direction] if @pose[:direction]
  2152.   end
  2153.   #--------------------------------------------------------------------------
  2154.   # *
  2155.   #--------------------------------------------------------------------------
  2156.   def update_pose_icon
  2157.     get_target.each do |target|
  2158.       if @pose[:delete]
  2159.         target.icon_list.delete(@pose[:index])
  2160.       else
  2161.         target.icon_list[@pose[:index]] = @pose.dup
  2162.       end
  2163.       target.sprite.update_icon
  2164.     end
  2165.   end
  2166.   #--------------------------------------------------------------------------
  2167.   # *
  2168.   #--------------------------------------------------------------------------
  2169.   def update_pose_picture
  2170.     if @pose[:show]
  2171.       $game_troop.screen.pictures[@pose[:id]].show(*@pose[:show])
  2172.     elsif @pose[:move]
  2173.       $game_troop.screen.pictures[@pose[:id]].move(*@pose[:move])
  2174.     elsif @pose[:delete]
  2175.      $game_troop.screen.pictures[@pose[:id]].erase
  2176.     end
  2177.   end
  2178.   #--------------------------------------------------------------------------
  2179.   # *
  2180.   #--------------------------------------------------------------------------
  2181.   def update_pose_throw
  2182.     get_target.each do |target|
  2183.       value = @pose.dup
  2184.       value[:user] = subject.sprite
  2185.       target.throw_list.push(value.dup)
  2186.       target.sprite.update_throw
  2187.     end   
  2188.   end
  2189.   #--------------------------------------------------------------------------
  2190.   # *
  2191.   #--------------------------------------------------------------------------
  2192.   def update_pose_shake
  2193.     if @pose[:screen]
  2194.       $game_troop.screen.start_shake(*@pose[:shake])
  2195.     else
  2196.       get_target.each {|target| target.start_shake(*@pose[:shake]) }
  2197.     end
  2198.   end
  2199.   #--------------------------------------------------------------------------
  2200.   # *
  2201.   #--------------------------------------------------------------------------
  2202.   def update_pose_flash
  2203.     if @pose[:screen]
  2204.       $game_troop.screen.start_flash(*@pose[:flash])
  2205.     else
  2206.       get_target.each {|target| target.sprite.flash(*@pose[:flash]) }
  2207.     end
  2208.   end
  2209.   #--------------------------------------------------------------------------
  2210.   # *
  2211.   #--------------------------------------------------------------------------
  2212.   def update_pose_movie
  2213.     Graphics.play_movie('Movies/' + @pose[:name]) if @pose[:name] != ""
  2214.     update_pose_tone
  2215.   end
  2216.   #--------------------------------------------------------------------------
  2217.   # *
  2218.   #--------------------------------------------------------------------------
  2219.   def update_pose_tone
  2220.     eval("update_#{@pose[:priority]}_tone")
  2221.   end
  2222.   #--------------------------------------------------------------------------
  2223.   # *
  2224.   #--------------------------------------------------------------------------
  2225.   def update_low_tone
  2226.     screen = $game_troop.screen
  2227.     screen.old_low_tone = screen.low_tone.dup unless screen.old_low_tone
  2228.     tone = @pose[:clear] ? screen.old_low_tone : @pose[:tone]
  2229.     $game_troop.screen.old_low_tone = nil if @pose[:clear]
  2230.     $game_troop.screen.start_low_tone_change(tone, @pose[:duration])
  2231.   end
  2232.   #--------------------------------------------------------------------------
  2233.   # *
  2234.   #--------------------------------------------------------------------------
  2235.   def update_normal_tone
  2236.     screen = $game_troop.screen
  2237.     screen.old_tone = screen.tone.dup unless screen.old_tone
  2238.     tone = @pose[:clear] ? $game_troop.screen.old_tone : @pose[:tone]
  2239.     $game_troop.screen.old_tone = nil if @pose[:clear]
  2240.     $game_troop.screen.start_tone_change(tone, @pose[:duration])
  2241.   end
  2242.   #--------------------------------------------------------------------------
  2243.   # *
  2244.   #--------------------------------------------------------------------------  
  2245.   def update_high_tone
  2246.     screen = $game_troop.screen
  2247.     screen.old_high_tone = screen.high_tone.dup unless screen.old_high_tone
  2248.     tone = @pose[:clear] ? screen.old_high_tone : @pose[:tone]
  2249.     $game_troop.screen.old_high_tone = nil if @pose[:clear]
  2250.     $game_troop.screen.start_high_tone_change(tone, @pose[:duration])
  2251.   end
  2252.   #--------------------------------------------------------------------------
  2253.   # *
  2254.   #--------------------------------------------------------------------------
  2255.   def setup_target_position(target)
  2256.     return unless @battler.use_sprite?
  2257.     if @pose[:value] == :move_to
  2258.       setup_move_to_target_position(target)
  2259.     elsif @pose[:value] == :step_foward
  2260.       setup_step_foward_position(target)
  2261.     elsif @pose[:value] == :step_backward
  2262.       setup_step_backward_position(target)
  2263.     elsif @pose[:value] == :escape
  2264.       setup_escape_position(target)
  2265.     elsif @pose[:value] == :retreat
  2266.       setup_retreat_position(target)
  2267.     end
  2268.     target.position_fix while target.sharing_position?
  2269.     target.target_position = target.current_position.dup if target.unmovable?
  2270.   end
  2271.   #--------------------------------------------------------------------------
  2272.   # *
  2273.   #--------------------------------------------------------------------------
  2274.   def setup_move_to_target_position(target)
  2275.     targets = @pose[:targets].select {|member| member.use_sprite? }
  2276.     return if targets.empty?
  2277.     return @waiting = true if targets.any? {|member| member.moving?}
  2278.     x = targets.collect {|member| member.current_position[:x]}.average
  2279.     y = targets.collect {|member| member.current_position[:y]}.average
  2280.     target.target_direction(x, y)
  2281.     y -= 32 if down?
  2282.     x += 32 if left?
  2283.     x -= 32 if right?
  2284.     y += 32 if up?
  2285.     target.target_position[:x] = x
  2286.     target.target_position[:y] = y
  2287.   end
  2288.   #--------------------------------------------------------------------------
  2289.   # *
  2290.   #--------------------------------------------------------------------------
  2291.   def setup_step_foward_position(target)
  2292.     target.target_position[:y] += 48 if down?
  2293.     target.target_position[:x] -= 48 if left?
  2294.     target.target_position[:x] += 48 if right?
  2295.     target.target_position[:y] -= 48 if up?
  2296.   end
  2297.   #--------------------------------------------------------------------------
  2298.   # *
  2299.   #--------------------------------------------------------------------------
  2300.   def setup_step_backward_position(target)
  2301.     target.target_position[:y] -= 48 if down?
  2302.     target.target_position[:x] += 48 if left?
  2303.     target.target_position[:x] -= 48 if right?
  2304.     target.target_position[:y] += 48 if up?
  2305.   end
  2306.   #--------------------------------------------------------------------------
  2307.   # *
  2308.   #--------------------------------------------------------------------------
  2309.   def setup_escape_position(target)
  2310.     target.target_position[:y] -= 240 if down?
  2311.     target.target_position[:x] += 240 if left?
  2312.     target.target_position[:x] -= 240 if right?
  2313.     target.target_position[:y] += 240 if up?
  2314.     position = target.target_position
  2315.     target.target_direction(position[:x], position[:y])
  2316.   end
  2317.   #--------------------------------------------------------------------------
  2318.   # *
  2319.   #--------------------------------------------------------------------------
  2320.   def setup_retreat_position(target)
  2321.     return if target.target_position[:x] == target.screen_x &&
  2322.               target.target_position[:y] == target.screen_y
  2323.     target.target_position[:x] = target.screen_x
  2324.     target.target_position[:y] = target.screen_y
  2325.     position = target.target_position
  2326.     target.target_direction(position[:x], position[:y])
  2327.   end  
  2328.   #--------------------------------------------------------------------------
  2329.   # *
  2330.   #--------------------------------------------------------------------------
  2331.   def reset_pose
  2332.     idle_pose = @battler.pose_name
  2333.     next_pose = get_idle_pose
  2334.     @frame = 0
  2335.     @battler.default_direction
  2336.     @battler.clear_idle_poses
  2337.     @battler.call_pose(next_pose)
  2338.     setup_pose
  2339.   end
  2340.   #--------------------------------------------------------------------------
  2341.   # *
  2342.   #--------------------------------------------------------------------------
  2343.   def get_idle_pose
  2344.     pose = :idle
  2345.     pose = :danger if @battler.danger?
  2346.     pose = @battler.state_pose  if @battler.state_pose?
  2347.     pose = :guard  if @battler.guard?
  2348.     pose = @battler.active_pose if @battler.active_pose
  2349.     pose = :dead   if @battler.dead?
  2350.     pose
  2351.   end
  2352.   #--------------------------------------------------------------------------
  2353.   # *
  2354.   #--------------------------------------------------------------------------
  2355.   def get_target
  2356.     @pose[:target] ? @pose[:target] : [subject]
  2357.   end
  2358.   #--------------------------------------------------------------------------
  2359.   # *
  2360.   #--------------------------------------------------------------------------
  2361.   def setup_positions
  2362.     positions = {x: @battler.screen_x, y: @battler.screen_y, h: 0, j: 0}
  2363.     @battler.target_position  = positions.dup
  2364.     @battler.current_position = positions.dup
  2365.     @battler.default_position = positions.dup
  2366.     @battler.jumping = {count: 0, height: 0, speed: 10}
  2367.     reset_pose
  2368.   end
  2369.   #--------------------------------------------------------------------------
  2370.   # *
  2371.   #--------------------------------------------------------------------------
  2372.   def position
  2373.     @battler.current_position
  2374.   end
  2375.   #--------------------------------------------------------------------------
  2376.   # *
  2377.   #--------------------------------------------------------------------------
  2378.   def update_position
  2379.     update_misc
  2380.     update_movement
  2381.     update_jumping
  2382.     self.x = position[:x] + adjust_x
  2383.     self.y = position[:y] + adjust_y - position[:h] - position[:j]
  2384.     self.z = position[:y] + (@battler.active? ? 2 : 1)
  2385.     self.angle  = @battler.angle if angle != @battler.angle
  2386.     self.angle += @battler.spin
  2387.   end
  2388.   #--------------------------------------------------------------------------
  2389.   # *
  2390.   #--------------------------------------------------------------------------
  2391.   def update_misc
  2392.     @battler.update_shake
  2393.     @battler.update_freeze
  2394.   end
  2395.   #--------------------------------------------------------------------------
  2396.   # *
  2397.   #--------------------------------------------------------------------------
  2398.   def adjust_x
  2399.     @battler.x_adj + [1, -1].random * rand(@battler.shake + 1)
  2400.   end
  2401.   #--------------------------------------------------------------------------
  2402.   # *
  2403.   #--------------------------------------------------------------------------
  2404.   def adjust_y
  2405.     @battler.y_adj + [1, -1].random * rand(@battler.shake + 1)
  2406.   end
  2407.   #--------------------------------------------------------------------------
  2408.   # *
  2409.   #--------------------------------------------------------------------------
  2410.   def update_movement
  2411.     return if @battler.frozen? || !@battler.moving?
  2412.     @battler.teleport ? update_teleport_movement : update_normal_movement
  2413.   end
  2414.   #--------------------------------------------------------------------------
  2415.   # *
  2416.   #--------------------------------------------------------------------------
  2417.   def update_teleport_movement
  2418.     @battler.current_position[:x] = @battler.target_position[:x]
  2419.     @battler.current_position[:y] = @battler.target_position[:y]
  2420.     @battler.current_position[:h] = [@battler.target_position[:h], 0].max
  2421.     @battler.teleport = false
  2422.   end
  2423.   #--------------------------------------------------------------------------
  2424.   # *
  2425.   #--------------------------------------------------------------------------
  2426.   def update_normal_movement
  2427.     distance = set_distance
  2428.     move     = {x: 1.0, y: 1.0, h: 1.0}
  2429.     if distance[:x].abs < distance[:y].abs
  2430.       move[:x] = 1.0 / (distance[:y].abs.to_f / distance[:x].abs)
  2431.     elsif distance[:y].abs < distance[:x].abs
  2432.       move[:y] = 1.0 / (distance[:x].abs.to_f / distance[:y].abs)
  2433.     elsif distance[:h].abs < distance[:x].abs
  2434.       move[:h] = 1.0 / (distance[:x].abs.to_f / distance[:h].abs)
  2435.     end
  2436.     speed = set_speed(distance)
  2437.     x = move[:x] * speed[:x]
  2438.     y = move[:y] * speed[:y]
  2439.     h = move[:h] * speed[:h]
  2440.     set_movement(x, y, h)
  2441.   end
  2442.   #--------------------------------------------------------------------------
  2443.   # *
  2444.   #--------------------------------------------------------------------------
  2445.   def set_distance
  2446.     x = @battler.target_distance(:x)
  2447.     y = @battler.target_distance(:y)
  2448.     h = @battler.target_distance(:h)
  2449.     {x: x, y: y, h: h}
  2450.   end
  2451.   #--------------------------------------------------------------------------
  2452.   # *
  2453.   #--------------------------------------------------------------------------
  2454.   def set_speed(distance)
  2455.     move_speed = @battler.move_speed
  2456.     x = move_speed * (distance[:x] == 0 ? 0 : (distance[:x] > 0 ? 8 : -8))
  2457.     y = move_speed * (distance[:y] == 0 ? 0 : (distance[:y] > 0 ? 8 : -8))
  2458.     h = move_speed * (distance[:h] == 0 ? 0 : (distance[:h] > 0 ? 8 : -8))
  2459.     {x: x, y: y, h: h}
  2460.   end
  2461.   #--------------------------------------------------------------------------
  2462.   # *
  2463.   #--------------------------------------------------------------------------
  2464.   def set_movement(x, y, h)
  2465.     target  = @battler.target_position
  2466.     current = @battler.current_position
  2467.     current[:x] += x
  2468.     current[:y] += y
  2469.     current[:h] += h
  2470.     current[:x] = target[:x] if in_distance?(current[:x], target[:x], x)
  2471.     current[:y] = target[:y] if in_distance?(current[:y], target[:y], y)
  2472.     current[:h] = target[:h] if in_distance?(current[:h], target[:h], h)
  2473.   end
  2474.   #--------------------------------------------------------------------------
  2475.   # *
  2476.   #--------------------------------------------------------------------------
  2477.   def in_distance?(x, y, z)
  2478.     x.between?(y - z - 1, y + z + 1)
  2479.   end
  2480.   #--------------------------------------------------------------------------
  2481.   # *
  2482.   #--------------------------------------------------------------------------
  2483.   def update_jumping
  2484.     return if @battler.jumping[:count] == 0 || @battler.frozen?
  2485.     jump = @battler.jumping
  2486.     jump[:count] = [jump[:count] - (1 * jump[:speed] / 10.0), 0].max.to_f
  2487.     count = jump[:count]
  2488.     speed = jump[:speed]
  2489.     peak  = jump[:height]
  2490.     result = (peak ** 2 - (count - peak).abs ** 2) / 2
  2491.     @battler.current_position[:j] = [result, 0].max
  2492.   end
  2493.   #--------------------------------------------------------------------------
  2494.   # *
  2495.   #--------------------------------------------------------------------------
  2496.   def update_icon
  2497.     @battler.icon_list.each do |key, value|
  2498.       icon = @icon_list[key]
  2499.       @icon_list[key] = Sprite_Icon.new(self, value) if !icon
  2500.       icon.refresh       if icon && value[:icon] != icon.icon
  2501.       icon.value = value if icon && icon.value != value
  2502.     end
  2503.     @icon_list.each do |key, value|
  2504.       value.update
  2505.       delete_icon(key) if value && !@battler.icon_list[key]
  2506.     end
  2507.   end
  2508.   #--------------------------------------------------------------------------
  2509.   # *
  2510.   #--------------------------------------------------------------------------
  2511.   def update_throw
  2512.     @battler.throw_list.each do |value|
  2513.       @throw_list.push(Sprite_Throw.new(self, value.dup))
  2514.       @battler.throw_list.delete(value)
  2515.     end
  2516.     @throw_list.each_with_index do |value, index|
  2517.       value.update
  2518.       delete_throw(index) if value.disposing?
  2519.     end
  2520.     @throw_list.compact!
  2521.   end
  2522.   #--------------------------------------------------------------------------
  2523.   # *
  2524.   #--------------------------------------------------------------------------
  2525.   def delete_icon(key)
  2526.     @icon_list[key].dispose
  2527.     @icon_list.delete(key)
  2528.   end
  2529.   #--------------------------------------------------------------------------
  2530.   # *
  2531.   #--------------------------------------------------------------------------
  2532.   def delete_throw(index)
  2533.     @throw_list[index].dispose
  2534.     @throw_list.delete_at(index)
  2535.   end
  2536.   #--------------------------------------------------------------------------
  2537.   # *
  2538.   #--------------------------------------------------------------------------
  2539.   def throwing?
  2540.     !@throw_list.empty?
  2541.   end
  2542.   #--------------------------------------------------------------------------
  2543.   # *
  2544.   #--------------------------------------------------------------------------
  2545.   def update_pose_loop_anim
  2546.     if @battler.pose_loop_anim && !loop_anim?(:pose_anim)
  2547.       @pose_name_list = @battler.pose_name_list.first
  2548.       animation = {type: :pose_anim, anim: @battler.pose_loop_anim, loop: 1}     
  2549.       add_loop_animation(animation)
  2550.     end
  2551.     if @battler.pose_loop_anim && loop_anim?(:pose_anim) &&
  2552.        @pose_name_list != @battler.pose_name_list.first
  2553.       @pose_loop_anim = nil
  2554.       @battler.pose_loop_anim = nil
  2555.       end_loop_anim(:pose_anim)
  2556.     end
  2557.   end
  2558. end
  2559.  
  2560. #==============================================================================
  2561. # ** Spriteset_Battle
  2562. #------------------------------------------------------------------------------
  2563. #  This class brings together battle screen sprites. It's used within the
  2564. # Scene_Battle class.
  2565. #==============================================================================
  2566.  
  2567. class Spriteset_Battle
  2568.   #--------------------------------------------------------------------------
  2569.   # *
  2570.   #--------------------------------------------------------------------------
  2571.   def create_actors
  2572.     @actor_sprites = $game_party.battle_members.reverse.collect do |actor|
  2573.       Sprite_Battler.new(@viewport1, actor)
  2574.     end
  2575.     @actors_party = $game_party.battle_members.dup
  2576.   end
  2577.   #--------------------------------------------------------------------------
  2578.   # *
  2579.   #--------------------------------------------------------------------------
  2580.   alias :initialize_ve_animated_battle :initialize
  2581.   def initialize
  2582.     init_action_plane
  2583.     initialize_ve_animated_battle
  2584.   end
  2585.   #--------------------------------------------------------------------------
  2586.   # *
  2587.   #--------------------------------------------------------------------------
  2588.   alias :update_ve_animated_battle :update
  2589.   def update
  2590.     update_ve_animated_battle
  2591.     update_action_plane
  2592.   end
  2593.   #--------------------------------------------------------------------------
  2594.   # *
  2595.   #--------------------------------------------------------------------------
  2596.   alias :dispose_ve_animated_battle :dispose
  2597.   def dispose
  2598.     dispose_ve_animated_battle
  2599.     dispose_action_plane
  2600.   end
  2601.   #--------------------------------------------------------------------------
  2602.   # *
  2603.   #--------------------------------------------------------------------------
  2604.   alias :create_pictures_ve_animated_battle :create_pictures
  2605.   def create_pictures
  2606.     battler_sprites.each {|battler| battler.setup_positions }
  2607.     create_pictures_ve_animated_battle
  2608.   end
  2609.   #--------------------------------------------------------------------------
  2610.   # *
  2611.   #--------------------------------------------------------------------------
  2612.   alias :create_viewports_ve_animated_battle :create_viewports
  2613.   def create_viewports
  2614.     create_viewports_ve_animated_battle
  2615.     @viewport4 = Viewport.new
  2616.     @viewport4.z = 200
  2617.   end
  2618.   #--------------------------------------------------------------------------
  2619.   # *
  2620.   #--------------------------------------------------------------------------
  2621.   alias :update_viewports_ve_animated_battle :update_viewports
  2622.   def update_viewports
  2623.     update_viewports_ve_animated_battle
  2624.     @viewport1.ox = [1, -1].random * rand($game_troop.screen.shake)
  2625.     @viewport1.oy = [1, -1].random * rand($game_troop.screen.shake)
  2626.     @back1_sprite.tone.set($game_troop.screen.low_tone)
  2627.     @back2_sprite.tone.set($game_troop.screen.low_tone)
  2628.     @viewport4.tone.set($game_troop.screen.high_tone)
  2629.   end
  2630.   #--------------------------------------------------------------------------
  2631.   # *
  2632.   #--------------------------------------------------------------------------
  2633.   def action?(subject)
  2634.     battler_sprites.compact.any? do |sprite|
  2635.       sprite.subject == subject && sprite.battler != subject
  2636.     end
  2637.   end
  2638.   #--------------------------------------------------------------------------
  2639.   # *
  2640.   #--------------------------------------------------------------------------
  2641.   def init_action_plane
  2642.     @action_plane = Action_Plane.new(@viewport1)
  2643.   end
  2644.   #--------------------------------------------------------------------------
  2645.   # *
  2646.   #--------------------------------------------------------------------------
  2647.   def update_action_plane
  2648.     @action_plane.update
  2649.   end
  2650.   #--------------------------------------------------------------------------
  2651.   # *
  2652.   #--------------------------------------------------------------------------
  2653.   def dispose_action_plane
  2654.     @action_plane.dispose
  2655.   end
  2656.   #--------------------------------------------------------------------------
  2657.   # *
  2658.   #--------------------------------------------------------------------------
  2659.   def action_plane(name, x, y, z, zoom_x, zoom_y, opacity, blend, duration)
  2660.     @action_plane.setup(name, x, y, z, zoom_x, zoom_y, opacity, blend, duration)
  2661.   end
  2662.   #--------------------------------------------------------------------------
  2663.   # *
  2664.   #--------------------------------------------------------------------------
  2665.   def delete_plane(duration)
  2666.     @action_plane.delete(duration)
  2667.   end
  2668. end
  2669.  
  2670. #==============================================================================
  2671. # ** Window_BattleLog
  2672. #------------------------------------------------------------------------------
  2673. #  This window shows the battle progress. Do not show the window frame.
  2674. #==============================================================================
  2675.  
  2676. class Window_BattleLog < Window_Selectable
  2677.   #--------------------------------------------------------------------------
  2678.   # *
  2679.   #--------------------------------------------------------------------------
  2680.   def display_added_states(target)
  2681.     target.result.added_state_objects.each do |state|
  2682.       state_msg = target.actor? ? state.message1 : state.message2
  2683.       next if state_msg.empty?
  2684.       replace_text(target.name + state_msg)
  2685.       wait
  2686.       wait_for_effect
  2687.     end
  2688.   end
  2689.   #--------------------------------------------------------------------------
  2690.   # *
  2691.   #--------------------------------------------------------------------------
  2692.   def display_counter(target, item)
  2693.     Sound.play_evasion
  2694.     add_text(sprintf(Vocab::CounterAttack, target.name))
  2695.   end
  2696.   #--------------------------------------------------------------------------
  2697.   # *
  2698.   #--------------------------------------------------------------------------
  2699.   def display_reflection(target, item)
  2700.     Sound.play_reflection
  2701.     add_text(sprintf(Vocab::MagicReflection, target.name))
  2702.   end
  2703.   #--------------------------------------------------------------------------
  2704.   # *
  2705.   #--------------------------------------------------------------------------
  2706.   def display_substitute(substitute, target)
  2707.     add_text(sprintf(Vocab::Substitute, substitute.name, target.name))
  2708.   end
  2709. end
  2710.  
  2711.  
  2712. #==============================================================================
  2713. # ** Scene_Battle
  2714. #------------------------------------------------------------------------------
  2715. #  This class performs battle screen processing.
  2716. #==============================================================================
  2717.  
  2718. class Scene_Battle < Scene_Base
  2719.   #--------------------------------------------------------------------------
  2720.   # *
  2721.   #--------------------------------------------------------------------------
  2722.   def abs_wait_short
  2723.   end
  2724.   #--------------------------------------------------------------------------
  2725.   # *
  2726.   #--------------------------------------------------------------------------
  2727.   def wait_for_animation
  2728.     update_for_wait
  2729.   end
  2730.   #--------------------------------------------------------------------------
  2731.   # *
  2732.   #--------------------------------------------------------------------------
  2733.   def wait_for_effect
  2734.     update_for_wait
  2735.   end
  2736.   #--------------------------------------------------------------------------
  2737.   # *
  2738.   #--------------------------------------------------------------------------
  2739.   def process_action
  2740.     return if scene_changing? || active?
  2741.     if next_subject?
  2742.       @subject = BattleManager.next_subject
  2743.       @subject.activate if @subject
  2744.     end
  2745.     return turn_end unless @subject
  2746.     return process_action_end if !@subject.active && !@subject.current_action
  2747.     if @subject.current_action
  2748.       @subject.current_action.prepare
  2749.       if @subject.current_action.valid?
  2750.         @status_window.open
  2751.         execute_action
  2752.       end
  2753.       @subject.remove_current_action
  2754.     end
  2755.   end
  2756.   #--------------------------------------------------------------------------
  2757.   # *
  2758.   #--------------------------------------------------------------------------
  2759.   def show_animation(targets, animation_id)
  2760.     if animation_id < 0
  2761.       show_animated_attack_animation(targets)
  2762.     else
  2763.       show_normal_animation(targets, animation_id)
  2764.     end
  2765.     wait_for_animation
  2766.   end
  2767.   #--------------------------------------------------------------------------
  2768.   # *
  2769.   #--------------------------------------------------------------------------
  2770.   def invoke_counter_attack(target, item)
  2771.     target.setup_counter(@subject)
  2772.     @counter_flag.push(target)
  2773.   end
  2774.   #--------------------------------------------------------------------------
  2775.   # *
  2776.   #--------------------------------------------------------------------------
  2777.   def invoke_magic_reflection(target, item)
  2778.     @subject.setup_reflect(item)
  2779.     @reflect_flag.push(target)
  2780.   end
  2781.   #--------------------------------------------------------------------------
  2782.   # * Alias method: apply_substitute
  2783.   #--------------------------------------------------------------------------
  2784.   def apply_substitute(target, item)
  2785.     if check_substitute(target, item)
  2786.       substitute = target.friends_unit.substitute_battler
  2787.       if substitute && target != substitute
  2788.         @substitution = {target: target, substitute: substitute}
  2789.         substitute.setup_substitute(target)
  2790.         return substitute
  2791.       end
  2792.     end
  2793.     target
  2794.   end
  2795.   #--------------------------------------------------------------------------
  2796.   # *
  2797.   #--------------------------------------------------------------------------
  2798.   alias :create_spriteset_ve_animated_battle :create_spriteset
  2799.   def create_spriteset
  2800.     create_spriteset_ve_animated_battle
  2801.     members = $game_party.movable_members
  2802.     members.each {|member| member.call_pose(:intro, :clear) }
  2803.     2.times { @spriteset.update }
  2804.   end
  2805.   #--------------------------------------------------------------------------
  2806.   # *
  2807.   #--------------------------------------------------------------------------
  2808.   alias :update_basic_ve_animated_battle :update_basic
  2809.   def update_basic
  2810.     update_basic_ve_animated_battle
  2811.     update_sprite_action
  2812.   end
  2813.   #--------------------------------------------------------------------------
  2814.   # *
  2815.   #--------------------------------------------------------------------------
  2816.   alias :turn_end_ve_animated_battle :turn_end
  2817.   def turn_end
  2818.     turn_end_ve_animated_battle
  2819.     @spriteset.battler_sprites.each {|sprite| sprite.reset_pose }
  2820.   end
  2821.   #--------------------------------------------------------------------------
  2822.   # *
  2823.   #--------------------------------------------------------------------------
  2824.   alias :next_command_ve_animated_battle :next_command
  2825.   def next_command
  2826.     BattleManager.set_active_pose
  2827.     next_command_ve_animated_battle
  2828.   end
  2829.   #--------------------------------------------------------------------------
  2830.   # *
  2831.   #--------------------------------------------------------------------------
  2832.   alias :prior_command_ve_animated_battle :prior_command
  2833.   def prior_command
  2834.     prior_command_ve_animated_battle
  2835.     BattleManager.clear_active_pose
  2836.   end
  2837.   #--------------------------------------------------------------------------
  2838.   # *
  2839.   #--------------------------------------------------------------------------
  2840.   def show_animated_attack_animation(targets)
  2841.     if @subject.actor? || $imported[:ve_actor_battlers]
  2842.       show_normal_animation(targets, @subject.atk_animation_id1, false)
  2843.     else
  2844.       Sound.play_enemy_attack
  2845.       abs_wait_short
  2846.     end
  2847.   end
  2848.   #--------------------------------------------------------------------------
  2849.   # *
  2850.   #--------------------------------------------------------------------------
  2851.   def next_subject?
  2852.     !@subject || !@subject.active?
  2853.   end
  2854.   #--------------------------------------------------------------------------
  2855.   # *
  2856.   #--------------------------------------------------------------------------
  2857.   def active?
  2858.     members = $game_troop.members + $game_party.battle_members
  2859.     members.any? {|member| member.active? }
  2860.   end
  2861.   #--------------------------------------------------------------------------
  2862.   # *
  2863.   #--------------------------------------------------------------------------
  2864.   def execute_action
  2865.     use_item
  2866.     @log_window.wait_and_clear
  2867.   end
  2868.   #--------------------------------------------------------------------------
  2869.   # *
  2870.   #--------------------------------------------------------------------------
  2871.   def use_item
  2872.     item = @subject.current_action.item
  2873.     @log_window.display_use_item(@subject, item)
  2874.     @subject.action_pose(item)
  2875.     @subject.use_item(item)
  2876.     refresh_status
  2877.   end
  2878.   #--------------------------------------------------------------------------
  2879.   # *
  2880.   #--------------------------------------------------------------------------
  2881.   def update_sprite_action
  2882.     @old_subject = @subject
  2883.     battlers = $game_party.battle_members + $game_troop.members
  2884.     battlers.each do |subject|
  2885.       @subject = subject
  2886.       call_animation if @subject.call_anim
  2887.       call_effect    if @subject.call_effect
  2888.     end
  2889.     @subject = @old_subject
  2890.   end
  2891.   #--------------------------------------------------------------------------
  2892.   # *
  2893.   #--------------------------------------------------------------------------
  2894.   def call_animation
  2895.     @subject.call_anim = false
  2896.     animation = @subject.animation
  2897.     @subject.animation = 0
  2898.     show_animation(@subject.targets, animation)
  2899.   end
  2900.   #--------------------------------------------------------------------------
  2901.   # *
  2902.   #--------------------------------------------------------------------------
  2903.   def call_effect
  2904.     @counter_flag = []
  2905.     @reflect_flag = []
  2906.     @substitution = nil
  2907.     @subject.call_effect = false
  2908.     targets = @subject.target_flag ? @subject.target_flag : @subject.targets
  2909.     item    = @subject.current_item
  2910.     targets.each {|target| item.repeats.times { invoke_item(target, item) } }
  2911.     @counter_flag.each {|target| @log_window.display_counter(target, item) }
  2912.     @reflect_flag.each {|target| @log_window.display_reflection(target, item) }
  2913.     if @substitution
  2914.       substitute = @substitution[:substitute]
  2915.       target     = @substitution[:target]
  2916.       @log_window.display_substitute(substitute, target)
  2917.     end
  2918.   end
  2919. end
  2920.  
  2921. #==============================================================================
  2922. # ** Sprite_Object
  2923. #------------------------------------------------------------------------------
  2924. #  This the base sprite used to display icons and throw animations.
  2925. #==============================================================================
  2926.  
  2927. class Sprite_Object < Sprite_Base
  2928.   #--------------------------------------------------------------------------
  2929.   # *
  2930.   #--------------------------------------------------------------------------
  2931.   attr_accessor :value
  2932.   #--------------------------------------------------------------------------
  2933.   # *
  2934.   #--------------------------------------------------------------------------
  2935.   def initialize(viewport)
  2936.     super(viewport)
  2937.     @right    = @battler.right?
  2938.     @up       = @battler.up?
  2939.     @spin     = 0
  2940.     @zooming  = 0
  2941.     @fade_in  = 0
  2942.     @fade_out = 0
  2943.     self.zoom_x = value[:izm]
  2944.     self.zoom_y = value[:izm]
  2945.   end
  2946.   #--------------------------------------------------------------------------
  2947.   # *
  2948.   #--------------------------------------------------------------------------
  2949.   def update
  2950.     super
  2951.     update_position
  2952.     update_opacity
  2953.     update_angle
  2954.     update_zoom
  2955.   end
  2956.   #--------------------------------------------------------------------------
  2957.   # *
  2958.   #--------------------------------------------------------------------------
  2959.   def update_opacity
  2960.     if value[:fin] > 0
  2961.       @fade_in += 1
  2962.       self.opacity = [@fade_in * value[:fin], value[:o]].min
  2963.     elsif value[:fout] > 0
  2964.       @fade_out += 1
  2965.       self.opacity = [value[:o] - @fade_out * value[:fin], 0].max
  2966.     else
  2967.       self.opacity =  value[:o]
  2968.     end
  2969.   end
  2970.   #--------------------------------------------------------------------------
  2971.   # *
  2972.   #--------------------------------------------------------------------------
  2973.   def update_angle
  2974.     @spin += 1 if Graphics.frame_count % 2 == 0
  2975.     self.angle  = value[:a] + value[:spin] * @spin
  2976.     self.angle *= -1 if @right || @up
  2977.   end
  2978.   #--------------------------------------------------------------------------
  2979.   # *
  2980.   #--------------------------------------------------------------------------
  2981.   def update_zoom
  2982.     if self.zoom_x < value[:ezm]
  2983.       @zooming += 1
  2984.       self.zoom_x = [value[:izm] + @zooming * value[:szm], value[:ezm]].min
  2985.       self.zoom_y = [value[:izm] + @zooming * value[:szm], value[:ezm]].min
  2986.     elsif self.zoom_x > value[:ezm]
  2987.       @zooming += 1
  2988.       self.zoom_x = [value[:izm] - @zooming * value[:szm], value[:ezm]].max
  2989.       self.zoom_y = [value[:izm] - @zooming * value[:szm], value[:ezm]].max
  2990.     end
  2991.   end
  2992.   #--------------------------------------------------------------------------
  2993.   # *
  2994.   #--------------------------------------------------------------------------
  2995.   def icon
  2996.     value[:icon]
  2997.   end
  2998.   #--------------------------------------------------------------------------
  2999.   # *
  3000.   #--------------------------------------------------------------------------
  3001.   def icon_changed?
  3002.     @icon_value != (value[:image] ?  value[:image] : icon)
  3003.   end
  3004.   #--------------------------------------------------------------------------
  3005.   # *
  3006.   #--------------------------------------------------------------------------
  3007.   def setup_icon
  3008.     p @icon_value if self.is_a?(Sprite_Throw)
  3009.     @icon_value = value[:image] ?  value[:image].dup : icon
  3010.     if value[:image]
  3011.       self.bitmap = Cache.picture(value[:image])
  3012.       self.src_rect.set(0, 0, bitmap.width, bitmap.height)
  3013.       self.ox = bitmap.width  / 2
  3014.       self.oy = bitmap.height / 2
  3015.     else
  3016.       self.bitmap = Cache.system("Iconset")
  3017.       self.src_rect.set(icon % 16 * 24, icon / 16 * 24, 24, 24)
  3018.       self.ox = 12
  3019.       self.oy = 12
  3020.     end
  3021.   end  
  3022. end
  3023.  
  3024. #==============================================================================
  3025. # ** Sprite_Icon
  3026. #------------------------------------------------------------------------------
  3027. #  This sprite is used to display icons.
  3028. #==============================================================================
  3029.  
  3030. class Sprite_Icon < Sprite_Object
  3031.   #--------------------------------------------------------------------------
  3032.   # *
  3033.   #--------------------------------------------------------------------------
  3034.   def initialize(battler, value)
  3035.     @battler = battler
  3036.     @value   = value.dup
  3037.     super(battler.viewport)
  3038.     setup_icon
  3039.   end
  3040.   #--------------------------------------------------------------------------
  3041.   # *
  3042.   #--------------------------------------------------------------------------
  3043.   def update_position
  3044.     setup_icon if icon_changed?
  3045.     self.x = pos[:x] + (@right ? -add_x : add_x)
  3046.     self.y = pos[:y] + (@up    ? -add_y : add_y)
  3047.     self.z = pos[:y] + value[:z] + 3
  3048.     self.mirror = @right || @up
  3049.   end
  3050.   #--------------------------------------------------------------------------
  3051.   # *
  3052.   #--------------------------------------------------------------------------
  3053.   def add_x
  3054.     value[:x] - @battler.ox / 2
  3055.   end
  3056.   #--------------------------------------------------------------------------
  3057.   # *
  3058.   #--------------------------------------------------------------------------
  3059.   def add_y
  3060.     value[:y] - pos[:h] - pos[:j] - @battler.oy / 2
  3061.   end
  3062.   #--------------------------------------------------------------------------
  3063.   # *
  3064.   #--------------------------------------------------------------------------
  3065.   def pos
  3066.     @battler.position
  3067.   end
  3068. end
  3069.  
  3070. #==============================================================================
  3071. # ** Sprite_Throw
  3072. #------------------------------------------------------------------------------
  3073. #  This sprite is used to display throw animations.
  3074. #==============================================================================
  3075.  
  3076. class Sprite_Throw < Sprite_Object
  3077.   #--------------------------------------------------------------------------
  3078.   # *
  3079.   #--------------------------------------------------------------------------
  3080.   def initialize(target, settings)
  3081.     @battler = settings[:user]
  3082.     @target  = target
  3083.     @value   = settings.dup
  3084.     super(target.viewport)
  3085.     setup_throw
  3086.   end
  3087.   #--------------------------------------------------------------------------
  3088.   # *
  3089.   #--------------------------------------------------------------------------
  3090.   def setup_throw
  3091.     set_initial_position
  3092.     setup_arc
  3093.     setup_icon
  3094.     setup_animation if $imported[:ve_loop_animation] && value[:anim]
  3095.   end
  3096.   #--------------------------------------------------------------------------
  3097.   # *
  3098.   #--------------------------------------------------------------------------
  3099.   def set_initial_position
  3100.     if value[:return]
  3101.       @current_position = @target.position.dup
  3102.       @target_position  = @battler.position.dup
  3103.       init_ox = @target.right?  ? -value[:init_x] : value[:init_x]
  3104.       init_oy = @target.up?     ? -value[:init_y] : value[:init_y]
  3105.       end_ox  = @battler.right? ? -value[:end_x]  : value[:end_x]
  3106.       end_oy  = @battler.up?    ? -value[:end_y]  : value[:end_y]
  3107.     else
  3108.       @current_position = @battler.position.dup
  3109.       @target_position  = @target.position.dup
  3110.       init_ox = @battler.right? ? -value[:init_x] : value[:init_x]
  3111.       init_oy = @battler.up?    ? -value[:init_x] : value[:init_x]
  3112.       end_ox  = @target.right?  ? -value[:end_x]  : value[:end_x]
  3113.       end_oy  = @target.up?     ? -value[:end_y]  : value[:end_y]
  3114.     end
  3115.     @current_position[:x] += value[:init_x] + init_ox
  3116.     @current_position[:y] += value[:init_y] + init_oy
  3117.     @target_position[:x]  += value[:end_x]  + end_ox
  3118.     @target_position[:y]  += value[:end_y]  + end_oy
  3119.     @initial_position = @current_position.dup
  3120.   end
  3121.   #--------------------------------------------------------------------------
  3122.   # *
  3123.   #--------------------------------------------------------------------------
  3124.   def setup_arc
  3125.     @arc = {}
  3126.     x_plus = (target_distance(:x) / 32.0).abs
  3127.     y_plus = (target_distance(:y) / 32.0).abs
  3128.     speed = Math.sqrt((x_plus ** 2) + (y_plus ** 2)) / value[:speed]
  3129.     @arc[:speed]  = value[:arc] * 5.0 / [speed, 1].max
  3130.     @arc[:height] = value[:arc]
  3131.     @arc[:count]  = value[:arc] * 2
  3132.     @current_position[:a] = 0
  3133.   end
  3134.   #--------------------------------------------------------------------------
  3135.   # *
  3136.   #--------------------------------------------------------------------------
  3137.   def setup_icon
  3138.     super
  3139.     self.angle = value[:a]
  3140.   end
  3141.   #--------------------------------------------------------------------------
  3142.   # *
  3143.   #--------------------------------------------------------------------------
  3144.   def setup_animation
  3145.     animation = {type: :throw, anim: value[:anim], loop: 1}
  3146.     add_loop_animation(animation)
  3147.   end
  3148.   #--------------------------------------------------------------------------
  3149.   # *
  3150.   #--------------------------------------------------------------------------
  3151.   def update
  3152.     super
  3153.     update_move
  3154.     update_arc
  3155.   end
  3156.   #--------------------------------------------------------------------------
  3157.   # *
  3158.   #--------------------------------------------------------------------------
  3159.   def update_move
  3160.     distance = set_distance
  3161.     move     = {x: 1.0, y: 1.0}
  3162.     if distance[:x].abs < distance[:y].abs
  3163.       move[:x] = 1.0 / (distance[:y].abs.to_f / distance[:x].abs)
  3164.     elsif distance[:y].abs < distance[:x].abs
  3165.       move[:y] = 1.0 / (distance[:x].abs.to_f / distance[:y].abs)
  3166.     end
  3167.     speed = set_speed(distance)
  3168.     x = move[:x] * speed[:x]
  3169.     y = move[:y] * speed[:y]
  3170.     set_movement(x, y)
  3171.   end
  3172.   #--------------------------------------------------------------------------
  3173.   # *
  3174.   #--------------------------------------------------------------------------
  3175.   def set_distance
  3176.     {x: target_distance(:x), y: target_distance(:y)}
  3177.   end
  3178.   #--------------------------------------------------------------------------
  3179.   # *
  3180.   #--------------------------------------------------------------------------
  3181.   def target_distance(symbol)
  3182.     @target_position[symbol] - @current_position[symbol]
  3183.   end
  3184.   #--------------------------------------------------------------------------
  3185.   # *
  3186.   #--------------------------------------------------------------------------
  3187.   def set_speed(distance)
  3188.     x = value[:speed] * (distance[:x] == 0 ? 0 : (distance[:x] > 0 ? 8 : -8))
  3189.     y = value[:speed] * (distance[:y] == 0 ? 0 : (distance[:y] > 0 ? 8 : -8))
  3190.     {x: x, y: y}
  3191.   end
  3192.   #--------------------------------------------------------------------------
  3193.   # *
  3194.   #--------------------------------------------------------------------------
  3195.   def set_movement(x, y)
  3196.     target  = @target_position
  3197.     current = @current_position
  3198.     current[:x] += x
  3199.     current[:y] += y
  3200.     current[:x] = target[:x] if in_distance?(current[:x], target[:x], x)
  3201.     current[:y] = target[:y] if in_distance?(current[:y], target[:y], y)
  3202.   end
  3203.   #--------------------------------------------------------------------------
  3204.   # *
  3205.   #--------------------------------------------------------------------------
  3206.   def in_distance?(x, y, z)
  3207.     x.between?(y - z - 1, y + z + 1)
  3208.   end
  3209.   #--------------------------------------------------------------------------
  3210.   # *
  3211.   #--------------------------------------------------------------------------
  3212.   def update_arc
  3213.     return if @arc[:count] == 0
  3214.     @arc[:count] = [@arc[:count] - (1 * @arc[:speed] / 10.0), 0].max.to_f
  3215.     count = @arc[:count]
  3216.     speed = @arc[:speed]
  3217.     peak  = @arc[:height]   
  3218.     result = (peak ** 2 - (count - peak).abs ** 2) / 2
  3219.     @current_position[:a] = value[:revert] ? -result : result
  3220.   end
  3221.   #--------------------------------------------------------------------------
  3222.   # *
  3223.   #--------------------------------------------------------------------------
  3224.   def update_position
  3225.     setup_icon if icon_changed?
  3226.     self.x = position[:x]
  3227.     self.y = position[:y] - position[:h] - position[:a]
  3228.     self.z = position[:y] + value[:z] + 4
  3229.     self.ox = 12
  3230.     self.oy = 12
  3231.     self.mirror = @right || @up
  3232.   end
  3233.   #--------------------------------------------------------------------------
  3234.   # *
  3235.   #--------------------------------------------------------------------------
  3236.   def position
  3237.     @current_position
  3238.   end
  3239.   #--------------------------------------------------------------------------
  3240.   # *
  3241.   #--------------------------------------------------------------------------
  3242.   def target
  3243.     @target_position
  3244.   end
  3245.   #--------------------------------------------------------------------------
  3246.   # *
  3247.   #--------------------------------------------------------------------------
  3248.   def disposing?
  3249.     position[:x] == target[:x] && position[:y] == target[:y]
  3250.   end
  3251. end
  3252.  
  3253. #==============================================================================
  3254. # ** Action_Plane
  3255. #------------------------------------------------------------------------------
  3256. #  
  3257. #==============================================================================
  3258.  
  3259. class Action_Plane < Plane
  3260.   #--------------------------------------------------------------------------
  3261.   # *
  3262.   #--------------------------------------------------------------------------
  3263.   def initialize(viewport)
  3264.     super(viewport)
  3265.     @settings = {x: 0, y: 0, opacity: 0, zoom_x: 1.0, zoom_y: 1.0}
  3266.     @duration = 1
  3267.   end
  3268.   #--------------------------------------------------------------------------
  3269.   # * dispose
  3270.   #--------------------------------------------------------------------------
  3271.   def dispose
  3272.     bitmap.dispose if bitmap
  3273.     super
  3274.   end
  3275.   #--------------------------------------------------------------------------
  3276.   # *
  3277.   #--------------------------------------------------------------------------
  3278.   def setup(name, x, y, z, zoom_x, zoom_y, opacity, blend, duration)
  3279.     self.bitmap = Cache.picture(name)
  3280.     self.z = z
  3281.     @settings[:x] = x
  3282.     @settings[:y] = y
  3283.     @settings[:zoom_x]  = zoom_x / 100.0
  3284.     @settings[:zoom_y]  = zoom_y / 100.0
  3285.     @settings[:opacity] = opacity
  3286.     @blend_type = blend
  3287.     @delete     = false
  3288.     @duration   = [duration, 1].max
  3289.   end
  3290.   #--------------------------------------------------------------------------
  3291.   # *
  3292.   #--------------------------------------------------------------------------
  3293.   def delete(duration = 60)
  3294.     @settings[:opacity] = 0
  3295.     @duration = [duration, 1].max
  3296.     @delete   = true
  3297.   end
  3298.   #--------------------------------------------------------------------------
  3299.   # *
  3300.   #--------------------------------------------------------------------------
  3301.   def value
  3302.     @settings
  3303.   end
  3304.   #--------------------------------------------------------------------------
  3305.   # *
  3306.   #--------------------------------------------------------------------------
  3307.   def update
  3308.     update_position
  3309.     update_opacity
  3310.     update_zoom
  3311.     update_delete
  3312.     @duration -= 1 if @duration > 0
  3313.   end
  3314.   #--------------------------------------------------------------------------
  3315.   # *
  3316.   #--------------------------------------------------------------------------
  3317.   def update_position
  3318.     self.ox += value[:x]
  3319.     self.oy += value[:y]
  3320.   end
  3321.   #--------------------------------------------------------------------------
  3322.   # *
  3323.   #--------------------------------------------------------------------------
  3324.   def update_opacity
  3325.     return if @duration == 0
  3326.     d = @duration
  3327.     self.opacity = (self.opacity * (d - 1) + value[:opacity]) / d
  3328.   end
  3329.   #--------------------------------------------------------------------------
  3330.   # *
  3331.   #--------------------------------------------------------------------------
  3332.   def update_zoom
  3333.     return if @duration == 0
  3334.     d = @duration
  3335.     self.zoom_x = (self.zoom_x * (d - 1) + value[:zoom_x]) / d
  3336.     self.zoom_y = (self.zoom_y * (d - 1) + value[:zoom_y]) / d
  3337.   end
  3338.   #--------------------------------------------------------------------------
  3339.   # *
  3340.   #--------------------------------------------------------------------------
  3341.   def update_delete
  3342.     return if !@delete || @duration > 0
  3343.     self.bitmap.dispose
  3344.     self.bitmap = nil
  3345.     @settings   = {x: 0, y: 0, opacity: 0, zoom_x: 100.0, zoon_y: 100.0}
  3346.     @blend_type = 0
  3347.     @delete = false
  3348.   end
  3349. end

捕获.PNG (500.09 KB, 下载次数: 5)

捕获.PNG

Project3.7z

517.11 KB, 下载次数: 41

最佳答案

查看完整内容

按楼主要求试伤害在动画结束后显示。 但是仅仅调了伤害显示,敌人还是会在刚开始显示动画就挂掉。 有问题的继续问我好了。

Lv1.梦旅人

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

评分

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

查看全部评分

回复

使用道具 举报

Lv1.梦旅人

矿工

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

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
14 小时
注册时间
2012-7-30
帖子
32
4
发表于 2013-7-17 21:02:57 | 只看该作者
哇,哪来的战斗图,这么好。是什么战斗系统
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
82 小时
注册时间
2013-3-17
帖子
63
5
 楼主| 发表于 2013-7-17 21:07:46 | 只看该作者
1332535 发表于 2013-7-17 21:02
哇,哪来的战斗图,这么好。是什么战斗系统

VE Animated Battle
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
82 小时
注册时间
2013-3-17
帖子
63
6
 楼主| 发表于 2013-7-17 21:08:35 | 只看该作者
876加几 发表于 2013-7-17 20:52
等待几帧后伤害,把本身的伤害公式删去,利用公共事件。

强制战斗指令?
回复

使用道具 举报

Lv1.梦旅人

矿工

梦石
0
星屑
134
在线时间
898 小时
注册时间
2012-10-5
帖子
1535
7
发表于 2013-7-17 21:57:46 | 只看该作者
chengzhuo5 发表于 2013-7-17 21:08
强制战斗指令?

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

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
82 小时
注册时间
2013-3-17
帖子
63
8
 楼主| 发表于 2013-7-18 00:09:02 手机端发表。 | 只看该作者
876加几 发表于 2013-7-17 21:57  各种条件分歧,如实在不会搜RMVA脚本库。  若搜不到只有搜外国网站了。

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

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
75
在线时间
91 小时
注册时间
2013-7-7
帖子
53
9
发表于 2013-7-18 03:17:37 | 只看该作者
chengzhuo5 发表于 2013-7-18 00:09
难道就不能改原脚本么?

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


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

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

回复

使用道具 举报

Lv1.梦旅人

矿工

梦石
0
星屑
134
在线时间
898 小时
注册时间
2012-10-5
帖子
1535
10
发表于 2013-7-18 08:52:24 | 只看该作者
chengzhuo5 发表于 2013-7-18 00:09
难道就不能改原脚本么?

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

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-18 08:49

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表