Target Any Add-On for Yanfly's Target Manager
Target Any Add-On for Yanfly's Target Managerby 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:
#==============================================================================# 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; enddef self.load_database load_database_any_target load_notetags_any_targetend #--------------------------------------------------------------------------# 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 endendend # 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_anyend #--------------------------------------------------------------------------# 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_anyend #--------------------------------------------------------------------------# 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_anyend #--------------------------------------------------------------------------# 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_anyend #--------------------------------------------------------------------------# new method: for_any_all?#--------------------------------------------------------------------------def for_any_all? return @scope == :target_any_allend #--------------------------------------------------------------------------# new method: for_any?#--------------------------------------------------------------------------def for_any? return @scope == :target_anyendend#==============================================================================# Window_BattleHelp#==============================================================================class Window_BattleHelp < Window_Help#--------------------------------------------------------------------------# alias method: refresh_special_case#--------------------------------------------------------------------------alias window_battlehelp_refresh_special_case_target_any refresh_special_casedef 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) endendend#==============================================================================# Game_Action#==============================================================================class Game_Action#--------------------------------------------------------------------------# * Public Instance Variables#--------------------------------------------------------------------------attr_accessor :ally#--------------------------------------------------------------------------# alias method: clear#--------------------------------------------------------------------------alias game_action_clear_target_any cleardef clear game_action_clear_target_any @ally = falseend#--------------------------------------------------------------------------# alias method: set_skill#--------------------------------------------------------------------------alias game_action_set_skill_targets_any set_skilldef set_skill(skill_id) game_action_set_skill_targets_any(skill_id) @ally = self.item.default_for_friend selfend#--------------------------------------------------------------------------# alias method: set_item#--------------------------------------------------------------------------alias game_action_set_item_targets_any set_itemdef set_item(item_id) game_action_set_item_targets_any(item_id) @ally = self.item.default_for_friend selfend#--------------------------------------------------------------------------# alias method: make_custom_targets#--------------------------------------------------------------------------alias game_action_make_custom_targets_target_any make_custom_targetsdef make_custom_targets array = game_action_make_custom_targets_target_any if item.for_any? if @ally array += else array += end elsif item.for_any_all? if @ally array |= friends_unit.alive_members else array |= opponents_unit.alive_members end end return arrayendend # 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 superend #--------------------------------------------------------------------------# new method: process_dir4#--------------------------------------------------------------------------def process_dir8 Sound.play_cursor Input.update deactivate call_handler(:dir8)endend # 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 superend #--------------------------------------------------------------------------# new method: process_dir4#--------------------------------------------------------------------------def process_dir2 Sound.play_cursor Input.update deactivate call_handler(:dir2)endend # Window_BattleActor#==============================================================================# Scene_Battle#==============================================================================class Scene_Battle < Scene_Base#--------------------------------------------------------------------------# * alias: create_actor_window#--------------------------------------------------------------------------alias scene_battle_create_actor_window_target_any create_actor_windowdef 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_windowdef 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_canceldef 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 endend #--------------------------------------------------------------------------# 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 endend #--------------------------------------------------------------------------# 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 = @itemend #--------------------------------------------------------------------------# 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 endendend
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/
页:
[1]