#=============================================================================== # # Yanfly Engine - Custom Target Select # Last Date Updated: 2009.04.18 # Level: Normal, Lunatic # # This script does a number of things. First off, it fixes the targetting pains # of Random Enemies. The problem with random targetting is that it can target # already dead enemies and causes your actor to lose out on a potential target # for the random attacks. This, sadly, isn't something that KGC fixes either, so # I've decided to make a fix for it. # # In addition to the fix, the users who want to go a little bit further can add # script tags into the skill's notebox to have extra targetting options. These # additional options include things such as multi attack (think dual attack # with more hits), target random enemies more than 4, target random allies, both # allies and enemies. Things such as that. # # Those who want to go even further can make custom targetting. This allows you # to do stuff such as attack multiple targets if under X HP or attack only # targets if their HP is above 50%. Things like that. # # Note: This script also affects items. It is also a jerk for not working for # the dumbest reasons beyond my comprehension. # #=============================================================================== # Updates: # ---------------------------------------------------------------------------- # o 2009.04.18 - Improved REGEXP cache. # o 2009.04.12 - Improved note tags. # o 2009.03.29 - Started script. #=============================================================================== # How to Use: Normal Mode #=============================================================================== # # Put one of these in your notebox. Only one will activate and priority takes # from top to bottom. # # The skill targets all live foes and all live allies. # The skill targets all live foes and all DEAD allies. # The skill targets one foe and attacks all the rest. # The skill targets one foe and chose x random foes. # The skill targets x number of random foes. # The skill targets one foe and hit x times. # The skill targets all allies but the user. # The skill targets one ally and targets all the rest. # The skill targets one ally and chose x random allies. # The skill targets x number of random allies. # #=============================================================================== # How to Use: Lunatic Mode #=============================================================================== # # If you want to make custom target selection a bit more different, you'll use # as your tag. The variable x will be replaced with the custom # targeting system's ID you'd like. Then, scroll down to "def pickcustom" and # modify the values there to adjust how you'd like the custom selecting to go. # #=============================================================================== # # Compatibility # - Overwrites: Game_BattleAction, make_obj_targets # - Overwrites: RPG::UsableItem, a whole lot of stuff # - Incompatible: KGC_TargetExtension # #=============================================================================== $imported = {} if $imported == nil $imported["CustomTargetSelect"] = true class Game_BattleAction #----------------------------------------------------------------------------- # Modify this section only if you're using xpick. Otherwise, there's no point # in looking any further. #----------------------------------------------------------------------------- def pickcustom(obj, pickcustom) selected = [] case pickcustom #--------------------------------------------------------------------------- # ////////////////////////////////////////////////////////////////////////// # This is where you begin editting your own targetting system #--------------------------------------------------------------------------- when 1 # Hits the target 10 times. for i in 0...10 selected.push(opponents_unit.smooth_target(@target_index)) end when 2 # Selects only targets with HP above 40 for member in opponents_unit.existing_members selected.push(member) if member.hp > 40 end when 3 #--------------------------------------------------------------------------- # This is the part you guys shouldn't touch afterwards. # ////////////////////////////////////////////////////////////////////////// #--------------------------------------------------------------------------- end return selected end end #=============================================================================== # Don't touch anything past here or else your computer will explode and you will # be a very sad person. #=============================================================================== module YE module REGEXP module SKILL # Everyone! EVERYBODY = /<(?:EVERYBODY|every body)>/i PHOENIX = /<(?:PHOENIX|fenix)>/i # Enemy targets. TARGETALLFOE = /<(?:TARGETALLFOE|target all foe)>/i TARGETRANDOMFOE = /<(?:TARGETRANDOMFOE|target random foe)[ ]*(\d+)>/i RANDOMFOE = /<(?:RANDOMFOE|random foe)[ ]*(\d+)>/i MULTI_FOE = /<(?:MULTI_FOE|multi foe|multifoe)[ ]*(\d+)>/i # Ally targets ALLBUTUSER = /<(?:ALLBUTUSER|all but user)>/i TARGETALLALLY = /<(?:TARGETALLALLY|target all ally)>/i TARGETRANDOMALLY = /<(?:TARGETRANDOMALLY|target random ally)[ ]*(\d+)>/i RANDOMALLY = /<(?:RANDOMALLY|random ally)[ ]*(\d+)>/i MULTI_ALLY = /<(?:MULTI_ALLY|multially|multi ally)[ ]*(\d+)>/i # Custom Target PICKCUSTOM = /<(?:PICK_CUSTOM|pick custom)[ ]*(\d+)>/i end end end #=============================================================================== # RPG BaseItem #=============================================================================== class RPG::BaseItem #-------------------------------------------------------------------------- # Yanfly_Cache_CTS #-------------------------------------------------------------------------- def yanfly_cache_cts @everybody = false; @phoenix = false; @targetallfoe = false @targetrandomfoe = 0; @randomfoe = 0; @multifoe = 0; @allbutuser = false @targetallally = false; @targetrandomally = 0; @randomally = 0 @multially = 0; @pickcustom = 0 self.note.split(/[\r\n]+/).each { |line| case line when YE::REGEXP::SKILL::EVERYBODY @everybody = true when YE::REGEXP::SKILL::PHOENIX @phoenix = true when YE::REGEXP::SKILL::TARGETALLFOE @targetallfoe = true when YE::REGEXP::SKILL::TARGETRANDOMFOE @targetrandomfoe = $1.to_i when YE::REGEXP::SKILL::RANDOMFOE @randomfoe = $1.to_i when YE::REGEXP::SKILL::MULTI_FOE @multifoe = $1.to_i when YE::REGEXP::SKILL::ALLBUTUSER @allbutuser = true when YE::REGEXP::SKILL::TARGETALLALLY @targetallally = true when YE::REGEXP::SKILL::TARGETRANDOMALLY @targetrandomally = $1.to_i when YE::REGEXP::SKILL::RANDOMALLY @randomally = $1.to_i when YE::REGEXP::SKILL::MULTI_ALLY @multially = $1.to_i when YE::REGEXP::SKILL::PICKCUSTOM @pickcustom = $1.to_i end } end # end yanfly_cache_cts #-------------------------------------------------------------------------- # Target Everybody? #-------------------------------------------------------------------------- def everybody? yanfly_cache_cts if @everybody == nil return @everybody end #-------------------------------------------------------------------------- # Target Phoenix? #-------------------------------------------------------------------------- def phoenix? yanfly_cache_cts if @phoenix == nil return @phoenix end #-------------------------------------------------------------------------- # Target and All Foes? #-------------------------------------------------------------------------- def targetallfoe? yanfly_cache_cts if @targetallfoe == nil return @targetallfoe end #-------------------------------------------------------------------------- # Call for Random Foes? #-------------------------------------------------------------------------- def targetrandomfoe yanfly_cache_cts if @targetrandomfoe == nil return @targetrandomfoe end #-------------------------------------------------------------------------- # Random Foes? #-------------------------------------------------------------------------- def randomfoe yanfly_cache_cts if @randomfoe == nil return @randomfoe end #-------------------------------------------------------------------------- # Multi Hit Foe? #-------------------------------------------------------------------------- def multifoe yanfly_cache_cts if @rmultifoe == nil return @multifoe end #-------------------------------------------------------------------------- # All But User? #-------------------------------------------------------------------------- def allbutuser? yanfly_cache_cts if @allbutuser == nil return @allbutuser end #-------------------------------------------------------------------------- # Target and All Allies? #-------------------------------------------------------------------------- def targetallally? yanfly_cache_cts if @targetallally == nil return @targetallally end #-------------------------------------------------------------------------- # Random Allies? #-------------------------------------------------------------------------- def targetrandomally yanfly_cache_cts if @targetrandomally == nil return @targetrandomally end #-------------------------------------------------------------------------- # Call for Random Allies? #-------------------------------------------------------------------------- def randomally yanfly_cache_cts if @randomally == nil return @randomally end #-------------------------------------------------------------------------- # Multi Hit Ally? #-------------------------------------------------------------------------- def multially yanfly_cache_cts if @multially == nil return @multially end #-------------------------------------------------------------------------- # Custom Picking? #-------------------------------------------------------------------------- def pickcustom yanfly_cache_cts if @pickcustom == nil return @pickcustom end end #============================================================================== # RPG::UsableItem #============================================================================== class RPG::UsableItem < RPG::BaseItem #-------------------------------------------------------------------------- # Does this need selecting? #-------------------------------------------------------------------------- def need_selection? return false if everybody? return false if phoenix? return false if allbutuser? return true if targetallfoe? return true if targetallally? return true if targetrandomfoe > 0 return false if randomfoe > 0 return true if multifoe > 0 return true if targetrandomally > 0 return false if randomally > 0 return true if multially > 0 return [1, 3, 7, 9].include?(@scope) end #-------------------------------------------------------------------------- # For Opponent? #-------------------------------------------------------------------------- def for_opponent? return true if targetallfoe? return false if targetallally? return true if targetrandomfoe > 0 return true if multifoe > 0 return false if targetrandomally > 0 return false if randomally > 0 return false if multially > 0 return [1, 2, 3, 4, 5, 6].include?(@scope) end #-------------------------------------------------------------------------- # For Friend? #-------------------------------------------------------------------------- def for_friend? return false if targetallfoe? return true if targetallally? return false if targetrandomfoe > 0 return false if multifoe > 0 return true if targetrandomally > 0 return true if randomally > 0 return true if multially > 0 return [7, 8, 9, 10, 11].include?(@scope) end #-------------------------------------------------------------------------- # For User? #-------------------------------------------------------------------------- def for_user? return false if allbutuser? return [11].include?(@scope) end end #=============================================================================== # Game_BattlerAction #=============================================================================== class Game_BattleAction #-------------------------------------------------------------------------- # make_obj_targets #-------------------------------------------------------------------------- def make_obj_targets(obj) targets = [] #------------------------------------------------ if obj.everybody? targets += opponents_unit.existing_members targets += friends_unit.existing_members elsif obj.phoenix? targets += opponents_unit.existing_members targets += friends_unit.dead_members #------------------------------------------------ elsif obj.targetallfoe? targets.push(opponents_unit.smooth_target(@target_index)) targetted = opponents_unit.smooth_target(@target_index) othertargets = opponents_unit.existing_members othertargets.delete(targetted) targets += othertargets elsif obj.targetrandomfoe > 0 number_of_targets = obj.targetrandomfoe targets.push(opponents_unit.smooth_target(@target_index)) number_of_targets.times do targets.push(opponents_unit.random_target) end elsif obj.randomfoe > 0 number_of_targets = obj.randomfoe number_of_targets.times do targets.push(opponents_unit.random_target) end elsif obj.multifoe > 0 number_of_targets = obj.multifoe hits = obj.multifoe for i in 0...hits targets.push(opponents_unit.smooth_target(@target_index)) end #------------------------------------------------ elsif obj.allbutuser? targets += friends_unit.existing_members targets.delete(battler) elsif obj.targetallally? targets.push(friends_unit.smooth_target(@target_index)) targetted = friends_unit.smooth_target(@target_index) othertargets = friends_unit.existing_members othertargets.delete(targetted) targets += othertargets elsif obj.targetrandomally > 0 number_of_targets = obj.targetrandomally targets.push(friends_unit.smooth_target(@target_index)) number_of_targets.times do targets.push(friends_unit.random_target) end elsif obj.randomally > 0 number_of_targets = obj.randomally number_of_targets.times do targets.push(friends_unit.random_target) end elsif obj.multially > 0 number_of_targets = obj.multially hits = obj.multially for i in 0...hits targets.push(friends_unit.smooth_target(@target_index)) end #------------------------------------------------ elsif obj.pickcustom > 0 targets = pickcustom(obj, obj.pickcustom) #------------------------------------------------ elsif obj.for_opponent? if obj.for_random? if obj.for_one? # One random enemy number_of_targets = 1 elsif obj.for_two? # Two random enemies number_of_targets = 2 else # Three random enemies number_of_targets = 3 end number_of_targets.times do targets.push(opponents_unit.random_target) end elsif obj.dual? # One enemy, dual targets.push(opponents_unit.smooth_target(@target_index)) targets += targets elsif obj.for_one? # One enemy targets.push(opponents_unit.smooth_target(@target_index)) else # All enemies targets += opponents_unit.existing_members end elsif obj.for_user? # User targets.push(battler) elsif obj.for_dead_friend? if obj.for_one? # One ally (incapacitated) targets.push(friends_unit.smooth_dead_target(@target_index)) else # All allies (incapacitated) targets += friends_unit.dead_members end elsif obj.for_friend? if obj.for_one? # One ally targets.push(friends_unit.smooth_target(@target_index)) else # All allies targets += friends_unit.existing_members end end return targets.compact end end #=============================================================================== # # END OF FILE # #===============================================================================