Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[VX] Leveling Weapons System

Akin

Member

Leveling Weapon System
Version 1.0
by Akin

Introduction

I did this for a request. This system assigns every weapon a level. Weapons can be leveled up from a special shop menu. When a level increases level, the stats it gives are increased. The weapon's increased stats stay regardless of which character equips the item. By default the maximum item level is set to 20 but this can be adjusted.

Features

  • Every weapon assigned a level
  • Weapon stats grow every time they level
  • Weapon levels are attached to the weapon so any character can equip
  • Set the item base stats using the default database
  • No need to setup arrays

Screenshots

http://i48.photobucket.com/albums/f203/ ... evels2.jpg[/img]

Demo
http://www.megaupload.com/?d=30IZ6AED

Scripts

Here it is

Code:
##########################################################
# Weapon Level System Script                             #
#        by Akin                                         #
#                                                        #
##########################################################
# Weapon Levels will produce a higher stat output        #
# Level weapons from the call:                           #
# "$scene = Scene_Weapons_Upgrade.new"             #
#                                                        #
# Search for A34sZ1A to find the formulas being used     #
# to calculate the stat point raise for each weapon      #
# and for the price increase to the cost                 #
#                                                        #
# This script uses the Window_Confirm class made by      #
# Prexus                                                 #
#                                                        #
##########################################################

# This is the window confirm class made by Prexus
class Window_Confirm < Window_Selectable
  def initialize(index = -1)
    super(192, 168, 160, 80)
    create_contents
    @item_max = 2
    @column_max = 2
    self.index = index
    self.active = false
    self.openness = 0
    refresh
  end
  #--------------------------------------------------------------------------
  def refresh
    for i in 0..@item_max
      rect = item_rect(i)
      self.contents.clear_rect(rect)
    end
    self.contents.draw_text(0, 0, self.contents.width, WLH, "Confirm?", 1)
    rect = item_rect(0)
    self.contents.draw_text(rect, "Yes", 1)
    rect = item_rect(1)
    self.contents.draw_text(rect, "No", 1)
  end
  #--------------------------------------------------------------------------
  def item_rect(index)
    rect = Rect.new(0, 0, 0, 0)
    rect.width = (contents.width + @spacing) / @column_max - @spacing
    rect.height = WLH
    rect.x = index % @column_max * (rect.width + @spacing)
    rect.y = (index / @column_max * WLH) + WLH
    return rect
  end
end

# This Module adds level to each weapon
module RPG
  class Weapon < BaseItem
  attr_accessor :level
  alias akin_weapon_level_system_ini initialize
    def initialize
      akin_weapon_level_system_ini
      @level = 1
    end
  end
end

# This Module calculates the weapon levelup
module Akin_Weapons
  def self.level_up(weapon_input)
    if weapon_input.level == nil or weapon_input.level == 0
      weapon_input.level = 1
    end
    weapon_input.level += 1
    
    #--------Level Up Functions-------------A34sZ1A -----------------------
    # The stats will increase by a 20% of their previous value + 1
    # Everytime they level up using this formula
    # Make sure you keep the value set to an Integer by using "Integer()"
    # There is one more location that needs to be changed
    # If the formula is altered find that location with BZ8q1
    weapon_input.atk = Integer(weapon_input.atk * 1.2 + 1)
    weapon_input.def = Integer(weapon_input.def * 1.2 + 1)
    weapon_input.spi = Integer(weapon_input.spi * 1.2 + 1)
    weapon_input.agi = Integer(weapon_input.agi * 1.2 + 1)
    #-------Level Up Functions End-----------------------------------------
  end
end

#------------------------------------------------------------------------------
#  Adds methods to window_base to draw actor's equiped weapon
#==============================================================================

class Window_Base < Window
  def draw_actor_weapon(actor, x, y)
    self.contents.font.color = power_up_color
    self.contents.draw_text(x, y, 96, WLH, "Equiped :")
    self.contents.font.color = normal_color
    n = actor.weapon_id
    equiped_weapon = $data_weapons[n]
    if equiped_weapon == nil
      self.contents.draw_text(x + 8, y + WLH, 192, WLH, "None")
    else
      self.contents.draw_text(x + 8, y + WLH, 192, WLH, equiped_weapon.name)
      if equiped_weapon.level == nil or equiped_weapon.level == 0
        $data_weapons[n].level = 1
        equiped_weapon = $data_weapons[n]
      end
      self.contents.font.color = system_color
      self.contents.draw_text(x + 8, y + WLH * 2, 112, WLH, "Weapon Lvl:")
      self.contents.font.color = normal_color
      self.contents.draw_text(x + 120, y + WLH * 2, 64, WLH, equiped_weapon.level)
    end
  end
