Project1
标题:
为什么总是没有往复运动呢?移动战斗图脚本修改的问题
[打印本页]
作者:
幻耶
时间:
2011-11-25 10:03
标题:
为什么总是没有往复运动呢?移动战斗图脚本修改的问题
本帖最后由 幻耶 于 2011-11-25 10:06 编辑
后知后觉的脚本,闪躲时会移动战斗图,我希望在命中时战斗图会左右左右左右震动一下,所以脚本
126~145行
是我添加的地方。但战斗时命中敌人只会左移一次,没有往复运动,请教解决方法!
class Game_Battler
attr_accessor :add_x
attr_accessor :add_y
alias hzhj_old_ini initialize
def initialize
hzhj_old_ini
$shake = 0
@add_x = 0
@add_y = 0
end
end
class Sprite_Battler < RPG::Sprite
MoveSpeed = 18 # X 方向每次移动多少像素
MoveSpeed_Y = 16 # Y 方向每次移动多少像素
Jump_SE = RPG::AudioFile.new("016-Jump02", 100, 100)
alias hzhj_old_initialize initialize
def initialize(*args)
hzhj_old_initialize(*args)
if not @battler.nil?
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_y
@hzhj_play_jump = true
end
@hzhj_x = self.x
@hzhj_y = self.y
end
def battler=(value)
if @battler != value and value != nil
self.x = value.screen_x
self.y = value.screen_y
self.z = value.screen_y
@hzhj_play_jump = true
end
@hzhj_x = self.x
@hzhj_y = self.y
@battler = value
end
alias hzhj_old_update update
def update
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
if self.y < @battler.screen_y + @battler.add_y
self.y = [self.y + MoveSpeed_Y, @battler.screen_y + @battler.add_y].min
elsif self.y > @battler.screen_y + @battler.add_y
self.y = [self.y - MoveSpeed_Y, @battler.screen_y + @battler.add_y].max
end
if self.x == @battler.screen_x and self.y == @battler.screen_y
@hzhj_play_jump = true
end
end
@hzhj_x = self.x
@hzhj_y = self.y
hzhj_old_update
self.x = @hzhj_x
self.y = @hzhj_y
self.z = @hzhj_y
end
def x
if @effect_hzhj
if @battler.nil?
return super
else
return @battler.screen_x
end
else
return super
end
end
def y
if @effect_hzhj
if @battler.nil?
return super
else
return @battler.screen_y
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
ACTOR_ADD_X = 64 # X 方向角色一共要移动的像素
ACTOR_ADD_Y = 48 # Y 方向角色一共要移动的像素
ENEMY_ADD_X = -64 # X 方向敌人一共要移动的像素
ENEMY_ADD_Y = -48 # Y 方向敌人一共要移动的像素
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?
if target.damage == "Miss"
if target.is_a?(Game_Actor)
target.add_x = ACTOR_ADD_X
target.add_y = ACTOR_ADD_Y
elsif target.is_a?(Game_Enemy)
target.add_x = ENEMY_ADD_X
target.add_y = ENEMY_ADD_Y
end
else
$shake += 1 # XXOO
case $shake
when 1..2
target.add_x -= 3
when 3..4
target.add_x += 6
when 5..6
target.add_x -= 6
when 7..8
target.add_x += 6
when 9..10
target.add_x -= 6
when 11..12
target.add_x += 6
when 13..14
target.add_x -= 6
when 15..16
target.add_x = 0
end
$shake = 0 if $shake == 16 # XXOO
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
target.add_y = 0
end
end
end
复制代码