Project1
标题: 淘到一个脚本,希望做些小修改 [打印本页]
作者: stella 时间: 2011-9-16 14:17
标题: 淘到一个脚本,希望做些小修改
本帖最后由 stella 于 2011-9-16 14:23 编辑
这个脚本的作用是当MISS的时候被攻击方移动战斗图,当播放完攻击动画再移回来,我希望添加的是:当命中的时候被攻击方的战斗图快速地左右移动三个来回,用来模仿抖动的样子,在播放完攻击动画之前移回原位,应该怎么改?- class Game_Battler
- attr_accessor :add_x
- alias hzhj_old_ini initialize
- def initialize
- hzhj_old_ini
- @add_x = 0
- end
- end
- class Sprite_Battler < RPG::Sprite
- MoveSpeed = 8
- alias hzhj_old_initialize initialize
- def initialize(viewport, battler = nil)
- hzhj_old_initialize(viewport, battler)
- if not @battler.nil?
- self.x = @battler.screen_x
- end
- @hzhj_x = self.x
- end
- def battler=(value)
- if @battler != value and value != nil
- self.x = value.screen_x
- end
- @hzhj_x = self.x
- @battler = value
- end
- alias hzhj_old_update update
- def update
- hzhj_old_update
- self.x = @hzhj_x
- if not @battler.nil? and not @battler.dead?
- if self.x < @battler.screen_x + @battler.add_x
- self.x = [self.x + MoveSpeed, @battler.screen_x + @battler.add_x].min
- elsif self.x > @battler.screen_x + @battler.add_x
- self.x = [self.x - MoveSpeed, @battler.screen_x + @battler.add_x].max
- end
- end
- @hzhj_x = self.x
- end
- def x
- if @effect_hzhj
- if @battler.nil?
- return super
- else
- return @battler.screen_x
- end
- else
- return super
- end
- end
- def update_animation
- @effect_hzhj = true
- super
- @effect_hzhj = false
- end
- def animation(*args)
- @effect_hzhj = true
- super(*args)
- @effect_hzhj = false
- end
- def update_damage
- @effect_hzhj = true
- super
- @effect_hzhj = false
- end
- def damage(*args)
- @effect_hzhj = true
- super(*args)
- @effect_hzhj = false
- end
- end
- class Scene_Battle
- alias hzhj_old_update_phase4_step4 update_phase4_step4
- def update_phase4_step4
- hzhj_old_update_phase4_step4
- for target in @target_battlers
- next if target.dead?
- next if target.damage != "Miss"
- if target.is_a?(Game_Actor)
- target.add_x = -64
- elsif target.is_a?(Game_Enemy)
- target.add_x = 64
- end
- end
- end
- alias hzhj_old_update_phase4_step5 update_phase4_step5
- def update_phase4_step5
- hzhj_old_update_phase4_step5
- for target in @target_battlers
- target.add_x = 0
- end
- end
- end
复制代码