02-02-2013, 10:38 AM
Introduction
I was eventing introductory messages for some of my troops, and I was wanting to disable it with a simple self switch. The only problem? Troops don't have self switches! Well, now they do, thanks to yours truly!
Features
Script
Instructions
Place above main and below Scene_Debug
Compatibility
Should be compatible with everything.
Terms & Conditions
Free to use in commercial and non-commercial projects, just give me a credit plz and thx ;D
I was eventing introductory messages for some of my troops, and I was wanting to disable it with a simple self switch. The only problem? Troops don't have self switches! Well, now they do, thanks to yours truly!
Features
- Set self switches on troops
- Plug 'n play
- Requires no fancy script calls, just normal eventing
Script
Troop : Self Switches
Code:
#===============================================================================
# ** Interpreter
#===============================================================================
class Interpreter
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :troopselfswitches_interpreter_command111, :command_111
alias_method :troopselfswitches_interpreter_command123, :command_123
#-----------------------------------------------------------------------------
# * Conditional Branch
#-----------------------------------------------------------------------------
def command_111
# Unless in battle and parameter signifies self-switches
unless $scene.is_a?(Scene_Battle) && @parameters[0] == 2
# The usual
return troopselfswitches_interpreter_command111
end
# Default result to false
result = false
# If troop ID is valid
if $game_temp.battle_troop_id > 0
# Get switch value
switch = case @parameters[1]
when 'A' then $game_troop.switch_a
when 'B' then $game_troop.switch_b
when 'C' then $game_troop.switch_c
when 'D' then $game_troop.switch_d
end
# If checking for switch to be true
if @parameters[2] == 0
# Set result based on switch being true
result = (switch == true)
# If checking for switch to be false
else
# Set result based on switch being false
result = (switch != true)
end
end
# Store determinant results in hash
@branch[@list[@index].indent] = result
# If determinant results are true
if @branch[@list[@index].indent] == true
# Delete branch data
@branch.delete(@list[@index].indent)
# Continue
return true
end
# If it doesn't meet the conditions: command skip
command_skip
end
#-----------------------------------------------------------------------------
# * Control Self Switch
#-----------------------------------------------------------------------------
def command_123
# Unless in battle
unless $scene.is_a?(Scene_Battle)
# The usual
return troopselfswitches_interpreter_command123
end
# If troop ID is valid
if $game_temp.battle_troop_id > 0
# Set switch value
case @parameters[0]
when 'A' then $game_troop.switch_a = (@parameters[1] == 0)
when 'B' then $game_troop.switch_b = (@parameters[1] == 0)
when 'C' then $game_troop.switch_c = (@parameters[1] == 0)
when 'D' then $game_troop.switch_d = (@parameters[1] == 0)
end
end
# Refresh map
$game_map.need_refresh = true
# Continue
return true
end
end
#===============================================================================
# ** Game_Troop
#===============================================================================
class Game_Troop
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :troopselfswitches_gmtroop_initialize, :initialize
#-----------------------------------------------------------------------------
# * Object Initialization
#-----------------------------------------------------------------------------
def initialize
# The usual
troopselfswitches_gmtroop_initialize
# Create self switches variable
@switches = Hash.new
# For each troop in database
for troop_id in 1...$data_troops.size
# Create a hash object for troop
@switches[troop_id] = Hash.new
# A, B, C, D each...
[:a, :b, :c, :d].each {|sign| @switches[troop_id][sign] = false}
end
end
#-----------------------------------------------------------------------------
# * Switch A
#-----------------------------------------------------------------------------
def switch_a
@switches[$game_temp.battle_troop_id][:a]
end
#-----------------------------------------------------------------------------
# * Switch A = (value)
#-----------------------------------------------------------------------------
def switch_a=(value)
@switches[$game_temp.battle_troop_id][:a] = value
end
#-----------------------------------------------------------------------------
# * Switch B
#-----------------------------------------------------------------------------
def switch_b
@switches[$game_temp.battle_troop_id][:b]
end
#-----------------------------------------------------------------------------
# * Switch B = (value)
#-----------------------------------------------------------------------------
def switch_b=(value)
@switches[$game_temp.battle_troop_id][:b] = value
end
#-----------------------------------------------------------------------------
# * Switch C
#-----------------------------------------------------------------------------
def switch_c
@switches[$game_temp.battle_troop_id][:c]
end
#-----------------------------------------------------------------------------
# * Switch C = (value)
#-----------------------------------------------------------------------------
def switch_c=(value)
@switches[$game_temp.battle_troop_id][:c] = value
end
#-----------------------------------------------------------------------------
# * Switch D
#-----------------------------------------------------------------------------
def switch_d
@switches[$game_temp.battle_troop_id][:d]
end
#-----------------------------------------------------------------------------
# * Switch D = (value)
#-----------------------------------------------------------------------------
def switch_d=(value)
@switches[$game_temp.battle_troop_id][:d] = value
end
end
Instructions
Place above main and below Scene_Debug
Compatibility
Should be compatible with everything.
Terms & Conditions
Free to use in commercial and non-commercial projects, just give me a credit plz and thx ;D