- 注册时间
- 2005-8-22
- 最后登录
- 2005-8-30
⑥精研
- 积分
- 1471
|
刚刚有人在QQ上问到怎么制作能够打击敌人全体的武器,我本想说“战斗特殊效果”可以,但想想,那个脚本一用,战斗冲突到无法再使用任何战斗相关脚本,故决定简单说说这个功能怎么实现,你可以做出属于你的兵器。
战斗中,判断我方普通攻击目标的是在Scene_Battle 4里面的198行开始,如下。我来添加一些注释大家就好理解了。
# 行动方的战斗者是角色的情况下
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
具体“怎么怎么样的情况”到底是什么,你可以查,如果懂了更好,但是对解决这个问题没有任何影响和帮助(嗯……这话的口气有点像新东方专门应试的老师……)。把else到对应的end之间的内容稍加修改,如下:
else
if @active_battler.weapon_id == 1 or @active_battler.weapon_id == 2 #当角色装备1号或者2号武器
if rand(100)<50 #50%几率。这里rand(100)会给出一个0-99的随机数,<50就是50%概率
for enemy in $game_troop.enemies #以下几行表示把所有敌人都放到目标中去。这是从别的地方考过来的
if enemy.exist?
@target_battlers.push(enemy)
end
end
else #50%以外情况,还是正常那套。
index = @active_battler.current_action.target_index
target = $game_troop.smooth_target_enemy(index)
end
else
index = @active_battler.current_action.target_index
target = $game_troop.smooth_target_enemy(index)
end
end
至于具体正常那套是什么,不用管。考过来就是了。
但这样还有一些小问题,就是这个函数本来用的是target这么个临时变量,现在直接操作了@target_battlers,所以把下面一行:
# 设置对像方的战斗者序列
@target_battlers = [target]
修改一下:
if @target_battlers == []
# 设置对像方的战斗者序列
@target_battlers = [target]
end
这样就可以了。这个修改是说,如果没有打出全体攻击,按照以前的方法走。
以下是完成后的脚本。也可以插入到main前面直接用。用1号和2号兵器打人的时候,50%几率打击敌人全体。所有修改内容上面都讲了,其他都是照搬。看看,脚本也没什么神秘的吗,这么轻易就一大篇脚本。
注意的一点,你最好在你的脚本中搜索“def make_basic_action_result”这个内容,改搜索出来的比较靠下的一个脚本上面的,这样才能保证有效。
脚本全部内容:
# ————————————————————————————————————
# 本脚本来自www.66rpg.com,转载请保留此信息
# ————————————————————————————————————
class Scene_Battle
#--------------------------------------------------------------------------
# ● 生成基本行动结果
#--------------------------------------------------------------------------
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
if @active_battler.weapon_id == 1 or @active_battler.weapon_id == 2
if rand(100)<50
for enemy in $game_troop.enemies
if enemy.exist?
@target_battlers.push(enemy)
end
end
else
index = @active_battler.current_action.target_index
target = $game_troop.smooth_target_enemy(index)
end
else
index = @active_battler.current_action.target_index
target = $game_troop.smooth_target_enemy(index)
end
end
end
if @target_battlers == []
# 设置对像方的战斗者序列
@target_battlers = [target]
end
# 应用通常攻击效果
for target in @target_battlers
target.attack_effect(@active_battler)
end
return
end
# 防御的情况下
if @active_battler.current_action.basic == 1
# 帮助窗口显示"防御"
@help_window.set_text($data_system.words.guard, 1)
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
|
|