Skill hotkeys in battle

piksalh

Veteran
Veteran
Joined
Jun 14, 2014
Messages
106
Reaction score
9
First Language
Lithuanian
Primarily Uses
RMMV
Hello!

There are hotkey scripts for action battle systems but what about vanilla battle system? Is there any way to select skill (there are only few of them in my game) with keyboard input instead going through battle menu? P.S.: my game is one player party game.

Example: 1. battle starts 2. player pushes keyboard button "P" 3. System selects skill#1 4. Player chooses target. 5. Happy end!

Any ideas how to do it?
 

piksalh

Veteran
Veteran
Joined
Jun 14, 2014
Messages
106
Reaction score
9
First Language
Lithuanian
Primarily Uses
RMMV
is it impossibru? :>
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,787
Reaction score
939
First Language
Chinese
Primarily Uses
N/A
How about Actor Personal Hotkeys by Riff?(even though the VXAN link seems to be dead)

################################################################################# ## ** Actor Personal Hotkeys by Riff ** ## ################################################################################################################################################################## ## ----------- ## ?Description ? ## ----------- ## ## This script provides implements hotkeys for each one of the actor in your ## party. You set the skills and item you want for your actor hotkeys bar from ## item menu and skill menu. ## Use skills and items from your hotkeys using the upper-row digits (from 1 ## up to 0). If an item/skill is unusable for any reason it is automatically ## disabled (plus a visual mark is placed upon their icons). ## You can set a switch to enable/disable the save option and the font used ## for the hotkeys index. ## ################################################################################################################################################################## ## ------------ ## ?Terms Of Use ? ## ------------ ## ## . You are free to use this script in both commercial and non-commercial ## games in whatever way that fits your needs. ## . You are free to edit this script in whatever way fits your needs. ## . No compatibility issue will be fixed. ## . For bug fixes or support, post at www.nerdynest.wordpress.com or at ## www.rpgmakervxace.net (questions explicitly answered in this header will ## be ignored). ## . For additionnal features requests, post at www.nerdynest.wordpress.com ## or at www.rpgmakervxace.net. However, note that you are not guaranteed ## to get it done(depending on the amount of work needed). ## . Full credits must be given to Riff. ## . You can repost this anywhere providing that credits are given ## accordingly. ## ################################################################################################################################################################## ## --------- ## ?Changelog ? ## --------- ## ## . 09/02/2013 ?Initial release ## ################################################################################################################################################################## ## ------------------------------- ## ?Concerning Compatibility issues ? ## ------------------------------- ## ## This script : ## + Modifies eight classes ## / Game_Actor ## / Scene_ItemBase ## / Scene_Item ## / Scene_Battle ## / Window_Selectable ## / Window_SkillList ## / Window_ItemList ## / Window_Help ## + Adds three new classes ## + Overwrites no method ## + Alias nine methods ## / setup (Game_Actor) ## / determine_item (Scene_ItemBase) ## / create_all_windows (Scene_Battle) ## / create_actor_command_window (Scene_Battle) ## / start_actor_command_window (Scene_Battle) ## / turn_start (Scene_Battle) ## / process_handling (Window_Selectable) ## / current_item_enabled? (Window_SkillList) ## / current_item_enabled? (Window_ItemList) ## + Modifies accessibility of two variables ## / attr_accessor :hotkeys (new ; Game_Actor) ## / attr_reader :category (Window_ItemList) ## + Uses too much new methods (56) ## ################################################################################################################################################################## ## ------------ ## ?Instructions ? ## ------------ ## ## + Pretty much plug & play. ## + You set the switch and the font you want to use just a bit below ## + If you want to change the icon used when an item/skill is unusable, ## follow those requirements : ## - 24x24 pixels ## - file named 'Stop' ## - file placed in your 'Pictures' folder ## #################################################################################($imported ||= {})['RIFF_HOTKEYS'] = truemodule RIFF module HOTKEYS ENABLE_SAVE = 1 # Write here the ID of the switch you're using to manage # access to 'Save' option. If false then no window will be # shown when attempting to use an item HOTKEYS_INDEX_FONT = 'VL Gothic Regular' # Font you want to be used for the # index of the hotkeys endend################################################################################################################################################################### DO NOT EDIT ANYTHING PAST THIS POINT ##################################################################################################################################################################### !Implementation of the bars! ###################################################################################################################################################################===============================================================================# ** Game_Actor#-------------------------------------------------------------------------------# Modified to handle personal hotkeys#===============================================================================class Game_Actor < Game_Battler attr_accessor :hotkeys alias :riff_hotkeys_setup :setup #----------------------------------------------------------------------------- # Add the hotkeys to actor's attributes #----------------------------------------------------------------------------- def setup(actor_id) riff_hotkeys_setup(actor_id) @hotkeys = Array.new(10) endend################################################################################################################################################################## !Scenes! ###################################################################################################################################################################===============================================================================# ** Scene_ItemBase#-------------------------------------------------------------------------------# Modified so that when trying to use an item/skill it will open a window# instead where you choose 'use' or 'save'.#===============================================================================class Scene_ItemBase < Scene_MenuBase alias :riff_hotkeys_determine_item :determine_item #----------------------------------------------------------------------------- # Modified so that if set switch is OFF the choice window won't pop up #----------------------------------------------------------------------------- def determine_item if $game_switches[RIFF::HOTKEYS::ENABLE_SAVE] process_hotkeys_command_window else riff_hotkeys_determine_item end end #----------------------------------------------------------------------------- # Called if set switch is ON # Open the choice window : Use is only selectable if item would normally be # usable. #----------------------------------------------------------------------------- def process_hotkeys_command_window @hotkeys_command_window = Window_Hotkeys_Command.new($game_party.usable?(item)) @hotkeys_command_window.x = Graphics.width - @hotkeys_command_window.width @hotkeys_command_window.y = Graphics.height - @hotkeys_command_window.height @hotkeys_command_window.z = 200 @hotkeys_command_window.set_handler:)use, method:)on_hotkeys_command_use)) @hotkeys_command_window.set_handler:)save, method:)on_hotkeys_command_save)) @hotkeys_command_window.set_handler:)cancel, method:)on_hotkeys_command_cancel)) end #----------------------------------------------------------------------------- # Called when choosing 'Use' in the choice window. # Close choice window and process item/skill use #----------------------------------------------------------------------------- def on_hotkeys_command_use @hotkeys_command_window.close if @hotkeys_command_window riff_hotkeys_determine_item end #----------------------------------------------------------------------------- # Called when escaping from choice window # Close choice window and activate item/skill list #----------------------------------------------------------------------------- def on_hotkeys_command_cancel @hotkeys_command_window.close if @hotkeys_command_window @item_window.activate end #----------------------------------------------------------------------------- # Called when choosing 'Save' from choice window # Close choice window and open hotkeys bar window #----------------------------------------------------------------------------- def on_hotkeys_command_save @hotkeys_command_window.close if @hotkeys_command_window @hotkeys_bar_window = Window_Hotkeys_Bar.new($game_party.menu_actor) @hotkeys_bar_window.x = (Graphics.width - @hotkeys_bar_window.width)/2 @hotkeys_bar_window.y = Graphics.height - 150 @hotkeys_bar_window.z = 200 @hotkeys_bar_window.set_handler:)ok, method:)save_on_hotkeys_window)) @hotkeys_bar_window.set_handler:)cancel, method:)cancel_on_hotkeys_window)) @hotkeys_bar_window.help_window = @help_window end #----------------------------------------------------------------------------- # Called after choosing a slot from hotkeys bar window # Call the method that process hotkeys modifications #----------------------------------------------------------------------------- def save_on_hotkeys_window save_item_as_hotkey($game_party.menu_actor, @item_window.item, @hotkeys_bar_window.index) end #----------------------------------------------------------------------------- # Called by save_on_hotkeys_window # Process hotkeys modifications #----------------------------------------------------------------------------- def save_item_as_hotkey(actor, item, index) actor.hotkeys[index] = item @hotkeys_bar_window.close if @hotkeys_bar_window @item_window.activate end #----------------------------------------------------------------------------- # Called when escaping from hotkeys bar window # Close hotkeys bar window and activate item/skill list #----------------------------------------------------------------------------- def cancel_on_hotkeys_window @hotkeys_bar_window.close if @hotkeys_bar_window @item_window.activate endend#===============================================================================# ** Scene_Item#-------------------------------------------------------------------------------# Modified because setting a hotkey requires to select an actor beforehand#===============================================================================class Scene_Item < Scene_ItemBase #----------------------------------------------------------------------------- # Called from Window_ItemList # Check that you're currently checking trying to use/save usable items #----------------------------------------------------------------------------- def save_enabled? return @item_window.category = :item end #----------------------------------------------------------------------------- # Called when choosing 'Save' from choice window # Open the actor selection window #----------------------------------------------------------------------------- def on_hotkeys_command_save @hotkeys_command_window.close if @hotkeys_command_window @hotkeys_actors_window = Window_Hotkeys_Actors.new @hotkeys_actors_window.x = (Graphics.width - @hotkeys_actors_window.width)/2 @hotkeys_actors_window.y = (Graphics.height - @hotkeys_actors_window.height)/2 @hotkeys_actors_window.z = 200 @hotkeys_actors_window.set_handler:)ok, method:)on_actor_selection_ok)) @hotkeys_actors_window.set_handler:)cancel, method:)on_actor_selection_cancel)) end #----------------------------------------------------------------------------- # Called after choosing an actor from the actor selection window # Store the actor choice and open the hotkeys bar window #----------------------------------------------------------------------------- def on_actor_selection_ok @hotkeys_actor = @hotkeys_actors_window.item @hotkeys_actors_window.close @hotkeys_bar_window = Window_Hotkeys_Bar.new(@hotkeys_actor) @hotkeys_bar_window.x = (Graphics.width - @hotkeys_bar_window.width)/2 @hotkeys_bar_window.y = Graphics.height - 150 @hotkeys_bar_window.z = 200 @hotkeys_bar_window.set_handler:)ok, method:)save_on_hotkeys_window)) @hotkeys_bar_window.set_handler:)cancel, method:)cancel_on_hotkeys_window)) @hotkeys_bar_window.help_window = @help_window end #----------------------------------------------------------------------------- # Called when escaping from actor selection window # Close actor selection window and activate item/skill list #----------------------------------------------------------------------------- def on_actor_selection_cancel @hotkeys_actors_window.close if @hotkeys_actors_window @item_window.activate end #----------------------------------------------------------------------------- # Called after choosing a slot from hotkeys bar window # Call the method that process hotkeys modifications #----------------------------------------------------------------------------- def save_on_hotkeys_window save_item_as_hotkey(@hotkeys_actor, @item_window.item, @hotkeys_bar_window.index) endend#===============================================================================# ** Scene_Battle#-------------------------------------------------------------------------------# Modified to show hotkeys bar of currently selected actor if its not empty and# make the upper-row digits effective#===============================================================================class Scene_Battle < Scene_Base alias :riff_hotkeys_create_all_windows :create_all_windows alias :riff_hotkeys_create_actor_command_window :create_actor_command_window alias :riff_hotkeys_start_actor_command_selection :start_actor_command_selection alias :riff_hotkeys_turn_start :turn_start #----------------------------------------------------------------------------- # Adds the creation of the hotkeys bar window #----------------------------------------------------------------------------- def create_all_windows riff_hotkeys_create_all_windows create_hotkeys_bar_window end #----------------------------------------------------------------------------- # Process the creation of hotkeys bar window #----------------------------------------------------------------------------- def create_hotkeys_bar_window @hotkeys_bar_window = Window_Hotkeys_BattleBar.new($game_party.battle_members[0]) @hotkeys_bar_window.x = (Graphics.width - @hotkeys_bar_window.width)/2 @hotkeys_bar_window.y = Graphics.height - (@actor_command_window.height + @hotkeys_bar_window.height) end #----------------------------------------------------------------------------- # Adds handlers for the upper-row digits #----------------------------------------------------------------------------- def create_actor_command_window riff_hotkeys_create_actor_command_window @actor_command_window.set_handler:)KEY_1, method:)process_KEY_1)) @actor_command_window.set_handler:)KEY_2, method:)process_KEY_2)) @actor_command_window.set_handler:)KEY_3, method:)process_KEY_3)) @actor_command_window.set_handler:)KEY_4, method:)process_KEY_4)) @actor_command_window.set_handler:)KEY_5, method:)process_KEY_5)) @actor_command_window.set_handler:)KEY_6, method:)process_KEY_6)) @actor_command_window.set_handler:)KEY_7, method:)process_KEY_7)) @actor_command_window.set_handler:)KEY_8, method:)process_KEY_8)) @actor_command_window.set_handler:)KEY_9, method:)process_KEY_9)) end #----------------------------------------------------------------------------- # Called after hotkey handler has been processed # Check that hotkeys are available and use item/skill if usable at the # moment and if not re-activate actor command window or party command window # depending on when did the player tried to use the hotkey #----------------------------------------------------------------------------- def call_hotkeys(hotkey_index) if @party_command_window.close? && @hotkeys_bar_window.visible == true @actor_command_window.deactivate actor = BattleManager.actor item = actor.hotkeys[hotkey_index] if item set_hotkey_action(item) else @actor_command_window.activate end else @party_command_window.activate end end #----------------------------------------------------------------------------- # All the hotkey processing methods (called from handlers) # Return the hotkey bar window index to a method that process hotkeys #----------------------------------------------------------------------------- def process_KEY_1 ; call_hotkeys(0); end def process_KEY_2 ; call_hotkeys(1); end def process_KEY_3 ; call_hotkeys(2); end def process_KEY_4 ; call_hotkeys(3); end def process_KEY_5 ; call_hotkeys(4); end def process_KEY_6 ; call_hotkeys(5); end def process_KEY_7 ; call_hotkeys(6); end def process_KEY_8 ; call_hotkeys(7); end def process_KEY_9 ; call_hotkeys(8); end def process_KEY_0 ; call_hotkeys(9); end #----------------------------------------------------------------------------- # Called by call_hotkeys # If item/skill usable then set it as the actor's action #----------------------------------------------------------------------------- def set_hotkey_action(item) if item.class == RPG::Skill @skill = item BattleManager.actor.input.set_skill(@skill.id) BattleManager.actor.last_skill.object = @skill if !@skill.need_selection? @skill_window.hide next_command elsif @skill.for_opponent? select_enemy_selection else select_actor_selection end elsif item.class == RPG::Item @item = item BattleManager.actor.input.set_item(@item.id) if !@item.need_selection? @item_window.hide next_command elsif @item.for_opponent? select_enemy_selection else select_actor_selection end $game_party.last_item.object = @item end end #----------------------------------------------------------------------------- # Refresh hotkeys bar window when changing active actor #----------------------------------------------------------------------------- def start_actor_command_selection riff_hotkeys_start_actor_command_selection @hotkeys_bar_window.setup(BattleManager.actor) end #----------------------------------------------------------------------------- # Hide hotkeys bar window when enemy turn begin #----------------------------------------------------------------------------- def turn_start @hotkeys_bar_window.hide riff_hotkeys_turn_start endend################################################################################################################################################################## !Windows! ###################################################################################################################################################################===============================================================================# ** Window_Selectable#-------------------------------------------------------------------------------# Modified to add handlers for the upper-row digits#===============================================================================class Window_Selectable < Window_Base alias :riff_hotkeys_process_handling :process_handling def process_handling riff_hotkeys_process_handling return call_handler:)KEY_1) if handle?:)KEY_1) && Input.trigger?:)KEY_1) return call_handler:)KEY_2) if handle?:)KEY_2) && Input.trigger?:)KEY_2) return call_handler:)KEY_3) if handle?:)KEY_3) && Input.trigger?:)KEY_3) return call_handler:)KEY_4) if handle?:)KEY_4) && Input.trigger?:)KEY_4) return call_handler:)KEY_5) if handle?:)KEY_5) && Input.trigger?:)KEY_5) return call_handler:)KEY_6) if handle?:)KEY_6) && Input.trigger?:)KEY_6) return call_handler:)KEY_7) if handle?:)KEY_7) && Input.trigger?:)KEY_7) return call_handler:)KEY_8) if handle?:)KEY_8) && Input.trigger?:)KEY_8) return call_handler:)KEY_9) if handle?:)KEY_9) && Input.trigger?:)KEY_9) return call_handler:)N0) if handle?:)N0) && Input.trigger?:)N0) endend#===============================================================================# ** Window_SkillList#-------------------------------------------------------------------------------# Modified so that even if skill isn't usable from menu you can hit enter on# it and save it as hotkeys.#===============================================================================class Window_SkillList < Window_Selectable alias :riff_hotkeys_current_item_enabled? :current_item_enabled? #----------------------------------------------------------------------------- # Check that the player is in Scene_Skill and that 'Save' option is enabled at # the current moment. #----------------------------------------------------------------------------- def current_item_enabled? return true if SceneManager.scene_is?(Scene_Skill) && $game_switches[RIFF::HOTKEYS::ENABLE_SAVE] return riff_hotkeys_current_item_enabled? endend#===============================================================================# ** Window_ItemList#-------------------------------------------------------------------------------# Modified so that even if item isn't usable from menu you can hit enter on it# and save it as hotey.#===============================================================================class Window_ItemList < Window_Selectable attr_reader :category alias :riff_hotkeys_current_item_enabled? :current_item_enabled? #----------------------------------------------------------------------------- # Check the current scene (must be Scene_Item), that 'Save' option is enabled # at the moment and that the item category is correct. #----------------------------------------------------------------------------- def current_item_enabled? return true if SceneManager.scene_is?(Scene_Item) && $game_switches[RIFF::HOTKEYS::ENABLE_SAVE] && SceneManager.scene.save_enabled? return riff_hotkeys_current_item_enabled? endend#===============================================================================# ** Window_Help#-------------------------------------------------------------------------------# Modified to add help when setting your hotkey bar#===============================================================================class Window_Help < Window_Base def set_item_help(item) item_text = "" if item item_text = "#{item.name}\n" if item.class == RPG::Skill if $game_party.menu_actor.skill_learn?(item) item_mp_cost = $game_party.menu_actor.skill_mp_cost(item) item_tp_cost = $game_party.menu_actor.skill_tp_cost(item) item_text += "MP cost : #{item_mp_cost} " if item_mp_cost > 0 item_text += "TP cost : #{item_tp_cost}" if item_tp_cost > 0 else item_text += 'Skill unknown to this character' end elsif item.class == RPG::Item item_text += $game_party.item_number(item) == 0 ? "Out of stock" : "Number : #{$game_party.item_number(item)}" end end set_text(item_text) endend#===============================================================================# ** Window_Hotkeys_Command#-------------------------------------------------------------------------------# New class that handles the choice window displaying 'Use' & 'Save'#===============================================================================class Window_Hotkeys_Command < Window_Command def initialize(x = 0, y = 0, item_enabled) @item_enabled = item_enabled super(x, y) end def make_command_list add_command('Use', :use, @item_enabled) add_command('Save', :save) endend#===============================================================================# ** Window_Hotkeys_Actors#-------------------------------------------------------------------------------# New class that handles actor selection window#===============================================================================class Window_Hotkeys_Actors < Window_Selectable def initialize super(0, 0, 220, 220) select(0) activate @data = $game_party.members refresh end def item_max return $game_party.members.size end def page_row_max return 2 end def col_max return 2 end def spacing return 5 end def item_width return 96 end def item_height return 96 end def item @data && index >= 0 ? @data[index] : nil end def draw_item(index) actor = @data[index] rect = item_rect(index) draw_actor_face(actor, rect.x, rect.y, true) endend#===============================================================================# ** Window_Hotkeys_Bar#-------------------------------------------------------------------------------# New class that handles the hotkeys bar window#===============================================================================class Window_Hotkeys_Bar < Window_Selectable def initialize(actor) super(0, 0, 282, 50) select(0) activate @data = actor.hotkeys @actor = actor refresh end def item_max return 10 end def col_max return 10 end def spacing return 2 end def item_width return 24 end def item_height return 24 end def row_max return 1 end def item @data && index >= 0 ? @data[index] : nil end def draw_item(index) item = @data[index] rect = item_rect(index) draw_item_icon(item.icon_index, rect.x, rect.y) if item draw_item_validity(item_valid?(item), rect.x, rect.y) if item draw_item_index(rect, index) end def draw_item_icon(icon_index, x, y, enabled = true) bitmap = Cache.system("Iconset") rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24) contents.blt(x, y, bitmap, rect, 255) end def draw_item_index(rect, index) rect.y += 6 contents.font = Font.new(RIFF::HOTKEYS::HOTKEYS_INDEX_FONT, 17) contents.font.out_color = Color.new(0, 0, 0, 255) contents.font.bold = true if index < 9 draw_text(rect, index + 1, 2) else draw_text(rect, 0, 2) end end def update_help @help_window.clear @help_window.set_item_help(item) end def draw_item_validity(item_validity, x, y) return if item_validity == true bitmap = Cache.picture('Stop') rect = Rect.new(0, 0, 24, 24) contents.blt(x, y, bitmap, rect, 255) end def item_valid?(item) if item.class == RPG::Item return $game_party.has_item?(item) elsif item.class == RPG::Skill return @actor.skill_learn?(item) end endend#===============================================================================# ** Window_Hotkeys_BattleBar#-------------------------------------------------------------------------------# New class that handles a declination of Window_Hotkeys_Bar for battle#===============================================================================class Window_Hotkeys_BattleBar < Window_Hotkeys_Bar def initialize(actor) super(actor) unselect self.deactivate self.opacity = 0 self.hide end def setup(actor) @data = actor.hotkeys refresh if contain_no_item?(@data) self.hide if self.visible == true else self.show if self.visible == false end end def contain_no_item?(hotkey_bar) hotkey_bar.each{ |item| return false if !item.nil?} endend
You'll also need a custom keymap script to actually let you use those hotkeys :)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,100
Reaction score
13,705
First Language
English
Primarily Uses
RMMV
I've moved this thread to RGSS3 Script Requests. Please be sure to post your threads in the correct forum next time. Thank you.
 

piksalh

Veteran
Veteran
Joined
Jun 14, 2014
Messages
106
Reaction score
9
First Language
Lithuanian
Primarily Uses
RMMV
Thank You for the answer! But the script does not work for me. I set switch 1 on but the special menu to use or save skill/item just never shows. It either uses item or does nothing. I tried script on clean version without any custom scripts. Do You know where is the problem?
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,787
Reaction score
939
First Language
Chinese
Primarily Uses
N/A
Thank You for the answer! But the script does not work for me. I set switch 1 on but the special menu to use or save skill/item just never shows. It either uses item or does nothing. I tried script on clean version without any custom scripts. Do You know where is the problem?
You may want to send me your project so I can inspect the issue further :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Are we allowed to post about non-RPG Maker games? And, if so, would any of you be interested in a short, proof of concept type non-euclidian puzzle game?
I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:

Forum statistics

Threads
105,883
Messages
1,017,232
Members
137,607
Latest member
Maddo
Top