设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 103|回复: 0

[转载发布] Target Any Add-On for Yanfly's Target Manager

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58883
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68848

    灌水之王

    发表于 2026-8-2 10:03:59 | 显示全部楼层 |阅读模式
    Target Any Add-On for Yanfly's Target Manager
    by Racheal

    Introduction
    This is a Add-On for Yanfly's Target Manager which allows you to set skills that can target friend OR foe.

    Features
    - Press Up/Down to switch between Ally and Enemy targeting for select skills.
    - Targeting defaults to whatever the scope in the editor is set to.
    - Works with Attack and Items too!

    How to Use
    - Insert in the materials section of the script editor.
    - Insert <targets: any> in the notetag of any skill or item you want to be able to select a single ally or enemy for.
    - Insert <targets: any all> in the notetag of any skill or item you want to be able to select all allies or all enemies for.
    - Make sure to set the scope in the editor to set which group it defaults to selecting first!

    ScriptSpoiler                Code:       
    1. #==============================================================================# Target Any Add-On for Yanfly's Target Manager# by: Racheal# Version 1.0# Created: 22/11/2013#==============================================================================# Allows for skills that can target enemy or ally.#==============================================================================# Instructions:# * Insert in the Materials section under Target Manager## -----------------------------------------------------------------------------# Skill / Item Notetags - These notetags go in the skills notebox in the database.# -----------------------------------------------------------------------------# <targets: any># Sets the targeting scope to hit either enemy or ally## <targets: any all># Sets the targeting scope to hit either all enemies or all allies#==============================================================================# ▼ Compatibility# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that# it will run with RPG Maker VX without adjusting.## This scripts requires Yanfly Ace Battle Engine and Yanfly Target Manager.# It is highly unlikely to without both of those scripts.#==============================================================================#==============================================================================# DataManager#==============================================================================module DataManager    #--------------------------------------------------------------------------  # alias method: load_database  #--------------------------------------------------------------------------  class <<self; alias load_database_any_target load_database; end  def self.load_database    load_database_any_target    load_notetags_any_target  end    #--------------------------------------------------------------------------  # new method: load_notetags_target  #--------------------------------------------------------------------------  def self.load_notetags_any_target    groups = [$data_skills, $data_items]    for group in groups      for obj in group        next if obj.nil?        obj.load_notetags_any_target      end    end  end  end # DataManager#==============================================================================# RPG::UsableItem#==============================================================================class RPG::UsableItem < RPG::BaseItem    #--------------------------------------------------------------------------  # * Public Instance Variables  #--------------------------------------------------------------------------  attr_reader :default_for_friend  #--------------------------------------------------------------------------  # common cache: load_notetags_any_target  #--------------------------------------------------------------------------  def load_notetags_any_target    @default_for_friend = for_friend?    self.note.split(/[\r\n]+/).each { |line|      case line      when YEA::REGEXP::USABLEITEM::TARGETS        case $1        when /ANY ALL/i          @scope = :target_any_all        when /ANY/i          @scope = :target_any        end      end    } # self.note.split    #---  end    #--------------------------------------------------------------------------  # alias method: for_opponent?  #--------------------------------------------------------------------------  alias rpg_usableitem_for_opponent_target_any for_opponent?  def for_opponent?    return true if @scope == :target_any_all    return true if @scope == :target_any    return rpg_usableitem_for_opponent_target_any  end    #--------------------------------------------------------------------------  # alias method: for_friend?  #--------------------------------------------------------------------------  alias rpg_usableitem_for_friend_target_any for_friend?  def for_friend?    return true if @scope == :target_any_all    return true if @scope == :target_any    return rpg_usableitem_for_friend_target_any  end    #--------------------------------------------------------------------------  # alias method: for_all?  #--------------------------------------------------------------------------  alias rpg_usableitem_for_all_target_any for_all?  def for_all?    return true if @scope == :target_any_all    rpg_usableitem_for_all_target_any  end    #--------------------------------------------------------------------------  # alias method: need_selection?  #--------------------------------------------------------------------------  alias rpg_usableitem_need_selection_target_any need_selection?  def need_selection?    return true if @scope == :target_any    return rpg_usableitem_need_selection_target_any  end    #--------------------------------------------------------------------------  # new method: for_any_all?  #--------------------------------------------------------------------------  def for_any_all?    return @scope == :target_any_all  end    #--------------------------------------------------------------------------  # new method: for_any?  #--------------------------------------------------------------------------  def for_any?    return @scope == :target_any  endend#==============================================================================# Window_BattleHelp#==============================================================================class Window_BattleHelp < Window_Help  #--------------------------------------------------------------------------  # alias method: refresh_special_case  #--------------------------------------------------------------------------  alias window_battlehelp_refresh_special_case_target_any refresh_special_case  def refresh_special_case(battler)    if $game_temp.battle_aid.for_any_all?      if BattleManager.actor.input.ally        text = YEA::BATTLE::HELP_TEXT_ALL_ALLIES      else        text = YEA::BATTLE::HELP_TEXT_ALL_FOES      end      return if text == @text      @text = text      contents.clear      reset_font_settings      draw_text(0, 0, contents.width, line_height*2, @text, 1)    else      window_battlehelp_refresh_special_case_target_any(battler)    end  endend#==============================================================================# Game_Action#==============================================================================class Game_Action  #--------------------------------------------------------------------------  # * Public Instance Variables  #--------------------------------------------------------------------------  attr_accessor :ally  #--------------------------------------------------------------------------  # alias method: clear  #--------------------------------------------------------------------------  alias game_action_clear_target_any clear  def clear    game_action_clear_target_any    @ally = false  end  #--------------------------------------------------------------------------  # alias method: set_skill  #--------------------------------------------------------------------------  alias game_action_set_skill_targets_any set_skill  def set_skill(skill_id)    game_action_set_skill_targets_any(skill_id)    @ally = self.item.default_for_friend    self  end  #--------------------------------------------------------------------------  # alias method: set_item  #--------------------------------------------------------------------------  alias game_action_set_item_targets_any set_item  def set_item(item_id)    game_action_set_item_targets_any(item_id)    @ally = self.item.default_for_friend    self  end  #--------------------------------------------------------------------------  # alias method: make_custom_targets  #--------------------------------------------------------------------------  alias game_action_make_custom_targets_target_any make_custom_targets  def make_custom_targets    array = game_action_make_custom_targets_target_any    if item.for_any?      if @ally        array += [friends_unit.smooth_target(@target_index)]      else        array += [opponents_unit.smooth_target(@target_index)]      end    elsif item.for_any_all?      if @ally        array |= friends_unit.alive_members      else        array |= opponents_unit.alive_members      end    end    return array  endend # Game_Action#==============================================================================# Window_BattleActor#==============================================================================class Window_BattleActor < Window_BattleStatus    #--------------------------------------------------------------------------  # overwrite method: process_handling  #--------------------------------------------------------------------------  def process_handling    return unless open? && active    return process_dir8 if Input.repeat?(:UP)    return super  end    #--------------------------------------------------------------------------  # new method: process_dir4  #--------------------------------------------------------------------------  def process_dir8    Sound.play_cursor    Input.update    deactivate    call_handler(:dir8)  end  end # Window_BattleActor#==============================================================================# Window_BattleActor#==============================================================================class Window_BattleEnemy < Window_Selectable    #--------------------------------------------------------------------------  # overwrite method: process_handling  #--------------------------------------------------------------------------  def process_handling    return unless open? && active    return process_dir2 if Input.repeat?(:DOWN)    return super  end    #--------------------------------------------------------------------------  # new method: process_dir4  #--------------------------------------------------------------------------  def process_dir2    Sound.play_cursor    Input.update    deactivate    call_handler(:dir2)  end  end # Window_BattleActor#==============================================================================# Scene_Battle#==============================================================================class Scene_Battle < Scene_Base  #--------------------------------------------------------------------------  # * alias: create_actor_window  #--------------------------------------------------------------------------  alias scene_battle_create_actor_window_target_any create_actor_window  def create_actor_window    scene_battle_create_actor_window_target_any    @actor_window.set_handler(:dir8,   method(:on_target_change))  end    #--------------------------------------------------------------------------  # * alias: create_enemy_window  #--------------------------------------------------------------------------  alias scene_battle_create_enemy_window_target_any create_enemy_window  def create_enemy_window    scene_battle_create_enemy_window_target_any    @enemy_window.set_handler(:dir2,   method(:on_target_change))  end    #--------------------------------------------------------------------------  # alias method: on_actor_cancel  #--------------------------------------------------------------------------  alias scene_battle_on_actor_cancel_target_any on_actor_cancel  def on_actor_cancel    scene_battle_on_actor_cancel_target_any    case @actor_command_window.current_symbol    when :attack      @status_window.show      @actor_command_window.activate      @help_window.hide    end  end    #--------------------------------------------------------------------------  # overwrite method: on_skill_ok  #--------------------------------------------------------------------------  def on_skill_ok    @skill = @skill_window.item    $game_temp.battle_aid = @skill    BattleManager.actor.input.set_skill(@skill.id)    BattleManager.actor.last_skill.object = @skill    if @skill.default_for_friend      select_actor_selection    elsif @skill.for_opponent?      select_enemy_selection    elsif @skill.for_friend?      select_actor_selection    else      @skill_window.hide      next_command      $game_temp.battle_aid = nil    end  end    #--------------------------------------------------------------------------  # overwrite method: on_item_ok  #--------------------------------------------------------------------------  def on_item_ok    @item = @item_window.item    $game_temp.battle_aid = @item    BattleManager.actor.input.set_item(@item.id)    if @item.default_for_friend      select_actor_selection    elsif @item.for_opponent?      select_enemy_selection    elsif @item.for_friend?      select_actor_selection    else      @item_window.hide      next_command      $game_temp.battle_aid = nil    end    $game_party.last_item.object = @item  end      #--------------------------------------------------------------------------  # new method: on_target_change  #--------------------------------------------------------------------------  def on_target_change    unless $game_temp.battle_aid.for_any? or $game_temp.battle_aid.for_any_all?       if @enemy_window.visible        @enemy_window.activate      else        @actor_window.activate      end      return    end    if @enemy_window.visible      @enemy_window.hide      select_actor_selection      BattleManager.actor.input.ally = true    else      @actor_window.hide      case @actor_command_window.current_symbol      when :attack        @status_window.show      when :skill        @skill_window.show      when :item        @item_window.show      end      select_enemy_selection      BattleManager.actor.input.ally = false    end  endend
    复制代码





    Credit and Thanks
    Racheal
    Yanfly

    Author's Notes
    This script requiresYanfly's Ace Battle Engine and Yanfly's Target Manager. This is mostly due to how you switch between targets, at least for the battle engine part. No additional versions are planned at this time.


    本贴来自国际rpgmaker官方论坛作者:Yato处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/target-any-add-on-for-yanflys-target-manager.20251/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-17 12:37 , Processed in 0.117042 second(s), 54 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表