I've made a "Status Glossary" which lists all the states in my game that has a rating of 2 or greater. I then have Conditional Branches checking for the name of the index you're currently highlighting which then shows a description of that state in another window. I want this to be an option in the command window in-battle as a quality-of-life improvement for the game.
I've made this using Scene_Item and Window_Item as a foundation, so when I went to find a way to show this in-battle, I went to Scene_Battle 1 and Scene_Battle 3 which handles the actor command stuff. I got far enough to show the option in the command window and to show the windows when selected, but I got stuck because, for some reason, the description doesn't change with the index that is being highlighted and I can't get out of the windows by pressing ESC like I can the others.
Disclaimer: I know it looks messy in-battle (if you choose to put it in a blank project to test), but I already know how to fix the messy-ness of it. I'm just trying to get the two windows to at least function properly.
Here's what I have so far:
I've made this using Scene_Item and Window_Item as a foundation, so when I went to find a way to show this in-battle, I went to Scene_Battle 1 and Scene_Battle 3 which handles the actor command stuff. I got far enough to show the option in the command window and to show the windows when selected, but I got stuck because, for some reason, the description doesn't change with the index that is being highlighted and I can't get out of the windows by pressing ESC like I can the others.
Disclaimer: I know it looks messy in-battle (if you choose to put it in a blank project to test), but I already know how to fix the messy-ness of it. I'm just trying to get the two windows to at least function properly.
Here's what I have so far:
Ruby:
#==============================================================================
# Window_StateDescription
#==============================================================================
class Window_StateDescription < Window_Base
def initialize
super(0, 0, 640, 275)
self.contents = Bitmap.new(width - 32, height - 32)
$StateHighlight = 0
refresh
end
def refresh
self.contents.clear
self.contents.font.size = 20
# Same as above.
@x = 10
@y = 36
@Y = -10
#self.contents.font.color = $ColorOptions[1]
self.contents.font.color = Color.new(255, 255, 255)
self.contents.font.bold = true
self.contents.draw_text(@x, 0, 625, 36, "Status Glossary", 1)
self.contents.draw_text(@x, @y * 6, 625, 36, "All Status Effects are 2 turns unless stated otherwise", 1)
self.contents.font.color = $ColorOptions[0]
if $StatusGlossary[$StateHighlight].name == "Stat Buffs"
self.contents.draw_text(@x, @y, 625, 36, "[Stat Name] = Can be STR, INT, DEX, SPD, HIT, DEF, RES, ATK, or EVA.")
self.contents.draw_text(@x, @y * 2, 625, 36, "[Stat Name] Buffs gives +20% to mentioned stat.")
self.contents.draw_text(@x, @y * 3, 625, 36, "[Stat Name] Buffs II (2nd tier) gives +40% to mentioned stat.")
self.contents.draw_text(@x, @y * 4, 625, 36, "*2nd Tier overwrites 1st Tier and the durations are not combined.")
end
if $StatusGlossary[$StateHighlight].name == "Stat Debuffs"
self.contents.draw_text(@x, @y, 625, 36, "[Stat Name] = Can be STR, INT, DEX, SPD, HIT, DEF, RES, ATK, or EVA.")
self.contents.draw_text(@x, @y * 2, 625, 36, "[Stat Name] Buffs gives -30% to mentioned stat.")
self.contents.draw_text(@x, @y * 3, 625, 36, "[Stat Name] Buffs II (2nd tier) gives -60% to mentioned stat.")
self.contents.draw_text(@x, @y * 4, 625, 36, "*2nd Tier overwrites 1st Tier and the durations are not combined.")
end
if $StatusGlossary[$StateHighlight].name == "Heal Debuff"
self.contents.draw_text(@x, @y, 625, 36, "Reduce healing the target recieves by 50%.")
self.contents.draw_text(@x, @y * 2, 625, 36, "*Undead are typically immune to this")
end
if $StatusGlossary[$StateHighlight].name == "Brand"
self.contents.draw_text(@x, @y, 625, 36, "Inflicted recieves 20% more damage from all sources, except")
self.contents.draw_text(@x, @y * 2, 625, 36, "damage-over-time status effects")
end
if $StatusGlossary[$StateHighlight].name == "HP Regen"
self.contents.draw_text(@x, @y, 625, 36, "Target heals equal to 10% of it's Max HP each turn or it's level x 5")
self.contents.draw_text(@x, @y * 2, 625, 36, "(Whichever is higher).")
self.contents.draw_text(@x, @y * 3, 625, 36, "*Enemies do not have levels so it's always 10% of their Max HP.")
end
if $StatusGlossary[$StateHighlight].name == "Provoke"
self.contents.draw_text(@x, @y, 625, 36, "Make all targets attack the user.")
self.contents.draw_text(@x, @y * 2, 625, 36, "*If two allies have this. They will be equally attacked (usually)")
self.contents.draw_text(@x, @y * 3, 625, 36, "*The Exception is if one has additional factors to their threat")
end
if $StatusGlossary[$StateHighlight].name == "Angered"
self.contents.draw_text(@x, @y, 625, 36, "Make all targets attack the opposite team with a basic attack")
self.contents.draw_text(@x, @y * 2, 625, 36, "Will disallow targets from using anything but their basic attack")
self.contents.draw_text(@x, @y * 3, 625, 36, "Grants the target +15% ATK but -15% DEF.")
end
if $StatusGlossary[$StateHighlight].name == "Life Enchant"
self.contents.draw_text(@x, @y, 625, 36, "Add 20% to your ATK. This is treated as Life damage. The effect")
self.contents.draw_text(@x, @y * 2, 625, 36, "travels between weapons. Only affects melee weapons.")
end
if $StatusGlossary[$StateHighlight].name == "CRIT Vulrenability"
self.contents.draw_text(@x, @y, 625, 36, "Increases chance for target to recieve a Critical Hit by 5%.")
self.contents.draw_text(@x, @y * 2, 625, 36, "Base Critical Hit: 5% Chance")
end
if $StatusGlossary[$StateHighlight].name == "CRI Fail Vulrenability"
self.contents.draw_text(@x, @y, 625, 36, "Increases chance for target to Critically Fail by 5%.")
self.contents.draw_text(@x, @y * 2, 625, 36, "Base Critical Hit: 5% Chance")
end
if $StatusGlossary[$StateHighlight].name == "Counterattack I"
self.contents.draw_text(@x, @y, 625, 36, "When attacked, counter with your basic attack at 70% damage.")
self.contents.draw_text(@x, @y * 2, 625, 36, "Counterattack II: 70% damage, +1 Turn")
self.contents.draw_text(@x, @y * 3, 625, 36, "Counterattack III: 100% damage, same turns as II")
self.contents.draw_text(@x, @y * 4, 625, 36, "Counterattack IV: 100% damage, +1 Turn from above")
self.contents.draw_text(@x, @y * 5, 625, 36, "*May counter with a Skill/Spell instead but that will be specified")
end
if $StatusGlossary[$StateHighlight].name == "Reflect"
self.contents.draw_text(@x, @y, 625, 36, "If dealt damage, attacker takes 30% of the damage.")
self.contents.draw_text(@x, @y * 2, 625, 36, "Reflect II: attacker takes 60% of the damage.")
self.contents.draw_text(@x, @y * 3, 625, 36, "Reflect III: attacker takes 100% of the damage.")
self.contents.draw_text(@x, @y * 4, 625, 36, "*You are still dealt the reflected damage.")
end
if $StatusGlossary[$StateHighlight].name == "CRITICAL! STUN"
self.contents.draw_text(@x, @y, 625, 36, "The inflicted cannot move or evade any attacks until their next turn")
self.contents.draw_text(@x, @y * 2, 625, 36, "*This is not resistable")
end
if $StatusGlossary[$StateHighlight].name == "CRITICAL! FAIL"
self.contents.draw_text(@x, @y, 625, 36, "The inflicted has these stats reduced by 50% until end of next turn:")
self.contents.draw_text(@x, @y * 2, 625, 36, "STR, INT, DEX, SPD, HIT, DEF, RES, and ATK.")
self.contents.draw_text(@x, @y * 3, 625, 36, "*This does effectively reduce your total hit chance by 75% by reducing")
self.contents.draw_text(@x, @y * 4, 625, 36, "your HIT and another stat affecting your total hit chance.")
self.contents.draw_text(@x, @y * 5, 625, 36, "*This is not resistable")
end
if $StatusGlossary[$StateHighlight].name == "Curse"
self.contents.draw_text(@x, @y, 625, 36, "The inflicted cannot remove harmful effects, excluding natural means")
self.contents.draw_text(@x, @y * 2, 625, 36, "The inflicted cannot gain beneficial effects by any means")
end
if $StatusGlossary[$StateHighlight].name == "Death Ward"
self.contents.draw_text(@x, @y, 625, 36, "If inflicted would die, go to 30% HP instead.")
self.contents.draw_text(@x, @y * 2, 625, 36, "*One can only be affected by Death Ward once per battle.")
end
if $StatusGlossary[$StateHighlight].name == "Burn"
self.contents.draw_text(@x, @y, 625, 36, "Inflicted is dealt fire damage at the start of each of it's turns.")
self.contents.draw_text(@x, @y * 2, 625, 36, "Fire Damage = 7.5% of Max HP, capped at 100")
self.contents.draw_text(@x, @y * 3, 625, 36, "*Damage is affected by magical and fire resistances")
self.contents.draw_text(@x, @y * 4, 625, 36, "*This will remove the Freezing Status.")
end
if $StatusGlossary[$StateHighlight].name == "Bleed"
self.contents.draw_text(@x, @y, 625, 36, "Inflicted is dealt physical damage at the start of each of it's turns.")
self.contents.draw_text(@x, @y * 2, 625, 36, "Physical Damage = 5% of Max HP, base damage capped at 50")
self.contents.draw_text(@x, @y * 3, 625, 36, "*Damage is affected by physical resistances and damage boosts on the inflicted.")
self.contents.draw_text(@x, @y * 4, 625, 36, "Includes but not limited to: DEF Buff, Debuff, and the Brand Status effect.")
self.contents.draw_text(@x, @y * 5, 625, 36, "*50 is only max base damage. Can be increased by external means, up to 100.")
end
if $StatusGlossary[$StateHighlight].name == "Poison"
self.contents.draw_text(@x, @y, 625, 36, "Inflicted is dealt poison damage at the start of each of it's turns.")
self.contents.draw_text(@x, @y * 2, 625, 36, "Poison Damage = 5% of Max HP, capped at 50")
self.contents.draw_text(@x, @y * 3, 625, 36, "*Damage is reduced by the inflicted's (STR - 20) / 2")
self.contents.draw_text(@x, @y * 4, 625, 36, "*This reduction is capped at 50% of the Poison Damage.")
end
if $StatusGlossary[$StateHighlight].name == "Seal"
self.contents.draw_text(@x, @y, 625, 36, "Inflicted cannot use Spells.")
end
if $StatusGlossary[$StateHighlight].name == "Sleep"
self.contents.draw_text(@x, @y, 625, 36, "Inflicted cannot evade or move but is no longer inflicted when attacked")
end
if $StatusGlossary[$StateHighlight].name == "Freezing"
self.contents.draw_text(@x, @y, 625, 36, "Inflicted has their Skills/Spells cost 30% more than usual.")
self.contents.draw_text(@x, @y * 2, 625, 36, "*This will remove Burn status.")
end
self.contents.font.size = 16
end
end
#==============================================================================
#Window_States
#==============================================================================
class Window_States < Window_Selectable
def initialize
super(0, 275, 640, 240)
@column_max = 3
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Get State
#--------------------------------------------------------------------------
def state
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
$StatusGlossary = []
for i in 1...$data_states.size
if $data_states[i].name != "" and not $data_states[i].rating <= 1
@data.push($data_states[i])
end
@data = @data.sort{|a, b| a.name <=> b.name }
$StatusGlossary = @data
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
def update_index
$StateHighlight = self.index
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
state = @data[index]
self.contents.font.color = normal_color
self.contents.font.bold = true
y = (index / 3 * 32)
x = (index % 3 * (107 + 55 + 40))
self.contents.font.size = 20
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(x + 28, y, 212, 32, state.name, 0)
end
end
#==============================================================================
# Scene_State
#==============================================================================
class Scene_State
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make help window, item window
Font.default_bold = true
@item_window = Window_States.new
@desc_window = Window_StateDescription.new
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@desc_window.dispose
@item_window.dispose
Font.default_bold = false
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@item_window.update
# If item window is active: call update_item
if @item_window.active
update_item
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when item window is active)
#--------------------------------------------------------------------------
def update_item
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Menu.new(0)
return
end
if Input.repeat?(Input::RIGHT) or Input.repeat?(Input::LEFT) or Input.repeat?(Input::DOWN) or Input.repeat?(Input::UP)
@item_window.update_index
@desc_window.refresh
end
end
end
I added the following to Scene_Battle 1 starting at line 25
Then, I added the following to Scene_Battle 3 in the "update_phase3_basic_command" method where it says when 1, when 2, etc, and i just added Status Glossary following that pattern in the method.
Following how items were coded in Scene_Battle 3, I used that as a foundation and made the two following methods at the bottom with the rest of the "start_x_select" and "end_x_select"
Lastly, I added, following how items were coded, the following code to have it show up when you select the command. I understand that I probably did something wrong here, but I don't know what, and I definitely don't know why it can't cancel out when I press ESC.
Ruby:
# Make actor command window
s1 = $data_system.words.attack
s2 = $data_system.words.skill
s3 = $data_system.words.guard
s4 = $data_system.words.item
s5 = "Glossary" #<= Added this
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4, s5]) #<= Added "s5"
Then, I added the following to Scene_Battle 3 in the "update_phase3_basic_command" method where it says when 1, when 2, etc, and i just added Status Glossary following that pattern in the method.
Ruby:
when 4 # status glossary
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Start item selection
start_status_select
Following how items were coded in Scene_Battle 3, I used that as a foundation and made the two following methods at the bottom with the rest of the "start_x_select" and "end_x_select"
Ruby:
#--------------------------------------------------------------------------
# * Start status Selection
#--------------------------------------------------------------------------
def start_status_select
# Make item window
@status_window = Window_States.new
@desc_window = Window_StateDescription.new
# Disable actor command window
@actor_command_window.active = false
@actor_command_window.visible = false
end
#--------------------------------------------------------------------------
# * End status Selection
#--------------------------------------------------------------------------
def end_status_select
# Dispose of item window
@status_window.dispose
@status_window = nil
@desc_window.dispose
@desc_window = nil
# Enable actor command window
@actor_command_window.active = true
@actor_command_window.visible = true
end
Lastly, I added, following how items were coded, the following code to have it show up when you select the command. I understand that I probably did something wrong here, but I don't know what, and I definitely don't know why it can't cancel out when I press ESC.
Ruby:
#--------------------------------------------------------------------------
# * Frame Update (actor command phase : status selection)
#--------------------------------------------------------------------------
def update_phase3_status_select
# Make item window visible
@status_window.visible = true
@desc_window.visible = true
# Update item window
@status_window.update
@desc_window.refresh
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# End item selection
end_status_select
return
end
if Input.repeat?(Input::RIGHT) or Input.repeat?(Input::LEFT) or Input.repeat?(Input::DOWN) or Input.repeat?(Input::UP)
@status_window.update_index
@desc_window.refresh
end
end