end

#==============================================================================
# ** Window_Char_WeaponStatus
#------------------------------------------------------------------------------
#  This window displays each players weapon and level on the upgrade sceen
#==============================================================================

class Window_Char_WeaponStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x, y, 384, 416)
    refresh
    self.active = false
    self.index = -1
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @item_max = $game_party.members.size
    for actor in $game_party.members
      draw_actor_face(actor, 2, actor.index * 96 + 2, 92)
      x = 104
      y = actor.index * 96 + WLH / 2
      draw_actor_name(actor, x, y)
      draw_actor_class(actor, x, y + WLH * 2)
      draw_actor_level(actor, x, y + WLH * 1)
      draw_actor_weapon(actor, x + 96, y)
    end
  end
  #--------------------------------------------------------------------------
  # * Update cursor
  #--------------------------------------------------------------------------
  def update_cursor
    if @index < 0               # No cursor
      self.cursor_rect.empty
    elsif @index < @item_max    # Normal
      self.cursor_rect.set(0, @index * 96, contents.width, 96)
    elsif @index >= 100         # Self
      self.cursor_rect.set(0, (@index - 100) * 96, contents.width, 96)
    else                        # All
      self.cursor_rect.set(0, 0, contents.width, @item_max * 96)
    end
  end
end

#==============================================================================
# ** Window_Akin_Price
#------------------------------------------------------------------------------
#  This window displays the price of the upgrade
#==============================================================================

class Window_Akin_Price < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize(x, y, price = 0)
    super(x, y, 160, 72)
    @price = price
    refresh(@price)
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh(price)
    self.contents.clear
    self.contents.draw_text(0, -4, 80, 24, "Price")
    draw_currency_value(price, 4, 12, 120)
  end
end


#==============================================================================
# ** Window_WeapUpgradeStatus
#------------------------------------------------------------------------------
#  This window displays the improvement that upgrading would give
#==============================================================================

class Window_WeapUpgradeStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x     : window X coordinate
  #     y     : window Y corrdinate
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(x, y, weapon)
    super(x, y, 160, WLH * 4 + 32)
    @weapon = weapon
    refresh(@weapon)
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh(weapon)
    @weapon = weapon
    unless @weapon == nil
      self.contents.clear
      draw_parameter(0, 0, 0)
      draw_parameter(0, WLH * 1, 1)
      draw_parameter(0, WLH * 2, 2)
      draw_parameter(0, WLH * 3, 3)
    end
  end
  #--------------------------------------------------------------------------
  # * Set Parameters After Equipping
  #     new_atk : attack after equipping
  #     new_def : defense after equipping
  #     new_spi : spirit after equipping
  #     new_agi : agility after equipping
  #--------------------------------------------------------------------------
  def set_new_stats(new_atk, new_def, new_spi, new_agi)
    if @new_atk != new_atk or @new_def != new_def or
       @new_spi != new_spi or @new_agi != new_agi
      @new_atk = new_atk
      @new_def = new_def
      @new_spi = new_spi
      @new_agi = new_agi
      refresh(@weapon)
    end
  end
  #--------------------------------------------------------------------------
  # * Get Post Equip Parameter Drawing Color
  #     old_value : parameter before equipment change
  #     new_value : parameter after equipment change
  #--------------------------------------------------------------------------
  def new_parameter_color(old_value, new_value)
    if new_value > old_value      # Get stronger
      return power_up_color
    elsif new_value == old_value  # No change
      return normal_color
    else                          # Get weaker
      return power_down_color
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Parameters
  #     x    : draw spot x-coordinate
  #     y    : draw spot y-coordinate
  #     type : type of parameter (0 - 3)
  #--------------------------------------------------------------------------
  def draw_parameter(x, y, type)
    case type
    when 0
      name = Vocab::atk
      value = @weapon.atk
      new_value = @new_atk
    when 1
      name = Vocab::def
      value = @weapon.def
      new_value = @new_def
    when 2
      name = Vocab::spi
      value = @weapon.spi
      new_value = @new_spi
    when 3
      name = Vocab::agi
      value = @weapon.agi
      new_value = @new_agi
    end
    self.contents.font.color = system_color
    self.contents.draw_text(x + 4, y, 80, WLH, name)
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 50, y, 30, WLH, value, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(x + 79, y, 20, WLH, ">", 1)
    if new_value != nil
      self.contents.font.color = new_parameter_color(value, new_value)
      self.contents.draw_text(x + 98, y, 30, WLH, new_value, 2)
    end
  end
