| 赞 | 2 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2016-5-4 |
| 在线时间 | 82 小时 |
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 82 小时
- 注册时间
- 2013-3-17
- 回帖
- 49
|
悬赏1星屑已解决
如题,脚本见范例。艾利克的“111”技能动画为陨石,但是动画刚刚播放就造成伤害(见图)。请问如何等到动画放完后再造成伤害??
可能相关的脚本
- #==============================================================================
- # ** Victor Engine - Animated Battle
- #------------------------------------------------------------------------------
- # Author : Victor Sant
- #
- # Version History:
- # v beta - 2012.01.28 > Beta relase
- #------------------------------------------------------------------------------
- # VE - Animated battle Beta
- #------------------------------------------------------------------------------
- # Compatibility
- # Requires the script 'Victor Engine - Basic Module'
- #
- #------------------------------------------------------------------------------
- # Instructions:
- # To instal the script, open you script editor and paste this script on
- # a new section on bellow the Materials section. This script must also
- # be bellow the script 'Victor Engine - Basic'
- #==============================================================================
- #==============================================================================
- # ** Victor Engine
- #------------------------------------------------------------------------------
- # Setting module for the Victor Engine
- #==============================================================================
- $imported[:ve_animated_battle] = true
- #==============================================================================
- # ** Object
- #------------------------------------------------------------------------------
- # This class is the superclass of all other classes.
- #==============================================================================
- class Object
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def custom_pose(type)
- note =~ /<#{type.upcase} POSE: (\w[\w ]+)>/i ? make_symbol($1) : nil
- end
- end
- #==============================================================================
- # ** BattleManager
- #------------------------------------------------------------------------------
- # This module handles the battle processing
- #==============================================================================
- class << BattleManager
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- attr_accessor :old_tone
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :init_members_ve_animated_battle :init_members
- def init_members
- $game_party.members.each {|member| member.clear_poses }
- init_members_ve_animated_battle
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :battle_end_ve_animated_battle :battle_end
- def battle_end(result)
- $game_party.members.each {|member| member.clear_poses }
- battle_end_ve_animated_battle(result)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :process_victory_ve_animated_battle :process_victory
- def process_victory
- process_victory_pose
- process_victory_ve_animated_battle
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :process_escape_ve_animated_battle :process_escape
- def process_escape
- @escaping = true
- success = process_escape_ve_animated_battle
- @escaping = false
- return success
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :process_abort_ve_animated_battle :process_abort
- def process_abort
- process_escape_pose if @escaping
- process_abort_ve_animated_battle
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def process_victory_pose
- SceneManager.scene.update_basic while $game_party.not_in_position?
- $game_party.movable_members.each do |member|
- member.clear_idle_poses
- member.call_pose(:victory)
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def process_escape_pose
- $game_party.movable_members.each do |member|
- member.clear_idle_poses
- member.call_pose(:escape)
- end
- 5.times { SceneManager.scene.update_basic }
- SceneManager.scene.update_basic while $game_party.moving?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_active_pose
- return unless actor
- actor.set_active_pose
- actor.reset_pose
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def clear_active_pose
- return unless actor
- actor.active_pose = nil
- actor.reset_pose
- end
- end
- #==============================================================================
- # ** Game_Screen
- #------------------------------------------------------------------------------
- # This class handles screen maintenance data, such as change in color tone,
- # flashes, etc. It's used within the Game_Map and Game_Troop classes.
- #==============================================================================
- class Game_Screen
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- attr_reader :low_tone
- attr_reader :high_tone
- attr_accessor :old_tone
- attr_accessor :old_low_tone
- attr_accessor :old_high_tone
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :clear_tone_ve_animated_battle :clear_tone
- def clear_tone
- clear_tone_ve_animated_battle
- @low_tone = Tone.new
- @high_tone = Tone.new
- @low_tone_target = Tone.new
- @high_tone_target = Tone.new
- @low_tone_duration = 0
- @high_tone_duration = 0
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :update_ve_animated_battle :update
- def update
- update_ve_animated_battle
- low_update_tone
- high_update_tone
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def start_low_tone_change(tone, duration)
- @low_tone_target = tone.clone
- @low_tone_duration = duration
- @low_tone = @low_tone_target.clone if @low_tone_duration == 0
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def start_high_tone_change(tone, duration)
- @high_tone_target = tone.clone
- @high_tone_duration = duration
- @high_tone = @high_tone_target.clone if @high_tone_duration == 0
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def low_update_tone
- if @low_tone_duration > 0
- d = @low_tone_duration
- tone = @low_tone_target
- @low_tone.red = (@low_tone.red * (d - 1) + tone.red) / d
- @low_tone.green = (@low_tone.green * (d - 1) + tone.green) / d
- @low_tone.blue = (@low_tone.blue * (d - 1) + tone.blue) / d
- @low_tone.gray = (@low_tone.gray * (d - 1) + tone.gray) / d
- @low_tone_duration -= 1
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def high_update_tone
- if @high_tone_duration > 0
- d = @high_tone_duration
- tone = @high_tone_target
- @high_tone.red = (@high_tone.red * (d - 1) + tone.red) / d
- @high_tone.green = (@high_tone.green * (d - 1) + tone.green) / d
- @high_tone.blue = (@high_tone.blue * (d - 1) + tone.blue) / d
- @high_tone.gray = (@high_tone.gray * (d - 1) + tone.gray) / d
- @high_tone_duration -= 1
- end
- end
- #--------------------------------------------------------------------------
- # * New method: tone_change?
- #--------------------------------------------------------------------------
- def tone_change?
- @tone_duration > 0 || @low_tone_duration > 0 || @high_tone_duration > 0
- end
- end
- #==============================================================================
- # ** Game_ActionResult
- #------------------------------------------------------------------------------
- # This class handles the results of actions. This class is used within the
- # Game_Battler class.
- #==============================================================================
- class Game_ActionResult
- #--------------------------------------------------------------------------
- # * New method: damage_value_adjust
- #--------------------------------------------------------------------------
- def damage_value_adjust(value, item)
- @hp_damage *= value
- @mp_damage *= value
- @hp_damage = @hp_damage.to_i
- @mp_damage = [@battler.mp, @mp_damage.to_i].min
- @hp_drain = @hp_damage if item.damage.drain?
- @mp_drain = @mp_damage if item.damage.drain?
- @hp_drain = [@battler.hp, @hp_drain].min
- end
- end
- #==============================================================================
- # ** Game_Battler
- #------------------------------------------------------------------------------
- # This class deals with battlers. It's used as a superclass of the Game_Actor
- # and Game_Enemy classes.
- #==============================================================================
- class Game_Battler < Game_BattlerBase
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- attr_accessor :row
- attr_accessor :frame
- attr_accessor :timing
- attr_accessor :freeze
-
- attr_accessor :direction
- attr_accessor :move_speed
- attr_accessor :jumping
- attr_accessor :shake
-
- attr_accessor :pose_list
-
- attr_accessor :immortals
-
- attr_accessor :attack_flag
- attr_accessor :damage_flag
- attr_accessor :result_flag
- attr_accessor :target_flag
-
- attr_accessor :spin
- attr_accessor :angle
- attr_accessor :sufix
- attr_accessor :active
- attr_accessor :targets
- attr_accessor :teleport
- attr_accessor :x_adj
- attr_accessor :y_adj
-
- attr_accessor :call_anim
- attr_accessor :call_effect
- attr_accessor :animation
- attr_accessor :countered
- attr_accessor :substitution
-
- attr_accessor :action_targets
- attr_accessor :active_pose
- attr_accessor :pose_loop_anim
-
- attr_accessor :previous_action
-
- attr_accessor :icon_list
- attr_accessor :throw_list
-
- attr_accessor :current_item
-
- attr_accessor :target_position
- attr_accessor :current_position
- attr_accessor :default_position
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :initialize_ve_animated_battle :initialize
- def initialize
- init_anim_battlers_variables
- initialize_ve_animated_battle
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :item_apply_ve_animated_battle :item_apply
- def item_apply(user, item)
- item_apply_ve_animated_battle(user, item)
- call_damage_pose(item, user) if movable?
- [url=home.php?mod=space&uid=131733]@substitution[/url] = false
- user.result_flag = @result.hit? ? :hit : :miss
- end
- #--------------------------------------------------------------------------
- # * Alias method: make_damage_value
- #--------------------------------------------------------------------------
- alias :make_damage_value_ve_animated_battle :make_damage_value
- def make_damage_value(user, item)
- make_damage_value_ve_animated_battle(user, item)
- @result.damage_value_adjust(user.damage_flag, item) if user.damage_flag
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :regenerate_hp_ve_animated_battle :regenerate_hp
- def regenerate_hp
- regenerate_hp_ve_animated_battle
- call_pose(:hurt, :clear) if @result.hp_damage > 0 && movable?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def dead?
- super && !immortal?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def refresh
- state_resist_set.each {|state_id| erase_state(state_id) }
- @hp = [[@hp, mhp].min, 0].max
- @mp = [[@mp, mmp].min, 0].max
- die if [url=home.php?mod=space&uid=90807]@Dying[/url] && !immortal?
- return if @dying
- valid = @hp == 0 && !immortal?
- valid ? add_state(death_state_id) : remove_state(death_state_id)
- reset_pose
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def immortal?
- return false unless $game_party.in_battle
- members = $game_troop.members + $game_party.battle_members
- members.any? {|member| member.immortals.include?(self) }
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :die_ve_animated_battle :die
- def die
- return @dying = true if immortal?
- call_pose(:die, :clear)
- @dying = false
- die_ve_animated_battle
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :revive_ve_animated_battle :revive
- def revive
- call_pose(:revive, :clear)
- revive_ve_animated_battle
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def init_anim_battlers_variables
- clear_poses
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def clear_poses
- @sufix = ""
- @row = 0
- @frame = 0
- [url=home.php?mod=space&uid=124954]@Angle[/url] = 0
- @spin = 0
- @x_adj = 0
- @y_adj = 0
- @direction = 2
- @move_speed = 1.0
- @pose_list = []
- @targets = []
- @immortals = []
- @throw_list = []
- @icon_list = {}
- @timing = {}
- @action_targets = []
- clear_shake
- clear_position
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def clear_shake
- @shake_power = 0
- @shake_speed = 0
- @shake_duration = 0
- @shake_direction = 1
- @shake = 0
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def clear_position
- @target_position = {x: 0, y: 0, h: 0, j: 0}
- @current_position = {x: 0, y: 0, h: 0, j: 0}
- @default_position = {x: 0, y: 0, h: 0, j: 0}
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def call_pose(symbol, insert = nil, item = nil, battler = nil)
- skip_pose if insert == :clear && pose_name_list.first == symbol
- pose = make_string(symbol)
- note = item ? item.note : ""
- notes = get_all_poses(note)
- code = "ACTION: #{pose}((?: *, *[\\w ]+)+)?"
- setup_pose(symbol, notes, code, insert, battler)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def get_all_poses(note = "")
- note + get_all_notes + battler_settings + default_settings
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def default_settings
- VE_DEFAULT_ACTION
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def battler_settings
- VE_ACTION_SETTINGS[battler_mode] ? VE_ACTION_SETTINGS[battler_mode] : ""
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def battler_mode
- sprite_value(:action)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def sprite_value(value)
- sprite_settings[value] ? sprite_settings[value] : VE_DEFAULT_SPRITE[value]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def sprite_settings
- VE_SPRITE_SETTINGS[@battler_name] ? VE_SPRITE_SETTINGS[@battler_name] :
- VE_DEFAULT_SPRITE
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_pose(pose, notes, code, insert, battler)
- regexp = /<#{code}>((?:[^<]|<[^\/])*)<\/ACTION>/im
- if notes.gsub(/\r\n/i, "") =~ regexp
- time, last = get_values($1)
- value = setup_value($2, battler == :skip ? nil : battler)
- return if value.empty?
- time.times do
- list = {pose: pose, next: last, value: value.dup, battler: battler}
- insert ? @pose_list.unshift(list) : @pose_list.push(list)
- end
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def pose_name_list
- @pose_list.collect {|pose| pose[:pose]}
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def pose_name
- pose_name_list.first
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def skip_pose
- @current_pose = pose_name
- @pose_list.shift while @current_pose == pose_name && !@pose_list.empty?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def get_values(value)
- if value
- time = value =~ /([^,]+) TIMES/i ? [eval($1), 1].max : 1
- last = value =~ /(\w[\w ]+)/i ? make_symbol($1) : nil
- [time, last]
- else
- [1, nil]
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def clear_idle_poses
- @pose_list.delete_if {|pose| idle_pose?(pose[:pose]) }
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def battler
- @pose[:battler] ? @pose[:battler] : self
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def idle_pose?(pose)
- idle_pose_list.include?(pose.downcase.to_sym)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def idle_pose_list
- [:idle, :guard, :danger, :dead, :item_cast, :magic_cast, :skill_cast,
- :default_cast] + states_pose
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def states_pose
- $data_states.compact.collect {|state| state.custom_pose("STATE") }.compact
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_value(settings, battler)
- values = []
- settings.scan(/(\w+)(?:: ([^;]+)[;\n\r])?/i) do |type, value|
- values.push(set_pose_value(type, value ? value : '', battler))
- end
- values
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_pose_value(type, value, battler)
- @pose = {}
- @pose[:battler] = battler
- @pose[:type] = make_symbol(type)
- @pose[:hit] = value =~ /HIT ONLY/i ? true : false
- @pose[:miss] = value =~ /MISS ONLY/i ? true : false
- set_pose_setting("#{type} #{value}")
- @pose
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_pose_setting(value)
- case value
- when /^POSE (.*)/i then set_pose($1)
- when /^WAIT (.*)/i then set_wait($1)
- when /^MOVE (.*)/i then set_move($1)
- when /^JUMP (.*)/i then set_jump($1)
- when /^ANIM (.*)/i then set_anim($1)
- when /^ICON (.*)/i then set_icon($1)
- when /^LOOP (.*)/i then set_loop($1)
- when /^TONE (.*)/i then set_tone($1)
- when /^THROW (.*)/i then set_throw($1)
- when /^SOUND (.*)/i then set_sound($1)
- when /^PLANE (.*)/i then set_plane($1)
- when /^FLASH (.*)/i then set_flash($1)
- when /^SHAKE (.*)/i then set_shake($1)
- when /^MOVIE (.*)/i then set_movie($1)
- when /^ACTION (.*)/i then set_action($1)
- when /^FREEZE (.*)/i then set_freeze($1)
- when /^EFFECT (.*)/i then set_effect($1)
- when /^PICTURE (.*)/i then set_picture($1)
- when /^COUNTER (.*)/i then set_counter($1)
- when /^DIRECTION (.*)/i then set_direction($1)
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_pose(value)
- @pose[:target] = set_targets(value)
- @pose[:row] = battler.set_row(value)
- @pose[:angle] = value =~ /ANGLE ([+-]?\d+)/i ? $1.to_i : 0
- @pose[:spin] = value =~ /SPIN ([+-]?\d+)/i ? $1.to_i : 0
- @pose[:sufix] = value =~ /SUFIX ([\[\]\w]+)/i ? $1.to_s : ""
- @pose[:x] = value =~ /X ([+-]?\d+)/i ? $1.to_i : 0
- @pose[:y] = value =~ /Y ([+-]?\d+)/i ? $1.to_i : 0
- if value =~ /(\d+|ALL) FRAMES?/i
- w = [value =~ /WAIT (\d+)/i ? $1.to_i : 1, 1].max
- m = /(\d+) FRAMES/i ? $1.to_i : :all
- l = value =~ /RETURN/i ? true : false
- r = value =~ /REVERT/i ? true : false
- @pose[:frame] = value =~ /FRAME (\d+)/i ? $1.to_i : 1
- @pose[:pose] = {wait: w, time: w, frame: m, loop: l, revert: r}
- else
- @pose[:pose] = {}
- @pose[:frame] = value =~ /FRAME (\d+)/i ? $1.to_i : 1
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_wait(value)
- @pose[:target] = set_targets(value)
- case value
- when /(\d+)/i
- @pose[:time] = $1.to_i
- @pose[:wait] = $1.to_i
- when /(ACTION|ANIMATION|MOVEMENT|ORIGIN|THROW|COUNTER|SUBSTITUTION|TONE)/i
- @pose[:time] = make_symbol($1)
- @pose[:wait] = make_symbol($1)
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_move(value)
- regexp = /(MOVE TO|STEP FOWARD|STEP BACKWARD|RETREAT|ESCAPE)/i
- @pose[:value] = make_symbol($1) if value =~ regexp
- @pose[:target] = battler.set_targets(value)
- @pose[:x] = value =~ /X ([+-]?\d+)/i ? $1.to_i : 0
- @pose[:y] = value =~ /Y ([+-]?\d+)/i ? $1.to_i : 0
- @pose[:h] = value =~ /HEIGHT (\d+)/i ? $1.to_i : 0
- @pose[:speed] = value =~ /SPEED (\d+)/i ? $1.to_i / 10.0 : 1.0
- @pose[:targets] = @action_targets if @pose[:value] == :move_to
- @pose[:teleport] = value =~ /TELEPORT/i
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_jump(value)
- @pose[:target] = set_targets(value)
- @pose[:move] = value =~ /MOVE/i
- @pose[:height] = value =~ /HEIGHT (\d+)/i ? [$1.to_i, 1].max : 5
- @pose[:speed] = value =~ /SPEED (\d+)/i ? [$1.to_i, 1].max : 10
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_action(value)
- @pose[:target] = set_targets(value)
- value.scan(/(\w[\w ]+)/) do
- not_action = ['target','actor','friend','enemy', 'user','self']
- next if not_action.include?($1.downcase)
- @pose[:action] = make_symbol($1)
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_freeze(value)
- @pose[:target] = set_targets(value)
- @pose[:duration] = value =~ /DURATION (\d+)/i ? [$1.to_i, 1].max : 1
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_sound(value)
- @pose[:name] = value =~ /NAME #{get_filename}/i ? $1 : ""
- @pose[:volume] = value =~ /VOLUME (\d+)/i ? $1.to_i : 100
- @pose[:pitch] = value =~ /PITCH (\d+)/i ? $1.to_i : 100
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_anim(value)
- @pose[:target] = set_targets(value)
- item = current_item ? current_item : nil
- case value
- when /CAST/i
- cast = item && $imported[:ve_cast_animation]
- anim = cast ? battler.cast_animation_id(item) : 0
- @pose[:anim] = anim
- when /EFFECT/i
- @pose[:anim] = item ? item.animation_id : 0
- when /ID (\d+)/i
- @pose[:anim] = $1.to_i
- when /WEAPON *(\d+)?/i
- @pose[:anim] = battler.atk_animation_id1
- @pose[:anim] = battler.atk_animation_id2 if $1 && $1.to_i == 2
- else
- @pose[:anim] = 0
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_icon(value)
- @pose[:target] = set_targets(value)
- @pose[:index] = value =~ /INDEX ([+-]?\d+)/i ? $1.to_i : 0
- @pose[:image] = value =~ /IMAGE #{get_filename}/i ? $1.to_s : nil
- @pose[:delete] = value =~ /DELETE/i ? true : false
- return if @pose[:delete]
- set_action_icon(value)
- @pose[:x] = value =~ /X ([+-]?\d+)/i ? $1.to_i : 0
- @pose[:y] = value =~ /Y ([+-]?\d+)/i ? $1.to_i : 0
- @pose[:z] = value =~ /Z ([+-]?\d+)/i ? $1.to_i : -1
- @pose[:a] = value =~ /ANGLE ([+-]?\d+)/i ? $1.to_i : 0
- @pose[:o] = value =~ /OPACITY (\d+)/i ? $1.to_i : 255
- @pose[:spin] = value =~ /SPIN ([+-]\d+)/i ? $1.to_i : 0
- @pose[:fin] = value =~ /FADE IN (\d+)/i ? $1.to_i : 0
- @pose[:fout] = value =~ /FADE OUT (\d+)/i ? $1.to_i : 0
- @pose[:izm] = value =~ /INIT ZOOM (\d+)/i ? $1.to_i / 100.0 : 1.0
- @pose[:ezm] = value =~ /END ZOOM (\d+)/i ? $1.to_i / 100.0 : 1.0
- @pose[:szm] = value =~ /ZOOM SPD (\d+)/i ? $1.to_i / 100.0 : 0.1
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_picture(value)
- @pose[:id] = value =~ /ID (\d+)/i ? [$1.to_i, 1].max : 1
- @pose[:delete] = value =~ /DELETE/i ? true : false
- return if @pose[:delete]
- name = value =~ /NAME #{get_filename}/i ? $1.to_s : ""
- orig = value =~ /ORIGIN CENTER/i ? 1 : 0
- x = value =~ /POS X ([+-]?\d+)/i ? $1.to_i : 0
- y = value =~ /POS Y ([+-]?\d+)/i ? $1.to_i : 0
- zoom_x = value =~ /ZOOM X ([+-]?\d+)/i ? $1.to_i : 100.0
- zoom_y = value =~ /ZOOM X ([+-]?\d+)/i ? $1.to_i : 100.0
- opacity = value =~ /OPACITY (\d+)/i ? $1.to_i : 255
- blend = value =~ /BLEND ([+-]\d+)/i ? $1.to_i : 0
- duration = value =~ /DURATION (\d+)/i ? $1.to_i : 0
- if value =~ /SHOW/i
- @pose[:show] = [name, orig, x, y, zoom_x, zoom_y, opacity, blend]
- elsif value =~ /MOVE/i
- @pose[:move] = [orig, x, y, zoom_x, zoom_y, opacity, blend, duration]
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_plane(value)
- @pose[:delete] = value =~ /DELETE/i ? true : false
- @pose[:duration] = value =~ /DURATION (\d+)/i ? $1.to_i : 0
- return if @pose[:delete]
- name = value =~ /NAME #{get_filename}/i ? $1.to_s : ""
- x = value =~ /MOVE X ([+-]?\d+)/i ? $1.to_i : 0
- y = value =~ /MOVE Y ([+-]?\d+)/i ? $1.to_i : 0
- z = value =~ /Z ([+-]?\d+)/i ? $1.to_i : 100
- zoom_x = value =~ /ZOOM X ([+-]?\d+)/i ? $1.to_i : 100.0
- zoom_y = value =~ /ZOOM X ([+-]?\d+)/i ? $1.to_i : 100.0
- opacity = value =~ /OPACITY (\d+)/i ? $1.to_i : 160
- blend = value =~ /BLEND ([+-]\d+)/i ? $1.to_i : 0
- duration = @pose[:duration]
- @pose[:list] = [name, x, y, z, zoom_x, zoom_y, opacity, blend, duration]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_throw(value)
- @pose[:target] = set_targets(value)
- @pose[:image] = value =~ /IMAGE #{get_filename}/i ? $1.to_s : nil
- set_action_icon(value)
- @pose[:revert] = value =~ /REVERT/i
- @pose[:return] = value =~ /RETURN/i
- @pose[:init_x] = value =~ /INIT X ([+-]?\d+)/i ? $1.to_i : 0
- @pose[:init_y] = value =~ /INIT Y ([+-]?\d+)/i ? $1.to_i : 0
- @pose[:end_x] = value =~ /END X ([+-]?\d+)/i ? $1.to_i : 0
- @pose[:end_y] = value =~ /END Y ([+-]?\d+)/i ? $1.to_i : 0
- @pose[:anim] = value =~ /ANIM (\d+)/i ? $1.to_i : nil
- @pose[:arc] = value =~ /ARC (\d+)/i ? $1.to_i : 0
- @pose[:speed] = value =~ /SPEED (\d+)/i ? $1.to_i / 10.0 : 1.0
- @pose[:spin] = value =~ /SPIN ([+-]\d+)/i ? $1.to_i : 0
- @pose[:fin] = value =~ /FADE IN (\d+)/i ? $1.to_i : 0
- @pose[:fout] = value =~ /FADE OUT (\d+)/i ? $1.to_i : 0
- @pose[:izm] = value =~ /INIT ZOOM (\d+)/i ? $1.to_i / 100.0 : 1.0
- @pose[:ezm] = value =~ /END ZOOM (\d+)/i ? $1.to_i / 100.0 : 1.0
- @pose[:szm] = value =~ /ZOOM SPD (\d+)/i ? $1.to_i / 100.0 : 0.1
- @pose[:z] = value =~ /Z ([+-]?\d+)/i ? $1.to_i : 0
- @pose[:o] = value =~ /OPACITY (\d+)/i ? $1.to_i : 255
- @pose[:a] = value =~ /ANGLE (\d+)/i ? $1.to_i : 0
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_action_icon(value)
- icon = weapon_icon($1.to_i) if value =~ /WEAPON (\d+)/i && battler.actor?
- icon = armor_icon($1.to_i) if value =~ /ARMOR (\d+)/i && battler.actor?
- icon = armor_icon(1) if value =~ /SHIELD/i && battler.actor?
- icon = action_icon if value =~ /ACTION/i
- icon = $1.to_i if value =~ /ICON (\d+)/i
- @pose[:icon] = icon ? icon : 0
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_shake(value)
- @pose[:target] = set_targets(value)
- @pose[:screen] = value =~ /SCREEN/i ? true : false
- power = value =~ /POWER (\d+)/i ? [$1.to_i, 2].max : 5
- speed = value =~ /SPEED (\d+)/i ? [$1.to_i, 2].max : 5
- duration = value =~ /DURATION (\d+)/i ? [$1.to_i, 1].max : 10
- @pose[:shake] = [power / 2.0, speed / 2.0, duration]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_movie(value)
- @pose[:name] = value =~ /NAME #{get_filename}/i ? $1.to_s : ""
- set_tone(value)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_tone(value)
- r = value =~ /RED ([+-]?\d+)/i ? $1.to_i : 0
- g = value =~ /GREEN ([+-]?\d+)/i ? $1.to_i : 0
- b = value =~ /BLUE ([+-]?\d+)/i ? $1.to_i : 0
- a = value =~ /GRAY ([+-]?\d+)/i ? $1.to_i : 0
- tone = [r, g, b, a]
- tone = [ 255, 255, 255, 0] if value =~ /WHITE/i
- tone = [-255, -255, -255, 0] if value =~ /BLACK/i
- @pose[:tone] = Tone.new(*tone)
- @pose[:clear] = true if value =~ /CLEAR/i
- @pose[:duration] = value =~ /DURATION (\d+)/i ? $1.to_i : 0
- @pose[:priority] = :normal
- @pose[:priority] = :high if value =~ /HIGH PRIORITY/i
- @pose[:priority] = :low if value =~ /LOW PRIORITY/i
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_flash(value)
- @pose[:target] = set_targets(value)
- @pose[:screen] = value =~ /SCREEN/i ? true : false
- r = value =~ /RED (\d+)/i ? $1.to_i : 255
- g = value =~ /GREEN (\d+)/i ? $1.to_i : 255
- b = value =~ /BLUE (\d+)/i ? $1.to_i : 255
- a = value =~ /ALPHA (\d+)/i ? $1.to_i : 160
- duration = value =~ /DURATION (\d+)/i ? [$1.to_i, 1].max : 10
- @pose[:flash] = [Color.new(r, g, b, a), duration]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_loop(value)
- @pose[:target] = set_targets(value)
- @pose[:loop_anim] = value =~ /ANIM (\d+)/i ? $1.to_i : 0
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_effect(value)
- @pose[:target] = set_targets(value)
- @pose[:damage] = $1.to_i / 100.0 if value =~ /(\d+)%/i
- @pose[:weapon] = [$1.to_i, 1].max if value =~ /WEAPON (\d+)/i
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_counter(value)
- @pose[:target] = set_targets(value)
- @pose[:counter] = true if value =~ /ON/i
- @pose[:counter] = false if value =~ /OFF/i
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_direction(value)
- @pose[:targets] = true if value =~ /TARGETS/i
- @pose[:return] = true if value =~ /RETURN/i
- @pose[:direction] = 2 if value =~ /DOWN/i
- @pose[:direction] = 4 if value =~ /LEFT/i
- @pose[:direction] = 6 if value =~ /RIGHT/i
- @pose[:direction] = 8 if value =~ /UP/i
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_targets(value)
- case value
- when /SELF/i
- [self]
- when /ACTOR ([^>,]+)/i
- acotor = $game_actors[eval($1)]
- target = $game_party.battle_members.include?(actor) ? [actor] : []
- when /FRIEND ([^>,]+)/i
- [$game_party.battle_members[eval($1)]].compact
- when /ENEMY ([^>,]+)/i
- [$game_troop.members[eval($1)]].compact
- when /RANDOM ENEMY/i
- battler.opponents_unit.members.random
- when /RANDOM FRIEND/i
- battler.firends_unit.members.random
- when /ALL ENEMIES/i
- battler.opponents_unit.members
- when /ALL FRIENDS/i
- battler.firends_unit.members
- when /TARGETS/i
- battler.action_targets.dup
- when /USER/i
- [battler]
- else
- nil
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_row(value)
- pose = battler.sprite_value(make_symbol($1)) if value =~ /ROW (\w+)/i
- pose = :direction if value =~ /ROW DIRECTION/i
- pose = $1.to_i if value =~ /ROW (\d+)/i
- pose ? pose : 0
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def weapon_icon(index)
- battler.weapons[index - 1] ? battler.weapons[index - 1].icon_index : nil
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def equip_list
- @equips
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def armor_icon(index)
- slot = battler.equip_slots[index]
- return nil unless slot && slot != 0 && battler.equip_list[slot]
- equip = battler.equip_list[slot]
- equip.object ? equip.object.icon_index : nil
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def action_icon
- current_item ? current_item.icon_index : 0
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def active?
- @active
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def down?
- @direction == 2
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def left?
- @direction == 4
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def right?
- @direction == 6
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def up?
- @direction == 8
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def target_direction(x, y, current = nil)
- position = current ? current : current_position
- relative_x = position[:x] - x
- relative_y = position[:y] - y
- if relative_y.abs > relative_x.abs && !sideview
- @direction = relative_y < 0 ? 2 : 8
- elsif relative_x.abs >= relative_y.abs && !frontview
- @direction = relative_x < 0 ? 6 : 4
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def position_fix
- value = 16 if left? || up?
- value = -16 if right? || down?
- target_position[rand(2) == 0 ? :x : :y] += value
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def sharing_position?
- units = $game_troop.members + $game_party.battle_members
- list = units.select do |target|
- target != self && target.target_position == target_position
- end
- !list.empty?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def sideview
- $imported[:ve_actor_battlers] && VE_BATTLE_FORMATION == :side
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def frontview
- $imported[:ve_actor_battlers] && VE_BATTLE_FORMATION == :front
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def action_direction
- units = @action_targets
- target_x = units.collect {|member| member.current_position[:x] }.average
- target_y = units.collect {|member| member.current_position[:y] }.average
- target_direction(target_x, target_y)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def target_distance(symbol)
- @target_position[symbol] - @current_position[symbol]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def moving?
- @current_position != @target_position
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def origin?
- @current_position[:x] != screen_x || @current_position[:y] != screen_y
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def activate
- return unless current_action && current_action.item
- @active = true
- @active_pose = nil
- @action_targets = current_action.make_targets.compact.dup
- setup_immortals
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_immortals
- @action_targets.each {|target| immortals.push(target) unless target.dead? }
- immortals.uniq!
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def deactivate
- @active = false
- @attack_flag = nil
- @result_flag = nil
- immortals = @immortals.dup
- @immortals.clear
- immortals.each {|member| member.refresh }
- @action_targets.clear
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def action_pose(item)
- activate
- @current_item = item
- pose = set_action_pose(item)
- call_action_poses(pose, item)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_action_pose(item)
- [setup_pose_type(item), false, item]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_pose_type(item)
- pose = weapons_pose("USE", :use)
- pose = weapons_pose("ITEM", :item) if item.item?
- pose = weapons_pose("MAGIC", :magic) if item.magical?
- pose = weapons_pose("SKILL", :skill) if item.skill?
- pose = attack_pose if item_attack?(item)
- pose = :defend if item_defend?(item)
- pose = custom_pose("ACTION", pose, item)
- pose
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def item_attack?(item)
- item.skill? && item.id == attack_skill_id
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def item_defend?(item)
- item.skill? && item.id == guard_skill_id
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def attack_pose
- pose = weapons_pose("ATTACK", :attack)
- pose = weapons_pose("DUAL", :dual_attack) if double_attack?
- pose
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def weapons_pose(type, pose)
- valid = actor? ? weapons : []
- list = valid.collect { |item| item.custom_pose(type) }.compact
- list.empty? || !pose_exist?(list.first) ? pose : list.first
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def custom_pose(type, pose, item)
- note = item ? item.note : ""
- custom = item.custom_pose(type)
- custom && pose_exist?(custom, note) ? custom : pose
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def pose_exist?(pose, note = "")
- value = "ACTION: #{make_string(pose)}"
- regexp = /<#{value}(?:(?: *, *[\w ]+)+)?>(?:[^<]|<[^\/])*<\/ACTION>/im
- get_all_poses(note) =~ regexp
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def call_action_poses(pose, item)
- clear_idle_poses
- call_move_pose("ADVANCE", :advance, item) if need_move?(item)
- call_pose(*pose)
- call_pose(:inactive)
- call_custom_pose("RETREAT", :retreat, item)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def call_move_pose(type, pose, item)
- pose = weapons_pose(type, pose)
- pose = custom_pose(type, pose, item)
- call_pose(pose, false, item)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def call_custom_pose(type, pose, item)
- pose = custom_pose(type, pose, item)
- call_pose(pose, false, item)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def need_move?(item)
- return true if item.note =~ /<ACTION MOVEMENT>/i
- return true if item.skill? && item.physical?
- return true if item.skill? && item.id == attack_skill_id
- return false
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def call_damage_pose(item, user)
- call_pose(:hurt, :clear, item, :skip) if hurt_pose?
- call_pose(:evade, :clear, item, :skip) if @result.evaded
- call_pose(:critical, :clear, item, :skip) if @result.critical
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def hurt_pose?
- @result.hit? && @result.hp_damage > 0 && !moving?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_active_pose
- return if (!current_action || !current_action.item) && !current_item
- item = current_action.item ? current_action.item : current_item
- pose = :ready if sprite_value(:ready)
- pose = :item_cast if item.item? && sprite_value(:item_cast)
- pose = :magic_cast if item.magical? && sprite_value(:magic_cast)
- pose = :skill_cast if item.physical? && sprite_value(:skill_cast)
- @active_pose = pose
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_counter(target)
- target.skip_pose unless [:inactive, :retreat].include?(target.pose_name)
- target.call_pose(:counter_on, :clear)
- @action_targets = [target]
- setup_immortals
- @current_item = $data_skills[attack_skill_id]
- pose = set_action_pose(@current_item)
- call_action_poses(pose, @current_item)
- call_pose(:counter_off)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_reflect(item)
- skip_pose unless [:reflection, :inactive, :retreat].include?(pose_name)
- @action_targets = [self]
- setup_immortals
- @current_item = item
- pose = set_action_pose(item)
- call_pose(:reflection, true, item)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_substitute(target)
- skip_pose unless [:substitution_on, :inactive, :retreat].include?(pose_name)
- @action_targets = [target]
- @substitution = true
- @current_position = target.current_position.dup
- @current_position[:x] += target.left? ? -16 : target.right? ? 16 : 0
- @current_position[:y] += target.up? ? -16 : target.down? ? 16 : 1
- @target_position = @current_position.dup
- call_pose(:substitution_off, true)
- call_pose(:substitution_on, true)
- sprite.update
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def double_attack?
- actor? && dual_wield? && weapons.size > 1
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def not_in_position?
- @current_position[:x] != screen_x || @current_position[:y] != screen_y
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def state_pose?
- state_pose
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def state_pose
- states.collect {|state| state.custom_pose("STATE") }.first
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def reset_pose
- return unless $game_party.in_battle
- sprite.reset_pose
- end
- #--------------------------------------------------------------------------
- # * New method: frames
- #--------------------------------------------------------------------------
- def frames
- @character_name[/\[F(\d+)\]/i] ? $1.to_i : 3
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def start_shake(power, speed, duration)
- @shake_power = power
- @shake_speed = speed
- @shake_duration = duration
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_shake
- return unless shaking?
- delta = (@shake_power * @shake_speed * @shake_direction) / 10.0
- clear = @shake_duration <= 1 && @shake * (@shake + delta) < 0
- @shake = clear ? 0 : @shake + delta
- @shake_direction = -1 if @shake > @shake_power * 2
- @shake_direction = 1 if @shake < - @shake_power * 2
- @shake_duration -= 1
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_freeze
- return if @freeze == 0 || !@freeze.numeric?
- @freeze -= 1
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def shaking?
- @shake_duration > 0 || @shake != 0
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def frozen?
- (@freeze.numeric? && @freeze > 0) || @freeze == :lock || unmovable?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def unmovable?
- get_all_notes =~ /<UNMOVEABLE>/i
- end
- end
- #==============================================================================
- # ** Game_Actor
- #------------------------------------------------------------------------------
- # This class handles actors. It's used within the Game_Actors class
- # ($game_actors) and referenced by the Game_Party class ($game_party).
- #==============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def perform_collapse_effect
- if $game_party.in_battle
- reset_pose
- case collapse_type
- when 0
- @sprite_effect_type = :collapse
- Sound.play_enemy_collapse
- when 1
- @sprite_effect_type = :boss_collapse
- Sound.play_boss_collapse1
- when 2
- @sprite_effect_type = :instant_collapse
- end
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def perform_damage_effect
- $game_troop.screen.start_shake(5, 5, 10) unless use_sprite?
- Sound.play_actor_damage
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :param_plus_ve_animated_battle :param_plus
- def param_plus(param_id)
- if param_id > 1 && @attack_flag
- atk_equips.compact.inject(super) {|r, item| r += item.params[param_id] }
- else
- param_plus_ve_animated_battle(param_id)
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def atk_feature_objects
- list = @attack_flag ? atk_equips : equips.compact
- states + [actor] + [self.class] + list
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def atk_all_features
- atk_feature_objects.inject([]) {|r, obj| r + obj.features }
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def atk_features(code)
- atk_all_features.select {|ft| ft.code == code }
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def atk_features_set(code)
- atk_features(code).inject([]) {|r, ft| r |= [ft.data_id] }
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def atk_elements
- set = atk_features_set(FEATURE_ATK_ELEMENT)
- set |= [1] if weapons.compact.empty?
- return set
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def atk_states
- atk_features_set(FEATURE_ATK_STATE)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def atk_equips
- ([weapons[@attack_flag - 1]] + armors).collect {|item| item }.compact
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def default_direction
- units = opponents_unit.members
- x = units.collect {|member| member.screen_x }.average
- y = units.collect {|member| member.screen_y }.average
- target_direction(x, y, {x: screen_x, y: screen_y})
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def screen_x
- return 0
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def screen_y
- return 0
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def character_hue
- hue
- end
- end
- #==============================================================================
- # ** Game_Enemy
- #------------------------------------------------------------------------------
- # This class handles enemy characters. It's used within the Game_Troop class
- # ($game_troop).
- #==============================================================================
- class Game_Enemy < Game_Battler
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :perform_collapse_effect_ve_animated_battle :perform_collapse_effect
- def perform_collapse_effect
- reset_pose
- perform_collapse_effect_ve_animated_battle
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def perform_damage_effect
- Sound.play_enemy_damage
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def character_name
- @battler_name
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def character_hue
- @battler_hue
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def character_index
- 0
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def visual_items
- [default_part]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def default_part
- {name: character_name.dup, index1: character_index, index2: character_index,
- hue: character_hue, priority: 0}
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def default_direction
- units = opponents_unit.battle_members
- x = units.collect {|member| member.screen_x }.average
- y = units.collect {|member| member.screen_y }.average
- target_direction(x, y, {x: screen_x, y: screen_y})
- end
- end
- #==============================================================================
- # ** Game_Party
- #------------------------------------------------------------------------------
- # This class handles the party. It includes information on amount of gold
- # and items. The instance of this class is referenced by $game_party.
- #==============================================================================
- class Game_Party < Game_Unit
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def not_in_position?
- movable_members.any? {|member| member.not_in_position? }
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def moving?
- movable_members.any? {|member| member.moving? }
- end
- end
- #==============================================================================
- # ** Game_Troop
- #------------------------------------------------------------------------------
- # This class handles enemy groups and battle-related data. Also performs
- # battle events. The instance of this class is referenced by $game_troop.
- #==============================================================================
- class Game_Troop < Game_Unit
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- attr_accessor :back_attack
- end
- #==============================================================================
- # ** Sprite_Battler
- #------------------------------------------------------------------------------
- # This sprite is used to display battlers. It observes a instance of the
- # Game_Battler class and automatically changes sprite conditions.
- #==============================================================================
- class Sprite_Battler < Sprite_Base
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- attr_accessor :battler
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :initialize_ve_animated_battle :initialize
- def initialize(viewport, battler = nil)
- initialize_ve_animated_battle(viewport, battler)
- init_variables
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :update_effect_ve_animated_battle :update_effect
- def update_effect
- setup_collapse
- update_effect_ve_animated_battle
- update_pose
- update_pose_loop_anim if $imported[:ve_loop_animation]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :revert_to_normal_ve_animated_battle :revert_to_normal
- def revert_to_normal
- revert_to_normal_ve_animated_battle
- update_rect if bitmap
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_collapse
- if @battler.dead? && !@dead
- @battler.perform_collapse_effect
- @dead = true
- elsif @dead && !@battler.dead?
- @dead = false
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_bitmap
- setup_bitmap if graphic_changed?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def init_visibility
- @battler_visible = !@battler.hidden?
- self.opacity = 0 unless @battler_visible
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def init_variables
- @frame = 0
- @sufix = ""
- @pose_sufix = ""
- @anim_sufix = VE_SPRITE_SUFIX
- @frame_width = 0
- @frame_height = 0
- @pose_value = {}
- @icon_list = {}
- @throw_list = []
- start_effect(:appear) if VE_BATTLE_INTRO_FADE && !@battler.hidden?
- @battler.clear_poses
- setup_positions
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def subject
- @pose_battler ? @pose_battler : @battler
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def sprite_value(value)
- @battler.sprite_value(value)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def graphic_changed?
- actor_name_change? || battler_name_change? || misc_change?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def actor_name_change?
- use_charset? && (@battler_name != @battler.character_name ||
- @battler_index != @battler.character_index ||
- @battler_hue != @battler.character_hue)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def battler_name_change?
- !use_charset? && (@battler_name != @battler.battler_name ||
- @battler_hue != @battler.battler_hue)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def misc_change?
- (visual_equip? && @visual_items != @battler.visual_items) ||
- @sufix != @battler.sufix || @direction != @battler.direction
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def use_charset?
- sprite_value(:mode) == :charset
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def visual_equip?
- $imported[:ve_visual_equip]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_bitmap
- if use_charset?
- @battler_name = @battler.character_name
- @battler_hue = @battler.character_hue
- @battler_index = @battler.character_index
- else
- @battler_name = @battler.battler_name
- @battler_hue = @battler.battler_hue
- end
- @sufix = @battler.sufix
- @direction = @battler.direction
- @visual_items = @battler.visual_items.dup if visual_equip?
- init_bitmap
- init_frame
- init_visibility
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def init_bitmap
- case sprite_value(:mode)
- when :charset
- if visual_equip?
- args = [@battler_name, @battler_hue, @visual_items, sufix]
- self.bitmap = Cache.character(*args)
- else
- self.bitmap = Cache.character(get_character_name, @battler_hue)
- end
- when :single
- self.bitmap = Cache.battler(get_battler_name, @battler_hue)
- when :sprite
- self.bitmap = Cache.battler(get_battler_name, @battler_hue)
- else
- self.bitmap = Cache.battler(@battler_name, @battler_hue)
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def sufix
- case sprite_value(:mode)
- when :charset then @sufix
- when :sprite then @anim_sufix + @sufix
- else @sufix
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def get_battler_name
- name = @battler_name + sufix
- battler_exist?(name) ? name : @battler_name
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def get_character_name
- name = @battler_name + sufix
- character_exist?(name) ? name : @battler_name
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def init_frame
- @frame_width = bitmap.width / frame_number
- @frame_height = bitmap.height / row_number
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def frame_number
- return @battler.frames if single_char?
- return @battler.frames * 4 if multi_char?
- return 1 unless battler_exist?(@battler_name + sufix)
- return sprite_value(:frames) if sprite_value(:mode) == :sprite
- return 1
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def row_number
- return 4 if single_char?
- return 8 if multi_char?
- return 1 unless battler_exist?(@battler_name + sufix)
- return sprite_value(:rows) if sprite_value(:mode) == :sprite
- return 1
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def single_char?
- use_charset? && (single_normal? || single_visual?)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def multi_char?
- use_charset? && (multi_normal? || multi_visual?)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def single_normal?
- !visual_equip? && @battler_name[/^[!]?[$]./]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def multi_normal?
- !visual_equip? && !@battler_name[/^[!]?[$]./]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def single_visual?
- visual_equip? && !get_sign
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def multi_visual?
- visual_equip? && get_sign
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def get_sign
- @visual_items.any? {|part| !part[:name][/^[!]?[$]./] }
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_origin
- update_rect if bitmap
- update_icon
- update_throw
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_rect
- setup_frame
- setup_rect
- self.ox = @frame_width / 2
- self.oy = @frame_height
- self.mirror = pose_mirror
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def pose_mirror
- mirror = sprite_value(:invert)
- return !mirror if right? && sprite_value(:mirror)
- return mirror
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def down?
- @battler.down?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def left?
- @battler.left?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def right?
- @battler.right?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def up?
- @battler.up?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_frame
- return if @battler.timing.empty?
- value = @battler.timing
- value[:time] -= 1
- value[:time] = value[:wait] if value[:time] == 0
- return if value[:time] != value[:wait]
- max = value[:frame] == :all ? sprite_value(:frames) : value[:frame]
- @frame += 1
- if value[:loop]
- @battler.frame = returing_value(@frame, max - 1)
- else
- @frame %= max
- @battler.frame = value[:revert] ? max - 1 - @frame : @frame
- reset_frame if @frame >= max - 1 || @frame == 0
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def reset_frame
- @battler.timing = {}
- @frame = 0
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_rect
- sign = @battler_name[/^[$]./]
- if use_charset? && !sign
- index = @battler_index
- frame = (index % 4 * @battler.frames + @battler.frame) * @frame_width
- row = (index / 4 * 4 + @battler.row) * @frame_height
- else
- frame = [[@battler.frame, 0].max, frame_number - 1].min * @frame_width
- row = [[@battler.row, 0].max, row_number - 1].min * @frame_height
- end
- self.src_rect.set(frame, row, @frame_width, @frame_height)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose
- setup_pose
- update_next_pose
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_next_pose
- next_pose unless @pose
- return if !@pose || !@pose[:type].is_a?(Symbol)
- update_pose_type
- next_pose unless @waiting
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_pose
- @current_pose = pose_list.first
- return unless @current_pose
- @battler.icon_list.clear if changed_pose?
- @frame = 0 if changed_pose?
- battler = @current_pose[:battler]
- @pose_battler = battler unless battler == :skip
- @pose_value = @current_pose[:value]
- @pose = @pose_value.first
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def changed_pose?
- @pose_value != @current_pose[:value]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def pose_list
- @battler.pose_list
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_type
- @waiting = false
- return if @pose[:hit] && @battler.result_flag != :hit
- return if @pose[:miss] && @battler.result_flag != :miss
- eval("update_pose_#{@pose[:type]}") #rescue ""
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def next_pose
- return unless @current_pose
- case @current_pose[:next]
- when :loop
- @pose_value.next_item
- when :reset
- @pose_value.shift
- reset_pose if @pose_value.empty?
- when Symbol
- @pose_value.shift
- @battler.call_pose(@current_pose[:next]) if @pose_value.empty?
- else
- last_value = @pose_value.shift
- end
- @pose_value.unshift(last_value) if @pose_value.empty? && pose_list.empty?
- @battler.pose_list.shift if @pose_value.empty?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_wait
- case @pose[:time]
- when :animation
- @waiting = SceneManager.scene.spriteset.animation?
- when :action
- @waiting = SceneManager.scene.spriteset.action?(subject)
- when :movement
- @waiting = get_target.any? {|target| target.moving? }
- when :origin
- @waiting = get_target.any? {|target| target.origin? }
- when :counter
- @waiting = get_target.any? {|target| target.countered }
- when :substitution
- @waiting = get_target.any? {|target| target.substitution }
- when :tone
- @waiting = $game_troop.screen.tone_change?
- when :throw
- @waiting = throwing?
- else
- @pose[:time] -= 1
- @pose[:time] = @pose[:wait] if @pose[:time] == 0
- @waiting = @pose[:time] != @pose[:wait]
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_clear
- battler.pose_list.clear
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_action
- get_target.each do |target|
- target.clear_idle_poses
- target.call_pose(@pose[:action], :clear, @battler.current_item, @battler)
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_anim
- subject.targets = get_target
- subject.call_anim = true
- subject.animation = @pose[:anim]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_effect
- subject.call_effect = true
- subject.attack_flag = @pose[:weapon]
- subject.damage_flag = @pose[:damage]
- subject.target_flag = @pose[:target] ? @pose[:target] : subject.targets
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_loop
- get_target.each {|target| target.pose_loop_anim = @pose[:loop_anim] }
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_reset
- @battler.actions[0] = @battler.previous_action if @pose[:action]
- reset_pose if @pose[:pose]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_plane
- if @pose[:delete]
- SceneManager.scene.spriteset.delete_plane(@pose[:duration])
- elsif @pose[:list]
- SceneManager.scene.spriteset.action_plane(*@pose[:list])
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_sound
- se = RPG::SE.new(@pose[:name], @pose[:volume], @pose[:pitch])
- se.play
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_pose
- get_target.each do |target|
- target.row = @pose[:row] - 1 if @pose[:row].is_a?(Numeric)
- target.row = target.direction / 2 - 1 if @pose[:row].is_a?(Symbol)
- target.sufix = @pose[:sufix]
- target.angle = @pose[:angle]
- target.spin = @pose[:spin]
- target.x_adj = @pose[:x]
- target.y_adj = @pose[:y]
- target.timing = @pose[:pose]
- target.frame = @pose[:frame] - 1
- target.frame %= target.sprite_value(:frames)
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_move
- get_target.each do |target|
- target.teleport = @pose[:teleport]
- setup_target_position(target)
- target.target_position[:x] += target.left? ? @pose[:x] : -@pose[:x]
- target.target_position[:y] += target.down? ? @pose[:y] : -@pose[:y]
- target.target_position[:h] += @pose[:h]
- target.move_speed = @pose[:speed]
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_counter
- get_target.each {|target| target.countered = @pose[:counter] }
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_substitution
- get_target.each {|target| target.substitution = @pose[:substitution] }
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_jump
- get_target.each do |target|
- if @pose[:move]
- x_plus = (target.target_distance(:x) / 32.0).abs
- y_plus = (target.target_distance(:y) / 32.0).abs
- speed = Math.sqrt((x_plus ** 2) + (y_plus ** 2)) / @battler.move_speed
- target.jumping[:speed] = @pose[:height] * 5.0 / [speed, 1].max
- else
- target.jumping[:speed] = @pose[:speed]
- end
- target.jumping[:height] = @pose[:height]
- target.jumping[:count] = target.jumping[:height] * 2
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_inactive
- subject.deactivate
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_direction
- dir = [subject.screen_x, subject.screen_y]
- subject.target_direction(*dir) if @pose[:return]
- subject.action_direction if @pose[:targets]
- subject.direction = @pose[:direction] if @pose[:direction]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_icon
- get_target.each do |target|
- if @pose[:delete]
- target.icon_list.delete(@pose[:index])
- else
- target.icon_list[@pose[:index]] = @pose.dup
- end
- target.sprite.update_icon
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_picture
- if @pose[:show]
- $game_troop.screen.pictures[@pose[:id]].show(*@pose[:show])
- elsif @pose[:move]
- $game_troop.screen.pictures[@pose[:id]].move(*@pose[:move])
- elsif @pose[:delete]
- $game_troop.screen.pictures[@pose[:id]].erase
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_throw
- get_target.each do |target|
- value = @pose.dup
- value[:user] = subject.sprite
- target.throw_list.push(value.dup)
- target.sprite.update_throw
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_shake
- if @pose[:screen]
- $game_troop.screen.start_shake(*@pose[:shake])
- else
- get_target.each {|target| target.start_shake(*@pose[:shake]) }
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_flash
- if @pose[:screen]
- $game_troop.screen.start_flash(*@pose[:flash])
- else
- get_target.each {|target| target.sprite.flash(*@pose[:flash]) }
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_movie
- Graphics.play_movie('Movies/' + @pose[:name]) if @pose[:name] != ""
- update_pose_tone
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_tone
- eval("update_#{@pose[:priority]}_tone")
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_low_tone
- screen = $game_troop.screen
- screen.old_low_tone = screen.low_tone.dup unless screen.old_low_tone
- tone = @pose[:clear] ? screen.old_low_tone : @pose[:tone]
- $game_troop.screen.old_low_tone = nil if @pose[:clear]
- $game_troop.screen.start_low_tone_change(tone, @pose[:duration])
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_normal_tone
- screen = $game_troop.screen
- screen.old_tone = screen.tone.dup unless screen.old_tone
- tone = @pose[:clear] ? $game_troop.screen.old_tone : @pose[:tone]
- $game_troop.screen.old_tone = nil if @pose[:clear]
- $game_troop.screen.start_tone_change(tone, @pose[:duration])
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_high_tone
- screen = $game_troop.screen
- screen.old_high_tone = screen.high_tone.dup unless screen.old_high_tone
- tone = @pose[:clear] ? screen.old_high_tone : @pose[:tone]
- $game_troop.screen.old_high_tone = nil if @pose[:clear]
- $game_troop.screen.start_high_tone_change(tone, @pose[:duration])
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_target_position(target)
- return unless @battler.use_sprite?
- if @pose[:value] == :move_to
- setup_move_to_target_position(target)
- elsif @pose[:value] == :step_foward
- setup_step_foward_position(target)
- elsif @pose[:value] == :step_backward
- setup_step_backward_position(target)
- elsif @pose[:value] == :escape
- setup_escape_position(target)
- elsif @pose[:value] == :retreat
- setup_retreat_position(target)
- end
- target.position_fix while target.sharing_position?
- target.target_position = target.current_position.dup if target.unmovable?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_move_to_target_position(target)
- targets = @pose[:targets].select {|member| member.use_sprite? }
- return if targets.empty?
- return @waiting = true if targets.any? {|member| member.moving?}
- x = targets.collect {|member| member.current_position[:x]}.average
- y = targets.collect {|member| member.current_position[:y]}.average
- target.target_direction(x, y)
- y -= 32 if down?
- x += 32 if left?
- x -= 32 if right?
- y += 32 if up?
- target.target_position[:x] = x
- target.target_position[:y] = y
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_step_foward_position(target)
- target.target_position[:y] += 48 if down?
- target.target_position[:x] -= 48 if left?
- target.target_position[:x] += 48 if right?
- target.target_position[:y] -= 48 if up?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_step_backward_position(target)
- target.target_position[:y] -= 48 if down?
- target.target_position[:x] += 48 if left?
- target.target_position[:x] -= 48 if right?
- target.target_position[:y] += 48 if up?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_escape_position(target)
- target.target_position[:y] -= 240 if down?
- target.target_position[:x] += 240 if left?
- target.target_position[:x] -= 240 if right?
- target.target_position[:y] += 240 if up?
- position = target.target_position
- target.target_direction(position[:x], position[:y])
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_retreat_position(target)
- return if target.target_position[:x] == target.screen_x &&
- target.target_position[:y] == target.screen_y
- target.target_position[:x] = target.screen_x
- target.target_position[:y] = target.screen_y
- position = target.target_position
- target.target_direction(position[:x], position[:y])
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def reset_pose
- idle_pose = @battler.pose_name
- next_pose = get_idle_pose
- @frame = 0
- @battler.default_direction
- @battler.clear_idle_poses
- @battler.call_pose(next_pose)
- setup_pose
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def get_idle_pose
- pose = :idle
- pose = :danger if @battler.danger?
- pose = @battler.state_pose if @battler.state_pose?
- pose = :guard if @battler.guard?
- pose = @battler.active_pose if @battler.active_pose
- pose = :dead if @battler.dead?
- pose
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def get_target
- @pose[:target] ? @pose[:target] : [subject]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_positions
- positions = {x: @battler.screen_x, y: @battler.screen_y, h: 0, j: 0}
- @battler.target_position = positions.dup
- @battler.current_position = positions.dup
- @battler.default_position = positions.dup
- @battler.jumping = {count: 0, height: 0, speed: 10}
- reset_pose
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def position
- @battler.current_position
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_position
- update_misc
- update_movement
- update_jumping
- self.x = position[:x] + adjust_x
- self.y = position[:y] + adjust_y - position[:h] - position[:j]
- self.z = position[:y] + (@battler.active? ? 2 : 1)
- self.angle = @battler.angle if angle != @battler.angle
- self.angle += @battler.spin
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_misc
- @battler.update_shake
- @battler.update_freeze
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def adjust_x
- @battler.x_adj + [1, -1].random * rand(@battler.shake + 1)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def adjust_y
- @battler.y_adj + [1, -1].random * rand(@battler.shake + 1)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_movement
- return if @battler.frozen? || !@battler.moving?
- @battler.teleport ? update_teleport_movement : update_normal_movement
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_teleport_movement
- @battler.current_position[:x] = @battler.target_position[:x]
- @battler.current_position[:y] = @battler.target_position[:y]
- @battler.current_position[:h] = [@battler.target_position[:h], 0].max
- @battler.teleport = false
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_normal_movement
- distance = set_distance
- move = {x: 1.0, y: 1.0, h: 1.0}
- if distance[:x].abs < distance[:y].abs
- move[:x] = 1.0 / (distance[:y].abs.to_f / distance[:x].abs)
- elsif distance[:y].abs < distance[:x].abs
- move[:y] = 1.0 / (distance[:x].abs.to_f / distance[:y].abs)
- elsif distance[:h].abs < distance[:x].abs
- move[:h] = 1.0 / (distance[:x].abs.to_f / distance[:h].abs)
- end
- speed = set_speed(distance)
- x = move[:x] * speed[:x]
- y = move[:y] * speed[:y]
- h = move[:h] * speed[:h]
- set_movement(x, y, h)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_distance
- x = @battler.target_distance(:x)
- y = @battler.target_distance(:y)
- h = @battler.target_distance(:h)
- {x: x, y: y, h: h}
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_speed(distance)
- move_speed = @battler.move_speed
- x = move_speed * (distance[:x] == 0 ? 0 : (distance[:x] > 0 ? 8 : -8))
- y = move_speed * (distance[:y] == 0 ? 0 : (distance[:y] > 0 ? 8 : -8))
- h = move_speed * (distance[:h] == 0 ? 0 : (distance[:h] > 0 ? 8 : -8))
- {x: x, y: y, h: h}
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_movement(x, y, h)
- target = @battler.target_position
- current = @battler.current_position
- current[:x] += x
- current[:y] += y
- current[:h] += h
- current[:x] = target[:x] if in_distance?(current[:x], target[:x], x)
- current[:y] = target[:y] if in_distance?(current[:y], target[:y], y)
- current[:h] = target[:h] if in_distance?(current[:h], target[:h], h)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def in_distance?(x, y, z)
- x.between?(y - z - 1, y + z + 1)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_jumping
- return if @battler.jumping[:count] == 0 || @battler.frozen?
- jump = @battler.jumping
- jump[:count] = [jump[:count] - (1 * jump[:speed] / 10.0), 0].max.to_f
- count = jump[:count]
- speed = jump[:speed]
- peak = jump[:height]
- result = (peak ** 2 - (count - peak).abs ** 2) / 2
- @battler.current_position[:j] = [result, 0].max
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_icon
- @battler.icon_list.each do |key, value|
- icon = @icon_list[key]
- @icon_list[key] = Sprite_Icon.new(self, value) if !icon
- icon.refresh if icon && value[:icon] != icon.icon
- icon.value = value if icon && icon.value != value
- end
- @icon_list.each do |key, value|
- value.update
- delete_icon(key) if value && !@battler.icon_list[key]
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_throw
- @battler.throw_list.each do |value|
- @throw_list.push(Sprite_Throw.new(self, value.dup))
- @battler.throw_list.delete(value)
- end
- @throw_list.each_with_index do |value, index|
- value.update
- delete_throw(index) if value.disposing?
- end
- @throw_list.compact!
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def delete_icon(key)
- @icon_list[key].dispose
- @icon_list.delete(key)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def delete_throw(index)
- @throw_list[index].dispose
- @throw_list.delete_at(index)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def throwing?
- !@throw_list.empty?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_pose_loop_anim
- if @battler.pose_loop_anim && !loop_anim?(:pose_anim)
- @pose_name_list = @battler.pose_name_list.first
- animation = {type: :pose_anim, anim: @battler.pose_loop_anim, loop: 1}
- add_loop_animation(animation)
- end
- if @battler.pose_loop_anim && loop_anim?(:pose_anim) &&
- @pose_name_list != @battler.pose_name_list.first
- @pose_loop_anim = nil
- @battler.pose_loop_anim = nil
- end_loop_anim(:pose_anim)
- end
- end
- end
- #==============================================================================
- # ** Spriteset_Battle
- #------------------------------------------------------------------------------
- # This class brings together battle screen sprites. It's used within the
- # Scene_Battle class.
- #==============================================================================
- class Spriteset_Battle
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def create_actors
- @actor_sprites = $game_party.battle_members.reverse.collect do |actor|
- Sprite_Battler.new(@viewport1, actor)
- end
- @actors_party = $game_party.battle_members.dup
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :initialize_ve_animated_battle :initialize
- def initialize
- init_action_plane
- initialize_ve_animated_battle
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :update_ve_animated_battle :update
- def update
- update_ve_animated_battle
- update_action_plane
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :dispose_ve_animated_battle :dispose
- def dispose
- dispose_ve_animated_battle
- dispose_action_plane
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :create_pictures_ve_animated_battle :create_pictures
- def create_pictures
- battler_sprites.each {|battler| battler.setup_positions }
- create_pictures_ve_animated_battle
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :create_viewports_ve_animated_battle :create_viewports
- def create_viewports
- create_viewports_ve_animated_battle
- @viewport4 = Viewport.new
- @viewport4.z = 200
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :update_viewports_ve_animated_battle :update_viewports
- def update_viewports
- update_viewports_ve_animated_battle
- @viewport1.ox = [1, -1].random * rand($game_troop.screen.shake)
- @viewport1.oy = [1, -1].random * rand($game_troop.screen.shake)
- @back1_sprite.tone.set($game_troop.screen.low_tone)
- @back2_sprite.tone.set($game_troop.screen.low_tone)
- @viewport4.tone.set($game_troop.screen.high_tone)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def action?(subject)
- battler_sprites.compact.any? do |sprite|
- sprite.subject == subject && sprite.battler != subject
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def init_action_plane
- @action_plane = Action_Plane.new(@viewport1)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_action_plane
- @action_plane.update
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def dispose_action_plane
- @action_plane.dispose
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def action_plane(name, x, y, z, zoom_x, zoom_y, opacity, blend, duration)
- @action_plane.setup(name, x, y, z, zoom_x, zoom_y, opacity, blend, duration)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def delete_plane(duration)
- @action_plane.delete(duration)
- end
- end
- #==============================================================================
- # ** Window_BattleLog
- #------------------------------------------------------------------------------
- # This window shows the battle progress. Do not show the window frame.
- #==============================================================================
- class Window_BattleLog < Window_Selectable
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def display_added_states(target)
- target.result.added_state_objects.each do |state|
- state_msg = target.actor? ? state.message1 : state.message2
- next if state_msg.empty?
- replace_text(target.name + state_msg)
- wait
- wait_for_effect
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def display_counter(target, item)
- Sound.play_evasion
- add_text(sprintf(Vocab::CounterAttack, target.name))
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def display_reflection(target, item)
- Sound.play_reflection
- add_text(sprintf(Vocab::MagicReflection, target.name))
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def display_substitute(substitute, target)
- add_text(sprintf(Vocab::Substitute, substitute.name, target.name))
- end
- end
- #==============================================================================
- # ** Scene_Battle
- #------------------------------------------------------------------------------
- # This class performs battle screen processing.
- #==============================================================================
- class Scene_Battle < Scene_Base
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def abs_wait_short
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def wait_for_animation
- update_for_wait
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def wait_for_effect
- update_for_wait
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def process_action
- return if scene_changing? || active?
- if next_subject?
- @subject = BattleManager.next_subject
- @subject.activate if @subject
- end
- return turn_end unless @subject
- return process_action_end if !@subject.active && !@subject.current_action
- if @subject.current_action
- @subject.current_action.prepare
- if @subject.current_action.valid?
- @status_window.open
- execute_action
- end
- @subject.remove_current_action
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def show_animation(targets, animation_id)
- if animation_id < 0
- show_animated_attack_animation(targets)
- else
- show_normal_animation(targets, animation_id)
- end
- wait_for_animation
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def invoke_counter_attack(target, item)
- target.setup_counter(@subject)
- @counter_flag.push(target)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def invoke_magic_reflection(target, item)
- @subject.setup_reflect(item)
- @reflect_flag.push(target)
- end
- #--------------------------------------------------------------------------
- # * Alias method: apply_substitute
- #--------------------------------------------------------------------------
- def apply_substitute(target, item)
- if check_substitute(target, item)
- substitute = target.friends_unit.substitute_battler
- if substitute && target != substitute
- @substitution = {target: target, substitute: substitute}
- substitute.setup_substitute(target)
- return substitute
- end
- end
- target
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :create_spriteset_ve_animated_battle :create_spriteset
- def create_spriteset
- create_spriteset_ve_animated_battle
- members = $game_party.movable_members
- members.each {|member| member.call_pose(:intro, :clear) }
- 2.times { @spriteset.update }
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :update_basic_ve_animated_battle :update_basic
- def update_basic
- update_basic_ve_animated_battle
- update_sprite_action
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :turn_end_ve_animated_battle :turn_end
- def turn_end
- turn_end_ve_animated_battle
- @spriteset.battler_sprites.each {|sprite| sprite.reset_pose }
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :next_command_ve_animated_battle :next_command
- def next_command
- BattleManager.set_active_pose
- next_command_ve_animated_battle
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias :prior_command_ve_animated_battle :prior_command
- def prior_command
- prior_command_ve_animated_battle
- BattleManager.clear_active_pose
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def show_animated_attack_animation(targets)
- if @subject.actor? || $imported[:ve_actor_battlers]
- show_normal_animation(targets, @subject.atk_animation_id1, false)
- else
- Sound.play_enemy_attack
- abs_wait_short
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def next_subject?
- !@subject || !@subject.active?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def active?
- members = $game_troop.members + $game_party.battle_members
- members.any? {|member| member.active? }
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def execute_action
- use_item
- @log_window.wait_and_clear
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def use_item
- item = @subject.current_action.item
- @log_window.display_use_item(@subject, item)
- @subject.action_pose(item)
- @subject.use_item(item)
- refresh_status
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_sprite_action
- @old_subject = @subject
- battlers = $game_party.battle_members + $game_troop.members
- battlers.each do |subject|
- @subject = subject
- call_animation if @subject.call_anim
- call_effect if @subject.call_effect
- end
- @subject = @old_subject
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def call_animation
- @subject.call_anim = false
- animation = @subject.animation
- @subject.animation = 0
- show_animation(@subject.targets, animation)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def call_effect
- @counter_flag = []
- @reflect_flag = []
- @substitution = nil
- @subject.call_effect = false
- targets = @subject.target_flag ? @subject.target_flag : @subject.targets
- item = @subject.current_item
- targets.each {|target| item.repeats.times { invoke_item(target, item) } }
- @counter_flag.each {|target| @log_window.display_counter(target, item) }
- @reflect_flag.each {|target| @log_window.display_reflection(target, item) }
- if @substitution
- substitute = @substitution[:substitute]
- target = @substitution[:target]
- @log_window.display_substitute(substitute, target)
- end
- end
- end
- #==============================================================================
- # ** Sprite_Object
- #------------------------------------------------------------------------------
- # This the base sprite used to display icons and throw animations.
- #==============================================================================
- class Sprite_Object < Sprite_Base
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- attr_accessor :value
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def initialize(viewport)
- super(viewport)
- @right = @battler.right?
- @up = @battler.up?
- @spin = 0
- @zooming = 0
- @fade_in = 0
- @fade_out = 0
- self.zoom_x = value[:izm]
- self.zoom_y = value[:izm]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update
- super
- update_position
- update_opacity
- update_angle
- update_zoom
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_opacity
- if value[:fin] > 0
- @fade_in += 1
- self.opacity = [@fade_in * value[:fin], value[:o]].min
- elsif value[:fout] > 0
- @fade_out += 1
- self.opacity = [value[:o] - @fade_out * value[:fin], 0].max
- else
- self.opacity = value[:o]
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_angle
- @spin += 1 if Graphics.frame_count % 2 == 0
- self.angle = value[:a] + value[:spin] * @spin
- self.angle *= -1 if @right || @up
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_zoom
- if self.zoom_x < value[:ezm]
- @zooming += 1
- self.zoom_x = [value[:izm] + @zooming * value[:szm], value[:ezm]].min
- self.zoom_y = [value[:izm] + @zooming * value[:szm], value[:ezm]].min
- elsif self.zoom_x > value[:ezm]
- @zooming += 1
- self.zoom_x = [value[:izm] - @zooming * value[:szm], value[:ezm]].max
- self.zoom_y = [value[:izm] - @zooming * value[:szm], value[:ezm]].max
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def icon
- value[:icon]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def icon_changed?
- @icon_value != (value[:image] ? value[:image] : icon)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_icon
- p @icon_value if self.is_a?(Sprite_Throw)
- @icon_value = value[:image] ? value[:image].dup : icon
- if value[:image]
- self.bitmap = Cache.picture(value[:image])
- self.src_rect.set(0, 0, bitmap.width, bitmap.height)
- self.ox = bitmap.width / 2
- self.oy = bitmap.height / 2
- else
- self.bitmap = Cache.system("Iconset")
- self.src_rect.set(icon % 16 * 24, icon / 16 * 24, 24, 24)
- self.ox = 12
- self.oy = 12
- end
- end
- end
- #==============================================================================
- # ** Sprite_Icon
- #------------------------------------------------------------------------------
- # This sprite is used to display icons.
- #==============================================================================
- class Sprite_Icon < Sprite_Object
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def initialize(battler, value)
- @battler = battler
- @value = value.dup
- super(battler.viewport)
- setup_icon
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_position
- setup_icon if icon_changed?
- self.x = pos[:x] + (@right ? -add_x : add_x)
- self.y = pos[:y] + (@up ? -add_y : add_y)
- self.z = pos[:y] + value[:z] + 3
- self.mirror = @right || @up
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def add_x
- value[:x] - @battler.ox / 2
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def add_y
- value[:y] - pos[:h] - pos[:j] - @battler.oy / 2
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def pos
- @battler.position
- end
- end
- #==============================================================================
- # ** Sprite_Throw
- #------------------------------------------------------------------------------
- # This sprite is used to display throw animations.
- #==============================================================================
- class Sprite_Throw < Sprite_Object
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def initialize(target, settings)
- @battler = settings[:user]
- @target = target
- @value = settings.dup
- super(target.viewport)
- setup_throw
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_throw
- set_initial_position
- setup_arc
- setup_icon
- setup_animation if $imported[:ve_loop_animation] && value[:anim]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_initial_position
- if value[:return]
- @current_position = @target.position.dup
- @target_position = @battler.position.dup
- init_ox = @target.right? ? -value[:init_x] : value[:init_x]
- init_oy = @target.up? ? -value[:init_y] : value[:init_y]
- end_ox = @battler.right? ? -value[:end_x] : value[:end_x]
- end_oy = @battler.up? ? -value[:end_y] : value[:end_y]
- else
- @current_position = @battler.position.dup
- @target_position = @target.position.dup
- init_ox = @battler.right? ? -value[:init_x] : value[:init_x]
- init_oy = @battler.up? ? -value[:init_x] : value[:init_x]
- end_ox = @target.right? ? -value[:end_x] : value[:end_x]
- end_oy = @target.up? ? -value[:end_y] : value[:end_y]
- end
- @current_position[:x] += value[:init_x] + init_ox
- @current_position[:y] += value[:init_y] + init_oy
- @target_position[:x] += value[:end_x] + end_ox
- @target_position[:y] += value[:end_y] + end_oy
- @initial_position = @current_position.dup
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_arc
- @arc = {}
- x_plus = (target_distance(:x) / 32.0).abs
- y_plus = (target_distance(:y) / 32.0).abs
- speed = Math.sqrt((x_plus ** 2) + (y_plus ** 2)) / value[:speed]
- @arc[:speed] = value[:arc] * 5.0 / [speed, 1].max
- @arc[:height] = value[:arc]
- @arc[:count] = value[:arc] * 2
- @current_position[:a] = 0
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_icon
- super
- self.angle = value[:a]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup_animation
- animation = {type: :throw, anim: value[:anim], loop: 1}
- add_loop_animation(animation)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update
- super
- update_move
- update_arc
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_move
- distance = set_distance
- move = {x: 1.0, y: 1.0}
- if distance[:x].abs < distance[:y].abs
- move[:x] = 1.0 / (distance[:y].abs.to_f / distance[:x].abs)
- elsif distance[:y].abs < distance[:x].abs
- move[:y] = 1.0 / (distance[:x].abs.to_f / distance[:y].abs)
- end
- speed = set_speed(distance)
- x = move[:x] * speed[:x]
- y = move[:y] * speed[:y]
- set_movement(x, y)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_distance
- {x: target_distance(:x), y: target_distance(:y)}
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def target_distance(symbol)
- @target_position[symbol] - @current_position[symbol]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_speed(distance)
- x = value[:speed] * (distance[:x] == 0 ? 0 : (distance[:x] > 0 ? 8 : -8))
- y = value[:speed] * (distance[:y] == 0 ? 0 : (distance[:y] > 0 ? 8 : -8))
- {x: x, y: y}
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_movement(x, y)
- target = @target_position
- current = @current_position
- current[:x] += x
- current[:y] += y
- current[:x] = target[:x] if in_distance?(current[:x], target[:x], x)
- current[:y] = target[:y] if in_distance?(current[:y], target[:y], y)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def in_distance?(x, y, z)
- x.between?(y - z - 1, y + z + 1)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_arc
- return if @arc[:count] == 0
- @arc[:count] = [@arc[:count] - (1 * @arc[:speed] / 10.0), 0].max.to_f
- count = @arc[:count]
- speed = @arc[:speed]
- peak = @arc[:height]
- result = (peak ** 2 - (count - peak).abs ** 2) / 2
- @current_position[:a] = value[:revert] ? -result : result
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_position
- setup_icon if icon_changed?
- self.x = position[:x]
- self.y = position[:y] - position[:h] - position[:a]
- self.z = position[:y] + value[:z] + 4
- self.ox = 12
- self.oy = 12
- self.mirror = @right || @up
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def position
- @current_position
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def target
- @target_position
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def disposing?
- position[:x] == target[:x] && position[:y] == target[:y]
- end
- end
- #==============================================================================
- # ** Action_Plane
- #------------------------------------------------------------------------------
- #
- #==============================================================================
- class Action_Plane < Plane
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def initialize(viewport)
- super(viewport)
- @settings = {x: 0, y: 0, opacity: 0, zoom_x: 1.0, zoom_y: 1.0}
- @duration = 1
- end
- #--------------------------------------------------------------------------
- # * dispose
- #--------------------------------------------------------------------------
- def dispose
- bitmap.dispose if bitmap
- super
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def setup(name, x, y, z, zoom_x, zoom_y, opacity, blend, duration)
- self.bitmap = Cache.picture(name)
- self.z = z
- @settings[:x] = x
- @settings[:y] = y
- @settings[:zoom_x] = zoom_x / 100.0
- @settings[:zoom_y] = zoom_y / 100.0
- @settings[:opacity] = opacity
- @blend_type = blend
- @delete = false
- @duration = [duration, 1].max
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def delete(duration = 60)
- @settings[:opacity] = 0
- @duration = [duration, 1].max
- @delete = true
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def value
- @settings
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update
- update_position
- update_opacity
- update_zoom
- update_delete
- @duration -= 1 if @duration > 0
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_position
- self.ox += value[:x]
- self.oy += value[:y]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_opacity
- return if @duration == 0
- d = @duration
- self.opacity = (self.opacity * (d - 1) + value[:opacity]) / d
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_zoom
- return if @duration == 0
- d = @duration
- self.zoom_x = (self.zoom_x * (d - 1) + value[:zoom_x]) / d
- self.zoom_y = (self.zoom_y * (d - 1) + value[:zoom_y]) / d
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_delete
- return if !@delete || @duration > 0
- self.bitmap.dispose
- self.bitmap = nil
- @settings = {x: 0, y: 0, opacity: 0, zoom_x: 100.0, zoon_y: 100.0}
- @blend_type = 0
- @delete = false
- end
- end
复制代码 |
最佳答案
查看完整内容
按楼主要求试伤害在动画结束后显示。
但是仅仅调了伤害显示,敌人还是会在刚开始显示动画就挂掉。
有问题的继续问我好了。
|