Tsukihime 1,489 Posted August 19, 2012 (edited) Scope Change -Tsukihime This script extends the scope system by allowing you to dynamically change scopes. You can change a skill's scope from one target to all targets (toggling), or change the scope from enemies to allies (inverting). This applies to all items and skills. Usage By default, all skills and items cannot change scopes. To enable scope changing, tag them with <invert scope> <toggle scope> The default key settings are: L (keyboard Q): toggle key R (keyboard W): invert key Scope changing can occur during a battle, or in the item/skill scenes. Download Script: Download here Required: Tsuki Action Notes For scripters: this script directly accesses and changes the `scope` attribute in RPG::Skill and RPG::Item. This means that the scopes do not "reset" to their original settings across battles, and if you were to close the game and restart it, the scopes will revert to their original settings UNLESS you are using scripts to save the state of the $data_ variables (which you shouldn't be doing anyways). Edited August 16, 2016 by Tsukihime 1 Share this post Link to post Share on other sites
Whale 0 Posted August 19, 2012 Once again, wow, thanks for an awesome script. Share this post Link to post Share on other sites
Tammsyn 8 Posted August 22, 2012 (edited) ok i cant get this to work im using yami's 8d battle system http://yamiworld.wor...s/#comment-1558 well ok it does work (forgot the tags) but for some reason when i switch targets from ally to enemy it just gets a null result and when switching from single to all then it only highlights one actor or enemy but still apply the affect to all (just not visual in selection) Edited August 22, 2012 by Pheebes Share this post Link to post Share on other sites
Tsukihime 1,489 Posted August 22, 2012 (edited) The script depends on the battle system. I only wrote it for the default system. Different battle systems will need to modify their battle scene to correctly handle scope changing. Edited August 22, 2012 by Tsukihime Share this post Link to post Share on other sites
Sidbot 3 Posted August 23, 2012 This is so useful. It's good to have the classic Final Fantasy scope selection! Share this post Link to post Share on other sites
Tsukihime 1,489 Posted August 23, 2012 (edited) Ok it looks like the script is incompatible with yanfly's target manager, though I don't know why. Edited August 23, 2012 by Tsukihime Share this post Link to post Share on other sites
Tammsyn 8 Posted August 23, 2012 it does work wit the target select (its used in yamis battle system and they both work it seams Share this post Link to post Share on other sites
Coolie 148 Posted September 18, 2012 I have Target Manager and got no errors, although I wasn't able to toggle a skill to all enemies. I was still able to invert it to all allies though. Share this post Link to post Share on other sites
Kayzee 4,055 Posted September 18, 2012 Neato sweeto! I wonder if I could fiddle with this script to make scope changing grathnodes. Also I wonder if it's possible to make a scope function rather then setting the attribute... Share this post Link to post Share on other sites
Coolie 148 Posted September 18, 2012 ^ I would replace the default script with that since it should have been a default feature in the first place. Share this post Link to post Share on other sites
Tsukihime 1,489 Posted September 18, 2012 Neato sweeto! I wonder if I could fiddle with this script to make scope changing grathnodes. Also I wonder if it's possible to make a scope function rather then setting the attribute... Can you elaborate on what you mean by making it a function? When I was thinking about how to make the scope system more useful, I was thinking of specifying multiple scopes. This skill CAN hit one enemy. This skill CAN hit one ally. I might use something like a bit array, where 1 means "ally", 2 means "enemy", 4 means "one", 8 means "all", etc. Then you would just take different sums, so if your scope has value 5, that means you can target "one ally", and if your scope was 13, then you could target "one or all allies". Similarly, 1 + 2 + 4 = 7 means you can target "one ally or enemy", while 1+2+8 = 11 means you can target "all allies or enemies" And then finally, 1 + 2 + 4 + 8 = 15 means you can target one/all allies/enemies. So a single bit can be used to represent *how many* battlers you can target. What about the other bits? Well, you can have a flag for "dead" or "alive" or both. You can have another flag for "self". You still have a whole bunch of bits available for other purposes as well, such as conditional checks and whatnot. Rather than assign an integer to the scope and that's it, you assign an integer to the scope, and then run it through a bunch of methods to determine a list of valid targets. Share this post Link to post Share on other sites
Kayzee 4,055 Posted September 18, 2012 (edited) I mean something like module RPG class UsableItem def scope # return scope here end def scope=(value) # set scope here end end end I haven't had much luck doing that though, but I did fiddle around and make it set and reset the scope on the fly, as well as some other stuff: =begin #============================================================================== ** Scope Change Author: Tsukihime Date: Aug 18, 2012 ------------------------------------------------------------------------------ ** Change log Aug 18 - initial release ------------------------------------------------------------------------------ This script allows to you change the scope of your skills by pressing a key. It allows you to switch between "all" and "single", as well as switching between "ally" and "enemy". By default, skills or items cannot change scopes. To allow a skill/item to toggle scopes, tag it with <toggle scope> <invert scope> Then press the toggle key (Q) or invert key (W) during battle or in the item scene to change it. #============================================================================== =end $imported = {} if $imported.nil? $imported["Tsuki_ScopeChange"] = true #============================================================================== # ** Configuration #============================================================================== module Tsuki module Scope_Change # toggles between "one" and "all" Toggle_Key = :L Invert_Key = :R #============================================================================== # ** Rest of the script #============================================================================== # one <--> all Toggle_Map = { 1 => 2, 2 => 1, 7 => 8, 8 => 7, 9 => 10, 10 => 9 } # enemy <--> ally Invert_Map = { 1 => 7, 2 => 8, 7 => 1, 8 => 2 } Can_Toggle_Regex = /<toggle_scope|toggle scope>/i Can_Invert_Regex = /<invert_scope|invert scope>/i end end module RPG class UsableItem attr_reader :realscope def can_toggle_scope? return @can_toggle unless @can_toggle.nil? return @can_toggle = load_notetags_scope_toggle end def can_invert_scope? return @can_invert unless @can_invert.nil? return @can_invert = load_notetags_scope_invert end # "one" or "all" def toggle_scope if Tsuki::Scope_Change::Toggle_Map.include?(@scope) self.scope = Tsuki::Scope_Change::Toggle_Map[@scope] end end # "ally" or "enemy" def invert_scope if Tsuki::Scope_Change::Invert_Map.include?(@scope) self.scope = Tsuki::Scope_Change::Invert_Map[@scope] end end def scope=(value) @realscope = @scope if @realscope.nil? @scope = value puts(self.class.name + " id " + @id.to_s + " Scope set to " + @scope.to_s) end def reset_scope @scope = @realscope unless @realscope.nil? puts(self.class.name + " id " + @id.to_s + " Scope set to " + @scope.to_s) end # also include "all enemies" and "all allies" def need_selection? [1, 2, 7, 8, 9, 10].include?(@scope) end def load_notetags_scope_toggle return !Tsuki::Scope_Change::Can_Toggle_Regex.match(self.note).nil? end def load_notetags_scope_invert return !Tsuki::Scope_Change::Can_Invert_Regex.match(self.note).nil? end end end #------------------------------------------------------------------------------- # * Menu related scene/windows #------------------------------------------------------------------------------- class Window_MenuActor < Window_MenuStatus def process_handling return unless open? && active return process_scope_toggle if Input.trigger?(Tsuki::Scope_Change::Toggle_Key) && handle?(:toggle) return super end def process_scope_toggle Sound.play_cursor Input.update deactivate call_handler(:toggle) end end class Scene_ItemBase < Scene_MenuBase alias :th_scope_change_actor_window :create_actor_window def create_actor_window th_scope_change_actor_window @actor_window.set_handler(:toggle, method(:toggle_scope)) end alias_method :determine_item_scope_base, :determine_item def determine_item item.reset_scope if item determine_item_scope_base end def toggle_scope if item && item.can_toggle_scope? item.toggle_scope @actor_window.select_for_item(item) end @actor_window.activate end end #------------------------------------------------------------------------------- # * Battle related scene/windows #------------------------------------------------------------------------------- class Window_BattleEnemy < Window_Selectable def process_handling return unless open? && active return process_scope_toggle if Input.trigger?(Tsuki::Scope_Change::Toggle_Key) && handle?(:toggle) return process_scope_invert if Input.trigger?(Tsuki::Scope_Change::Invert_Key) && handle?(:invert) return super end def process_scope_toggle Sound.play_cursor Input.update deactivate call_handler(:toggle) create_flags if $imported["YEA-BattleEngine"] end def process_scope_invert Sound.play_cursor Input.update deactivate call_handler(:invert) create_flags if $imported["YEA-BattleEngine"] end end class Window_BattleActor < Window_BattleStatus def process_handling return unless open? && active return process_scope_toggle if Input.trigger?(Tsuki::Scope_Change::Toggle_Key) && handle?(:toggle) return process_scope_invert if Input.trigger?(Tsuki::Scope_Change::Invert_Key) && handle?(:invert) return super end def process_scope_toggle Sound.play_cursor Input.update deactivate call_handler(:toggle) create_flags if $imported["YEA-BattleEngine"] end def process_scope_invert Sound.play_cursor Input.update deactivate call_handler(:invert) create_flags if $imported["YEA-BattleEngine"] end end class Scene_Battle # set handler for scope changing alias :th_scope_change_create_actor_window :create_actor_window def create_actor_window th_scope_change_create_actor_window @actor_window.set_handler(:toggle, method(:toggle_actor_scope)) @actor_window.set_handler(:invert, method(:invert_actor_scope)) end alias :th_scope_change_create_enemy_window :create_enemy_window def create_enemy_window th_scope_change_create_enemy_window @enemy_window.set_handler(:toggle, method(:toggle_enemy_scope)) @enemy_window.set_handler(:invert, method(:invert_enemy_scope)) end # returns true if the skill/item targets all def select_all? BattleManager.actor.input.item.for_all? end # toggle related def toggle_scope if BattleManager.actor.input.item.can_toggle_scope? BattleManager.actor.input.item.toggle_scope end end def toggle_actor_scope toggle_scope select_actor_selection end def toggle_enemy_scope toggle_scope select_enemy_selection end def select_enemy_selection @enemy_window.cursor_all = select_all? @enemy_window.refresh @enemy_window.show.activate end def select_actor_selection @actor_window.cursor_all = select_all? @actor_window.refresh @actor_window.show.activate end # invert related def invert_actor_scope if BattleManager.actor.input.item.can_invert_scope? BattleManager.actor.input.item.invert_scope @actor_window.hide select_enemy_selection else select_actor_selection end end def invert_enemy_scope if BattleManager.actor.input.item.can_invert_scope? BattleManager.actor.input.item.invert_scope @enemy_window.hide select_actor_selection else select_enemy_selection end end def on_actor_ok BattleManager.actor.input.target_index = @actor_window.index @actor_window.hide @skill_window.hide @item_window.hide next_command end end class Game_Action def clear @item = Game_BaseItem.new @target_index = -1 @value = 0 @scope = nil end #-------------------------------------------------------------------------- # * Set Skill #-------------------------------------------------------------------------- def set_skill(skill_id) @item.object = $data_skills[skill_id] @item.object.reset_scope self end #-------------------------------------------------------------------------- # * Set Item #-------------------------------------------------------------------------- def set_item(item_id) @item.object = $data_items[item_id] @item.object.reset_scope self end def target_index=(value) @target_index = value @scope = @item.object.scope if @item end #-------------------------------------------------------------------------- # * Create Target Array #-------------------------------------------------------------------------- alias_method :make_targets_scope_base, :make_targets def make_targets @item.object.scope = @scope if @scope return make_targets_scope_base end end Edited September 18, 2012 by KilloZapit Share this post Link to post Share on other sites
Tsukihime 1,489 Posted September 29, 2012 Script now requires Tsuki Action. Scope is stored with the action and referenced from there. Just makes more sense. Share this post Link to post Share on other sites
Kayzee 4,055 Posted September 29, 2012 (edited) Tee-hee... did I inspire that change? Also, you may want to put the "need_selection?" methods in "if $imported["YEA-BattleEngine"]" blocks, but I am not sure how your scope scripts will react with YEA Battle Engine now... Maybe I will try and get it working for you? Edit: Man, it's pretty problematic getting YEA Battle Engine to work together with your scripts actualy... I think I have an idea though... Edited September 29, 2012 by KilloZapit Share this post Link to post Share on other sites
Tsukihime 1,489 Posted September 29, 2012 `need_selection?` is defined in RPG::UsableItem and is called as such whenever you select an skill/item. Share this post Link to post Share on other sites
Kayzee 4,055 Posted September 29, 2012 `need_selection?` is defined in RPG::UsableItem and is called as such whenever you select an skill/item. I know, I am just saying including all scopes in it makes some things act funny. Share this post Link to post Share on other sites
Tsukihime 1,489 Posted September 29, 2012 (edited) I know, I am just saying including all scopes in it makes some things act funny. Examples? Edited September 29, 2012 by Tsukihime Share this post Link to post Share on other sites
Kayzee 4,055 Posted September 29, 2012 (edited) I know, I am just saying including all scopes in it makes some things act funny. Examples? Well, mostly YEA Battle Engine assumes anything with 'need_selection?' is single target. Honestly YEA Battle Engine has lots of weird incompatibilities with your action script so it's probably not really worth fixing. Which is a shame cause I just got your target script to work with it Though given the way I do it is by overwriting item's scopes and resetting them later to fool other scripts. Also one thing I tried with the action script is storing the current action in game temp and having RPG::UsableItem return the action's attributes... I donno. Edited September 29, 2012 by KilloZapit Share this post Link to post Share on other sites
Tsukihime 1,489 Posted September 29, 2012 (edited) I think it's somewhat ok to assume that need_selection? implies single target, though I assumed it just meant "do I need to show the selection window?" since that's pretty much where it's used. My action script simply moves basically everything into the Action (and ActionScope), so unless yanfly is also modifying the action class it shouldn't be too difficult to work-around. The main issue is the fact that the @item stored in Game_Action is a Game_BaseItem object which automatically means you're fetching from the database. This is really what I was getting away from. If it was just an RPG::Skill or Item object then I could have easily cloned a copy from the database and life is good. Edited September 29, 2012 by Tsukihime Share this post Link to post Share on other sites
Kayzee 4,055 Posted September 29, 2012 (edited) I think it's somewhat ok to assume that need_selection? implies single target, though I assumed it just meant "do I need to show the selection window?" since that's pretty much where it's used. My action script simply moves basically everything into the Action (and ActionScope), so unless yanfly is also modifying the action class it shouldn't be too difficult to work-around. Well the main problem is you overwrite Scene_Battle.use_item... which wouldn't be a big of a deal if yanfly didn't have a bunch of stuff for other scripts there... that's the problem with breaking yanfly's scripts... it tends to break a lot of other scripts too. Honestly it's probably not that big of a deal. Incompatibilities come and go, and scripters just need to deal with um. Edited September 29, 2012 by KilloZapit Share this post Link to post Share on other sites
Tsukihime 1,489 Posted September 29, 2012 Well the main problem is you overwrite Scene_Battle.use_item... which wouldn't be a big of a deal if yanfly didn't have a bunch of stuff for other scripts there... that's the problem with breaking yanfly's scripts... it tends to break a lot of other scripts too. Honestly it's probably not that big of a deal. Incompatibilities come and go, and scripters just need to deal with um. What about just placing this script above all of yanfly's script? Yanfly shouldn't assume that the information is necessarily drawn from the item itself. Share this post Link to post Share on other sites
Kayzee 4,055 Posted September 29, 2012 (edited) Well the main problem is you overwrite Scene_Battle.use_item... which wouldn't be a big of a deal if yanfly didn't have a bunch of stuff for other scripts there... that's the problem with breaking yanfly's scripts... it tends to break a lot of other scripts too. Honestly it's probably not that big of a deal. Incompatibilities come and go, and scripters just need to deal with um. What about just placing this script above all of yanfly's script? Yanfly shouldn't assume that the information is necessarily drawn from the item itself. It does in the case of repeats and scope. Though really the scope thing is mostly cosmetic. The actual attack will have the correct scope regardless, it's only the targeting cursor that it stubborn about it. Edit: Oooh actually, you know what might be a good idea? Simply cloning the action item. Edited September 29, 2012 by KilloZapit Share this post Link to post Share on other sites
Tsukihime 1,489 Posted September 29, 2012 It does in the case of repeats and scope. Though really the scope thing is mostly cosmetic. I would just go through those methods and tell it to check the Game_Action, since I am just copying those values from the item into the action anyways. Share this post Link to post Share on other sites
Kayzee 4,055 Posted September 29, 2012 It does in the case of repeats and scope. Though really the scope thing is mostly cosmetic. I would just go through those methods and tell it to check the Game_Action, since I am just copying those values from the item into the action anyways. I could do that, I am always kind of afraid to copy code that might be updated elsewhere though. :/ Share this post Link to post Share on other sites