end

#==============================================================================
# ** Scene_Weapons_Upgrade
#------------------------------------------------------------------------------
#  This class performs the weapon upgrade processing.
#==============================================================================

class Scene_Weapons_Upgrade < Scene_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     weapon_up_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(weapon_up_index = 0, player_index = 0)
    @weapon_up_index = weapon_up_index
    @actor_index = player_index
    @actor = $game_party.members[player_index]
    n = @actor.weapon_id
    @weapon = $data_weapons[n]
  end
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_background
    create_select_window
    @gold_window = Window_Gold.new(384, 360)
    @character_window = Window_Char_WeaponStatus.new(0, 0)
    @header_window = Window_Base.new(384, 0, 160, 80)
    #--------Shop Heading --------------------A34sZ1A -----------------------
    @header_window.contents.draw_text(0, 0, 128, 24, "Select Weapon", 1)
    @header_window.contents.draw_text(0, 24, 128, 24, "to Upgrade", 1)
    #--------Shop Heading End ----------------A34sZ1A -----------------------
    @upgrade_window = Window_WeapUpgradeStatus.new(384, 160, @weapon)
    @upgrade_window.visible = false
    @price_window = Window_Akin_Price.new(384, 288, 0)
    @price_window.visible = false
    @confirm_window = Window_Confirm.new
    @confirm_window.visible = false
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    @select_window.dispose
    @gold_window.dispose
    @character_window.dispose
    @header_window.dispose
    @upgrade_window.dispose
    @price_window.dispose
    @confirm_window.dispose
    $game_party.last_actor_index = 0
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    update_menu_background
    @select_window.update
    @gold_window.update
    @character_window.update
    @confirm_window.update
    if @select_window.active
      @upgrade_window.visible = false
      @price_window.visible = false
      update_select_selection
    elsif @character_window.active
      @upgrade_window.visible = true
      @price_window.visible = true
      update_actor_selection
      update_weapon_upgrade
    elsif @confirm_window.active
      update_confirm_window_selection
    end
  end
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  def create_select_window
  #-------- Menu Vocabulary -------------A34sZ1A ------------------------
    s1 = "Upgrade"
    s2 = "Exit"
  #------- Menu Vocabulary End-------------------------------------------
    @select_window = Window_Command.new(160, [s1, s2])
    @select_window.x = 384
    @select_window.y = 80
    @select_window.index = @weapon_up_index
  end
  #--------------------------------------------------------------------------
  # * Update Command Selection
  #--------------------------------------------------------------------------
  def update_select_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      return_scene
    elsif Input.trigger?(Input::C)
      Sound.play_decision
      case @select_window.index
      when 0      # Upgrade
        start_actor_selection
      when 1      # Back
        return_scene
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Start Actor Selection
  #--------------------------------------------------------------------------
  def start_actor_selection
    @select_window.active = false
    @character_window.active = true
    @character_window.index = 0
  end
  #--------------------------------------------------------------------------
  # * End Actor Selection
  #--------------------------------------------------------------------------
  def end_actor_selection
    @select_window.active = true
    @character_window.active = false
    @character_window.index = -1
  end
  #--------------------------------------------------------------------------
  # * Update Actor Selection
  #--------------------------------------------------------------------------
  def update_actor_selection
    if Input.trigger?(Input::B)
      @upgrade_window.visible = false
      @price_window.visible = false
      Sound.play_cancel
      end_actor_selection
    elsif Input.trigger?(Input::C)
      $game_party.last_actor_index = @character_window.index
      upgrade_weapon($game_party.last_actor_index)
    end
  end
  #--------------------------------------------------------------------------
  # * Update Confirm Window
  #--------------------------------------------------------------------------
  def update_confirm_window_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @confirm_window.active = false
      @confirm_window.visible = false
      @confirm_window.index = 0
      @character_window.active = true
      @confirm_window.close
    elsif Input.trigger?(Input::C)
      if @confirm_window.index == 0 # Yes
        @confirm_window.active = false
        @confirm_window.visible = false
        @confirm_window.index = 0
        @character_window.active = true
        Sound.play_use_skill
        player_index = @character_window.index
        @actor = $game_party.members[player_index]
        n = @actor.weapon_id
        equiped_weapon = $data_weapons[n]
        $game_party.lose_gold(@price)
        Akin_Weapons.level_up(equiped_weapon)
        @character_window.refresh
        @gold_window.refresh
      elsif @confirm_window.index == 1 # No
        Sound.play_cancel
        @confirm_window.active = false
        @confirm_window.visible = false
        @confirm_window.index = 0
        @character_window.active = true
        @confirm_window.close
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Update Upgrade Window
  #--------------------------------------------------------------------------
  def update_weapon_upgrade
    player_index = @character_window.index
    @actor = $game_party.members[player_index]
    n = @actor.weapon_id
    @weapon = $data_weapons[n]
    unless @weapon == nil
      #--------The Price formula -------------A34sZ1A -----------------------
      # The stats will increase by a 20% of their previous value + 1
      # Make this formula the same as the lvl up formula to make
      # The proper value display in the upgrade window
      # Make sure you keep the value set to an Integer by using ".to_i"
      # There is one more loaction of the price formula
      # find it with "SER23"
      temp = Math.exp(@weapon.level / 1.7)
      @price = 100 * @weapon.level + temp
      @price = @price.to_i
      #-------Price formula End ---------------------------------------------
      @upgrade_window.refresh(@weapon)
      @price_window.refresh(@price)
      @upgrade_window.visible = true
      @price_window.visible = true
      if @weapon.level < 20
        #--------Level Up Functions------BZ8q1-------A34sZ1A -----------------------
        # The stats will increase by a 20% of their previous value + 1
        # Make this formula the same as the lvl up formula to make
        # The proper value display in the upgrade window
        # Make sure you keep the value set to an Integer by using "Integer()"
        after_atk = Integer(@weapon.atk * 1.2 + 1)
        after_def = Integer(@weapon.def * 1.2 + 1)
        after_spi = Integer(@weapon.spi * 1.2 + 1)
        after_agi = Integer(@weapon.agi * 1.2 + 1)
        #-------Level Up Functions End-----------------------------------------
        @upgrade_window.set_new_stats(after_atk, after_def, after_spi, after_agi)
      else
        @upgrade_window.set_new_stats(@weapon.atk, @weapon.def, @weapon.spi, @weapon.agi)
        @price_window.refresh("N/A")
      end
    else
      @upgrade_window.visible = false
      @price_window.visible = false
    end
  end
  #--------------------------------------------------------------------------
  # * Upgrade Weapon Selected
  #--------------------------------------------------------------------------
  def upgrade_weapon(player_index)
    @actor = $game_party.members[player_index]
    n = @actor.weapon_id
    equiped_weapon = $data_weapons[n]
    if equiped_weapon == nil
      Sound.play_buzzer
    else
      #--------The Price formula ----SER23---------A34sZ1A -------------------
      # The stats will increase by a 20% of their previous value + 1
      # Make this formula the same as the lvl up formula to make
      # The proper value display in the upgrade window
      # Make sure you keep the value set to an Integer by using ".to_i"
      temp = Math.exp(@weapon.level / 1.7)
      @price = 100 * @weapon.level + temp
      @price = @price.to_i
      #-------Price formula End ---------------------------------------------
      
      #--------Item Max Level-------------A34sZ1A -----------------------
      # Change the number after "if equiped_weapon.level >="
      # to whatever you want the max weapon level to be
      if equiped_weapon.level >= 20
      #--------Item Max Level End----- ---A34sZ1A -----------------------
        Sound.play_buzzer
      elsif @price > $game_party.gold
        Sound.play_buzzer
      else
        Sound.play_decision
        @confirm_window.visible = true
        @character_window.active = false
        @confirm_window.open
        @confirm_window.index = 0
        @confirm_window.active = true
      end
        @character_window.refresh
    end
  end
  
  #--------------------------------------------------------------------------
  # * Return to Original Screen
  #--------------------------------------------------------------------------
  def return_scene
    #--------End Return-------------A34sZ1A ----------------------- 
    # Edit this line of code if you want to use this system as
    # part of the main menu
    #$scene = Scene_Menu.new(0) #Change this number to the options spot -1 on main menu
    $scene = Scene_Map.new
  end
