本帖最后由 KB.Driver 于 2020-3-24 13:25 编辑
在技能备注栏写<回溯>,效果范围必须设置为使用者
module CLD99 module REWIND_HP_MP # 回溯的回合数 DEPTH = 3 # 信息格式(请不要修改汉字以外的部分) FMT = "%s的%s与%s恢复到了#{DEPTH}回合之前" end end #--------------------------------------------------------------------------# # ● 修改以下部分所造成的后果由修改者本人负责 ● # #--------------------------------------------------------------------------# class RPG::Skill def rewind_skill? self.note =~ /<回溯>/ end end class Game_Actor #-------------------------------------------------------------------------- # ● 战斗开始处理 #-------------------------------------------------------------------------- def on_battle_start super store_hp_mp end #-------------------------------------------------------------------------- # ● 回合结束处理 #-------------------------------------------------------------------------- def on_turn_end super store_hp_mp end #-------------------------------------------------------------------------- # ● 战斗结束处理 #-------------------------------------------------------------------------- def on_battle_end super clear_stroring_hp_mp end def store_hp_mp if skills.any?{|s| s.rewind_skill? } @storing_hp ||= [] @storing_mp ||= [] @storing_hp << @hp @storing_mp << @mp end end def rewind_hp_mp turn = [$game_troop.turn_count - CLD99::REWIND_HP_MP::DEPTH, 0].max @hp = @storing_hp[turn] @mp = @storing_mp[turn] end def clear_stroring_hp_mp if skills.any?{|s| s.rewind_skill? } @storing_hp && @storing_hp.clear @storing_mp && @storing_mp.clear end end end class Scene_Battle #-------------------------------------------------------------------------- # ● 发动技能/物品 #-------------------------------------------------------------------------- alias invoke_item_for_rewind_hp_mp invoke_item def invoke_item(target, item) invoke_item_for_rewind_hp_mp(target, item) if item.is_a?(RPG::Skill) && item.rewind_skill? target.rewind_hp_mp end end end class Window_BattleLog #-------------------------------------------------------------------------- # ● 显示行动结果 #-------------------------------------------------------------------------- alias display_action_results_for_rewind_hp_mp display_action_results def display_action_results(target, item) if item.is_a?(RPG::Skill) && item.rewind_skill? add_text(CLD99::REWIND_HP_MP::FMT % [target.name, Vocab.hp, Vocab.mp]) end display_action_results_for_rewind_hp_mp(target, item) end end
module CLD99
module REWIND_HP_MP
# 回溯的回合数
DEPTH = 3
# 信息格式(请不要修改汉字以外的部分)
FMT = "%s的%s与%s恢复到了#{DEPTH}回合之前"
end
end
#--------------------------------------------------------------------------#
# ● 修改以下部分所造成的后果由修改者本人负责 ● #
#--------------------------------------------------------------------------#
class RPG::Skill
def rewind_skill?
self.note =~ /<回溯>/
end
end
class Game_Actor
#--------------------------------------------------------------------------
# ● 战斗开始处理
#--------------------------------------------------------------------------
def on_battle_start
super
store_hp_mp
end
#--------------------------------------------------------------------------
# ● 回合结束处理
#--------------------------------------------------------------------------
def on_turn_end
super
store_hp_mp
end
#--------------------------------------------------------------------------
# ● 战斗结束处理
#--------------------------------------------------------------------------
def on_battle_end
super
clear_stroring_hp_mp
end
def store_hp_mp
if skills.any?{|s| s.rewind_skill? }
@storing_hp ||= []
@storing_mp ||= []
@storing_hp << @hp
@storing_mp << @mp
end
end
def rewind_hp_mp
turn = [$game_troop.turn_count - CLD99::REWIND_HP_MP::DEPTH, 0].max
@hp = @storing_hp[turn]
@mp = @storing_mp[turn]
end
def clear_stroring_hp_mp
if skills.any?{|s| s.rewind_skill? }
@storing_hp && @storing_hp.clear
@storing_mp && @storing_mp.clear
end
end
end
class Scene_Battle
#--------------------------------------------------------------------------
# ● 发动技能/物品
#--------------------------------------------------------------------------
alias invoke_item_for_rewind_hp_mp invoke_item
def invoke_item(target, item)
invoke_item_for_rewind_hp_mp(target, item)
if item.is_a?(RPG::Skill) && item.rewind_skill?
target.rewind_hp_mp
end
end
end
class Window_BattleLog
#--------------------------------------------------------------------------
# ● 显示行动结果
#--------------------------------------------------------------------------
alias display_action_results_for_rewind_hp_mp display_action_results
def display_action_results(target, item)
if item.is_a?(RPG::Skill) && item.rewind_skill?
add_text(CLD99::REWIND_HP_MP::FMT % [target.name, Vocab.hp, Vocab.mp])
end
display_action_results_for_rewind_hp_mp(target, item)
end
end
|