Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # * [ACE] Tool Cycler Addon for XAS ABS
- #===============================================================================
- # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
- # * Version: 1.2
- # * Updated: 18/05/2018
- # * Requires: XAS ABS
- #-------------------------------------------------------------------------------
- # * < Change Log >
- #-------------------------------------------------------------------------------
- # * Version 1.0 (30/09/2015)
- # - Initial release.
- # * Version 1.1 (14/10/2016)
- # - Fixed a typo that could have trigger crashes.
- # * Version 1.2 (18/05/2018)
- # - Fixed a crash issue with item cycling.
- #-------------------------------------------------------------------------------
- # * < 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 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.
- #-------------------------------------------------------------------------------
- # * < Note-Tags: >
- #-------------------------------------------------------------------------------
- # * If you want a tool to be skipped from the cycles, just tag them with
- # the following note-tag:
- #
- # Exclude From Tool Cycle
- #-------------------------------------------------------------------------------
- # * < Installation >
- #-------------------------------------------------------------------------------
- # * Place this scipt below the last script from XAS ABS script series
- # but above Main!
- #-------------------------------------------------------------------------------
- # * < 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 script at all in your game, you can set
- # this setting to 0, and it will be always enabled.
- #-----------------------------------------------------------------------------
- EnableSwitch = 88
- #-----------------------------------------------------------------------------
- # 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: [:tool_type,:cycle_dir] => button,
- #
- # :tool_type = This is the type of the tool you set the button up.
- # Can be: :weapon, :armor, :item, :item.
- # 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 a custom input/keyboard script.
- # The default buttons are detailed below.
- #
- # :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.
- #-----------------------------------------------------------------------------
- Cycles = {
- [:weapon,:prev] => :k1, # Previous weapon trigger.
- [:weapon,:next] => :k2, # Next weapon trigger.
- [:armor,:prev] => :k3, # Previous "shield" trigger (off-hand).
- [:armor,:next] => :k4, # Next "shield" trigger (off-hand).
- [:item,:prev] => :k5, # Previous item trigger.
- [:item,:next] => :k6, # Next item trigger.
- [:skill,:prev] => :k7, # Previous skill trigger.
- [:skill,:next] => :k8, # Next skill trigger.
- }
- #-----------------------------------------------------------------------------
- # 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).
- :item => RPG::SE.new("Evasion1",80,100), # For item tool.
- :skill => RPG::SE.new("Saint5",80,100), # For skill tool.
- }
- 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, :item => 0, :skill => 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 Cycle")
- }
- 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 Cycle")
- }
- 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 :item
- data = $game_party.items
- if !@item_id.nil? && @item_id > 0 && !data.include?($data_items[@item_id])
- data.insert(@cycleskill[:item] || 0, $data_items[@item_id])
- end
- data.delete_if {|it| it.note.include?("Exclude From Tool Cycle")}
- max = data.size
- return if max == 0
- return if max <= 1 && !@item_id.nil? && @item_id > 0
- $game_system.disable_item_pop = true
- @cycleskill[:item] = data.index($data_items[@item_id]) if !@item_id.nil? && @item_id > 0
- cycle_tool_vars(type,dir,max)
- @item_id = data[@cycleskill[:item]].id
- ToolCycler::SoundEffects[type].play if !ToolCycler::SoundEffects[type].nil?
- $game_system.disable_item_pop = false
- when :skill
- data = skills
- data.delete_if {|it| it.note.include?("Exclude From Tool Cycle")}
- max = data.size
- return if max == 0
- return if max <= 1 && !@skill_id.nil? && @skill_id > 0
- @cycleskill[:skill] = data.index($data_skills[@skill_id]) if !@skill_id.nil? && @skill_id > 0
- cycle_tool_vars(type,dir,max)
- @skill_id = data[@cycleskill[:skill]].id
- 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 Input.trigger?(button)
- end
- end
- add_cycling_tools7732
- end
- end
- #==============================================================================
- # !!END OF SCRIPT - OHH, NOES!!
- #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement