Easy Weapon Upgrade
By: FamilyGamer7
IntroductionBy: FamilyGamer7
Features
Screenshots
Demo
Script
Ruby:
#==============================================================================
# Title: Easy Weapon Upgrade
# Author: FamilyGamer7 (FG7)
# Version: 1.0
# Engine: RPG Maker VX Ace
#==============================================================================
# ** Change Log |
# ---------------
# 1.0 => Created Script
#==============================================================================
# ** Description |
# ----------------
# The easiest way to implement an Weapon Upgrade System while providing many
# features for flexbility and customization.
#==============================================================================
# ** Terms of Use |
# -----------------
# * Free to use in non-commercial projects and commercial projects
# * Feel free to modify and improve the script. Credit is still required.
# * Credit FamilyGamer7
#==============================================================================
# ** Setup - Required |
# --------------------
# This script works by simply appending a starting value of "1" on the end of
# the weapon name. This makes the script simple without having to define a
# "level" for the weapon as this value acts as a level indicator.
#
# For each actor weapon, you will need need to append the correct setup for the
# script to properly work. If the weapon name is.. Hand Ax, see examples below.
#
# - Acceptable actor weapon name setup in the game database
# EX: Hand Ax 1
# EX: Hand Ax Lv. 1
# Ex: Hand Ax Lv.1
# EX: Hand Ax Lvl. 1
# Ex: Hand Ax Lvl.1
#
# The script will automatically replace the weapon number value that is
# appended on the weapon name and increase by a value of 1.
#
# *** PLEASE ENSURE THE WEAPON PRICE IS SET TO "0" IN THE GAME DATABASE ***
# (You can set a price on the WPN, but incremental upgrade will not work as intended)
#
# To script call the WPN Upgrade scene: SceneManager.call(Scene_WeaponUpgrade)
#
# * All fine tuning will need to be done in the Module section below.
#==============================================================================
# ** WARNING! |
# ------------
# This script leverages the game database "price" on the actor weapon to help
# perform the weapon upgrade. It is NOT intended to be used in a game where
# you buy and sell weapons as this will affect the script in a negative way.
#==============================================================================
# ** Note(s) |
# -----------
# Even though this script was designed for actors to have a weapon equipped at
# all times, logic as been added to check if the actor has a weapon equipped
# or not to prevent errors being thrown. Enjoy!
#==============================================================================
#==============================================================================
# ** Module: FG7::Easy_Weapon_Upgrade
#------------------------------------------------------------------------------
# This modules creates a static variable to be used within the script.
#==============================================================================
module FG7
module Easy_Weapon_Upgrade
#==============================================================================
# -------------------- ALLOWED TO EDIT BELOW THIS LINE ---------------------- #
#==============================================================================
# --------------------------------
# | Game Variable(s) Configuration |
# --------------------------------
# | !!!! REQUIRED !!!! |
# --------------------------------
# Sets the game variable value for the cost to upgrade
# (Choose any unused $game_variable to run this script)
Game_Variable = 10
# Sets the game variable value for the WPN level #
# (Choose any unused $game_variable to run this script)
Game_Variable2 = 11
# Sets/flips the game switch if no WPN is equipped
# (Choose any unused $game_switch to run this script)
Game_Switch = 12
# ------------------------------
# | Weapon Upgrade Configuration |
# ------------------------------
# Sets the incremental value once you start upgrading the WPN
# (This value is added each time you upgrade)
WPN_Incremental_Value = 1200
# Sets the +attack paramater value when upgrading WPN level ech time
WPN_Attack_Value = 5
# Sets the max level every actor can reach when upgrading the WPN
# (There is technically no limit to the max upgrade level for Weapons)
WPN_Level_Max = 15
# --------------------------
# | Additional Configuration |
# --------------------------
# Sets the name for the Level parameter on the WPN
WPN_Level_Text = "WLVL"
# Sets the name for the weapon attack paramater on the WPN
WPN_Level_Attack_Text = "WATK"
# Sets the text when you do not have enough currency to upgrade actor WPN
Not_Enough_Currency = "Not Enough Currency!"
# Sets the text indicating before the currency value for the WPN upgrade
WPN_Upgrade_Text = "Upgrade Cost:"
# Sets the text when you have reach the Max WPN level upgrade
WPN_Maxed_Out_Text = "Currently Maxed Out!"
# Sets the text when you have reach the Max WPN level upgrade
WPN_Not_Equipped = " No Weapon Equipped!"
# Sets whether to show the actor face on the weapon upgrade window
Show_Actor_Face = true
# --------------------------------------
# | WPN - Window Positioning Configuration |
# --------------------------------------
# Sets the "X" coordinate of the windows
X_Horizontal = 203
# Sets the "Y" coordinate of the windows
Y_Vertical = 139
# ------------------------------
# | Title - Window Configuration |
# ------------------------------------------
# | !!!! ONLY WORKS IF SET TO "TRUE" !!!! |
# ------------------------------------------
# Sets the title window on the weapon upgrade scene
Show_Title_Window = true
# Sets the text on the title window on the weapon upgrade scene
Show_Title_Window_Text = "Blacksmith"
# Sets the "X" coordinate of the windows
Title_X_Horizontal = 10
# Sets the "Y" coordinate of the windows
Title_Y_Vertical = 12
# Sets the "Width" of the title window
Title_Width = 137
# Sets the "Height" of the title window
Title_Height = 50
#==============================================================================
# ---------- DO NOT EDIT BELOW THIS LINE (FOR ADVANCED USERS) --------------- #
#==============================================================================
end
end
#==============================================================================
# ** Window_Gold
#------------------------------------------------------------------------------
# This window displays the party's gold.
#==============================================================================
class Window_Gold < Window_Base
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
alias :fg7_easy_weapon_upgrade_window_width :window_width
def window_width
if SceneManager.scene_is?(Scene_WeaponUpgrade)
return 126
end
fg7_easy_weapon_upgrade_window_width
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
alias :fg7_easy_weapon_upgrade_refresh :refresh
def refresh
fg7_easy_weapon_upgrade_refresh
if SceneManager.scene_is?(Scene_WeaponUpgrade)
contents.clear
draw_currency_value(value, currency_unit, 1, 0, contents.width - 8)
end
end
end
#==============================================================================
# ** Window_WeaponStatus
#------------------------------------------------------------------------------
# This window displays all the information on the actor for weapon upgrading.
#==============================================================================
class Window_WeaponStatus < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 0, Graphics.width, Graphics.height)
self.opacity = 0
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Set Actor
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
# Draws actor face
draw_actor_face(@actor, 138, 25) if FG7::Easy_Weapon_Upgrade::Show_Actor_Face == true
# Draws actor name
draw_actor_name(@actor, 12, 110)
# Draws pre-defined text for the scene
change_color(text_color(4))
draw_text(12, 122, 100, 50, FG7::Easy_Weapon_Upgrade::WPN_Level_Text)
draw_text(130, 122, 100, 50, FG7::Easy_Weapon_Upgrade::WPN_Level_Attack_Text)
# Creates static variables for "draw_text" of the upgrade cost
cost_x = -65; cost_y = 195
# Checks if an actor weapon is equipped (Flip $game_switch if not)
if @actor.weapons[0] == nil
$game_variables[FG7::Easy_Weapon_Upgrade::Game_Switch] = false
change_color(text_color(0))
draw_text(12, 145, 800, 50, "----------")
draw_text(-64, 122, 300, 50, "--", 2)
draw_text(-189, 122, 300, 50, "--", 2)
draw_text(cost_x - 13, cost_y, 300, 50, FG7::Easy_Weapon_Upgrade::WPN_Not_Equipped, 2)
# Since actor weapon is equipped - show all information for upgrading
else
$game_variables[FG7::Easy_Weapon_Upgrade::Game_Switch] = true
# Actor Weapon - Name (Removes all numbers from name and Lv.)
change_color(text_color(0))
draw_text(12, 145, 800, 50, @actor.weapons[0].name.tr("0-9", "").tr("Lv.", "").tr("Lvl.", "").strip)
# Actor Weapon - Level (Removes all non-digits from name)
change_color(text_color(0))
draw_text(-189, 122, 300, 50, @actor.weapons[0].name.tr("^0-9", ""), 2)
# Actor Weapon Attack stat
draw_text(-64, 122, 300, 50, @actor.weapons[0].params[2], 2)
change_color(text_color(14))
# Draws WPN database price (that is +value on the WPN upgrade)
change_color(text_color(0))
if $game_party.gold < @actor.weapons[0].price + FG7::Easy_Weapon_Upgrade::WPN_Incremental_Value
draw_text(cost_x - 11, cost_y, 300, 50, FG7::Easy_Weapon_Upgrade::Not_Enough_Currency, 2)
elsif @actor.weapons[0].name.gsub(/[^0-9]/, '') == "1"
draw_text(cost_x - 91, cost_y, 300, 50, FG7::Easy_Weapon_Upgrade::WPN_Upgrade_Text, 2)
draw_text(cost_x, cost_y, 300, 50, FG7::Easy_Weapon_Upgrade::WPN_Incremental_Value.to_s + Vocab::currency_unit, 2)
elsif @actor.weapons[0].name.gsub(/[^0-9]/, '').to_i == FG7::Easy_Weapon_Upgrade::WPN_Level_Max.to_i
draw_text(cost_x - 13, cost_y, 300, 50, FG7::Easy_Weapon_Upgrade::WPN_Maxed_Out_Text , 2)
else
draw_text(cost_x - 91, cost_y, 300, 50, FG7::Easy_Weapon_Upgrade::WPN_Upgrade_Text, 2)
draw_text(cost_x, cost_y, 300, 50, (@actor.weapons[0].price + FG7::Easy_Weapon_Upgrade::WPN_Incremental_Value).to_s + Vocab::currency_unit, 2)
end
# Sets the actor WPN level into a variable (To disable upgrade button)
$game_variables[FG7::Easy_Weapon_Upgrade::Game_Variable2] = @actor.weapons[0].name.gsub(/[^0-9]/, '')
# Sets the actor WPN price into a variable (To disable upgrade button)
$game_variables[FG7::Easy_Weapon_Upgrade::Game_Variable] = @actor.weapons[0].price + FG7::Easy_Weapon_Upgrade::WPN_Incremental_Value
end
end
end
#==============================================================================
# ** Window_WeaponCommand
#------------------------------------------------------------------------------
# This window is the weapon upgrade command for the scene.
#==============================================================================
class Window_WeaponCommand < Window_Command
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0)
end
#--------------------------------------------------------------------------
# * Get Digit Count
#--------------------------------------------------------------------------
def col_max
return 1
end
#--------------------------------------------------------------------------
# * Create Command List
#--------------------------------------------------------------------------
def make_command_list
add_command("Upgrade", :upgrade, no_gold_or_wpn_max_level_or_no_wpn_equipped)
add_command("Change", :change, no_extra_party_members)
add_command("Cancel", :cancel)
end
#--------------------------------------------------------------------------
# * Disabled - No Gold or WPN mac level
#--------------------------------------------------------------------------
def no_gold_or_wpn_max_level_or_no_wpn_equipped
return true if $game_variables[FG7::Easy_Weapon_Upgrade::Game_Variable2].to_i != FG7::Easy_Weapon_Upgrade::WPN_Level_Max.to_i && $game_party.gold > $game_variables[FG7::Easy_Weapon_Upgrade::Game_Variable].to_i && $game_variables[FG7::Easy_Weapon_Upgrade::Game_Switch] == true
end
#--------------------------------------------------------------------------
# * Disabled - No Additional/Extra Party Members
#--------------------------------------------------------------------------
def no_extra_party_members
return true if $game_party.members.size > 1
end
end
#==============================================================================
# ** Window_WeaponUpgradeConfirm
#------------------------------------------------------------------------------
# This window is a confirm window when upgrading your actor weapon level.
#==============================================================================
class Window_WeaponUpgradeConfirm < Window_Command
#--------------------------------------------------------------------------
# * Added Method: Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0)
self.opacity = 0
self.openness = 255
end
#--------------------------------------------------------------------------
# * Added Method: Get Digit Count
#--------------------------------------------------------------------------
def col_max
return 1
end
#--------------------------------------------------------------------------
# * Added Method: Create Command List
#--------------------------------------------------------------------------
def make_command_list
add_command("Yes", :yes)
add_command("No", :no)
end
end
#==============================================================================
# ** Window_UpgradeText
#------------------------------------------------------------------------------
# Window class created for the single custom single window usage.
#==============================================================================
class Window_UpgradeText < Window_Base
#--------------------------------------------------------------------------
# * Defines the Window used - Used for upgrade & title text
#--------------------------------------------------------------------------
def initialize(x, y, width, height, title)
super(x, y, width, height)
draw_text(4, 0, contents.width + 30, line_height, title)
end
end
#==============================================================================
# ** Scene_MenuBase
#------------------------------------------------------------------------------
# This class performs basic processing related to the menu screen.
#==============================================================================
class Scene_MenuBase < Scene_Base
#--------------------------------------------------------------------------
# * Creates Single Text Window - Used for upgrade text background window
#--------------------------------------------------------------------------
def create_upgrade_text_window(x, y, width, height, title)
@upgrade_text_window = Window_UpgradeText.new(x, y, width, height, title)
end
#--------------------------------------------------------------------------
# * Creates Single Text Window - Used for upgrade title window
#--------------------------------------------------------------------------
def create_upgrade_title_window(x, y, width, height, title)
@upgrade_title_window = Window_UpgradeText.new(x, y, width, height, title)
end
end
#==============================================================================
# ** Scene_WeaponUpgrade
#------------------------------------------------------------------------------
# This class scene performs the upgrading of the weapon level.
#==============================================================================
class Scene_WeaponUpgrade < Scene_MenuBase
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start
super
create_upgrade_cost_window
create_gold_window
create_weapon_status_bg_window
create_weapon_status_window
create_weapon_status_command_window
create_upgrade_title_window(FG7::Easy_Weapon_Upgrade::Title_X_Horizontal, FG7::Easy_Weapon_Upgrade::Title_Y_Vertical, FG7::Easy_Weapon_Upgrade::Title_Width, FG7::Easy_Weapon_Upgrade::Title_Height, FG7::Easy_Weapon_Upgrade::Show_Title_Window_Text) if FG7::Easy_Weapon_Upgrade::Show_Title_Window == true
create_upgrade_text_window(9999, FG7::Easy_Weapon_Upgrade::Y_Vertical, 126, 96, "Upgrade?")
create_weapon_upgrade_confirm_window
end
#--------------------------------------------------------------------------
# * Create Cost For Weapon Upgrade Window
#--------------------------------------------------------------------------
def create_upgrade_cost_window
x = FG7::Easy_Weapon_Upgrade::X_Horizontal
y = FG7::Easy_Weapon_Upgrade::Y_Vertical + 96
width = 266
height = 48
@upgrade_cost_window = Window_Base.new(x, y, width, height)
@upgrade_cost_window.show
end
#--------------------------------------------------------------------------
# * Create Weapon Status Window
#--------------------------------------------------------------------------
def create_weapon_status_window
@weapon_status_window = Window_WeaponStatus.new(@actor)
@weapon_status_window.x = FG7::Easy_Weapon_Upgrade::X_Horizontal - 1
@weapon_status_window.y = FG7::Easy_Weapon_Upgrade::Y_Vertical - 111
@weapon_status_window.width = 800
@weapon_status_window.height = 430
end
#--------------------------------------------------------------------------
# * Create Weapon Status Background Window
#--------------------------------------------------------------------------
def create_weapon_status_bg_window
x = FG7::Easy_Weapon_Upgrade::X_Horizontal
y = FG7::Easy_Weapon_Upgrade::Y_Vertical
width = 266
height = 96
@status_weapon_actor_bg_window = Window_Base.new(x, y, width, height)
@status_weapon_actor_bg_window.show
end
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_weapon_status_command_window
@weapon_status_command_window = Window_WeaponCommand.new
@weapon_status_command_window.x = FG7::Easy_Weapon_Upgrade::X_Horizontal - 126
@weapon_status_command_window.y = FG7::Easy_Weapon_Upgrade::Y_Vertical
@weapon_status_command_window.width = 126
@weapon_status_command_window.height = 96
@weapon_status_command_window.activate
@weapon_status_command_window.set_handler(:upgrade, method(:upgrade_weapon))
@weapon_status_command_window.set_handler(:change, method(:next_actor))
@weapon_status_command_window.set_handler(:pagedown, method(:next_actor))
@weapon_status_command_window.set_handler(:pageup, method(:prev_actor))
@weapon_status_command_window.set_handler(:cancel, method(:return_scene))
@weapon_status_command_window.refresh
end
#--------------------------------------------------------------------------
# * Create Weapon Upgrade Confirm Window
#--------------------------------------------------------------------------
def create_weapon_upgrade_confirm_window
@weapon_upgrade_confirm_window = Window_WeaponUpgradeConfirm.new
@weapon_upgrade_confirm_window.x = FG7::Easy_Weapon_Upgrade::X_Horizontal - 126
@weapon_upgrade_confirm_window.y = FG7::Easy_Weapon_Upgrade::Y_Vertical + 24
@weapon_upgrade_confirm_window.width = 126
@weapon_upgrade_confirm_window.height = 84
@weapon_upgrade_confirm_window.hide.deactivate
@weapon_upgrade_confirm_window.set_handler(:yes, method(:upgrade_weapon_confirm))
@weapon_upgrade_confirm_window.set_handler(:no, method(:upgrade_weapon_confirm_cancel))
@weapon_upgrade_confirm_window.set_handler(:cancel, method(:upgrade_weapon_confirm_cancel))
@weapon_upgrade_confirm_window.refresh
end
#--------------------------------------------------------------------------
# * Added Method: Create Gold Window
#--------------------------------------------------------------------------
def create_gold_window
@gold_window = Window_Gold.new
@gold_window.x = FG7::Easy_Weapon_Upgrade::X_Horizontal - 126
@gold_window.y = FG7::Easy_Weapon_Upgrade::Y_Vertical + 96
@gold_window.width = 126
end
#--------------------------------------------------------------------------
# * Upgrade Weapon
#--------------------------------------------------------------------------
def upgrade_weapon
@weapon_status_command_window.hide
@upgrade_text_window.x = FG7::Easy_Weapon_Upgrade::X_Horizontal - 126
@weapon_upgrade_confirm_window.show.activate.select(0)
end
#--------------------------------------------------------------------------
# * Upgrade Weapon - Confirm
#--------------------------------------------------------------------------
def upgrade_weapon_confirm
# Grabs the current weapon level number
@Current_WPN_Level = @actor.weapons[0].name.gsub(/[^0-9]/, '')
# Adds the current level weapon number and counts +1 on it
@New_WPN_Level = @Current_WPN_Level.to_i + 1
# Strips out the number from the actor weapon name
@actor.weapons[0].name = @actor.weapons[0].name.tr("0-9", "")
# Renames the actor weapon to resemble a new level from upgrading
@actor.weapons[0].name = @actor.weapons[0].name + @New_WPN_Level.to_s
# Added the paramater back together with a +value
@actor.weapons[0].params[2] = @actor.weapons[0].params[2] + FG7::Easy_Weapon_Upgrade::WPN_Attack_Value
# Checks for actor weapon level and adds incremental value on each upgrade
if @actor.weapons[0].name.gsub(/[^0-9]/, '') == "1"
@actor.weapons[0].price = FG7::Easy_Weapon_Upgrade::WPN_Incremental_Value
else
@actor.weapons[0].price = @actor.weapons[0].price + FG7::Easy_Weapon_Upgrade::WPN_Incremental_Value
end
# Lose gold for upgrading weapon
$game_party.lose_gold(@actor.weapons[0].price)
# Creates hammer sharpening sound that the weapon has been upgraded
20.times { Graphics.update }
RPG::SE.new("Hammer").play
20.times { Graphics.update }
RPG::SE.new("Hammer").play
20.times { Graphics.update }
RPG::SE.new("Decision2").play
# Refresh and update scenes
@weapon_upgrade_confirm_window.hide.deactivate
@upgrade_text_window.x = 9999
@weapon_status_window.refresh
@gold_window.refresh
@weapon_status_command_window.refresh
@weapon_status_command_window.show.activate
@weapon_status_command_window.select(0)
end
#--------------------------------------------------------------------------
# * Upgrade Weapon - Confirm Cancel
#--------------------------------------------------------------------------
def upgrade_weapon_confirm_cancel
@weapon_upgrade_confirm_window.hide.deactivate
@upgrade_text_window.x = 9999
@weapon_status_command_window.show.activate
@weapon_status_command_window.select(0)
end
#--------------------------------------------------------------------------
# * Change Actors
#--------------------------------------------------------------------------
def on_actor_change
@weapon_status_window.actor = @actor
@weapon_status_window.refresh
@weapon_status_command_window.refresh
@weapon_status_command_window.activate
end
end
How to Use
Terms of Use