Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # * [ACE] Tool Cycler Addon for Falcao's Pearl ABS Liquid v3
- #===============================================================================
- # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
- # * Version: 1.2
- # * Updated: 18/10/2015
- # * Requires: Falcao's Pearl ABS Liquid v3
- #-------------------------------------------------------------------------------
- # * < Change Log >
- #-------------------------------------------------------------------------------
- # * Version 1.0 (29/09/2015)
- # - Initial release.
- # * Version 1.1 (30/09/2015)
- # - Fixed cycling errors when there are more weapon or armor tools of the same
- # kind in the inventory.
- # * Version 1.2 (18/10/2015)
- # - Added the possibility to require 2 buttons for the tool cycle triggers.
- # You can set it up so that the player needs to hold down one button and
- # press another one to change the tools.
- #-------------------------------------------------------------------------------
- # * < Description >
- #-------------------------------------------------------------------------------
- # * This script will allow you to implement button triggers which will cycle
- # through the available tools when they are used.
- # * You can set up cycle tool buttons for every tool slot.
- # * Previous and next tool buttons are both available, and both are optional.
- # * You can either use the default input methods for button checks, or the one
- # that Falcao provided with the ABS script, or you can use buttons from a
- # custom input/keyboard script as well (if it uses the Input.trigger?(button)
- # check, that is).
- # * Enable/disable the script during the game anytime.
- # * Automatic "anti-duplicate tool" feature, so it will prevent the player to
- # equip the same tool on different slots at the same time.
- #-------------------------------------------------------------------------------
- # * < Installation >
- #-------------------------------------------------------------------------------
- # * Place this scipt below the last script from Falcao's Pearl ABS Liquid v3
- # script series but above Main!
- # * You can do an optional edit in the "Pearl Item Pop Up" script. This edit
- # will prevent the item gain popup when you change your tools with the cycle
- # buttons. It's kinda annoying and looks bad to see that popup everytime the
- # player changes an equipped tool.
- #
- # Anyway, here is what you need to do:
- # Right at the start, after the settings part, you will see this method:
- #
- #~ alias falcaopearl_itempop_gain gain_item
- #~ def gain_item(item, amount, include_equip = false)
- #~ if !item_container(item.class).nil? && SceneManager.scene_is?(Scene_Map)
- #~ if amount > 0
- #~ $game_system.item_object = [item, amount]
- #~ RPG::SE.new(PearlItemPop::ItemSe, 80).play rescue nil
- #~ end
- #~ end
- #~ falcaopearl_itempop_gain(item, amount, include_equip = false)
- #~ end
- #
- # Replace that whole definition with the one below:
- #
- #~ alias falcaopearl_itempop_gain gain_item
- #~ def gain_item(item, amount, include_equip = false)
- #~ unless $game_system.disable_item_pop == true
- #~ if !item_container(item.class).nil? && SceneManager.scene_is?(Scene_Map)
- #~ if amount > 0
- #~ $game_system.item_object = [item, amount]
- #~ RPG::SE.new(PearlItemPop::ItemSe, 80).play rescue nil
- #~ end
- #~ end
- #~ end
- #~ falcaopearl_itempop_gain(item, amount, include_equip = false)
- #~ end
- #
- # I couldn't just overwrite it, because that would make compatibility issues
- # with many scripts, and I could not alias it in any way, because the popup
- # mechanic is already in it, so that would be called no matter how I alias it.
- #
- # Simply copy the above method, and paste it over the old method, deleting
- # the old one in the process. After this, select the copied method and press
- # CTRL+Q while it's highlighted to remove the comment sings from it.
- # Do NOT remove the comment signs from this header!
- #
- # I hope this little copy/paste job won't be hard to do for anyone. :P
- #-------------------------------------------------------------------------------
- # * < Compatibility Info >
- #-------------------------------------------------------------------------------
- # * No known incompatibilities.
- #-------------------------------------------------------------------------------
- # * < Known Issues >
- #-------------------------------------------------------------------------------
- # * No known issues.
- #-------------------------------------------------------------------------------
- # * < Terms of Use >
- #-------------------------------------------------------------------------------
- # * Free to use for whatever purposes you want.
- # * Credit me (Sixth) in your game, pretty please! :P
- # * Posting modified versions of this script is allowed as long as you notice me
- # about it with a link to it!
- #===============================================================================
- $imported = {} if $imported.nil?
- $imported["SixthABSToolCycler"] = true
- #===============================================================================
- # Settings:
- #===============================================================================
- module ToolCycler
- #-----------------------------------------------------------------------------
- # Enable Switch Settings:
- #-----------------------------------------------------------------------------
- # You can enable/disable the script with the switch you set up here.
- # If the switch is turned ON, the script is enabled, if it is OFF, the script
- # is disabled.
- # If you don't want to disable this scrpt at all in your game, you can set
- # this setting to 0, and it will be always enabled.
- #-----------------------------------------------------------------------------
- EnableSwitch = 88
- #-----------------------------------------------------------------------------
- # Input Type Settings:
- #-----------------------------------------------------------------------------
- # You can choose which input type you want to use here.
- # ---- Type 1. ---------------------------------------------------------------
- # :pearl = This is the keyboard input type Falcao provided with the ABS.
- # If you chose this, you will need to use his input buttons for the
- # 'Cycles' settings below (PearlKey::Letter).
- # ---- Type 2. ---------------------------------------------------------------
- # :default = This is the default input type for the VX Ace engine.
- # If you chose this, you will need to use the default input buttons
- # for the 'Cycles' settings below. The default buttons are:
- # :DOWN, :LEFT, :RIGHT, :UP - direction keys. These are used for player
- # movement by default, so it's not a good idea
- # to use them here.
- # :F5, :F6, :F7, :F8, :ALT - Feel free to use any of these keys, they do
- # nothing by default.
- # They are pretty self explanatory.
- # :A - This is the Shift on the keyboard and is the Dash feature by defaut.
- # If you are using this button for dashing, don't use it here.
- # :X - This is the A key on the keyboard and does nothing by default.
- # :Y - This is the S key on the keyboard and does nothing by default.
- # :Z - This is the D key on the keyboard and does nothing by default.
- # :L - This is the Q or Page Up key on the keyboard.
- # Does nothing by default.
- # :R - This is the W or Page Down key on the keyboard.
- # Does nothing by default.
- #-----------------------------------------------------------------------------
- InputType = :pearl # :pearl or :default
- #-----------------------------------------------------------------------------
- # Tool Cycle Button Settings:
- #-----------------------------------------------------------------------------
- # This is where you set up your tool cycling buttons.
- # Note that any setting here is optional!
- # Simply comment out the ones you don't need and remove the comment signs
- # from the ones you need.
- #
- # Format 1 : [:tool_type,:cycle_dir] => button,
- # This format is for single button press triggers.
- #
- # Format 2 : [:tool_type,:cycle_dir] => [hold_button,button],
- # This format is for the new 2 buttons triggers. Using this, the player
- # would need to hold down the 1st button entered and press the 2nd button
- # while holding down the 1st button to change the tool.
- #
- # You can use both format if you want.
- #
- # :tool_type = This is the type of the tool you set the button up.
- # Can be: :weapon, :armor, :item1, :item2,
- # :skill1, :skill2, :skill3, :skill4.
- # Should be obvious what these mean.
- # :cycle_dir = The direction of cycling. Can be: :prev or :next.
- # :prev will switch to the previous tool on the list while
- # :next will switch to the next tool on the list.
- # button = This can be one of the default VX Ace engine button symbols, or
- # a keyboard button from Falcao's PearlKey input module.
- # The default buttons are detailed above, for Pearl buttons refer to
- # the Pearl Kernel script of the ABS scripts.
- # The 'InputType' setting will determine which type of buttons you
- # can use here.
- # In case yoou are using another input module which uses the
- # Input.trigger?(button) method, you are free to use the buttons from
- # that script as well, just make sure to set the 'InputType' setting
- # above to :default.
- # hold_button = Same as above, a button setting. This is only used for the 2
- # buttons triggers. This is the button the player would need
- # to hold down.
- #-----------------------------------------------------------------------------
- Cycles = {
- [:weapon,:prev] => [PearlKey::Q,PearlKey::N1], # Previous weapon trigger.
- [:weapon,:next] => [PearlKey::Q,PearlKey::N2], # Next weapon trigger.
- [:armor,:prev] => PearlKey::N3, # Previous "shield" trigger (off-hand).
- [:armor,:next] => PearlKey::N4, # Next "shield" trigger (off-hand).
- [:item1,:prev] => PearlKey::N5, # Previous item trigger (1st slot).
- [:item1,:next] => PearlKey::N6, # Next item trigger (1st slot).
- [:item2,:prev] => PearlKey::N7, # Previous item trigger (2nd slot).
- [:item2,:next] => PearlKey::N8, # Next item trigger (2nd slot).
- [:skill1,:prev] => PearlKey::N9, # Previous skill trigger (1st slot).
- [:skill1,:next] => PearlKey::N0, # Next skill trigger (1st slot).
- #[:skill2,:prev] => PearlKey::N9, # Previous skill trigger (2nd slot).
- #[:skill2,:next] => PearlKey::N0, # Next skill trigger (2nd slot).
- #[:skill3,:prev] => PearlKey::N9, # Previous skill trigger (3rd slot).
- #[:skill3,:next] => PearlKey::N0, # Next skill trigger (3rd slot).
- #[:skill4,:prev] => PearlKey::N9, # Previous skill trigger (4th slot).
- #[:skill4,:next] => PearlKey::N0, # Next skill trigger (4th slot).
- }
- #-----------------------------------------------------------------------------
- # Sound Effect Settings:
- #-----------------------------------------------------------------------------
- # Each time you switch a toool with a tool cycle button, a sound effect will
- # be played. You can set up a sound effect for each tool type here.
- #
- # Format: :tool_type => RPG::SE.new("file name",volume,pitch)
- #
- # "file name" = The name of the audio file to be played.
- # The file must be in the game's Audio\SE folder!
- # volume = The volume of the sound effect.
- # pitch = The pitch level of the sound effect.
- #
- # You can set them to nil if you don't want any SE to be played when switching.
- #-----------------------------------------------------------------------------
- SoundEffects = {
- :weapon => RPG::SE.new("Sword4",80,100), # For weapon tool.
- :armor => RPG::SE.new("Equip1",80,100), # For shield tool (off hand).
- :item1 => RPG::SE.new("Evasion1",80,100), # For item tool (slot 1).
- :item2 => RPG::SE.new("Evasion1",80,100), # For item tool (slot 2).
- :skill1 => RPG::SE.new("Saint5",80,100), # For skill tool (slot 1).
- :skill2 => RPG::SE.new("Saint5",80,100), # For skill tool (slot 2).
- :skill3 => RPG::SE.new("Saint5",80,100), # For skill tool (slot 3).
- :skill4 => RPG::SE.new("Saint5",80,100), # For skill tool (slot 4).
- }
- end
- #===============================================================================
- # End of settings! O.o
- #===============================================================================
- class Game_Actor < Game_Battler
- alias add_cycling_tools5541 setup
- def setup(actor_id)
- @cycleskill = {
- :weapon => 0, :armor => 0, :item1 => 0, :item2 => 0,
- :skill1 => 0, :skill2 => 0, :skill3 => 0, :skill4 => 0,
- }
- add_cycling_tools5541(actor_id)
- end
- def cycle_tool(type,dir)
- dir = dir == :prev ? -1 : 1
- case type
- when :weapon
- data = $game_party.weapons_unsorted.select {|wp|
- equippable?(wp) && !wp.note.include?("Exclude From Tool Menu = true")
- }
- data << equips[0] if !equips[0].nil? && !data.include?(equips[0])
- max = data.size
- return if max <= 1
- data = data.sort_by {|item| item.id }
- $game_system.disable_item_pop = true
- @cycleskill[:weapon] = data.index(equips[0]) if !equips[0].nil?
- cycle_tool_vars(type,dir,max)
- change_equip_by_id(0, data[@cycleskill[:weapon]].id)
- ToolCycler::SoundEffects[type].play if !ToolCycler::SoundEffects[type].nil?
- $game_system.disable_item_pop = false
- when :armor
- data = $game_party.armors_unsorted.select {|ar|
- equippable?(ar) && ar.etype_id == 1 &&
- !ar.note.include?("Exclude From Tool Menu = true")
- }
- data << equips[1] if !equips[1].nil? && !data.include?(equips[1])
- max = data.size
- return if max <= 1
- data = data.sort_by {|item| item.id }
- $game_system.disable_item_pop = true
- @cycleskill[:armor] = data.index(equips[1]) if !equips[1].nil?
- cycle_tool_vars(type,dir,max)
- change_equip_by_id(1, data[@cycleskill[:armor]].id)
- ToolCycler::SoundEffects[type].play if !ToolCycler::SoundEffects[type].nil?
- $game_system.disable_item_pop = false
- when :item1
- data = $game_party.items
- data.delete_if {|it| it.note.include?("Exclude From Tool Menu = true")}
- data.delete(@assigned_item2) if !@assigned_item2.nil?
- max = data.size
- return if max == 0
- return if max <= 1 && !@assigned_item.nil?
- $game_system.disable_item_pop = true
- @cycleskill[:item1] = data.index(@assigned_item) if !@assigned_item.nil?
- cycle_tool_vars(type,dir,max)
- @assigned_item = data[@cycleskill[:item1]]
- ToolCycler::SoundEffects[type].play if !ToolCycler::SoundEffects[type].nil?
- $game_system.disable_item_pop = false
- when :item2
- data = $game_party.items
- data.delete_if {|it| it.note.include?("Exclude From Tool Menu = true")}
- data.delete(@assigned_item) if !@assigned_item.nil?
- max = data.size
- return if max == 0
- return if max <= 1 && !@assigned_item2.nil?
- $game_system.disable_item_pop = true
- @cycleskill[:item2] = data.index(@assigned_item2) if !@assigned_item2.nil?
- cycle_tool_vars(type,dir,max)
- @assigned_item2 = data[@cycleskill[:item2]]
- ToolCycler::SoundEffects[type].play if !ToolCycler::SoundEffects[type].nil?
- $game_system.disable_item_pop = false
- when :skill1
- data = skills
- data.delete_if {|it| it.note.include?("Exclude From Tool Menu = ")}
- data.delete(@assigned_skill2) if !@assigned_skill2.nil?
- data.delete(@assigned_skill3) if !@assigned_skill3.nil?
- data.delete(@assigned_skill4) if !@assigned_skill4.nil?
- max = data.size
- return if max == 0
- return if max <= 1 && !@assigned_skill.nil?
- @cycleskill[:skill1] = data.index(@assigned_skill) if !@assigned_skill.nil?
- cycle_tool_vars(type,dir,max)
- @assigned_skill = data[@cycleskill[:skill1]]
- ToolCycler::SoundEffects[type].play if !ToolCycler::SoundEffects[type].nil?
- when :skill2
- data = skills
- data.delete_if {|it| it.note.include?("Exclude From Tool Menu = true")}
- data.delete(@assigned_skill) if !@assigned_skill.nil?
- data.delete(@assigned_skill3) if !@assigned_skill3.nil?
- data.delete(@assigned_skill4) if !@assigned_skill4.nil?
- max = data.size
- return if max == 0
- return if max <= 1 && !@assigned_skill2.nil?
- @cycleskill[:skill2] = data.index(@assigned_skill2) if !@assigned_skill2.nil?
- cycle_tool_vars(type,dir,max)
- @assigned_skill2 = data[@cycleskill[:skill2]]
- ToolCycler::SoundEffects[type].play if !ToolCycler::SoundEffects[type].nil?
- when :skill3
- data = skills
- data.delete_if {|it| it.note.include?("Exclude From Tool Menu = true")}
- data.delete(@assigned_skill2) if !@assigned_skill2.nil?
- data.delete(@assigned_skill) if !@assigned_skill.nil?
- data.delete(@assigned_skill4) if !@assigned_skill4.nil?
- max = data.size
- return if max == 0
- return if max <= 1 && !@assigned_skill3.nil?
- @cycleskill[:skill3] = data.index(@assigned_skill3) if !@assigned_skill3.nil?
- cycle_tool_vars(type,dir,max)
- @assigned_skill3 = data[@cycleskill[:skill3]]
- ToolCycler::SoundEffects[type].play if !ToolCycler::SoundEffects[type].nil?
- when :skill4
- data = skills
- data.delete_if {|it| it.note.include?("Exclude From Tool Menu = true")}
- data.delete(@assigned_skill2) if !@assigned_skill2.nil?
- data.delete(@assigned_skill3) if !@assigned_skill3.nil?
- data.delete(@assigned_skill) if !@assigned_skill.nil?
- max = data.size
- return if max == 0
- return if max <= 1 && !@assigned_skill4.nil?
- @cycleskill[:skill4] = data.index(@assigned_skill4) if !@assigned_skill4.nil?
- cycle_tool_vars(type,dir,max)
- @assigned_skill4 = data[@cycleskill[:skill4]]
- ToolCycler::SoundEffects[type].play if !ToolCycler::SoundEffects[type].nil?
- end
- end
- def cycle_tool_vars(type,dir,max)
- @cycleskill[type] += dir
- @cycleskill[type] = 0 if @cycleskill[type] >= max && dir == 1
- @cycleskill[type] = max - 1 if @cycleskill[type] < 0 && dir == -1
- end
- end
- class Game_Party < Game_Unit
- def weapons_unsorted
- @weapons.keys.collect {|id| $data_weapons[id] }
- end
- def armors_unsorted
- @armors.keys.collect {|id| $data_armors[id] }
- end
- end
- class Game_System
- attr_accessor :disable_item_pop
- alias disable_pop_switch9974 initialize
- def initialize
- @disable_item_pop = false
- disable_pop_switch9974
- end
- end
- class Scene_Map < Scene_Base
- alias add_cycling_tools7732 update
- def update
- if (ToolCycler::EnableSwitch == 0 || $game_switches[ToolCycler::EnableSwitch])&&
- !$game_message.busy? && !$game_map.interpreter.running?
- ToolCycler::Cycles.each do |key,button|
- $game_party.members[0].cycle_tool(key[0],key[1]) if tool_cycle_trigger?(button)
- end
- end
- add_cycling_tools7732
- end
- def tool_cycle_trigger?(button)
- case ToolCycler::InputType
- when :pearl
- if button.is_a?(Array)
- return PearlKey.press?(button[0]) && PearlKey.trigger?(button[1])
- else
- return PearlKey.trigger?(button)
- end
- when :default
- if button.is_a?(Array)
- return Input.press?(button[0]) && Input.trigger?(button[1])
- else
- return Input.trigger?(button)
- end
- end
- end
- end
- #==============================================================================
- # !!END OF SCRIPT - OHH, NOES!!
- #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement