+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker XP (RGSS) Engine (https://www.save-point.org/forum-116.html)
+---- Thread: Custom Commands (/thread-2453.html)
Custom Commands - Dargor - 03-07-2008
Custom Commands by Dargor Version 1.9
Introduction
I'll start posting all my VX scripts here, and I'll start with this one!
This scripting tool deals with general commands such as Menu, Party and Actor commands.
It helps modifying these commands without having to worry about their index in the window.
NEW: Version 1.5 supports commands substitution based on actor's class ID.
Search for
Code:
class RPG::Class
and edit the @commands array.
IMPORTANT: READ THE NOTES BELOW!
Features
Supports Menu, Title, Party and Actor Commands
Commands are now 'String Based' (Instead of 'Index Based')
Add/remove any commands of any windows at any index
Support for commands substitutes (based on an actor class ID)
Comes with a template for Custom Battle Commands!
Script
Read the script comments carefully before using this it!
module Custom_Commands
# Maximum number of commands visible at the same time in the
# command windows
Menu_Item_Max = 6
Party_Item_Max = 4
Actor_Item_Max = 4
Title_Item_Max = 4
end
#==============================================================================
# ** RPG::Class
#------------------------------------------------------------------------------
# This class handles actors classes.
#==============================================================================
class RPG::Class
#--------------------------------------------------------------------------
# * Command Name
# Returns a substitute to command_name.
# Returns the original command name if no substitues are found.
# command_name : command name
#--------------------------------------------------------------------------
def command_name(command)
# Commands Substitution Array
@commands = []
# SYNTAX: @commands[class_ID] = { original_command => substitute }
@commands[1] = {
Vocab::attack => 'Strike',
Vocab::item => 'Things',
}
@commands[2] = {
Vocab::guard => 'Protect',
Vocab::item => 'Stuff',
}
# Get command substitute
if @commands[@id].nil? or @commands[@id][command].nil?
return command
end
return @commands[@id][command]
end
end
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles system-related data. Also manages vehicles and BGM, etc.
# The instance of this class is referenced by $game_system.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :menu_commands
attr_accessor :party_commands
attr_accessor :title_commands
attr_accessor :disabled_menu_commands
attr_accessor :disabled_party_commands
attr_accessor :disabled_title_commands
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias dargor_vx_cmc_system_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
dargor_vx_cmc_system_initialize
@disabled_menu_commands = {}
@disabled_party_commands = {}
@disabled_title_commands = {}
s1 = Vocab::item
s2 = Vocab::skill
s3 = Vocab::equip
s4 = Vocab::status
s5 = Vocab::save
s6 = Vocab::game_end
@menu_commands = []
add_menu_command(0,[s1, s2, s3, s4, s5, s6])
s1 = Vocab::fight
s2 = Vocab::escape
@party_commands = []
add_party_command(0,[s1, s2])
s1 = Vocab::new_game
s2 = Vocab::continue
s3 = Vocab::shutdown
@title_commands = []
add_title_command(0,[s1, s2, s3])
end
#--------------------------------------------------------------------------
# * Add Menu Command
#--------------------------------------------------------------------------
def add_menu_command(index, command)
return if @menu_commands.include?(command)
if command.is_a?(String)
@menu_commands.insert(index, command)
@disabled_menu_commands[command] = false
elsif command.is_a?(Array)
for i in 0...command.size
@menu_commands.insert(index+i, command[i])
@disabled_menu_commands[command[i]] = false
end
end
end
#--------------------------------------------------------------------------
# * Add Party Command
#--------------------------------------------------------------------------
def add_party_command(index, command)
return if @party_commands.include?(command)
if command.is_a?(String)
@party_commands.insert(index, command)
@disabled_party_commands[command] = false
elsif command.is_a?(Array)
for i in 0...command.size
@party_commands.insert(index+i, command[i])
@disabled_party_commands[command[i]] = false
end
end
end
#--------------------------------------------------------------------------
# * Add Title Command
#--------------------------------------------------------------------------
def add_title_command(index, command)
return if @title_commands.include?(command)
if command.is_a?(String)
@title_commands.insert(index, command)
@disabled_party_commands[command] = false
elsif command.is_a?(Array)
for i in 0...command.size
@title_commands.insert(index+i, command[i])
@disabled_title_commands[command[i]] = false
end
end
end
#--------------------------------------------------------------------------
# * Remove Menu Command
#--------------------------------------------------------------------------
def remove_menu_command(command)
if command.is_a?(String)
@menu_commands.delete(command)
elsif command.is_a?(Array)
for i in command
@menu_commands.delete(i)
end
end
end
#--------------------------------------------------------------------------
# * Remove Party Command
#--------------------------------------------------------------------------
def remove_party_command(command)
if command.is_a?(String)
@party_commands.delete(command)
elsif command.is_a?(Array)
for i in command
@party_commands.delete(i)
end
end
end
#--------------------------------------------------------------------------
# * Remove Title Command
#--------------------------------------------------------------------------
def remove_title_command(command)
if command.is_a?(String)
@title_commands.delete(command)
elsif command.is_a?(Array)
for i in command
@party_commands.delete(i)
end
end
end
#--------------------------------------------------------------------------
# * Add Menu Command
#--------------------------------------------------------------------------
def enable_menu_command(command)
@disabled_menu_commands[command] = false
end
#--------------------------------------------------------------------------
# * Add Party Command
#--------------------------------------------------------------------------
def enable_party_command(command)
@disabled_party_commands[command] = false
end
#--------------------------------------------------------------------------
# * Add Title Command
#--------------------------------------------------------------------------
def enable_title_command(command)
@disabled_title_commands[command] = false
end
#--------------------------------------------------------------------------
# * Add Menu Command
#--------------------------------------------------------------------------
def disable_menu_command(command)
@disabled_menu_commands[command] = true
end
#--------------------------------------------------------------------------
# * Add Party Command
#--------------------------------------------------------------------------
def disable_party_command(command)
@disabled_party_commands[command] = true
end
#--------------------------------------------------------------------------
# * Add Title Command
#--------------------------------------------------------------------------
def disable_title_command(command)
@disabled_title_commands[command] = true
end
#--------------------------------------------------------------------------
# * Add Menu Command
#--------------------------------------------------------------------------
def menu_command_disabled?(command)
return @disabled_menu_commands[command]
end
#--------------------------------------------------------------------------
# * Add Party Command
#--------------------------------------------------------------------------
def party_command_disabled?(command)
return @disabled_party_commands[command]
end
#--------------------------------------------------------------------------
# * Add Title Command
#--------------------------------------------------------------------------
def title_command_disabled?(command)
return @disabled_title_commands[command]
end
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles actors. It's used within the Game_Actors class
# ($game_actors) and referenced by the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :commands # battle commands
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
alias dargor_vx_battle_commands_actor_setup setup
#--------------------------------------------------------------------------
# * Setup
# actor_id : actor ID
#--------------------------------------------------------------------------
def setup(actor_id)
dargor_vx_battle_commands_actor_setup(actor_id)
actor = $data_actors[actor_id]
s1 = self.class.command_name(Vocab::attack)
s2 = self.class.command_name(Vocab::skill)
s3 = self.class.command_name(Vocab::guard)
s4 = self.class.command_name(Vocab::item)
if self.class.skill_name_valid # Skill command name is valid?
s2 = self.class.skill_name # Replace command name
end
@commands = [s1, s2, s3, s4]
end
#--------------------------------------------------------------------------
# * Add Command
#--------------------------------------------------------------------------
def add_command(index, command)
return if @commands.include?(command)
if command.is_a?(String)
@commands.insert(index, command)
elsif command.is_a?(Array)
for i in 0...command.size
@commands.insert(index+i, command[i])
end
end
end
#--------------------------------------------------------------------------
# * Remove Command
#--------------------------------------------------------------------------
def remove_command(command)
if command.is_a?(String)
@commands.delete(command)
elsif command.is_a?(Array)
for i in command
@commands.delete(i)
end
end
end
end
#==============================================================================
# ** Window_Selectable
#------------------------------------------------------------------------------
# This window contains cursor movement and scroll functions.
#==============================================================================
class Window_Selectable < Window_Base
#--------------------------------------------------------------------------
# * Selection
#--------------------------------------------------------------------------
def selection
return @commands[self.index]
end
end
#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
# This window deals with general command choices.
#==============================================================================
class Window_Command < Window_Selectable
alias dargor_vx_cmc_window_command_draw_item draw_item
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# enabled : enabled flag. When false, draw semi-transparently.
#--------------------------------------------------------------------------
def draw_item(index, enabled = true)
return if index.nil?
dargor_vx_cmc_window_command_draw_item(index, enabled)
end
end
#==============================================================================
# ** Window_PartyCommand
#------------------------------------------------------------------------------
# This window is used to select whether to fight or escape on the battle
# screen.
#==============================================================================
#==============================================================================
# ** Window_ActorCommand
#------------------------------------------------------------------------------
# This window is used to select actor commands, such as "Attack" or "Skill".
#==============================================================================
class Window_ActorCommand < Window_Command
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(128, [], 1, 4)
self.active = false
end
#--------------------------------------------------------------------------
# * Setup
# actor : actor
#--------------------------------------------------------------------------
def setup(actor)
@commands = actor.commands
@item_max = @commands.size
height = 8 + Custom_Commands::Actor_Item_Max * WLH
self.contents = Bitmap.new(width - 32, height)
refresh
self.index = 0
end
end
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs the menu screen processing.
#==============================================================================
class Scene_Menu < Scene_Base
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
@command_window = Window_Command.new(160, $game_system.menu_commands)
@command_window.index = @menu_index
@command_window.height = 8 + Custom_Commands::Menu_Item_Max * 24
if $game_party.members.size == 0 # If number of party members is 0
index = $game_system.menu_commands.index(Vocab::item)
@command_window.draw_item(index, false) # Disable item
index = $game_system.menu_commands.index(Vocab::skill)
@command_window.draw_item(index, false) # Disable skill
index = $game_system.menu_commands.index(Vocab::equip)
@command_window.draw_item(index, false) # Disable equipment
index = $game_system.menu_commands.index(Vocab::status)
@command_window.draw_item(index, false) # Disable status
end
if $game_system.save_disabled # If save is forbidden
index = $game_system.menu_commands.index(Vocab::save)
@command_window.draw_item(index, false) # Disable save
end
for command in $game_system.menu_commands
index = $game_system.menu_commands.index(command)
if $game_system.menu_command_disabled?(command)
@command_window.draw_item(index, false) # Disable command
end
end
end
#--------------------------------------------------------------------------
# * Update Command Selection
#--------------------------------------------------------------------------
def update_command_selection
command = @command_window.selection
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
if $game_party.members.size == 0 and (command == Vocab::item or
command == Vocab::skill or
command == Vocab::equip or
command == Vocab::status)
Sound.play_buzzer
return
elsif $game_system.save_disabled and command == Vocab::save
Sound.play_buzzer
return
elsif $game_system.menu_command_disabled?(command)
Sound.play_buzzer
return
end
Sound.play_decision
case command
when Vocab::item
$scene = Scene_Item.new
when Vocab::skill,Vocab::equip,Vocab::status
start_actor_selection
when Vocab::save # Save
$scene = Scene_File.new(true, false, false)
when Vocab::game_end
$scene = Scene_End.new
end
end
end
#--------------------------------------------------------------------------
# * Update Actor Selection
#--------------------------------------------------------------------------
def update_actor_selection
if Input.trigger?(Input::B)
Sound.play_cancel
end_actor_selection
elsif Input.trigger?(Input::C)
$game_party.last_actor_index = @status_window.index
Sound.play_decision
case @command_window.selection
when Vocab::skill # skill
$scene = Scene_Skill.new(@status_window.index)
when Vocab::equip # equipment
$scene = Scene_Equip.new(@status_window.index)
when Vocab::status # status
$scene = Scene_Status.new(@status_window.index)
end
end
end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias dargor_vx_custom_commands_battle_create_info_viewport create_info_viewport
#--------------------------------------------------------------------------
# * Create Information Display Viewport
#--------------------------------------------------------------------------
def create_info_viewport
dargor_vx_custom_commands_battle_create_info_viewport
for command in $game_system.party_commands
index = $game_system.party_commands.index(command)
if $game_system.party_command_disabled?(command)
@party_command_window.draw_item(index, false) # Disable command
end
end
end
#--------------------------------------------------------------------------
# * Update Party Command Selection
#--------------------------------------------------------------------------
def update_party_command_selection
if Input.trigger?(Input::C)
case @party_command_window.selection
when Vocab::fight # Fight
Sound.play_decision
@status_window.index = @actor_index = -1
next_actor
when Vocab::escape # Escape
if $game_troop.can_escape == false
Sound.play_buzzer
return
end
Sound.play_decision
process_escape
end
end
end
#--------------------------------------------------------------------------
# * Update Actor Command Selection
#--------------------------------------------------------------------------
def update_actor_command_selection
skill = Vocab::skill
if @active_battler.class.skill_name_valid
skill = @active_battler.class.skill_name
end
if Input.trigger?(Input::B)
Sound.play_cancel
prior_actor
elsif Input.trigger?(Input::C)
case @actor_command_window.selection
when @active_battler.class.command_name(Vocab::attack) # Attack
Sound.play_decision
@active_battler.action.set_attack
start_target_enemy_selection
when skill # Skill
Sound.play_decision
start_skill_selection
when @active_battler.class.command_name(Vocab::guard) # Guard
Sound.play_decision
@active_battler.action.set_guard
next_actor
when @active_battler.class.command_name(Vocab::item) # Item
Sound.play_decision
start_item_selection
end
end
end
end
#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
# This class performs the title screen processing.
#==============================================================================
class Scene_Title < Scene_Base
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
@command_window = Window_Command.new(172, $game_system.title_commands)
@command_window.x = (544 - @command_window.width) / 2
@command_window.y = 288
@command_window.height = 8 + Custom_Commands::Title_Item_Max * 24
continue_index = $game_system.title_commands.index(Vocab::continue)
if @continue_enabled # If continue is enabled
@command_window.index = continue_index # Move cursor over command
else # If disabled
@command_window.draw_item(continue_index, false) # Make command semi-transparent
end
for command in $game_system.title_commands
index = $game_system.title_commands.index(command)
if $game_system.title_command_disabled?(command)
@command_window.draw_item(index, false) # Disable command
end
end
@command_window.openness = 0
@command_window.open
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
@command_window.update
if Input.trigger?(Input::C)
case @command_window.selection
when Vocab::new_game #New game
command_new_game
when Vocab::continue # Continue
command_continue
when Vocab::shutdown # Shutdown
command_shutdown
end
end
end
end
#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
# This class performs the item screen processing.
#==============================================================================
class Scene_Item < Scene_Base
#--------------------------------------------------------------------------
# * Return to Original Screen
#--------------------------------------------------------------------------
def return_scene
index = $game_system.menu_commands.index(Vocab::item)
$scene = Scene_Menu.new(index)
end
end
#==============================================================================
# ** Scene_Skill
#------------------------------------------------------------------------------
# This class performs the skill screen processing.
#==============================================================================
class Scene_Skill < Scene_Base
#--------------------------------------------------------------------------
# * Return to Original Screen
#--------------------------------------------------------------------------
def return_scene
index = $game_system.menu_commands.index(Vocab::skill)
$scene = Scene_Menu.new(index)
end
end
#==============================================================================
# ** Scene_Equip
#------------------------------------------------------------------------------
# This class performs the equipment screen processing.
#==============================================================================
class Scene_Equip < Scene_Base
#--------------------------------------------------------------------------
# * Return to Original Screen
#--------------------------------------------------------------------------
def return_scene
index = $game_system.menu_commands.index(Vocab::equip)
$scene = Scene_Menu.new(index)
end
end
#==============================================================================
# ** Scene_Status
#------------------------------------------------------------------------------
# This class performs the status screen processing.
#==============================================================================
class Scene_Status < Scene_Base
#--------------------------------------------------------------------------
# * Return to Original Screen
#--------------------------------------------------------------------------
def return_scene
index = $game_system.menu_commands.index(Vocab::status)
$scene = Scene_Menu.new(index)
end
end
#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
# This class performs the save and load screen processing.
#==============================================================================
class Scene_File < Scene_Base
#--------------------------------------------------------------------------
# * Return to Original Screen
#--------------------------------------------------------------------------
alias dargor_vx_custom_commands_return_scene return_scene
#--------------------------------------------------------------------------
# * Return to Original Screen
#--------------------------------------------------------------------------
def return_scene
if !@from_title && !@from_event
index = $game_system.menu_commands.index(Vocab::save)
$scene = Scene_Menu.new(index)
else
dargor_vx_custom_commands_return_scene
end
end
end
#==============================================================================
# ** Scene_End
#------------------------------------------------------------------------------
# This class performs game end screen processing.
#==============================================================================
class Scene_End < Scene_Base
#--------------------------------------------------------------------------
# * Return to Original Screen
#--------------------------------------------------------------------------
def return_scene
index = $game_system.menu_commands.index(Vocab::game_end)
$scene = Scene_Menu.new(index)
end
end
[li]Devour - Requested by Ryuzaki[/li]
[li]Darkside - Requested by iceplosion[/li]
[li]Prayer - Requested by wsensor[/li]
[li]Run - Requested by Chronopro[/li]
Menu Commands
[li]Dargor's Bestiary - Requested by Reikei[/li]
[li]Lettuce's Stat Points Distribution - Requested by Sesune[/li]
Notes
An important note:
This script overrides the following methods:
> Window_PartyCommand
<> initialize
> Window_ActorCommand
<> initialize
<> setup
> Scene_Menu
<> create_command_window
<> update_command_selection
<> update_actor_selection
> Scene_Battle
<> update_party_command_selection
<> update_actor_command_selection
This script will be incompatible with any other scripts modifying these methods unless they are based on the Custom Commands script methods.
BE SURE TO PLACE THIS SCRIPT ABOVE EVERY CUSTOM SCRIPTS!