[VX Ace] Sixth's "One Ally No User" Script Conflicting with "One Ally (Dead)" Scope

Hello everyone! This is my first post on the guild, so forgive me if I’m doing anything wrong, as I need to familiarize myself with this website after transitioning from the forums.

I’m using a script made by Sixth in my game (Which uses the Yanfly Engine), this script created the scope that allows one ally to be targeted except for the user, though note that, as I wrote on line 98, I did modify the script slightly to accommodate having 5 party members at once, as that’s how it is in my game.

Here’s the following script:

=begin
 
- Target One Ally (Not the User) Scope - 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.
 
To make a skill use this scope, make sure to set it's database scope to
the "One Ally" type, and use this note-tag in it's note-box:
 
  <one_ally_no_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 =~ /<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
 
  #This part was modified to accommodate for the UI displaying 5 party members.
  
  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

I understand that this script wasn’t made with outside scripts in mind, including Yanfly, but I realized that this script made the “One Ally (Dead)” scope practically useless, as it effectively functions as “One Ally”, except upon using the skill/item on someone alive, it does nothing.

Is it at all possible to fix this issue, so that “One Ally (Dead)” will not allow you to click on an ally that’s currently alive, like it is normally?

Hope I’m not asking for too much, thank you in advance!

I took a look and I believe I found the cause. Yanfly’s Ace Battle Engine defines its own version of Window_BattleActor’s current_item_enabled?, and that version is what blocks you from selecting a living ally when a skill has the One Ally (Dead) scope. Sixth’s script overwrites that same method instead of aliasing it, and its fallback is super, which skips Yanfly’s version entirely and lands on Window_Selectable’s, which just returns true for everything. So once Sixth’s script loads below Yanfly, the dead only check disappears, every ally becomes selectable, and picking a living one fires the skill at an invalid target and does nothing. I think that’s why it started acting like plain One Ally for you.

There’s a second smaller issue in the same script. It aliases targets_for_friends and uses that as the body of item_target_candidates, which are two different methods. item_target_candidates is what auto battle and the AI use to list valid targets, so routing it through targets_for_friends scrambles the candidate lists for dead scope and enemy scope items even if you haven’t hit symptoms from it yet.

Here’s a fixed version that swaps those overwrites for aliases so Yanfly’s checks stay intact: one_ally_no_user_fixed.zip (1.9 KB)

Replace your current copy with it in the same slot below Yanfly. Everything the script did before still works the same, the note tag scope, the enemy targeting fix, the menu buzzer, the greyed out user name, and I kept your 5 member draw_actor_name modification. Since Yanfly’s check is back, the engine’s own buzzer plays again when a living ally is clicked with a dead scope skill. One thing to keep in mind, if you’re running other scripts that also touch Window_BattleActor, this fixed version needs to sit below those too so its aliases grab the final versions.

Worked like a charm, thank you very much!