end


# This edits the Scene_File class to add on saving and loading of weapon levels
class Scene_File < Scene_Base
  #-------------------------------Alias List
  alias akin_weaps_write_save_data write_save_data
  alias akin_weaps_read_save_data read_save_data
  
  def write_save_data(file)
	akin_weaps_write_save_data(file)
	Marshal.dump($data_weapons,        file)
  end
  
  def read_save_data(file)
	akin_weaps_read_save_data(file)
	$data_weapons         = Marshal.load(file)
  end 
end

Instructions

Put the scripts in the usual place above main. Call the upgrade menu using "$scene = Scene_Weapons_Upgrade.new". Each weapon ID has its own level assigned and the level spreads to copies of the same weapon with the same ID number.

Example
If Item 1 is a Club and you have Clubs on 2 characters, raising the level of either club will raise both of their levels and the level of any new club you acquire.

This shouldn't be a concern since most people who use this script will want a system where weapons are few and unique to certain characters, but its something that should be kept in mind when designing a game using this system.

Compatibility

Dargor Large Party Script
I altered part of Dargor's script into a patch for my script that allows the leveling weapons script to work with Dargor's large party script. Here it is, place this below the leveling weapon's script.

Code:
#==============================================================================
# ** Window_Char_WeaponStatus Patch
#------------------------------------------------------------------------------
#  This is a mod of Dargor's script and allows Akin's Leveling Weapon
#  System menu to function properly with a Large Party
#==============================================================================

