Project1
标题:
如何在角色攻击时调用公共事件
[打印本页]
作者:
我真的是智障
时间:
2017-2-22 22:32
标题:
如何在角色攻击时调用公共事件
本帖最后由 RyanBern 于 2017-3-1 21:44 编辑
怎么设置 当第n号角色攻击时调用第n号事件(简单点)
作者:
guoxiaomi
时间:
2017-2-23 09:07
本帖最后由 guoxiaomi 于 2017-2-26 18:14 编辑
众所周知RMXP的数据库里物品和特技是有关联公共事件的。这个公共事件将在技能结算完毕之后触发,公共事件执行完了就进入下一个角色的回合。但是攻击和防御是没有关联公共事件的,其实这个很容易做到。
请看Scene_Battle 4的178-240行的 make_basic_action_result 方法,在每个return(这里是第35行和第43行)前添加
@common_event_id = XXX
当然也可以根据情况进行判断具体执行哪个公共事件,这里只是给出添加关联的位置。下面是修改过的 make_basic_action_result 方法,攻击和防御在执行结束后会触发1号和2号公共事件。
def make_basic_action_result
# 攻击的情况下
if @active_battler.current_action.basic == 0
# 设置攻击 ID
@animation1_id = @active_battler.animation1_id
@animation2_id = @active_battler.animation2_id
# 行动方的战斗者是敌人的情况下
if @active_battler.is_a?(Game_Enemy)
if @active_battler.restriction == 3
target = $game_troop.random_target_enemy
elsif @active_battler.restriction == 2
target = $game_party.random_target_actor
else
index = @active_battler.current_action.target_index
target = $game_party.smooth_target_actor(index)
end
end
# 行动方的战斗者是角色的情况下
if @active_battler.is_a?(Game_Actor)
if @active_battler.restriction == 3
target = $game_party.random_target_actor
elsif @active_battler.restriction == 2
target = $game_troop.random_target_enemy
else
index = @active_battler.current_action.target_index
target = $game_troop.smooth_target_enemy(index)
end
end
# 设置对像方的战斗者序列
@target_battlers = [target]
# 应用通常攻击效果
for target in @target_battlers
target.attack_effect(@active_battler)
end
# 设置攻击公共事件 id
@common_event_id = 1
return
end
# 防御的情况下
if @active_battler.current_action.basic == 1
# 帮助窗口显示"防御"
@help_window.set_text($data_system.words.guard, 1)
# 设置防御公共事件 id
@common_event_id = 2
return
end
# 逃跑的情况下
if @active_battler.is_a?(Game_Enemy) and
@active_battler.current_action.basic == 2
# 帮助窗口显示"逃跑"
@help_window.set_text("逃跑", 1)
# 逃跑
@active_battler.escape
return
end
# 什么也不做的情况下
if @active_battler.current_action.basic == 3
# 清除强制行动对像的战斗者
$game_temp.forcing_battler = nil
# 移至步骤 1
@phase4_step = 1
return
end
end
end
复制代码
n号角色攻击时执行n号公共事件,就注释掉44行,然后修改36行为:
if @active_battler.is_a?(Game_Actor)
@common_event_id = @active_battler.id
end
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1