查看: 1091|回复: 2

[有事请教] 技能/物品范围设定为不含使用者的单个队友

[复制链接]
梦石
0
星屑
1207
在线时间
162 小时
注册时间
2008-1-19
回帖
10
发表于 2025-7-26 09:14:31 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
VA默认的技能范围“单个队友”也可以选择使用者自身,但有些技能不适合做成可对自己使用(如使队友行动2次),尤其是在由敌人AI使用这些技能时如果选择自己十分违和。这个应该如何实现。
之前试着修改了技能实际作用的对象,但发现对敌人用的技能无效。希望能在选择时就把使用者自身排除出范围。
梦石
0
星屑
29896
在线时间
5733 小时
注册时间
2016-3-8
回帖
1653
发表于 2025-7-28 18:58:47 | 显示全部楼层
本帖最后由 alexncf125 于 2025-7-28 20:30 编辑

[pre lang="ruby"]=begin

- 技能效果范围:除自身外的单个队友 - What a silly title!
- Made by: Sixth

- Description

This script will let you make a new scope for your skills (kinda).
That scope will let the player target anyone from an ally except the user.

首先,你需要将技能的效果范围设定为【单个队友】,然后添加技能备注:

  <非自身单个队友>

This will setup the new scope for the skill. It will work in the menu outside
the battles too, but only on skills.(地图菜单中也会生效,但仅技能)
Due to how the user is set for the items in the item menu (the member with the
highest PHA stat will be the user every time you use an item), it wouldn't make
much sense to enable this new scope there (but if you still used the mentioned
note-tag on an item with the "One Ally" scope, it will function as expected
during battles, so the user will not be able to use the item on him/herself.

As a necessary fix, I also made enemies not target the last troop member every
time they use a skill with the "One Ally" scope. Instead, they will now target
random allies, but if the used skill got the <one_ally_no_user> note-tag, they
won't be able to target themselves with the skill.(脚本作者还修正了敌人使用
【单个队友】技能时只会对准最后一个敌群敌人的问题,当敌人使用带<非自身单个队友>备注
的技能时,会选择随机目标)

This is tested without any custom battle scripts, so there is no guarantee that
it will work with those!

=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 =~ /<非自身单个队友>/i ? true : false
  end

end

class Game_Action

  alias check_no_user1232 item_target_candidates
  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)
    return false if item.nil? || (item.one_no_user && friends_unit.alive_members.size <= 1)
    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
  
  def draw_actor_name(actor, x, y, width = 112)
    if BattleManager.actor && BattleManager.actor.input.item.one_no_user &&
       actor == BattleManager.actor
       act_enable = false
     else
       act_enable = true
    end
    change_color(hp_color(actor),act_enable)
    draw_text(x, y, width, 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[/pre]

点评

成功了,非常感谢  发表于 2025-8-4 11:26
回复 1 0

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部