class Window_Char_WeaponStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias akin_large_party_patch_ini initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y)
    @selection_rect = false
    @selection_y = 0
    akin_large_party_patch_ini(x, y)
    height = 416 + (96 * ($game_party.members.size-4))
    self.contents = Bitmap.new(width - 32, height - 32)
    self.height = 416
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    if @selection_rect
      color = Color.new(0,0,0,160)
      self.contents.fill_rect(2, @selection_y, contents.width-4, 92, color)
    end
    @item_max = $game_party.members.size
    for actor in $game_party.members
      draw_actor_face(actor, 2, actor.index * 96 + 2, 92)
      x = 104
      y = actor.index * 96 + WLH / 2
      draw_actor_name(actor, x, y)
      draw_actor_class(actor, x, y + WLH * 2)
      draw_actor_level(actor, x, y + WLH * 1)
      draw_actor_weapon(actor, x + 96, y)
    end
  end
  #--------------------------------------------------------------------------
  # * Set Selection Rect
  #--------------------------------------------------------------------------
  def set_selection_rect(index)
    @selection_rect = true
    @selection_y = index * 96 - WLH / 2 + 14
    refresh
  end
  #--------------------------------------------------------------------------
  # * Clear Selection Rect
  #--------------------------------------------------------------------------
  def clear_selection_rect
    @selection_rect = false
    refresh
  end
  #--------------------------------------------------------------------------
  # * Update cursor
  #--------------------------------------------------------------------------  
  alias akin_large_party_patch_update_cursor update_cursor
  def update_cursor
    #akin_large_party_patch_update_cursor (note: this must be an overwrite)
    if @index < 0
      self.cursor_rect.empty
      return
    end
    # Get top row
    row = @index  / @column_max
    if row < self.top_row
      self.top_row = row
    end
    # Reset Top Row if at bottom of list
    if row > self.top_row + (self.page_row_max - 1)
      self.top_row = row - (self.page_row_max - 1)
    end
    y = @index / @column_max * 96 - self.oy
    # Draw the cursor
    self.cursor_rect.set(0, y, contents.width, 96)
  end
  #--------------------------------------------------------------------------
  # * Get Top Row
  #--------------------------------------------------------------------------  
  def top_row
    return self.oy / 96
  end
  #--------------------------------------------------------------------------
  # * Set Top Row
  #     row : row shown on top
  #--------------------------------------------------------------------------  
  def top_row=(row)
    if row < 0
      row = 0
    end
    if row > row_max - 1
      row = row_max - 1
    end
    self.oy = row * 96
  end
  #--------------------------------------------------------------------------
  # * Get Number of Rows Displayable on 1 Page
  #--------------------------------------------------------------------------  
  def page_row_max
    return 4
  end
