加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
我想实现一个“每场战斗中,只有使用了技能一才能使用技能二,使用了技能二才能使用技能三,战斗结束重置”功能的脚本。
无关内容脚本部分省略。
首先,在Game_Battler 1 中新建了一个hash表。
attr_accessor :skill_prereq def initialize @skill_prereq = {3=>{2=>false}} end
attr_accessor :skill_prereq
def initialize
@skill_prereq = {3=>{2=>false}}
end
然后,在Scene_Battle 1 中写:
def main for actor in $game_party.actors for restricted_skill in actor.skill_prereq.values for skill_req in restricted_skill.keys restricted_skill[skill_req] = false end end end # 开始自由战斗回合 start_phase1 end end
def main
for actor in $game_party.actors
for restricted_skill in actor.skill_prereq.values
for skill_req in restricted_skill.keys
restricted_skill[skill_req] = false
end
end
end
# 开始自由战斗回合
start_phase1
end
end
接下来,在Game_Battler 3 中写:
def skill_can_use?(skill_id) if @skill_prereq.keys[skill_id] != nil for skill_qua in @skill_prereq[skill_id].values unless skill_qua;return false;end end end
def skill_can_use?(skill_id)
if @skill_prereq.keys[skill_id] != nil
for skill_qua in @skill_prereq[skill_id].values
unless skill_qua;return false;end
end
end
最后,在Game_Battler 3 中继续写:
def skill_effect(user, skill) # 清除会心一击标志 self.critical = false for restricted_skill in @skill_prereq.values for skill_req in restricted_skill.keys id skill_req = skill_id restircted_skill[skill_req] = true end end
def skill_effect(user, skill)
# 清除会心一击标志
self.critical = false
for restricted_skill in @skill_prereq.values
for skill_req in restricted_skill.keys
id skill_req = skill_id
restircted_skill[skill_req] = true
end
end
以上感谢狂人。
最后,战斗测试的时候发现,这一切
并没有什么卵用。
特技一和特技二依然可以同时使用。
是插入的地方错了呢?
还是什么地方写错了呢?
还是什么地方少写了呢? |