赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 0 |
经验 | 0 |
最后登录 | 2012-6-11 |
在线时间 | 8 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 210
- 在线时间
- 8 小时
- 注册时间
- 2012-6-9
- 帖子
- 4
|
本帖最后由 BWBW00123 于 2012-6-9 14:34 编辑
我用的是約束版.其實我猜跟版本沒關係.是我笨,不懂
請求教教我這新手..
- #==============================================================================
- # ■ Sprite_Battler Ver2.6
- #------------------------------------------------------------------------------
- # 角色用于现实的战斗动作。
- #==============================================================================
- class Sprite_Battler < Sprite_Base
- #--------------------------------------------------------------------------
- # ● 初期化
- #--------------------------------------------------------------------------
- def initialize(viewport, battler = nil)
- super(viewport)
- @battler = battler
- @battler_visible = false
- @effect_type = 0 # 效果的种类
- @effect_duration = 0 # 效果的残留时间
- @move_x = 0 # 已变化的X坐标的累计
- @move_y = 0 # 已变化的Y坐标的累计
- @move_z = 0 # 已变化的Z坐标的累计
- @distanse_x = 0 # X坐标的移动距离
- @distanse_y = 0 # Y坐标的移动距离
- @moving_x = 0 #1单位所相当的X坐标移动距离
- @moving_y = 0 #1单位所相当的Y坐标移动距离
- @move_speed_x = 0 # X坐标的移动速度
- @move_speed_y = 0 # Y坐标的移动速度
- @move_speed_plus_x = 0 # X坐标在加减速时的补充移动速度
- @move_speed_plus_y = 0 # Y坐标在加减速时的补充移动速度
- @move_boost_x = 0 # X坐标加速度
- @move_boost_y = 0 # Y坐标加速度
- @jump_time = 0 # 跳跃时间
- @jump_time_plus = 0 # 跳跃时间补充
- @jump_up = 0 # 跳跃上升
- @jump_down = 0 # 跳跃下降
- @jump_size = 0 # 跳跃高度
- @float_time = 0 # 漂浮时间
- @float_up = 0 # 1单位所相当于的浮遊高度
- @jump_plus = 0 # 根据跳跃补充影位置
- @angle = 0 # 旋转角度
- @angling = 0 # 1单位所相当于的旋转角度
- @angle_time = 0 # 旋转时间
- @angle_reset = 0 # 是否初始化角度
- @zoom_x = 0 # 横向放大率
- @zoom_y = 0 # 纵向放大率
- @zooming_x = 0 # 1单位所相当于的横向放大率
- @zooming_y = 0 # 1单位所相当于的纵向放大率
- @zoom_time = 0 # 放大时间
- @zoom_reset = 0 # 是否初始化放大
- @target_battler = [] # 目标角色情报
- @now_targets = [] # 目标角色记忆
- @pattern = 0 # 横图片位置(更新位置)
- @pattern_back = false # 循环标志
- @wait = 0 # 到下个动作的等待时间
- @unloop_wait = 0 # 非循环系动画完毕时的等待时间
- @action = [] # 行动
- @anime_kind = 0 # 纵图片位置(动画种类位置)
- @anime_speed = 0 # 图片更新速度
- @frame = 0 # 被消费图片更新时间
- @anime_loop = 0 # 循环方式
- @anime_end = false # 角色的动画是否完毕
- @anime_freeze = false # 是否是固定动画
- @anime_freeze_kind = false # 固定图案位置
- @anime_moving = false # 是否在飞出动画中
- @base_width = N01::ANIME_PATTERN # 图片的横分割数
- @base_height = N01::ANIME_KIND # 图片的纵分割数
- @width = 0 # 横矩形
- @height = 0 # 纵矩形
- @picture_time = 0 # 图片显示时间
- @individual_targets = [] # 单独处理的保持目标
- @balloon_duration = 65 # 飞出动画时间
- @reverse = false # 动画的反向再生标志
- # 角色不存在的时候将中断处理
- return @battler_visible = false if @battler == nil
- # 角色是主人公时、或者敌方动画为NO时
- @anime_flug = true if @battler.actor?
- @anime_flug = true if [email protected]? && @battler.anime_on
- # 角色作成
- make_battler
- end
- #--------------------------------------------------------------------------
- # ● 角色作成
- #--------------------------------------------------------------------------
- def make_battler
- # 初期配置的取得
- @battler.base_position
- # 色相通过角色认别
- @battler_hue = @battler.battler_hue
- # 角色是主人公时、或者敌方动画为NO时
- if @anime_flug
- # 准备武器
- @weapon_R = Sprite_Weapon.new(viewport,@battler)
- # 取得我方人物名、敌人角色名
- @battler_name = @battler.character_name if @battler.actor?
- @battler_name = @battler.battler_name unless @battler.actor?
- # 敌方反转为NO的时候 画像被反转
- self.mirror = true if [email protected]? && @battler.action_mirror
- # 是不是利用行图片图来改变转送前的矩形尺寸的认识处
- self.bitmap = Cache.character(@battler_name) if N01::WALK_ANIME
- self.bitmap = Cache.character(@battler_name + "_1") unless N01::WALK_ANIME
- # 获取转送前的矩形
- @width = self.bitmap.width / @base_width
- @height = self.bitmap.height / @base_height
- # 矩形设定
- @sx = @pattern * @width
- @sy = @anime_kind * @height
- # 角色本体的描绘
- self.src_rect.set(@sx, @sy, @width, @height)
- # 不作动画的角色时
- else
- # bitmap的获取、设定
- @battler_name = @battler.battler_name
- self.bitmap = Cache.battler(@battler_name, @battler_hue)
- @width = bitmap.width
- @height = bitmap.height
- end
- # 偷袭时画像反转
- self.mirror = false if self.mirror && $back_attack && N01::BACK_ATTACK
- self.mirror = true if $back_attack && !self.mirror && N01::BACK_ATTACK
- # 位置初期化
- @battler.reset_coordinate
- # 决定原点
- self.ox = @width / 2
- self.oy = @height * 2 / 3
- # 设定偷袭时的坐标
- update_move
- # 准备飞出动画的精灵
- @move_anime = Sprite_MoveAnime.new(viewport,battler)
- # 准备图片用精灵
- @picture = Sprite.new
- # 准备影子精灵
- make_shadow if N01::SHADOW
- # 作成伤害精灵
- @damage = Sprite_Damage.new(viewport,battler)
- end
- #--------------------------------------------------------------------------
- # ● 影作成
- #--------------------------------------------------------------------------
- def make_shadow
- @shadow.dispose if @shadow != nil
- @battler_hue = @battler.battler_hue
- @shadow = Sprite.new(viewport)
- @shadow.z = 200
- @shadow.visible = false
- # 准备角色的影子精灵
- @shadow.bitmap = Cache.character(@battler.shadow)
- @shadow_height = @shadow.bitmap.height
- # 影位置的稍微调整
- @shadow_plus_x = @battler.shadow_plus[0] - @width / 2
- @shadow_plus_y = @battler.shadow_plus[1]
- # 配合角色画像的大小使用影画像
- @shadow.zoom_x = @width * 1.0 / @shadow.bitmap.width
- # 更新
- update_shadow
- # fade中影子就像没有关联一样放置
- @skip_shadow = true
- end
- #--------------------------------------------------------------------------
- # ● 解放
- #--------------------------------------------------------------------------
- def dispose
- self.bitmap.dispose if self.bitmap != nil
- @weapon_R.dispose if @weapon_R != nil
- @move_anime.dispose if @move_anime != nil
- @picture.dispose if @picture != nil
- @shadow.dispose if @shadow != nil
- @damage.dispose if @damage != nil
- @balloon.dispose if @balloon != nil
- mirage_off
- super
- end
- #--------------------------------------------------------------------------
- # ● 伤害动作 action = [动画ID,反转标志,反方向许可]
- #--------------------------------------------------------------------------
- def damage_action(action)
- damage = @battler.hp_damage
- damage = @battler.mp_damage if @battler.mp_damage != 0
- # 如果HP和MP两个同时做出伤害
- if @battler.hp_damage != 0 && @battler.mp_damage != 0
- @battler.double_damage = true
- damage = @battler.hp_damage
- end
- # 吸收攻击使HP为0的处理
- if action[0] == "absorb"
- absorb = true
- action[0] = nil
- end
- # 只有在命中时动画才被执行
- unless @battler.evaded or @battler.missed or action[0] == nil
- @battler.animation_id = action[0]
- @battler.animation_mirror = action[1]
- end
- # 执行伤害动画
- start_action(@battler.damage_hit) if damage > 0 && action[2]
- # 攻击没有命中时执行回避动画
- if @battler.evaded or @battler.missed
- start_action(@battler.evasion) if action[2]
- Sound.play_evasion
- end
- @damage.damage_pop unless absorb or action[3] != nil
- end
- #--------------------------------------------------------------------------
- # ● 伤害数值POP
- #--------------------------------------------------------------------------
- def damage_pop(damage)
- @damage.damage_pop(damage)
- end
- #--------------------------------------------------------------------------
- # ● 战斗开始行动
- #--------------------------------------------------------------------------
- def first_action
- # 检查能否行动、只有在不能的情况下那个状态的动作开始
- action = @battler.first_action unless @battler.restriction == 4
- action = $data_states[@battler.state_id].base_action if @battler.states[0] != nil && @battler.restriction == 4
- start_action(action)
- @skip_shadow = false
- end
- #--------------------------------------------------------------------------
- # ● 动作开始
- #--------------------------------------------------------------------------
- def start_action(kind)
- # 初期化各种动作
- reset
- #记录现在取得的待机动作
- stand_by
- # 决定新的动作内容
- @action = N01::ACTION[kind].dup
- # 从行动配列的前头开始移动
- active = @action.shift
- # 自动完毕
- @action.push("完毕")
- # 确定现在的动作
- @active_action = N01::ANIME[active]
- # 等待设定
- @wait = active.to_i if @active_action == nil
- # 单独动作开始
- action
- end
- #--------------------------------------------------------------------------
- # ● 强制单独动作开始
- #--------------------------------------------------------------------------
- def start_one_action(kind,back)
- # 初期化各种动作
- reset
- # 记录现在取得的待机动作
- stand_by
- # 设置坐标初始化动作
- @action = [back]
- # 自动完毕
- @action.push("完毕")
- # 确定现在的动作
- @active_action = N01::ANIME[kind]
- # 单独动作开始
- action
- end
- #--------------------------------------------------------------------------
- # ● 到下一个动作
- #--------------------------------------------------------------------------
- def next_action
- # 等待中时取消
- return @wait -= 1 if @wait > 0
- # 或者全部图片动画没有被完成时取消
- return if @anime_end == false
- # 最后的图片显示等待
- return @unloop_wait -= 1 if @unloop_wait > 0
- # 从行动配列的前头开始移动
- active = @action.shift
- # 确定现在的动作
- @active_action = N01::ANIME[active]
- # 等待设定
- @wait = active.to_i if @active_action == nil
- # 单独动作开始
- action
- end
- #--------------------------------------------------------------------------
- # ● 待机动作
- #--------------------------------------------------------------------------
- def stand_by
- # 到通常待机
- @repeat_action = @battler.normal
- # HP为1/4时显示危急表情
- @repeat_action = @battler.pinch if @battler.hp <= @battler.maxhp / 4
- # 防御中
- @repeat_action = @battler.defence if @battler.guarding?
- # 如果什么状态都没有时完毕
- return if @battler.state_id == nil
- for state in @battler.states.reverse
- # 动作禁止的状态时跳过处理
- next if state.extension.include?("禁止状态动作")
- # 敌方被动作禁止状态时跳过处理
- next if @battler.is_a?(Game_Enemy) && state.extension.include?("敌方除外")
- # 状态的表情
- @repeat_action = state.base_action
- end
- end
- #--------------------------------------------------------------------------
- # ● 待机动作的插入
- #--------------------------------------------------------------------------
- def push_stand_by
- action = @battler.normal
- action = @battler.pinch if @battler.hp <= @battler.maxhp / 4
- action = @battler.defence if @battler.guarding?
- for state in @battler.states.reverse
- # 动作禁止的状态时跳过处理
- next if state.extension.include?("禁止状态动作")
- # 敌方被动作禁止状态时跳过处理
- next if @battler.is_a?(Game_Enemy) && state.extension.include?("敌方除外")
- # 状态的表情
- action = state.base_action
- end
- @repeat_action = action
- # 插入
- @action.delete("完毕")
- act = N01::ACTION[action].dup
- for i in 0...act.size
- @action.push(act)
- end
- @action.push("完毕")
- @anime_end = true
- end
- #--------------------------------------------------------------------------
- # ● 各种变化的初期化
- #--------------------------------------------------------------------------
- def reset
- self.zoom_x = self.zoom_y = 1
- self.oy = @height * 2 / 3
- @angle = self.angle = 0
- @anime_end = true
- @non_repeat = false
- @anime_freeze = false
- @unloop_wait = 0
- end
- #--------------------------------------------------------------------------
- # ● 跳跃的初期化
- #--------------------------------------------------------------------------
- def jump_reset
- @battler.jump = @jump_time = @jump_time_plus = @jump_up = @jump_down = 0
- @jump_size = @jump_plus = @float_time = @float_up = 0
- end
- #--------------------------------------------------------------------------
- # ● 受取目标情报
- #--------------------------------------------------------------------------
- def get_target(target)
- # 单独处理中是中止(全区域中自身被卷入时目标情报是不是正常的样子)
- return if @battler.individual
- @target_battler = target
- end
- #--------------------------------------------------------------------------
- # ● 动作情报在角色中收藏
- #--------------------------------------------------------------------------
- def send_action(action)
- @battler.play = 0
- @battler.play = action if @battler.active
- end
- #--------------------------------------------------------------------------
- # ● 角色追加
- #--------------------------------------------------------------------------
- def battler_join
- if @battler.exist? && !@battler_visible
- # 从战斗不能的復活时的处理被跳过
- if @battler.revival && @anime_flug
- return @battler.revival = false
- elsif @battler.revival && !@anime_flug
- @battler.revival = false
- self.visible = true
- return
- end
- @anime_flug = true if @battler.actor?
- @anime_flug = true if [email protected]? && @battler.anime_on
- make_battler
- @damage = Sprite_Damage.new(viewport,battler)
- @join = true
- first_action
- end
- end
- #--------------------------------------------------------------------------
- # ● 图片更新 ※再定义
- #--------------------------------------------------------------------------
- def update
- super
- # 角色不存在时跳过
- return self.bitmap = nil if @battler == nil
- # 追加角色
- battler_join
- # 到下一个动作
- next_action
- # 动画图像更新
- update_anime_pattern
- # 目标更新
- update_target
- # 强制动作更新
- update_force_action
- # 坐标更新
- update_move
- # 影更新
- update_shadow if @shadow != nil
- # 武器更新
- @weapon_R.update if @weapon_action
- # 漂浮更新
- update_float if @float_time > 0
- # 旋转更新
- update_angle if @angle_time > 0
- # 放大缩小更新
- update_zoom if @zoom_time > 0
- # 残像更新
- update_mirage if @mirage_flug
- # 图片更新
- update_picture if @picture_time > 0
- # 飞出动画更新
- update_move_anime if @anime_moving
- # 飞出动画更新(图片动画)
- update_balloon if @balloon_duration <= 64
- # 伤害精灵更新
- @damage.update if @damage != nil
- setup_new_effect
- update_effect
- update_battler_bitmap
- end
- #--------------------------------------------------------------------------
- # ● 动画图像更新
- #--------------------------------------------------------------------------
- def update_anime_pattern
- # 更新时间在到之前跳过
- return @frame -= 1 if @frame != 0
- # 只有在必要的时候更新武器动画
- @weapon_R.action if @weapon_action && @weapon_R != nil
- # 动画到最后是检查是否是循环
- if @pattern_back
- # 往返循环
- if @anime_loop == 0
- # 反向再生
- if @reverse
- @pattern += 1
- if @pattern == @base_width - 1
- @pattern_back = false
- @anime_end = true
- end
- # 通常再生
- else
- @pattern -= 1
- if @pattern == 0
- @pattern_back = false
- @anime_end = true
- end
- end
- # 单程或者是不循环时
- else
- @anime_end = true
- if @anime_loop == 1
- @pattern = 0 if !@reverse
- @pattern = @base_width - 1 if @reverse
- @pattern_back = false
- end
- end
- # 推进动画
- else
- if @reverse
- @pattern -= 1
- @pattern_back = true if @pattern == 0
- else
- @pattern += 1
- @pattern_back = true if @pattern == @base_width - 1
- end
- end
- # 初期化更新时间
- @frame = @anime_speed
- # 动画固定时,固定横矩形
- return if @anime_freeze
- # 设定转送处的矩形
- return unless @anime_flug
- @sx = @pattern * @width
- @sy = @anime_kind * @height
- self.src_rect.set(@sx, @sy, @width, @height)
- end
- #--------------------------------------------------------------------------
- # ● 目标更新 action = ["N01target_change",目标情报]
- #--------------------------------------------------------------------------
- def update_target
- # 目标确认
- return if @battler.force_target == 0
- # 单独处理中中止(全区域中自身被卷入时目标情报是不是)
- return if @battler.individual
- @target_battler = @battler.force_target[1]
- @battler.force_target = 0
- end
- #--------------------------------------------------------------------------
- # ● 強制动作更新 action = [识别,复原,实行动作]
- #--------------------------------------------------------------------------
- def update_force_action
- # 确认強制动作
- action = @battler.force_action
- return if action == 0
- @battler.force_action = 0
- # 主动中不能插入
- return if @battler.active
- # 击倒时就那样直接连接行动
- return collapse_action if action[0] == "N01collapse"
- # 单独时就那样直接连接
- return start_one_action(action[2],action[1]) if action[0] == "单独"
- # 通用作为动作对待
- start_action(action[2])
- # 有无坐标复原
- return if action[1] == ""
- # 完毕位置替换成重复动作
- @action.delete("完毕")
- @action.push(action[1])
- @action.push("完毕")
- end
- #--------------------------------------------------------------------------
- # ● 坐标更新
- #--------------------------------------------------------------------------
- def update_move
- # 补完加减速中距离的增减
- if @move_speed_plus_x > 0
- # 计算移动
- @move_x += @moving_x
- # 实行移动
- @battler.move_x = @move_x
- @move_speed_plus_x -= 1
- elsif @move_speed_x > 0
- # 加速时
- if @move_boost_x != 0
- @moving_x += @move_boost_x
- end
- # 计算移动
- @move_x += @moving_x
- # 实行移动
- @battler.move_x = @move_x
- @move_speed_x -= 1
- end
- # 补完加减速中距离的增减
- if @move_speed_plus_y > 0
- # 计算移动
- @move_y += @moving_y
- # 实行移动
- @battler.move_y = @move_y
- @move_speed_plus_y -= 1
- elsif @move_speed_y > 0
- # 加速时
- if @move_boost_y != 0
- @moving_y += @move_boost_y
- end
- # 计算移动
- @move_y += @moving_y
- # 实行移动
- @battler.move_y = @move_y
- @move_speed_y -= 1
- end
- # 跳跃上升
- if @jump_up != 0
- # 计算移动
- @jump_plus += @jump_up
- # 实行移动
- @battler.jump = @jump_plus
- @jump_up = @jump_up / 2
- @jump_time -= 1
- # 如果跳跃到了顶点时
- if @jump_time == 0 or @jump_up == @jump_sign
- @jump_down = @jump_up * 2 * @jump_sign * @jump_sign2
- @jump_time_plus += @jump_time * 2
- @jump_up = 0
- return
- end
- end
- # 跳跃下降
- if @jump_down != 0
- if @jump_time_plus != 0
- @jump_time_plus -= 1
- elsif @jump_down != @jump_size
- # 计算移动
- @jump_plus += @jump_down
- # 实行移动
- @battler.jump = @jump_plus
- @jump_down = @jump_down * 2
- if @jump_down == @jump_size
- if @jump_flug
- @jump_flug = false
- else
- # 计算移动
- @jump_plus += @jump_down
- # 实行移动
- @battler.jump = @jump_plus
- @jump_down = @jump_size = 0
- end
- end
- end
- end
- # 设定精灵的坐标
- self.x = @battler.position_x
- self.y = @battler.position_y
- self.z = @battler.position_z
- end
- #--------------------------------------------------------------------------
- # ● 影更新
- #--------------------------------------------------------------------------
- def update_shadow
- @shadow.opacity = self.opacity
- @shadow.x = self.x + @shadow_plus_x
- @shadow.y = self.y + @shadow_plus_y - @jump_plus
- end
- #--------------------------------------------------------------------------
- # ● 漂浮更新
- #--------------------------------------------------------------------------
- def update_float
- @float_time -= 1
- @jump_plus += @float_up
- @battler.jump = @jump_plus
- end
- #--------------------------------------------------------------------------
- # ● 旋转更新
- #--------------------------------------------------------------------------
- def update_angle
- # 实行旋转
- @angle += @angling
- self.angle = @angle
- @angle_time -= 1
- # 旋转时间结束时项目初始化
- return @angle = 0 if @angle_time == 0
- # 如果有复原标志时角度返回0
- self.angle = 0 if @angle_reset
- end
- #--------------------------------------------------------------------------
- # ● 扩大缩小更新
- #--------------------------------------------------------------------------
- def update_zoom
- # 实行扩大缩小
- @zoom_x += @zooming_x
- @zoom_y += @zooming_y
- self.zoom_x = @zoom_x
- self.zoom_y = @zoom_y
- @zoom_time -= 1
- # 扩大缩小时间结束时项目初始化
- return if @zoom_time != 0
- @zoom_x = @zoom_y = 0
- self.oy = @height * 2 / 3
- # 如果有复原标志时还原
- self.zoom_x = self.zoom_y = 1 if @zoom_reset
- end
- #--------------------------------------------------------------------------
- # ● 残像更新
- #--------------------------------------------------------------------------
- def update_mirage
- # 残像最大能显示3个、2格图片中更新
- mirage(@mirage0) if @mirage_count == 1
- mirage(@mirage1) if @mirage_count == 3
- mirage(@mirage2) if @mirage_count == 5
- @mirage_count += 1
- @mirage_count = 0 if @mirage_count == 6
- end
- #--------------------------------------------------------------------------
- # ● 图片更新
- #--------------------------------------------------------------------------
- def update_picture
- @picture_time -= 1
- @picture.x += @moving_pic_x
- @picture.y += @moving_pic_y
- end
- #--------------------------------------------------------------------------
- # ● 飞出动画 更新
- #--------------------------------------------------------------------------
- def update_move_anime
- @move_anime.update
- @anime_moving = false if @move_anime.finish?
- @move_anime.action_reset if @move_anime.finish?
- end
- #--------------------------------------------------------------------------
- # ● 崩坏效果的更新 ※再定义
- #--------------------------------------------------------------------------
- def update_collapse
- normal_collapse if @collapse_type == 2
- boss_collapse1 if @collapse_type == 3
- end
- #--------------------------------------------------------------------------
- # ● 飞出动画更新 (图片动画)
- #--------------------------------------------------------------------------
- def update_balloon
- @balloon_duration -= 1 if @balloon_duration > 0 && !@balloon_back
- @balloon_duration += 1 if @balloon_back
- if @balloon_duration == 64
- @balloon_back = false
- @balloon.visible = false
- elsif @balloon_duration == 0
- @balloon.visible = false if @balloon_loop == 0
- @balloon_back = true if @balloon_loop == 1
- end
- @balloon.x = self.x
- @balloon.y = self.y
- @balloon.z = 10
- @balloon.opacity = self.opacity
- sx = 7 * 32 if @balloon_duration < 12
- sx = (7 - (@balloon_duration - 12) / 8) * 32 unless @balloon_duration < 12
- @balloon.src_rect.set(sx, @balloon_id * 32, 32, 32)
- end
- #--------------------------------------------------------------------------
- # ● 转送处bitmap的更新 ※再定义
- #--------------------------------------------------------------------------
- def update_battler_bitmap
- return if @battler.actor?
- if @battler.battler_name != @battler_name or @battler.battler_hue != @battler_hue
- @battler_name = @battler.battler_name
- @battler_hue = @battler.battler_hue
- make_battler
- self.opacity = 0 if @battler.dead? or @battler.hidden
- end
- end
- #--------------------------------------------------------------------------
- # ● 实行动作
- #--------------------------------------------------------------------------
- def action
- return if @active_action == nil
- action = @active_action[0]
- # 反转时
- return mirroring if action == "反转"
- # 旋转时
- return angling if action == "angle"
- # 扩大缩小时
- return zooming if action == "zoom"
- # 残像ON时
- return mirage_on if action == "残像ON"
- # 残像OFF时
- return mirage_off if action == "残像OFF"
- # 图片表示时
- return picture if action == "pic"
- # 图片消去时
- return @picture.visible = false && @picture_time = 0 if action == "消去图片"
- # 图片文件变更时
- return graphics_change if action == "change"
- # 战斗动画表示时
- return battle_anime if action == "anime"
- # 飞出动画表示时 (图片动画)
- return balloon_anime if action == "balloon"
- # BGM/BGS/SE演奏时
- return sound if action == "sound"
- # 游戏开关操作时
- return $game_switches[@active_action[1]] = @active_action[2] if action == "switch"
- # 游戏变量操作时
- return variable if action == "variable"
- # 二刀限定时
- return two_swords if action == "二刀限定"
- # 非二刀限定时
- return non_two_swords if action == "非二刀限定"
- # 动作条件时
- return necessary if action == "nece"
- # 技能连发时
- return derivating if action == "der"
- # 单独处理开始时
- return individual_action if action == "个别处理开始"
- # 单独处理完毕时
- return individual_action_end if action == "个别处理完毕"
- # 待机不能移动时
- return non_repeat if action == "待机不能移动"
- # 变更初期位置时
- return @battler.change_base_position(self.x, self.y) if action == "变更初期位置"
- # 解除变更初期位置
- return @battler.base_position if action == "解除变更初期位置"
- # 变更目标时
- return change_target if action == "target"
- # 目标的击倒许可
- return send_action(action) if action == "击倒许可"
- # 解除主动
- return send_action(action) if action == "解除主动"
- # 赋予状态时
- return state_on if action == "sta+"
- # 解除状态时
- return state_off if action == "sta-"
- # 变更游戏整体的行进速度时
- return Graphics.frame_rate = @active_action[1] if action == "fps"
- # 漂浮时
- return floating if action == "float"
- # 脚本操作时
- return eval(@active_action[1]) if action == "script"
- # 强制动作时
- return force_action if @active_action.size == 4
- # 坐标初始化时
- return reseting if @active_action.size == 5
- # 移动时
- return moving if @active_action.size == 7
- # 角色动画时
- return battler_anime if @active_action.size == 9
- # 动画飛ばし时
- return moving_anime if @active_action.size == 11
- # 完毕时
- return anime_finish if action == "完毕"
- end
- #--------------------------------------------------------------------------
- # ● 实行反转
- #--------------------------------------------------------------------------
- def mirroring
- # 如果已经反转就还原
- if self.mirror
- self.mirror = false
- # 武器动画也反映
- @weapon_R.mirroring if @anime_flug
- else
- self.mirror = true
- # 武器动画也反映
- @weapon_R.mirroring if @anime_flug
- end
- end
- #--------------------------------------------------------------------------
- # ● 实行旋转
- #--------------------------------------------------------------------------
- def angling
- # 初期化跳跃
- jump_reset
- # 情报确认
- @angle_time = @active_action[1]
- start_angle = @active_action[2]
- end_angle = @active_action[3]
- @angle_reset = @active_action[4]
- # 袭击時时逆转
- start_angle *= -1 if $back_attack
- end_angle *= -1 if $back_attack
- # 敌方被逆转
- start_angle *= -1 if @battler.is_a?(Game_Enemy)
- end_angle *= -1 if @battler.is_a?(Game_Enemy)
- # 时间要是0以下时立即到最后角度
- if @angle_time <= 0
- self.angle = end_angle
- return @angle_time = 0
- end
- # 从旋转时间计算一格相当于的角度
- @angling = (end_angle - start_angle) / @angle_time
- # 不能整除的剩余到初期角度
- @angle = (end_angle - start_angle) % @angle_time + start_angle
- end
- #--------------------------------------------------------------------------
- # ● 实行放大缩小
- #--------------------------------------------------------------------------
- def zooming
- # 初期化跳跃
- jump_reset
- # 情报确认
- @zoom_time = @active_action[1]
- zoom_x = @active_action[2] - 1
- zoom_y = @active_action[3] - 1
- @zoom_reset = @active_action[4]
- @zoom_x = @zoom_y = 1
- # 时间是0以下时跳过
- return @zoom_time = 0 if @zoom_time <= 0
- # 从放大时间中计算一格相当于的放大率
- @zooming_x = zoom_x / @zoom_time
- @zooming_y = zoom_y / @zoom_time
- end
- #--------------------------------------------------------------------------
- # ● 残像开始
- #--------------------------------------------------------------------------
- def mirage_on
- # 战斗不能時不表现残像
- return if @battler.dead?
- @mirage0 = Sprite.new(self.viewport)
- @mirage1 = Sprite.new(self.viewport)
- @mirage2 = Sprite.new(self.viewport)
- @mirage_flug = true
- @mirage_count = 0
- end
- #--------------------------------------------------------------------------
- # ● 残像表示
- #--------------------------------------------------------------------------
- def mirage(body)
- body.bitmap = self.bitmap.dup
- body.x = self.x
- body.y = self.y
- body.ox = self.ox
- body.oy = self.oy
- body.z = self.z
- body.mirror = self.mirror
- body.angle = @angle
- body.opacity = 160
- body.zoom_x = self.zoom_x
- body.zoom_y = self.zoom_y
- body.src_rect.set(@sx, @sy, @width, @height) if @anime_flug
- body.src_rect.set(0, 0, @width, @height) unless @anime_flug
- end
- #--------------------------------------------------------------------------
- # ● 残像完毕
- #--------------------------------------------------------------------------
- def mirage_off
- @mirage_flug = false
- @mirage0.dispose if @mirage0 != nil
- @mirage1.dispose if @mirage1 != nil
- @mirage2.dispose if @mirage2 != nil
- end
- #--------------------------------------------------------------------------
- # ● 图片表示
- #--------------------------------------------------------------------------
- def picture
- # 确认移动开始位置
- pic_x = @active_action[1]
- pic_y = @active_action[2]
- # 确认移动完毕位置
- pic_end_x = @active_action[3]
- pic_end_y = @active_action[4]
- @picture_time = @active_action[5]
- # 用时间除、计算一个相当于的移动速度
- @moving_pic_x = (pic_end_x - pic_x)/ @picture_time
- @moving_pic_y = (pic_end_y - pic_y)/ @picture_time
- # 不能整除时到最初上加算
- plus_x = (pic_end_x - pic_x)% @picture_time
- plus_y = (pic_end_y - pic_y)% @picture_time
- # 图片表示
- @picture.bitmap = Cache.picture(@active_action[7])
- @picture.x = pic_x + plus_x
- @picture.y = pic_y + plus_y
- # Z坐标调整
- @picture.z = 1
- @picture.z = 1000 if @active_action[6]
- @picture.visible = true
- end
- #--------------------------------------------------------------------------
- # ● 图像文件变更
- #--------------------------------------------------------------------------
- def graphics_change
- # 主人公限定
- return if @battler.is_a?(Game_Enemy)
- # 图像变更
- @battler_name = @active_action[2]
- # 是否使用歩行图像中改变转送处的矩形大小的辨别处
- self.bitmap = Cache.character(@battler_name) if N01::WALK_ANIME
- self.bitmap = Cache.character(@battler_name + "_1") unless N01::WALK_ANIME
- # 获取转送处的矩形
- @width = self.bitmap.width / @base_width
- @height = self.bitmap.height / @base_height
- # 如果想让战斗后的人物图也显示为变更后的化在这里修改
- @battler.graphic_change(@active_action[2]) unless @active_action[1]
- end
- #--------------------------------------------------------------------------
- # ● 显示战斗动画 [判別,ID,对象,反转,等待,二刀标志]
- #--------------------------------------------------------------------------
- def battle_anime
- # 取消敌人的二刀标志动画处理
- return if @active_action[5] && [email protected]?
- # 不是二刀的角色,取消二刀标志动画处理
- return if @active_action[5] && @battler.weapons[1] == nil
- # 如果二刀为右手(上面设置过)无武器只有左手(下面设置)持有时
- if @battler.actor?
- return if !@active_action[5] && @battler.weapons[0] == nil && @battler.weapons[1] != nil
- end
- anime_id = @active_action[1]
- # 偷袭时动画画像被反转
- if $back_attack
- mirror = true if @active_action[3] == false
- mirror = false if @active_action[3]
- end
- # 武器和技能动画时
- if anime_id < 0
- # 用行动的种类分歧动画处
- if @battler.action.skill? && anime_id != -2
- anime_id = @battler.action.skill.animation_id
- elsif @battler.action.item? && anime_id != -2
- anime_id = @battler.action.item.animation_id
- else
- # 没有武器时使用空手动画
- anime_id = N01::NO_WEAPON
- if @battler.actor?
- weapon_id = @battler.weapon_id
- anime_id = $data_weapons[weapon_id].animation_id if weapon_id != 0
- # 二刀动画时
- anime_id = @battler.atk_animation_id2 if @active_action[5]
- else
- weapon_id = @battler.weapon
- anime_id = $data_weapons[weapon_id].animation_id if weapon_id != 0
- end
- end
- # 等待設定
- @wait = $data_animations[anime_id].frame_max * 4 if $data_animations[anime_id] != nil && @active_action[4]
- waitflug = true
- # 显示伤害动画时、为了先计算出伤害計算而中断处理
- damage_action = [anime_id, mirror, true]
- return @battler.play = ["对象动画",damage_action] if @battler.active
- end
- # 实行动画
- if @active_action[2] == 0 && $data_animations[anime_id] != nil
- @battler.animation_id = anime_id
- @battler.animation_mirror = mirror
- elsif $data_animations[anime_id] != nil
- for target in @target_battler
- target.animation_id = anime_id
- target.animation_mirror = mirror
- end
- end
- # 等待设定
- @wait = $data_animations[anime_id].frame_max * 4 if $data_animations[anime_id] != nil && @active_action[4] && !waitflug
- end
- #--------------------------------------------------------------------------
- # ● 显示飞出动画 (图片动画)
- #--------------------------------------------------------------------------
- def balloon_anime
- return if self.opacity == 0
- if @balloon == nil
- @balloon = Sprite.new
- @balloon.bitmap = Cache.system("Balloon")
- @balloon.ox = @width / 16
- @balloon.oy = @balloon.height / 10 + @height / 3
- end
- @balloon_id = @active_action[1]
- @balloon_loop = @active_action[2]
- @balloon_duration = 64
- @balloon_back = false
- update_balloon
- @balloon.visible = true
- end
- #--------------------------------------------------------------------------
- # ● BGM/BGS/SE演奏
- #--------------------------------------------------------------------------
- def sound
- # 获取情报
- pitch = @active_action[2]
- vol = @active_action[3]
- name = @active_action[4]
- # 实行
- case @active_action[1]
- when "se"
- Audio.se_play("Audio/SE/" + name, vol, pitch)
- when "bgm"
- # 没有指定名字时、不改变现在的BGM
- if @active_action[4] == ""
- now_bgm = RPG::BGM.last
- name = now_bgm.name
- end
- Audio.bgm_play("Audio/BGM/" + name, vol, pitch)
- when "bgs"
- # 没有指定名字时、不改变现在的BGS
- if @active_action[4] == ""
- now_bgs = RPG::BGS.last
- name = now_bgs.name
- end
- Audio.bgs_play("Audio/BGS/" + name, vol, pitch)
- end
- end
- #--------------------------------------------------------------------------
- # ● 游戏变量操作
- #--------------------------------------------------------------------------
- def variable
- # 检查操作
- operand = @active_action[3]
- # 变数操作的分歧
- case @active_action[2]
- when 0 # 代入
- $game_variables[@active_action[1]] = operand
- when 1 # 加算
- $game_variables[@active_action[1]] += operand
- when 2 # 減算
- $game_variables[@active_action[1]] -= operand
- when 3 # 乗算
- $game_variables[@active_action[1]] *= operand
- when 4 # 除算
- $game_variables[@active_action[1]] /= operand
- when 5 # 剰余
- $game_variables[@active_action[1]] %= operand
- end
- end
- #--------------------------------------------------------------------------
- # ● 二刀限定
- #--------------------------------------------------------------------------
- def two_swords
- # 敌方不被处理
- return @action.shift unless @battler.actor?
- # 左手(下部显示)没有武器就会消除下面的动作
- return @action.shift if @battler.weapons[1] == nil
- # 从行动配类的前面移动
- active = @action.shift
- # 确定现在的动作
- @active_action = N01::ANIME[active]
- # 等待设定
- @wait = active.to_i if @active_action == nil
- # 单独动作开始
- action
- end
- #--------------------------------------------------------------------------
- # ● 非二刀限定
- #--------------------------------------------------------------------------
- def non_two_swords
- # 敌方不被处理
- return unless @battler.actor?
- # 左手(下部显示)没有武器就会消除下面的动作
- return @action.shift if @battler.weapons[1] != nil
- # 从行动配类的前面移动
- active = @action.shift
- # 确定现在的动作
- @active_action = N01::ANIME[active]
- # 等待设定
- @wait = active.to_i if @active_action == nil
- # 单独动作开始
- action
- end
- #--------------------------------------------------------------------------
- # ● 动作条件
- #--------------------------------------------------------------------------
- def necessary
- nece1 = @active_action[3]
- nece2 = @active_action[4]
- # 目标确认
- case @active_action[1]
- # 0自身 1目标 2敌全体 3我方全体
- when 0
- target = [$game_party.members[@battler.index]] if @battler.is_a?(Game_Actor)
- target = [$game_troop.members[@battler.index]] if @battler.is_a?(Game_Enemy)
- when 1
- target = @target_battler
- when 2
- target = $game_troop.members
- when 3
- target = $game_party.members
- end
- # 目标为空出时看作失败
- return start_action(@battler.recover_action) if target.size == 0
- # 内容确认
- case @active_action[2]
- # 指定了状态ID时
- when 0
- # 补充正号为「正在此状态」、负号为「不在此状态」的条件
- state_on = true if nece2 > 0
- # 获取条件人数
- state_member = nece2.abs
- # 0从队友数中获取
- if nece2 == 0
- state_member = $game_party.members.size if @battler.is_a?(Game_Actor)
- state_member = $game_troop.members.size if @battler.is_a?(Game_Enemy)
- end
- # 目标的状态确认后清点人数
- for member in target
- state_member -= 1 if member.state?(nece1)
- end
- # 条件全部满足后执行动作
- if state_member == 0 && state_on
- return
- elsif state_member == nece2.abs
- return if state_on == nil
- end
- # 指定了参数时
- when 1
- # 补充了正号为「数值以上」、负号为「数值以下」的条件
- num_over = true if nece2 > 0
- # 参照数值
- num = 0
- # 确认目标的参数
- for member in target
- # 参照参数来分歧
- case nece1
- when 0 # 现HP
- num += member.hp
- when 1 # 现MP
- num += member.mp
- when 2 # 攻击力
- num += member.atk
- when 3 # 防御力
- num += member.def
- when 4 # 精神力
- num += member.spi
- when 5 # 敏捷性
- num += member.agi
- end
- end
- # 平均
- num = num / target.size
- # 条件全部满足时执行动作
- if num > nece2.abs && num_over
- return
- elsif num < nece2.abs
- return if num_over == nil
- end
- # 指定了开关时
- when 2
- # 条件全部满足时执行动作
- if $game_switches[nece1]
- # 补充为true时「开关ON」、false时「开关OFF」的条件
- return if nece2
- # 开关为OFF时与ON时是相反的
- else
- return unless nece2
- end
- # 指定了变量时
- when 3
- # 补充为正号时「数值以上」、负号时「数値以下」的条件
- if nece2 > 0
- return if $game_variables[nece1] > nece2
- else
- return unless $game_variables[nece1] > nece2.abs
- end
- # 指定了习得技能时
- when 4
- # 获取技能条件人数
- skill_member = nece2.abs
- for member in target
- skill_member -= 1 if member.skill_learn?(nece1)
- # 条件确认
- return if skill_member == 0
- end
- end
- # 条件没有被满足时动作中断
- return @action = ["完毕"] if @non_repeat
- # 不让防御中看起来不自然,坐标不被还原
- action = @battler.recover_action
- action = @battler.defence if @battler.guarding?
- return start_action(action)
- end
- #--------------------------------------------------------------------------
- # ● 技能连发
- #--------------------------------------------------------------------------
- def derivating
- # 如果让没学的的技能不能连发时
- return if !@active_action[2] && [email protected]_id_learn?(@active_action[3])
- # 确率分歧
- return if rand(100) > @active_action[1]
- # 连发成功
- @battler.derivation = @active_action[3]
- # 之后的动作被中断
- @action = ["完毕"]
- end
- #--------------------------------------------------------------------------
- # ● 个别处理开始
- #--------------------------------------------------------------------------
- def individual_action
- # 反复标志ON
- @battler.individual = true
- # 保持反复动作
- @individual_act = @action.dup
- # 保持目标、一个一个的发出行动目标
- send_action(["个别处理"])
- @individual_targets = @target_battler.dup
- @target_battler = [@individual_targets.shift]
- end
- #--------------------------------------------------------------------------
- # ● 个别处理完毕
- #--------------------------------------------------------------------------
- def individual_action_end
- # 目标没有残留时行动完毕
- return @battler.individual = false if @individual_targets.size == 0
- @action = @individual_act.dup
- @target_battler = [@individual_targets.shift]
- end
- #--------------------------------------------------------------------------
- # ● 待机不能移动
- #--------------------------------------------------------------------------
- def non_repeat
- @repeat_action = []
- @non_repeat = true
- anime_finish
- end
- #--------------------------------------------------------------------------
- # ● 目标变更 action = [判別, 变更对象, 变更处]
- #--------------------------------------------------------------------------
- def change_target
- # 还原自身变更了的目标
- return @target_battler = @now_targets.dup if @active_action[2] == 3
- # 发送目标情报
- target = [@battler] if @active_action[2] == 0
- target = @target_battler.dup if @active_action[2] != 0
- # 自身的目标发送到对方时、记录现在的目标
- if @active_action[2] == 2
- @now_targets = @target_battler.dup
- @target_battler = []
- end
- # 发送目标指定目录时
- if @active_action[1] >= 1000
- members = $game_party.members if @battler.actor?
- members = $game_troop.members unless @battler.actor?
- index = @active_action[1] - 1000
- if index < members.size
- if members[index].exist? && @battler.index != index
- # 目标变更
- members[index].force_target = ["N01target_change", target]
- # 自身的目标发送到相手时
- @target_battler = [members[index]] if @active_action[2] == 2
- change = true
- else
- for member in members
- next if @battler.index == member.index
- next unless member.exist?
- member.force_target = ["N01target_change", target]
- @target_battler = [member] if @active_action[2] == 2
- break change = true
- end
- end
- end
- # 指定了发送目标的状态ID时
- elsif @active_action[1] > 0
- for member in $game_party.members + $game_troop.members
- if member.state?(@active_action[1])
- member.force_target = ["N01target_change", target]
- @target_battler.push(member) if @active_action[2] == 2
- change = true
- end
- end
- # 指定了发送目标学的的技能时
- elsif @active_action[1] < 0
- skill_id = @active_action[1].abs
- for actor in $game_party.members
- if actor.skill_learn?(skill_id)
- actor.force_target = ["N01target_change", target]
- @target_battler.push(target) if @active_action[2] == 2
- change = true
- end
- end
- # 发送目标是目标时
- else
- for member in @target_battler
- member.force_target = ["N01target_change", target]
- @target_battler.push(member) if @active_action[2] == 2
- change = true
- end
- end
- # 条件未满足时之后的动作被中断
- return if change
- return @action = ["完毕"] if @non_repeat
- return start_action(@battler.recover_action)
- end
- #--------------------------------------------------------------------------
- # ● 状态付与
- #--------------------------------------------------------------------------
- def state_on
- state_id = @active_action[2]
- # 分歧对象
- case @active_action[1]
- when 0
- @battler.add_state(state_id)
- when 1
- if @target_battler != nil
- for target in @target_battler
- target.add_state(state_id)
- end
- end
- when 2
- for target in $game_troop.members
- target.add_state(state_id)
- end
- when 3
- for target in $game_party.members
- target.add_state(state_id)
- end
- when 4
- for target in $game_party.members
- if target.index != @battler.index
- target.add_state(state_id)
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 状态解除
- #--------------------------------------------------------------------------
- def state_off
- state_id = @active_action[2]
- # 分歧对象
- case @active_action[1]
- when 0
- @battler.remove_state(state_id)
- when 1
- if @target_battler != nil
- for target in @target_battler
- target.remove_state(state_id)
- end
- end
- when 2
- for target in $game_troop.members
- target.remove_state(state_id)
- end
- when 3
- for target in $game_party.members
- target.remove_state(state_id)
- end
- when 4
- for target in $game_party.members
- if target.index != @battler.index
- target.remove_state(state_id)
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 实行漂浮
- #--------------------------------------------------------------------------
- def floating
- # 初期化跳跃
- jump_reset
- # 情报确认
- @jump_plus = @active_action[1]
- float_end = @active_action[2]
- @float_time = @active_action[3]
- # 计算一格相当的移动高度
- @float_up = (float_end - @jump_plus)/ @float_time
- # 漂浮结束前不执行下个动作
- @wait = @float_time
- # 反映漂浮动画的设定
- if @anime_flug
- move_anime = N01::ANIME[@active_action[4]]
- # 没有指定图片时跳过处理
- if move_anime != nil
- # 写下现在的动作
- @active_action = move_anime
- # 角色动画开始
- battler_anime
- # 漂浮完毕时即动画完毕
- @anime_end = true
- end
- end
- # 漂浮到初期高度
- @battler.jump = @jump_plus
- end
- #--------------------------------------------------------------------------
- # ● 强制动作
- #--------------------------------------------------------------------------
- def force_action
- # 动作是单独还是通用的判别
- kind = @active_action[0]
- # 确认有无复原
- rebirth = @active_action[2]
- # 获取强制动作的内容
- play = @active_action[3]
- # 归纳上面3个情报
- action = [kind,rebirth,play]
- # 目标指定目录时
- if @active_action[1] >= 1000
- members = $game_party.members if @battler.actor?
- members = $game_troop.members unless @battler.actor?
- index = @active_action[1] - 1000
- if index < members.size
- if members[index].exist? && @battler.index != index
- # 交付角色情报
- return members[index].force_action = action
- else
- for target in members
- next if @battler.index == target.index
- next unless target.exist?
- force = true
- break target.force_action = action
- end
- end
- end
- # 条件未满足时之后的动作全部中断
- return if force
- return @action = ["完毕"] if @non_repeat
- return start_action(@battler.recover_action)
- # 指定目标时
- elsif @active_action[1] == 0
- for target in @target_battler
- target.force_action = action if target != nil
- end
- # 指定状态ID时
- elsif @active_action[1] > 0
- for target in $game_party.members + $game_troop.members
- target.force_action = action if target.state?(@active_action[1])
- end
- # 指定习得技能时
- elsif @active_action[1] < 0
- # 敌方不被处理时
- return if @battler.is_a?(Game_Enemy)
- for actor in $game_party.members
- # 自身除外
- unless actor.id == @battler.id
- # 交付角色情报
- actor.force_action = action if actor.skill_id_learn?(@active_action[1].abs)
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 实行坐标初始化
- #--------------------------------------------------------------------------
- def reseting
- # 初始化跳跃
- jump_reset
- # 还原旋转
- self.angle = 0
- # 情报确认
- @distanse_x = @move_x * -1
- @distanse_y = @move_y * -1
- @move_speed_x = @active_action[1]
- @move_speed_y = @move_speed_x
- @move_boost_x = @active_action[2]
- @move_boost_y = @move_boost_x
- @jump = @active_action[3]
- # 计算移动
- move_distance
- # 反映移动画面的设定
- if @anime_flug
- move_anime = N01::ANIME[@active_action[4]]
- # 没有指定图片时跳过处理
- if move_anime != nil
- # 写下现在的动作
- @active_action = move_anime
- # 角色动画开始
- battler_anime
- end
- # 移动完毕时即动画也完毕
- @anime_end = true
- end
- end
- #--------------------------------------------------------------------------
- # ● 实行移动
- #--------------------------------------------------------------------------
- def moving
- # 初期化跳跃
- jump_reset
- # 方便调出X轴的移动
- xx = @active_action[1]
- # 袭击时X轴逆转
- xx *= -1 if $back_attack
- # 确认移动目标的目标
- case @active_action[0]
- when 0 # 自身
- @distanse_x = xx
- @distanse_y = @active_action[2]
- when 1 # 目标
- # 目标没有决定时、变换成自身
- if @target_battler == nil
- @distanse_x = xx
- @distanse_y = @active_action[2]
- else
- # 一个一个的确认目标对象
- target_x = 0
- target_y = 0
- time = 0
- for i in 0...@target_battler.size
- if @target_battler != nil
- time += 1
- target_x += @target_battler.position_x
- target_y += @target_battler.position_y
- end
- end
- # 目标空出时、变换成自身
- if time == 0
- @distanse_x = xx
- @distanse_y = @active_action[2]
- else
- # 计算出复数目标的中心位置
- target_x = target_x / time
- target_y = target_y / time
- # 算出最终的移动距离
- @distanse_y = target_y - self.y + @active_action[2]
- # X坐标是角色和敌人的逆向计算
- if @battler.is_a?(Game_Actor)
- @distanse_x = target_x - self.x + xx
- else
- @distanse_x = self.x - target_x + xx
- end
- end
- end
- when 2 # 画面
- # X坐标是角色和敌人的逆向计算
- if @battler.is_a?(Game_Actor)
- @distanse_x = xx - self.x
- @distanse_x = Graphics.width + xx - self.x if $back_attack
- else
- @distanse_x = self.x - xx
- @distanse_x = self.x - (Graphics.width + xx) if $back_attack
- end
- @distanse_y = @active_action[2] - self.y
- when 3 # 初期位置
- # X坐标是角色和敌人的逆向计算
- if @battler.is_a?(Game_Actor)
- @distanse_x = xx + @battler.base_position_x - self.x
- else
- @distanse_x = xx + self.x - @battler.base_position_x
- end
- @distanse_y = @active_action[2] + @battler.base_position_y - @battler.position_y
- end
- @move_speed_x = @active_action[3]
- @move_speed_y = @active_action[3]
- @move_boost_x = @active_action[4]
- @move_boost_y = @active_action[4]
- @jump = @active_action[5]
- @jump_plus = 0
- # 计算移动
- move_distance
- # 反映移动动画的设定
- if @anime_flug
- move_anime = N01::ANIME[@active_action[6]]
- # 没有指定图片时跳过处理
- if move_anime != nil
- # 写下现在的动作
- @active_action = move_anime
- # 角色动画开始
- battler_anime
- end
- # 移动完毕时即动画也完毕
- @anime_end = true
- end
- end
- #--------------------------------------------------------------------------
- # ● 计算移动
- #--------------------------------------------------------------------------
- def move_distance
- # 速度为0时、停留在那个地方
- if @move_speed_x == 0
- @moving_x = 0
- @moving_y = 0
- else
- # 计算一格相当的移动距离
- @moving_x = @distanse_x / @move_speed_x
- @moving_y = @distanse_y / @move_speed_y
- # 剩余的距离在这时移动消化
- over_x = @distanse_x % @move_speed_x
- over_y = @distanse_y % @move_speed_y
- @move_x += over_x
- @move_y += over_y
- @battler.move_x = @move_x
- @battler.move_y = @move_y
- @distanse_x -= over_x
- @distanse_y -= over_y
- end
- # 判定是否移动
- if @distanse_x == 0
- @move_speed_x = 0
- end
- if @distanse_y == 0
- @move_speed_y = 0
- end
- # 计算X坐标移动
- # 根据加减速修正移动格数
- boost_x = @moving_x
- move_x = 0
- # 加速时
- if @move_boost_x > 0 && @distanse_x != 0
- # 加减速的正负调整成左右移动
- if @distanse_x == 0
- @move_boost_x = 0
- elsif @distanse_x < 0
- @move_boost_x *= -1
- end
- # 事先计算距离的变化
- for i in 0...@move_speed_x
- boost_x += @move_boost_x
- move_x += boost_x
- # 记录超过距离
- over_distance = @distanse_x - move_x
- # 记录右移动时距离超越的时第几格
- if @distanse_x > 0 && over_distance < 0
- @move_speed_x = i
- break
- # 记录右移动时距离超越的时第几格
- elsif @distanse_x < 0 && over_distance > 0
- @move_speed_x = i
- break
- end
- end
- # 将超越距离还原到前一次
- before = over_distance + boost_x
- # 剩余的距离加算到等速移动的格数中
- @move_speed_plus_x = (before / @moving_x).abs
- # 即使这样剩余的距离也在这时移动消化
- @move_x += before % @moving_x
- @battler.move_x = @move_x
- # 减速时
- elsif @move_boost_x < 0 && @distanse_x != 0
- # 加减速的正负调整成左右移动
- if @distanse_x == 0
- @move_boost_x = 0
- elsif @distanse_x < 0
- @move_boost_x *= -1
- end
- # 事先计算距离的变化
- for i in 0...@move_speed_x
- boost_x += @move_boost_x
- move_x += boost_x
- # 记录不足的距离
- lost_distance = @distanse_x - move_x
- before = lost_distance
- # 记录右移动速度到0时是第几格
- if @distanse_x > 0 && boost_x < 0
- @move_speed_x = i - 1
- # 不足的距离还原到前一次
- before = lost_distance + boost_x
- break
- # 记录左移动速度到0时是第几格
- elsif @distanse_x < 0 && boost_x > 0
- @move_speed_x= i - 1
- # 不足的距离还原到前一次
- before = lost_distance + boost_x
- break
- end
- end
- # 不足的距离加算到等速移动的格数中
- plus = before / @moving_x
- @move_speed_plus_x = plus.abs
- # 即是如此剩余的距离也在这时移动消化
- @move_x += before % @moving_x
- @battler.move_x = @move_x
- end
- # 计算Y坐标移动
- # 根据加减速修正移动格数
- boost_y = @moving_y
- move_y = 0
- # 加速时
- if @move_boost_y > 0 && @distanse_y != 0
- # 加减速的正负调整成左右移动
- if @distanse_y == 0
- @move_boost_y = 0
- elsif @distanse_y < 0
- @move_boost_y *= -1
- end
- # 事先计算距离的变化
- for i in 0...@move_speed_y
- boost_y += @move_boost_y
- move_y += boost_y
- # 记录超越的距离
- over_distance = @distanse_y - move_y
- # 记录右移动时距离超越的时第几格
- if @distanse_y > 0 && over_distance < 0
- @move_speed_y = i
- break
- # 记录左移动时距离超越的时第几格
- elsif @distanse_y < 0 && over_distance > 0
- @move_speed_y = i
- break
- end
- end
- # 超越的距离还原到前一次
- before = over_distance + boost_y
- # 剩余的距离加算到等速移动的格数中
- @move_speed_plus_y = (before / @moving_y).abs
- # 即使这样剩余的距离也在这时移动消化
- @move_y += before % @moving_y
- @battler.move_y = @move_y
- # 減速时
- elsif @move_boost_y < 0 && @distanse_y != 0
- # 加减速的正负调整成左右移动
- if @distanse_y == 0
- @move_boost_y = 0
- elsif @distanse_y < 0
- @move_boost_y *= -1
- end
- # 事先计算距离的变化
- for i in 0...@move_speed_y
- boost_y += @move_boost_y
- move_y += boost_y
- # 记录不足的距离
- lost_distance = @distanse_y - move_y
- before = lost_distance
- # 记录右移动速度到0时是第几格
- if @distanse_y > 0 && boost_y < 0
- @move_speed_y = i
- # 不足的距离还原到前一次
- before = lost_distance + boost_y
- break
- # 记录左移动速度到0时是第几格
- elsif @distanse_y < 0 && boost_y > 0
- @move_speed_y = i
- # 不足的距离还原到前一次
- before = lost_distance + boost_y
- break
- end
- end
- # 不足的距离加算到等速移动的格数中
- plus = before / @moving_y
- @move_speed_plus_y = plus.abs
- # 即是如此剩余的距离也在这时移动消化
- @move_y += before % @moving_y
- @battler.move_y = @move_y
- end
- # 算出移动完毕的时间
- x = @move_speed_plus_x + @move_speed_x
- y = @move_speed_plus_y + @move_speed_y
- if x > y
- end_time = x
- else
- end_time = y
- end
- # 移动完毕前不进行下个动作
- @wait = end_time
- # 计算跳跃
- if @jump != 0
- # 没有移动只跳跃时
- if @wait == 0
- # 时间记入
- @wait = @active_action[3]
- end
- # 从移动完毕时间算出跳跃时间
- @jump_time = @wait / 2
- # 不能插入时的剩余时间
- @jump_time_plus = @wait % 2
- # 判别跳跃是正还是负
- @jump_sign = 0
- @jump_sign2 = 0
- if @jump < 0
- @jump_sign = -1
- @jump_sign2 = 1
- @jump = @jump * -1
- else
- @jump_sign = 1
- @jump_sign2 = -1
- end
- # 决定跳跃初始速度
- @jump_up = 2 ** @jump * @jump_sign
- # 略微调整条约时间的尾数
- if @jump_time == 0
- @jump_up = 0
- elsif @jump_time != 1
- @jump_size = @jump_up * @jump_sign * @jump_sign2
- else
- @jump_size = @jump_up * 2 * @jump_sign * @jump_sign2
- @jump_flug = true
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 角色动画开始
- #--------------------------------------------------------------------------
- def battler_anime
- # 反映动画设定
- @anime_kind = @active_action[1]
- @anime_speed = @active_action[2]
- @anime_loop = @active_action[3]
- # 如果有等待时间时加算
- @unloop_wait = @active_action[4]
- @anime_end = true
- @reverse = false
- # 只有有武器动作时进行更新
- if @weapon_R != nil && @active_action[8] != ""
- # 确认武器的设定
- weapon_kind = N01::ANIME[@active_action[8]]
- # 敌方和不使用二刀角色的取消二刀标志动画处理
- two_swords_flug = weapon_kind[11]
- return if two_swords_flug && [email protected]?
- return if two_swords_flug && @battler.weapons[1] == nil && @battler.actor?
- if @battler.actor? && @battler.weapons[0] == nil && !two_swords_flug
- @weapon_R.action_reset
- elsif @battler.actor? && @battler.weapons[1] == nil && two_swords_flug
- @weapon_R.action_reset
- elsif [email protected]? && @battler.weapon == 0
- @weapon_R.action_reset
- else
- # 初期化
- @weapon_R.action_reset
- # 动画图像是固定时的获取武器位置
- if @active_action[5] != -1
- @weapon_R.freeze(@active_action[5])
- end
- # 设定武器画像
- @weapon_R.weapon_graphics unless two_swords_flug
- @weapon_R.weapon_graphics(true) if two_swords_flug
- # 交付武器动作
- @weapon_R.weapon_action(@active_action[8],@anime_loop)
- @weapon_action = true
- # 更新最初的武器动作
- @weapon_R.action
- end
- elsif @weapon_R != nil
- @weapon_R.action_reset
- end
- @anime_end = false
- # 动画图片是固定时
- if @active_action[5] != -1 && @active_action[5] != -2
- # 标志ON
- @anime_freeze = true
- # 看作动画是通常的完毕了
- @anime_end = true
- # 单程逆转再生时
- elsif @active_action[5] == -2
- @anime_freeze = false
- # 标志ON
- @reverse = true
- # 更新最初的动画图像
- @pattern = @base_width - 1
- # 只有在有武器动画时更新
- if @weapon_action && @weapon_R != nil
- @weapon_R.action
- @weapon_R.update
- end
- # 更新通常动画时
- else
- @anime_freeze = false
- # 更新最初动画图像
- @pattern = 0
- # 只有在有武器动画时更新
- if @weapon_action && @weapon_R != nil
- @weapon_R.action
- @weapon_R.update
- end
- end
- @pattern_back = false
- @frame = @anime_speed
- # 设定Z坐标
- @battler.move_z = @active_action[6]
- # 是否有影
- if @shadow != nil
- @shadow.visible = true if @active_action[7]
- @shadow.visible = false unless @active_action[7]
- @shadow.visible = false if @skip_shadow
- end
- # 分期从编号读取文件名
- if @active_action[0] == 0
- file_name = @battler_name
- else
- file_name = @battler_name + "_" + @active_action[0].to_s
- end
- # 无动画角色时处理完毕
- return unless @anime_flug
- self.bitmap = Cache.character(file_name)
- # 设定转送前的矩形
- @sx = @pattern * @width
- @sy = @anime_kind * @height
- @sx = @active_action[5] * @width if @anime_freeze
- self.src_rect.set(@sx, @sy, @width, @height)
- end
- #--------------------------------------------------------------------------
- # ● 动画飞出
- #--------------------------------------------------------------------------
- def moving_anime
- # 如果前个飞出动画还有残留时初期化
- @move_anime.action_reset if @anime_moving
- @anime_moving = true
- # 袭击中动画、武器画像反转
- mirror = false
- mirror = true if $back_attack
- # 动画ID
- id = @active_action[1]
- # 对象
- target = @active_action[2]
- x = y = mem = 0
- # 对象为单体时
- if target == 0
- # 没有决定目标时、变换为自身
- if @target_battler == nil
- x = self.x
- y = self.y
- else
- # 目标空出时、变换为自身
- if @target_battler[0] == nil
- x = self.x
- y = self.y
- else
- # 决定最初进入的目标为对象
- x = @target_battler[0].position_x
- y = @target_battler[0].position_y
- end
- end
- # 对象在敌方中心时
- elsif target == 1
- # 自身是主人公时计算敌方的中心
- if @battler.is_a?(Game_Actor)
- for target in $game_troop.members
- x += target.position_x
- y += target.position_y
- mem += 1
- end
- x = x / mem
- y = y / mem
- # 自身是敌方时计算主人公的中心
- else
- for target in $game_party.members
- x += target.position_x
- y += target.position_y
- mem += 1
- end
- x = x / mem
- y = y / mem
- end
- # 对象在我方中心时
- elsif target == 2
- # 自身是主人公时计算主人公的中心
- if @battler.is_a?(Game_Actor)
- for target in $game_party.members
- x += target.position_x
- y += target.position_y
- mem += 1
- end
- x = x / mem
- y = y / mem
- # 自身是敌方时计算敌方的中心
- else
- for target in $game_troop.members
- x += target.position_x
- y += target.position_y
- mem += 1
- end
- x = x / mem
- y = y / mem
- end
- # 对象是自身时
- else
- x = self.x
- y = self.y
- end
- # 开始位置的略微调整
- plus_x = @active_action[6]
- plus_y = @active_action[7]
- # 敌方是X轴逆转
- plus_x *= -1 if @battler.is_a?(Game_Enemy)
- # 算出最終的移动距离
- distanse_x = x - self.x - plus_x
- distanse_y = y - self.y - plus_y
- # 飞出类型
- type = @active_action[3]
- # 速度
- speed = @active_action[4]
- # 轨道
- orbit = @active_action[5]
- # 如果自身在开始位置时
- if @active_action[8] == 0
- @move_anime.base_x = self.x + plus_x
- @move_anime.base_y = self.y + plus_y
- # 对象在开始位置时
- elsif @active_action[8] == 1
- @move_anime.base_x = x + plus_x
- @move_anime.base_y = y + plus_y
- # 把距离作为反面
- distanse_y = distanse_y * -1
- distanse_x = distanse_x * -1
- # 如果不能动
- else
- @move_anime.base_x = x
- @move_anime.base_y = y
- distanse_x = distanse_y = 0
- end
- # 无武器动作时不显示武器
- if @active_action[10] == ""
- weapon = ""
- # 无动画的敌方不显示武器
- elsif @anime_flug != true
- weapon = ""
- # 武器动作时
- else
- # 确认是否指定了飞出武器图片
- if @battler.is_a?(Game_Actor)
- battler = $game_party.members[@battler.index]
- weapon_id = battler.weapon_id
- else
- battler = $game_troop.members[@battler.index]
- weapon_id = battler.weapon
- end
- # 判别是使用技能画像还是使用武器画像
- weapon_act = N01::ANIME[@active_action[10]].dup if @active_action[10] != ""
- # 如果利用武器画像时并不是空手
- if weapon_id != 0 && weapon_act.size == 3
- weapon_file = $data_weapons[weapon_id].flying_graphic
- # 如果没有指定别的画像时获取既存的武器图片
- if weapon_file == ""
- weapon_name = $data_weapons[weapon_id].graphic
- icon_weapon = false
- # 然后没有指定时使用ICON图片
- if weapon_name == ""
- weapon_name = $data_weapons[weapon_id].icon_index
- icon_weapon = true
- end
- # 指定时获取那个图片名
- else
- icon_weapon = false
- weapon_name = weapon_file
- end
- # 武器动作情报を取得
- weapon = @active_action[10]
- # 指定了武器画像时不显示空手
- elsif weapon_act.size == 3
- weapon = ""
- # 使用技能画像
- elsif weapon_act != nil && @battler.action.skill != nil
- icon_weapon = false
- weapon_name = $data_skills[@battler.action.skill.id].flying_graphic
- weapon = @active_action[10]
- end
- end
- # 决定Z坐标
- @move_anime.z = 1
- @move_anime.z = 1000 if @active_action[9]
- # 已上的全部情报都已飞出动画送到精灵
- @move_anime.anime_action(id,mirror,distanse_x,distanse_y,type,speed,orbit,weapon,weapon_name,icon_weapon)
- end
- #--------------------------------------------------------------------------
- # ● 动作完毕
- #--------------------------------------------------------------------------
- def anime_finish
- # 单独处理完毕省略时做反复
- return individual_action_end if @individual_targets.size != 0
- # 主动向角色归纳动作情报
- send_action(@active_action[0]) if @battler.active
- # 如果有残像时开放
- mirage_off if @mirage_flug
- # 重复待机动作
- start_action(@repeat_action) unless @non_repeat
- end
- #--------------------------------------------------------------------------
- # ● 击倒动作
- #--------------------------------------------------------------------------
- def collapse_action
- @non_repeat = true
- @effect_type = COLLAPSE
- @collapse_type = @battler.collapse_type unless @battler.actor?
- @battler_visible = false unless @battler.actor?
- @effect_duration = N01::COLLAPSE_WAIT + 48 if @collapse_type == 2
- @effect_duration = 401 if @collapse_type == 3
- end
- #--------------------------------------------------------------------------
- # ● 普通击倒
- #--------------------------------------------------------------------------
- def normal_collapse
- if @effect_duration == 47
- Sound.play_enemy_collapse
- self.blend_type = 1
- self.color.set(255, 128, 128, 128)
- end
- self.opacity = 256 - (48 - @effect_duration) * 6 if @effect_duration <= 47
- end
- #--------------------------------------------------------------------------
- # ● BOSS击倒
- #--------------------------------------------------------------------------
- def boss_collapse1
- if @effect_duration == 320
- Audio.se_play("Audio/SE/Absorb1", 100, 80)
- self.flash(Color.new(255, 255, 255), 60)
- viewport.flash(Color.new(255, 255, 255), 20)
- end
- if @effect_duration == 280
- Audio.se_play("Audio/SE/Absorb1", 100, 80)
- self.flash(Color.new(255, 255, 255), 60)
- viewport.flash(Color.new(255, 255, 255), 20)
- end
- if @effect_duration == 220
- Audio.se_play("Audio/SE/Earth4", 100, 80)
- reset
- self.blend_type = 1
- self.color.set(255, 128, 128, 128)
- self.wave_amp = 6
- end
- if @effect_duration < 220
- self.src_rect.set(0, @effect_duration / 2 - 110, @width, @height)
- self.x += 8 if @effect_duration % 4 == 0
- self.x -= 8 if @effect_duration % 4 == 2
- self.wave_amp += 1 if @effect_duration % 10 == 0
- self.opacity = @effect_duration
- return if @effect_duration < 50
- Audio.se_play("Audio/SE/Earth4", 100, 50) if @effect_duration % 50 == 0
- end
- end
- end
|
|