end

I don't know of any others. This doesn't rewrite anything it just adds a few methods to the windows class. Everything else added onto using alias so it should be fine.

Credits and Thanks

Prexus for his window_confirm class. It's really nice simple and adds a lot to your script menus.

Author's Notes

I might update this in a few weeks to make editing things in the script more user friendly.

Terms and Conditions

Use however you want if non-profit. If project is commercial PM me.
 
Hm... Is there a way we could use items to level up the weapons instead of gold? Like, let's say the party has 3 Upgrade Spheres and can use them on the weapons, but once they are used, you can't upgrade anymore.

If there is a way to do this, then I'll definitely use it for my game! :). (And give credit of course.)
~Innnoccence
 
Hmm, this is very nice. Just the way I described it. However I do notice one little bug. When you scroll down past the first four characters, the window doesn't update to accomodate the changes.

So you can move your cursor down past the window, but the faces and weapons don't change to show who's actually selected.
 

Akin

Member

Innoccence: yes its possible, but I don't plan of adding that kinda thing myself in the near future. Maybe somewhere down the road I will, but if your interested in modifying my script, the line of code that calls for a weapon to level up is this
Code:
Akin_Weapons.level_up(weapon_input)
# weapon input is where you input the weapon that you want to level up
# you can set up any kind of system or menu you want and call this to
# execute on any weapon, and that weapon will be leveled.

Skie Fortress: you'll have to send me the script your using for to have a party greater than 4. I'll take a look and see if there's an easy way to make them compatible.
 
Mr. Akin, this is really interesting script.  :thumb: I have some questions.

#1.
Could you tell me how to made the upgrade exclusively just for certain weapon?
I mean, something like, only weapon ID 001, 002, 003 and 004 that can be upgraded, else cannot.

#2.
I'm thinking if we can limit the maximum level upgrade for each weapon. Something like:
Weapon 003 max level 20  --> It can be upgraded until level 20
Weapon 004 max level 5  --> It can be upgraded until level 5
Weapon 005 max level 1  --> It cannot be upgraded

If you can answered the second question, then no need to answer my first question.

Thank you very very much for your help. :)
 

Akin

Member

Here is where a level is created for each weapon. I'm adding it as a variable to the Weapon class within the RPG module. The weapon class is for every weapon you make when using the RPG Maker VX database.
Code:
# This Module adds level to each weapon
module RPG
  class Weapon < BaseItem
  attr_accessor :level
  alias akin_weapon_level_system_ini initialize
    def initialize
      akin_weapon_level_system_ini
      @level = 1
    end
  end
end

What happens though is that since the database doesn't give any information on weapon level, since thats not a part of the information you input through the database, every weapon's level starts out as nil.

Thats where this comes in
Code:
module Akin_Weapons
  def self.level_up(weapon_input)
    if weapon_input.level == nil or weapon_input.level == 0
      weapon_input.level = 1
    end
    weapon_input.level += 1
    # leveling functions go here (omitted for this)
  end
end

The line "if weapon_input.level == nil or weapon_input.level == 0" makes it so that any weapon that doesn't have a level or for some reason is 0(I don't think that its possible I just coded it to be safe) is treated as though its level 1.

You'll find a similar line of code in the display that shows where weapon levels are shown in the level up menu.

Code:
class Window_Base < Window
  def draw_actor_weapon(actor, x, y)
    # some stuff
    if equiped_weapon == nil #check if the hand is empty
      # if empty display 'none'
    else
      # otherwise draw weapon name
      if equiped_weapon.level == nil or equiped_weapon.level == 0 #check if the weapon level is nil or 0
        $data_weapons[n].level = 1 #if it is make the level 1
        #rest of code
      end
      #rest of code
    end
  end
end

