本帖最后由 QQ蚊子湯 于 2017-2-27 07:45 编辑
連假早上有點空閒,寫個給你參考
我沒怎麼改你的結構,只改我想吐血的部分www
你可以感受一下實例變量和全局變量的不同之處
class Game_Actor attr_accessor :game_Shield attr_accessor :magic_Shield def add_state(state_id) super self.game_Shield =500 if state_id == 50 end def apply_guard(value) super if state?(50) && value > 0 # 50 号状态 v = @game_Shield if v >= value @hurt_Shield = value @magic_Shield = true @game_Shield -= value.to_i return 0 else value -= v @hurt_Shield = value @magic_Shield = true @game_Shield = 0 self.remove_state(50) value end else @magic_Shield = false value end end end class Game_ActionResult #-------------------------------------------------------------------------- # ● 获取 HP 伤害的文字 #-------------------------------------------------------------------------- def hp_damage_text if @hp_drain > 0 fmt = @battler.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain sprintf(fmt, @battler.name, Vocab::hp, @hp_drain) elsif @hp_damage > 0 fmt = @battler.actor? ? Vocab::ActorDamage : Vocab::EnemyDamage sprintf(fmt, @battler.name, @hp_damage) elsif @hp_damage < 0 fmt = @battler.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery sprintf(fmt, @battler.name, Vocab::hp, -hp_damage) elsif @battler.magic_Shield == true fmt = "护盾抵消了%s点伤害,还剩下#{@battler.game_Shield}点护盾。" @battler.magic_Shield = false sprintf(fmt,@Hurt_Shield.to_i) else fmt = @battler.actor? ? Vocab::ActorNoDamage : Vocab::EnemyNoDamage sprintf(fmt, @battler.name) end end end
class Game_Actor
attr_accessor :game_Shield
attr_accessor :magic_Shield
def add_state(state_id)
super
self.game_Shield =500 if state_id == 50
end
def apply_guard(value)
super
if state?(50) && value > 0 # 50 号状态
v = @game_Shield
if v >= value
@hurt_Shield = value
@magic_Shield = true
@game_Shield -= value.to_i
return 0
else
value -= v
@hurt_Shield = value
@magic_Shield = true
@game_Shield = 0
self.remove_state(50)
value
end
else
@magic_Shield = false
value
end
end
end
class Game_ActionResult
#--------------------------------------------------------------------------
# ● 获取 HP 伤害的文字
#--------------------------------------------------------------------------
def hp_damage_text
if @hp_drain > 0
fmt = @battler.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
sprintf(fmt, @battler.name, Vocab::hp, @hp_drain)
elsif @hp_damage > 0
fmt = @battler.actor? ? Vocab::ActorDamage : Vocab::EnemyDamage
sprintf(fmt, @battler.name, @hp_damage)
elsif @hp_damage < 0
fmt = @battler.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
sprintf(fmt, @battler.name, Vocab::hp, -hp_damage)
elsif @battler.magic_Shield == true
fmt = "护盾抵消了%s点伤害,还剩下#{@battler.game_Shield}点护盾。"
@battler.magic_Shield = false
sprintf(fmt,@Hurt_Shield.to_i)
else
fmt = @battler.actor? ? Vocab::ActorNoDamage : Vocab::EnemyNoDamage
sprintf(fmt, @battler.name)
end
end
end
|