大家好!这是我在这个公会的第一篇帖子,如果有什么做得不对的地方请见谅,毕竟我刚从论坛转过来,还在熟悉这个网站。
我在我的游戏(使用了 Yanfly 引擎)中使用了一个由 Sixth 制作的脚本。这个脚本创建了一个范围,允许选择一个友方单位作为目标,但排除使用者自己。不过请注意,正如我在第 98 行所写的那样,我对脚本进行了一些微调,以适应游戏中同时拥有 5 名队员的设定。
以下是该脚本的代码:
=begin
- 目标:一名友方(非使用者)范围 - 标题有点傻!
- 制作者:Sixth
- 描述
此脚本允许你为技能创建一个新的范围(某种程度上)。
该范围允许玩家选择除使用者以外的任何友方单位。
要使技能使用此范围,请确保在数据库中将范围设置为
“一名友方”类型,并在备注框中使用以下备注标签:
<one_ally_no_user>
这将设置技能的新范围。它在战斗外的菜单中也有效,但仅对技能有效。
由于物品菜单中使用者设定方式的原因(每次使用物品时,PHA 属性最高的成员将成为使用者),
在那里启用此新范围意义不大(但如果你仍然在具有“一名友方”范围的物品上使用上述备注标签,
它在战斗中仍会按预期工作,即使用者无法对自己使用该物品)。
作为必要的修复,我还修改了敌人使用具有“一名友方”范围的技能时,
不再每次都瞄准小队中的最后一个成员。相反,它们现在会随机瞄准友方单位,
但如果使用的技能带有 <one_ally_no_user> 备注标签,它们将无法对自己使用该技能。
此脚本在未使用自定义战斗脚本的情况下进行了测试,因此不能保证它与那些脚本兼容!
=end
class RPG::UsableItem < RPG::BaseItem
attr_accessor :one_no_user
def one_no_user
init_one_no_user if @one_no_user.nil?
return @one_no_user
end
def init_one_no_user
@one_no_user = @note =~ /<one_ally_no_user>/i ? true : false
end
end
class Game_Action
alias check_no_user1232 targets_for_friends
def item_target_candidates
trgs = check_no_user1232
trgs.delete(subject) if item.one_no_user && item.for_one?
return trgs
end
alias check_no_user1132 targets_for_friends
def targets_for_friends
if subject.is_a?(Game_Enemy) && item.scope == 7
ids = []
friends_unit.alive_members.each_with_index do |mem,i|
next if item.one_no_user && mem == subject
ids << $game_troop.members.index(mem)
end
@target_index = ids.sample
end
trgs = check_no_user1132
return trgs
end
end
class Game_BattlerBase
alias check_no_user7541 usable?
def usable?(item)
if item.is_a?(RPG::UsableItem) && item.one_no_user && friends_unit.alive_members.size <= 1
return false
end
check_no_user7541(item)
end
end
class Game_Actor < Game_Battler
alias check_no_user9265 item_test
def item_test(user, item)
return false if item.one_no_user && self == user
check_no_user9265(user, item)
end
end
class Window_BattleActor < Window_BattleStatus
# 这部分进行了修改,以适应显示 5 名队员的用户界面。
def draw_actor_name(actor, dx, dy, dw = 112)
if BattleManager.actor && BattleManager.actor.input.item.one_no_user &&
actor == BattleManager.actor
act_enable = false
else
act_enable = true
end
reset_font_settings
contents.font.size = YEA::BATTLE::BATTLESTATUS_NAME_FONT_SIZE
change_color(hp_color(actor),act_enable)
draw_text(dx+24, dy, dw-24, line_height, actor.name)
end
def current_item_enabled?
if BattleManager.actor && BattleManager.actor.input.item.one_no_user &&
$game_party.members[@index] == BattleManager.actor
return false
else
super
end
end
end
class Scene_Skill < Scene_ItemBase
alias check_no_user8826 use_item
def use_item
if item.one_no_user && user == $game_party.members[@actor_window.index]
return Sound.play_buzzer
end
check_no_user8826
end
end
class Scene_Battle < Scene_Base
alias check_no_user5413 on_actor_ok
def on_actor_ok
if BattleManager.actor.input.item.one_no_user &&
BattleManager.actor == $game_party.battle_members[@actor_window.index]
return Sound.play_buzzer
end
check_no_user5413
end
end
我知道这个脚本在制作时并没有考虑到外部脚本(包括 Yanfly),但我发现这个脚本使得“一名友方(已死亡)”范围实际上变得毫无用处,因为它实际上等同于“一名友方”,只是当对存活的单位使用该技能/物品时,它不会执行任何操作。
有没有可能修复这个问题,使得“一名友方(已死亡)”范围不允许你点击当前存活的友方单位,就像通常情况那样?
希望我没有提出过高的要求,提前感谢!