So to answer your question, the way I got the levels to stick with each weapon is because I added the "level" variable to the "Weapon" class inside the RPG module. I put checks for 'nil' to be treated as level 1, and thats basically it. So there arn't really any checks to the weapon ID to decide if a level will be levelable or not since every weapon now has a level variable even if its nil.

However, it could be done but there really isn't much in place in the current code to accomidate for it.

Line 534 in the code has the check for the maximum level
Code:
      if equiped_weapon.level >= 20
      #--------Item Max Level End----- ---A34sZ1A -----------------------
        Sound.play_buzzer

This could perhaps be expaned upon to something like
Code:
     if equiped_weapon.id = 'weapon_id here'
         if equiped_weapon.level >= 'max level' #max level wanted for that weapon

I'm pretty sure that thats basically how and where it should be done if you wanted to add something like that. Like I've said before I'm not planning on adding anything like that in the near future, but if you want to try to modify the code yourself I'd be glad to help explain my code better such or help you find where certain things are located within my code.

*well on second thought I might update the script later to make so that only certain weapons can be leveled.
 
Would you be interested in adding Armor to the lv up process... I know it's out of place... but just a small suggestion/request. I know it would be a lot of work... and will deviate from the original purpose of the script.
If not... it's no problem... great script btw...  :smile:
 
Wow, this reminds me of Disgaea, xD

But, lemme ask, is it possible to make it so that each weapon (even clones) level up separately? So, let's say you have a club, you train it to lv.20. Then you buy another, but it's lv.1 (or 0 or whatever). Can you make it like that? So that you don't master a weapon and then just rebuy them at the same level infinit times?

Also, can you make a small addition where leveled up weapons sell for a bit more?

Armors and accessories that level up would be nice as well. ^^

Thanks for a wonderful script. =)
-Krobe
 

Akin

Member

Xemnas13: well actually that wouldn't be hard to add armor. I'd just make a different menu call to start the process like "$scene = Scene_Weapons_Upgrade.new" for weapons and "$scene = Scene_Armor_Upgrade.new" for armor. I've got to finish up some personal projects first before I play with this script more though.

Krobelus: no I'm afraid thats the limit to this system. If you think about your inventrory when you have 2 clubs the game has no way of distinguishing one from the other. The game just knows that you have 2 of item#1 for example. So to attach levels to each weapon, I had to attach it to the ID number. Its just not possible to do otherwise without doing a major rehaul on how weapons in inventory are handled.

The leveled weapons selling for more is interesting, I'll consider adding something like that.
 
I'm glad that piqued your interest. I'm just wondering, but would it be hard to make weapons and armor non stackable? If not then it's alright, but yea.

Again, great script! =P
-Krobe
 

Akin

Member

If you want them not stackable just make multiple copies of them in the game database. For example, make weapon 1 though 25 all Clubs with the same starting stats and description. Just add as many clubs as you plan to give out.
 

Hero

Member

One question. Is it possible to transfer the levels from one weapon to the next? I'm just wondering because I plan to change the name of the weapons as well when they reach a certain level and would like for the weapon with the new name to keep the level.
 

Akin

Member

well if your not planning to change anything else but the weapon name then you could do something like this
$data_weapons[n].name = "new weapon name" were n is the ID number of the weapon.

you could also do something like this. n1 = original weapon ID# and n2 = new weapon ID#.

Code:
temp = $data_weapons[n1].level
if temp == nil
   temp = 1
end
while temp != 1
   Akin_Weapons.level_up($data_weapon[n2])
   temp -= 1
end

Just toss that code onto the event that you want to change the weapon at and it "should" work.
 
Just a little bug:
In the script explanation it is said that to call the script you must call "$scene = Scene_Scene_Weapons_Upgrade.new".
It's "$scene = Scene_Weapons_Upgrade.new".

Hero":xmi2k3xt said:
One question. Is it possible to transfer the levels from one weapon to the next? I'm just wondering because I plan to change the name of the weapons as well when they reach a certain level and would like for the weapon with the new name to keep the level.
Well, ain't a bad idea, but how far can the database handle weapons? If you'll use 15 levels of weaponry with 50 weapons, that's already 750 slots used...

Akin":xmi2k3xt said:
Put the scripts in the usual place above main. Call the upgrade menu using "$scene = Scene_Weapons_Upgrade.new". Each weapon ID has its own level assigned but the level does not spread to copies of the same weapons.

Example
If Item 1 is a Club and you have Clubs on 2 characters, raising the level of either club will raise both of their levels and the level of any new club you acquire..

This shouldn't be a concern since most people who use this script will want a system where weapons are few and unique to certain characters, but its something that should be kept in mind when designing a game using this system.
Can you set this script for making that only ONE player learns the weapon's skill (like Secret of Mana)?

Krobelus":xmi2k3xt said:
But, lemme ask, is it possible to make it so that each weapon (even clones) level up separately? So, let's say you have a club, you train it to lv.20. Then you buy another, but it's lv.1 (or 0 or whatever). Can you make it like that? So that you don't master a weapon and then just rebuy them at the same level infinit times?
If that's possible, would be very interesting to use this script as an blacksmith's shop system...

Innoccence":xmi2k3xt said:
Hm... Is there a way we could use items to level up the weapons instead of gold? Like, let's say the party has 3 Upgrade Spheres and can use them on the weapons, but once they are used, you can't upgrade anymore.
That's something cool also... Recalls Ragnarok Online, where you'd need certain ore to do such upgrades.
Is it possible??

Somethin' cool I realized about:
In order to define the price of the level up (or refining, whatever), you can search for line 483 and 527 (OR search for BZ8q1 and SER23, respectively). Change the part in red (@price = 100 * @weapon.level + temp) into whatever you desires. This way you can set the pricing to be a standard or not, or add a different value.
 

Akin

Member

Typo fixed in the script posted but not in the demo.

foxbuster":2453afa4 said:
Can you set this script for making that only ONE player learns the weapon's skill (like Secret of Mana)?

No, the weapon level is attached to the weapon ID. There is no way to seperate the two this is the way weapons are defined in RGSS. If you want weapons with the same name but different levels you have to make multiple copies of them in the database.

foxbuster":2453afa4 said:
If that's possible, would be very interesting to use this script as an blacksmith's shop system...

again not possible. Every Weapon in the database is made up of serveral things ID, Name, ATK, DEF, SPI, PRICE, and Quantity. Whenever Quantity is set to any number greater than 0, the game draws the Weapon Name and Quantity in your inventory. You never actually "make a copy" of the weapon. Your never actually getting a sword in the game. You just increasing the Quanitity Value by 1 and making it bigger than 0.

Since you never actually get a copy of the weapon, there is no place to store level values for "clone" weapons. Since there are no "clone" weapons. You just changed the Weapon Quantity value from 1 to 2, or 1 to 3, etc.

The only place I can put a weapon level is with the ID#, because that is the only thing that actually exists. If all clubs have the same ID number all clubs will have the same level.

Sidenote: thanks for noticing the places that I marked the prices I wanted people to be able to change things if they wanted.
 
Akin":3ge6qlg7 said:
foxbuster":3ge6qlg7 said:
If that's possible, would be very interesting to use this script as an blacksmith's shop system...
again not possible. Every Weapon in the database is made up of serveral things ID, Name, ATK, DEF, SPI, PRICE, and Quantity. Whenever Quantity is set to any number greater than 0, the game draws the Weapon Name and Quantity in your inventory. You never actually "make a copy" of the weapon. Your never actually getting a sword in the game. You just increasing the Quanitity Value by 1 and making it bigger than 0.

Since you never actually get a copy of the weapon, there is no place to store level values for "clone" weapons. Since there are no "clone" weapons. You just changed the Weapon Quantity value from 1 to 2, or 1 to 3, etc.
It is possible IF we can when evolving the weapons, change the ID code of the selected weapon to another one, like you mentioned before, but we'd need a load of space in the RGSS database. Do you know how much can it handle? like 1000 or 10000 weapons in DB?

Akin":3ge6qlg7 said:
Sidenote: thanks for noticing the places that I marked the prices I wanted people to be able to change things if they wanted.
We're here to help... XD

Still, remained the question...

foxbuster":3ge6qlg7 said:
Innoccence":3ge6qlg7 said:
Hm... Is there a way we could use items to level up the weapons instead of gold? Like, let's say the party has 3 Upgrade Spheres and can use them on the weapons, but once they are used, you can't upgrade anymore.
That's something cool also... Recalls Ragnarok Online, where you'd need certain ore to do such upgrades.
Is it possible??
Is it possible?? ²
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top