Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Digioso Weapon Upgrades, Ever wanted to upgrade your weapons?
Digioso
post Oct 24 2011, 10:19 AM
Post #1


Level 2
Group Icon

Group: Member
Posts: 20
Type: Event Designer
RM Skill: Skilled




Digioso Weapon Upgrades

Version 1.3
Author: Digioso - http://www.digioso.org
Release Date: 24.10.2011
Version 1.1: 30.10.2011
Version 1.2: 08.11.2011
Version 1.3: 03.12.2011

Introduction
This script provides kind of an upgrading system for weapons. It puts the
current level into the description of a weapon and raises the attack of a
weapon by a fixed value or percentage you can specify below.
Warning: This changes the weapon completely. So this system is designed for
games that use a limited amount of weapons (like Secret of Mana does). If
you have two "Short swords" and upgrade "Short sword" then both swords are on
level 2. So if your enemies drop weapons like crazy this script is not for you.

Features
- Provides upgradeable weapons
- You can specify how much attack the weapons gain per level based on percentages or fixed values
- Change weapon names, their icons and their description
- The script can put the level of a weapon and the current icon it uses into a game variable you can then use in your events

Script
Script

CODE
=begin
Digioso Weapon Upgrades 1.3
Ever wanted to upgrade your weapons?
Newest version available at: http://www.digioso.org/Digioso_weapons

Changelog:
1.1 - 30.10.2011
You now can use multiple lines when you want to set the name or description.
I'm replacing the newlines you'd normally have with nothing so that they're not
shown in the game anymore.
However to change the name you have to use $Digioso_weapons.set_name(weapon_id, "Name...")
instead of $data_weapons[weapon_id].name = "Name..."
1.2 - 08.11.2011
If you saved and loaded your game all upgrades done via this script
were lost. So all your weapons were back to level 1 and only had the base damage.
This is now fixed.
1.3 - 03.12.2011
You can now change the icons of weapons as well. And you can put the current
icon id into a variable.

=end

class Digioso_weapons
  
  def initialize
    
    # Manual:
    
    # This script provides kind of an upgrading system for weapons. It puts the
    # current level into the description of a weapon and raises the attack of a
    # weapon by a fixed value or percentage you can specify below.
    # Warning: This changes the weapon completely. So this system is designed for
    # games that use a limited amount of weapons (like Secret of Mana does). If
    # you have two "Short swords" and upgrade "Short sword" then both swords are on
    # level 2. So if your enemies drop weapons like crazy this script is not for you.
    
    # Commands:
    # $Digioso_weapons.add_level(weapon_id) <- adds a level to weapon
    # Example: $Digioso_weapons.add_level(1) <- adds a level to the weapon with id 1

    # $Digioso_weapons.change_plus(weapon_id, value) <- changes the attack value
    # you gain per level for this item
    # Example: $Digioso_weapons.change_plus(1, 10) <- you will now gain 10 attack
    # per level for weapon 1
    # You don't have to specify a weapon in the script. With the above command
    # it sets the attack value you gain per level in any case, regardless if you
    # have set something up in this script below or not.
    
    # $Digioso_weapons.get_icon(weapon_id) <- Puts the current icon of this
    # weapon into the variable you define below.
    
    # $Digioso_weapons.set_icon(weapon_id, icon) <- Set the icon of this
    # weapon into the icon you specified. Please be aware that the top left icon
    # has ID 0. So the second icon is 1, the third 3 and so on.
    
    # $Digioso_weapons.put_var(weapon_id) <- Puts the current level of this weapon into
    # the variable you define below.
    # Example: $Digioso.put_var(1) <- The variable will now contain the level for
    # the weapon with id 1
    
    # A note on setting the description and the name. As you might now the size of
    # the script command in an event is limited. If you use multiple lines for your
    # script call you'd normally have the newlines shown as squares in the game.
    # I scripted around this so you can have as many lines of text as you want.
    # However if the text is too long the game will make it smaller ingame.
    
    # $Digioso_weapons.set_description(weapon_id, "description") <- Changes the description
    # of weapon weapon_id
    # Example: $Digioso_weapons.set_description(3, "Delivers the wrath of Digioso")
    # This sets the description of weapon 3 to: Delivers the wrath of Digioso
    # Another note on this: If you turn off the description based level indicator
    # (see further below) you can still put a (Level xx) in your description and
    # even if the description system is turned off these weapons will then get a
    # description with the upgrade level. So basically this is a way you can enable
    # the description system for some weapons. Scroll down to the "use_lvl" manual
    # to read more on this.
    
    # To change the name of a weapon:
    # $Digioso_weapons.set_name(weapon_id, "Name...")
    # Example: $Digioso_weapons.set_name(1, "Digiosos sword of ultimate doom")
    # Changes the name of weapon 1 to "Digiosos sword of ultimate doom".
    
    # Here's an idea on how to use all this:
    # Tink of Secret of Mana (Seiken Densetsu 2).
    # There you have to find weapon orbs in order to make your weapons better.
    # Instead of just adding a level to the description
    # (Sword (Level 1), Sword (Level 2), ...)
    # they change the name and the description. And the attack value of course.
    # The weapons in RMVX normally don't have any level indicator in their
    # description.
    # The script automatically handles these weapons as level 1 and makes them
    # level 2 the first time you execute the script for a weapon.
    # In case you want to specify a starting level for a weapon you simply have
    # to change the description in the RMVX Editors database.
    # Eg. weapon 22 (Golden Staff):
    # Description is: A magic staff that emits a golden glow.
    # Change it to: A magic staff that emits a golden glow. (Level 5)
    # Now this weapon starts at Level 5.
    # Please be aware that the "Level" text is what you have to define behind
    # "description" below. So if you name it "Lvl" there you have to name it "Lvl"
    # in the database as well.
    
    # Configuration hash - don't change next row
    @weapons = {
    
    # Define here which Game Variable the script should use (Standard is 1)
      "var"      => 1,
    
    # Define the default attack value you gain per level behind def_plus
      "def_plus" => 5,
      
    # Set percent to true if you want to gain attack based on percent
    # Eg: If a weapon has 10 base attack and you add 10% you will have 11 after that
    # In this case without percent you will have 20 (10 base + 10 = 20)
    # Only full numbers count for percent calculation! 10% of 19
    # is still 1 and not 1,9!
      "percent" => false,
      
    # To identify the current weapon level the script adds someting behind the
    # weapon description.
    # Eg your simple sword has the description "A simple sword"
    # Then the script changes it to this: "A simple sword (Level 2)
    # Next time you execute the script you will get "A simple sword (Level 3)
    # and so on
      "description" => "Level",
      
    # The standard behavior of the script is to use what I described above.
    # It adds a level indicator behind the description.
    # But if you want to create something similar to Secret of Mana you probably
    # don't want this. Set use_lvl to false in this case. Otherwise leave it on true.
    # If you have specified a level description for a weapon in the database
    # the description will be updated regardless if use_lvl is turned on or not.
    # So basically this way you can have some weapons which use the system and
    # some that don't use it!
      "use_lvl" => true,
      
    # Now here's the place to spefiy the attack value you gain per level.
    # The syntax is: weapon_id => value
    # Example: 1 => 5
    # This adds 5 (or 5%) to the attack value of weapon 1.
    # If you don't want to use unique settings per weapon delete the next row.
    # Also remove the comma (,) at the end of the use_lvl row.
    # If you decide to again use it put the comma (,) back there.
    # And of course you can change/add these values with the change_plus command
    # as described above.
    # Don't forget to add a comma to the end of every row (except the last one)
    # if you want to add multiple weapons.
    1 =>   5,
    2 =>  10
      
#---End of configuration! Don't edit further unless you know what you're doing!---
    }
    
    # This hash contains the current level of all weapons.
    # Is is automatically filles with values when you upgrade a weapon.
    @weapon_level = Hash.new
    
  end
  
  # Changes (or adds) the attack value you gain per level for weapon_id
  def change_plus(weapon_id, value)
    @weapons[weapon_id] = value
  end
  
  # Adds a level to a weapon
  def add_level(weapon_id)

    # Does the weapon already have a level description?
    if($data_weapons[weapon_id].description =~ /^(.*?)\(#{@weapons["description"]} (\d+)\)(.*?)$/)
      description1 = $1
      currentlevel = $2.to_i
      description2 = $3
      # Add one level
      if(@weapon_level.has_key?(weapon_id))
        @weapon_level[weapon_id] += 1
      else
        @weapon_level[weapon_id]  = currentlevel + 1
      end
      # Set new description
      $data_weapons[weapon_id].description  = "#{description1}(#{@weapons["description"]} #{@weapon_level[weapon_id]}#{description2})"
    else
      # Do we want to use the Description based level system?
      if(@weapons["use_lvl"])
        # A weapon normally starts at level 1 so the first time you
        # upgrade it you automatically have level 2.
        $data_weapons[weapon_id].description += " (#{@weapons["description"]} 2)"
      end
      # Update weapon level hash
      if(@weapon_level.has_key?(weapon_id))
        @weapon_level[weapon_id] += 1
      else
        @weapon_level[weapon_id]  = 2
      end
    end
    # Do we have a specific entry for this weapon_id?
    if(@weapons.has_key?(weapon_id))
      # Do we want to use percent?
      if(@weapons["percent"])
        # New attack = Current attack + (Current attack * attack_value_growth) / 100
        $data_weapons[weapon_id].atk += ($data_weapons[weapon_id].atk * @weapons[weapon_id]) / 100
      else
        # New attack = Current attack + attack_value_growth
        $data_weapons[weapon_id].atk += @weapons[weapon_id]
      end
    # No entry for this weapon_id. Use default.
    else
      # Do we want to use percent?
      if(@weapons["percent"])
        # New attack = Current attack + (Current attack * attack_value_growth) / 100
        $data_weapons[weapon_id].atk += ($data_weapons[weapon_id].atk * @weapons["def_plus"]) / 100
      else
        # New attack = Current attack + attack_value_growth
        $data_weapons[weapon_id].atk += @weapons["def_plus"]
      end
    end
  end
  
  # This method set's the description of a weapon
  def set_description(weapon_id, description)
    # Remove newlines (\n) from the String.
    description.gsub!("\n", "")
    # Does the weapon already have a level description?
    if($data_weapons[weapon_id].description =~ /^.*?\(#{@weapons["description"]} (\d+)\)(.*?)$/)
      # Set new description
      $data_weapons[weapon_id].description  = "#{description}(#{@weapons["description"]} #{$1}#{$2})"
    else
      # Do we want to use the Description based level system?
      if(@weapons["use_lvl"])
        # A weapon normally starts at level 1. If we end of here this weapon
        # doesn't have the upgrade level in it's description yet. Let's set it to 1.
        $data_weapons[weapon_id].description = "#{description} (#{@weapons["description"]} 1)"
      else
        # We don't want to use this system so let's just change the description.
        $data_weapons[weapon_id].description = description
      end
    end
  end
  
  def get_icon(weapon_id)
    $game_variables[@weapons["var"]] = $data_weapons[weapon_id].icon_index
  end
  
  def set_icon(weapon_id, icon)
    $data_weapons[weapon_id].icon_index = icon.to_i
  end
  
  def set_name(weapon_id, name)
    # Remove newlines (\n) from the String and set the name
    $data_weapons[weapon_id].name = name.gsub("\n", "")
  end
  
  # Puts the current upgrade level of weapon weapon_id into a game variable.
  def put_var(weapon_id)
    # Is the level already set in the hash?
    if(@weapon_level.has_key?(weapon_id))
      $game_variables[@weapons["var"]] = @weapon_level[weapon_id]
    # If it isn't, check if we can get the current level from the description.
    elsif($data_weapons[weapon_id].description =~ /^.*?\(#{@weapons["description"]} (\d+)\)/)
      $game_variables[@weapons["var"]] = $1
    # Still no result? Well, then the weapon must be on Level 1
    else
      $game_variables[@weapons["var"]] = 1
    end
  end
  
end

class Scene_File < Scene_Base
  # Save current data
  alias digioso_write_save_data_digioso_weapons write_save_data
  def write_save_data(file)
    digioso_write_save_data_digioso_weapons(file)
    Marshal.dump($Digioso_weapons, file)
    Marshal.dump($data_weapons, file)
  end

  # Load current data
  alias digioso_read_save_data_digioso_weapons read_save_data
  def read_save_data(file)
    digioso_read_save_data_digioso_weapons(file)
    $Digioso_weapons = Marshal.load(file)
    $data_weapons = Marshal.load(file)
  end
end

# Create a new object of this class and put it into $Digioso_weapons
$Digioso_weapons = Digioso_weapons.new


Customization
Manual
CODE
# Manual:
    
    # This script provides kind of an upgrading system for weapons. It puts the
    # current level into the description of a weapon and raises the attack of a
    # weapon by a fixed value or percentage you can specify below.
    # Warning: This changes the weapon completely. So this system is designed for
    # games that use a limited amount of weapons (like Secret of Mana does). If
    # you have two "Short swords" and upgrade "Short sword" then both swords are on
    # level 2. So if your enemies drop weapons like crazy this script is not for you.
    
    # Commands:
    # $Digioso_weapons.add_level(weapon_id) <- adds a level to weapon
    # Example: $Digioso_weapons.add_level(1) <- adds a level to the weapon with id 1

    # $Digioso_weapons.change_plus(weapon_id, value) <- changes the attack value
    # you gain per level for this item
    # Example: $Digioso_weapons.change_plus(1, 10) <- you will now gain 10 attack
    # per level for weapon 1
    # You don't have to specify a weapon in the script. With the above command
    # it sets the attack value you gain per level in any case, regardless if you
    # have set something up in this script below or not.
    
    # $Digioso_weapons.get_icon(weapon_id) <- Puts the current icon of this
    # weapon into the variable you define below.
    
    # $Digioso_weapons.set_icon(weapon_id, icon) <- Set the icon of this
    # weapon into the icon you specified. Please be aware that the top left icon
    # has ID 0. So the second icon is 1, the third 3 and so on.
    
    # $Digioso_weapons.put_var(weapon_id) <- Puts the current level of this weapon into
    # the variable you define below.
    # Example: $Digioso.put_var(1) <- The variable will now contain the level for
    # the weapon with id 1
    
    # A note on setting the description and the name. As you might now the size of
    # the script command in an event is limited. If you use multiple lines for your
    # script call you'd normally have the newlines shown as squares in the game.
    # I scripted around this so you can have as many lines of text as you want.
    # However if the text is too long the game will make it smaller ingame.
    
    # $Digioso_weapons.set_description(weapon_id, "description") <- Changes the description
    # of weapon weapon_id
    # Example: $Digioso_weapons.set_description(3, "Delivers the wrath of Digioso")
    # This sets the description of weapon 3 to: Delivers the wrath of Digioso
    # Another note on this: If you turn off the description based level indicator
    # (see further below) you can still put a (Level xx) in your description and
    # even if the description system is turned off these weapons will then get a
    # description with the upgrade level. So basically this is a way you can enable
    # the description system for some weapons. Scroll down to the "use_lvl" manual
    # to read more on this.
    
    # To change the name of a weapon:
    # $Digioso_weapons.set_name(weapon_id, "Name...")
    # Example: $Digioso_weapons.set_name(1, "Digiosos sword of ultimate doom")
    # Changes the name of weapon 1 to "Digiosos sword of ultimate doom".
    
    # Here's an idea on how to use all this:
    # Tink of Secret of Mana (Seiken Densetsu 2).
    # There you have to find weapon orbs in order to make your weapons better.
    # Instead of just adding a level to the description
    # (Sword (Level 1), Sword (Level 2), ...)
    # they change the name and the description. And the attack value of course.
    # The weapons in RMVX normally don't have any level indicator in their
    # description.
    # The script automatically handles these weapons as level 1 and makes them
    # level 2 the first time you execute the script for a weapon.
    # In case you want to specify a starting level for a weapon you simply have
    # to change the description in the RMVX Editors database.
    # Eg. weapon 22 (Golden Staff):
    # Description is: A magic staff that emits a golden glow.
    # Change it to: A magic staff that emits a golden glow. (Level 5)
    # Now this weapon starts at Level 5.
    # Please be aware that the "Level" text is what you have to define behind
    # "description" below. So if you name it "Lvl" there you have to name it "Lvl"
    # in the database as well.
    
    # Configuration hash - don't change next row
    @weapons = {
    
    # Define here which Game Variable the script should use (Standard is 1)
      "var"      => 1,
    
    # Define the default attack value you gain per level behind def_plus
      "def_plus" => 5,
      
    # Set percent to true if you want to gain attack based on percent
    # Eg: If a weapon has 10 base attack and you add 10% you will have 11 after that
    # In this case without percent you will have 20 (10 base + 10 = 20)
    # Only full numbers count for percent calculation! 10% of 19
    # is still 1 and not 1,9!
      "percent" => false,
      
    # To identify the current weapon level the script adds someting behind the
    # weapon description.
    # Eg your simple sword has the description "A simple sword"
    # Then the script changes it to this: "A simple sword (Level 2)
    # Next time you execute the script you will get "A simple sword (Level 3)
    # and so on
      "description" => "Level",
      
    # The standard behavior of the script is to use what I described above.
    # It adds a level indicator behind the description.
    # But if you want to create something similar to Secret of Mana you probably
    # don't want this. Set use_lvl to false in this case. Otherwise leave it on true.
    # If you have specified a level description for a weapon in the database
    # the description will be updated regardless if use_lvl is turned on or not.
    # So basically this way you can have some weapons which use the system and
    # some that don't use it!
      "use_lvl" => true,
      
    # Now here's the place to spefiy the attack value you gain per level.
    # The syntax is: weapon_id => value
    # Example: 1 => 5
    # This adds 5 (or 5%) to the attack value of weapon 1.
    # If you don't want to use unique settings per weapon delete the next row.
    # Also remove the comma (,) at the end of the use_lvl row.
    # If you decide to again use it put the comma (,) back there.
    # And of course you can change/add these values with the change_plus command
    # as described above.
    # Don't forget to add a comma to the end of every row (except the last one)
    # if you want to add multiple weapons.
    1 =>   5,
    2 =>  10


Compatibility
No known issues. But the script changes the description of weapons if you use it with the default settings.
I tried to minimize the impact it could have here but their might be compatibility issues with other scripts that change or rely on weapon descriptions.
I'm aliasing the methods "read_save_data" and "write_save_data" from the Scene_File class.

Screenshot
http://www.digioso.org/cgi-bin/gallery.pl?...pon_upgrade.jpg

DEMO
http://www.digioso.org/Digioso_weapons

Installation
Put below "Materials" and above "Main Process".
See the manual in the script for further details.
Also check the demo to see the script in action!

FAQ
Q: The demo won't open, how to open it?
A: Download 7zip and try again.

Terms and Conditions
Free to use in non-commercial projects. Modify the script if you like but credit me. Also I'd like to be informed of edits so that I can update the script here and maybe use them myself. smile.gif

Credits
Digioso

This post has been edited by Digioso: Dec 3 2011, 05:24 AM


__________________________
Leg dich nie mit einem BAOD an, oder du bist selber dran.

Das Leben ist grausam.
Wenn es mal nicht grausam ist, ist es grausamer.

Go to the top of the page
 
+Quote Post
   
nevious
post Oct 27 2011, 06:25 PM
Post #2


Hyperfunctional Drive Modulator?
Group Icon

Group: Revolutionary
Posts: 337
Type: Artist
RM Skill: Advanced




is there a way you can level up only one weapon at a time? such as if a character were to wield a lvl 2 short sword and a lvl 4 short sword at the same time. it would make for a very interesting script. otherwise having it lvl up all weapons of that type only acomidates to users of that style only.

i want to set up a game kind of like legend of mana were the character is able to place in a simple weapon and change it in to a element upgrade weapon or other types. thats what this script sorta sounds like but for the amount of weapon drops i plan on doing it wont work for me. a shame really it sounds amazing...


__________________________
Artist: Advanced
Musician: None
Scripter: Undisclosed
Writer: Beginner
Developer: None
Event Designer: Intermediate







[Show/Hide] Signatures








necroking nevious


Check out my Gallery!! (please leave comments constructive critizism helps. but please dont be rude.
My Gallery!!

Omegazions rougelike battlesystem in action


Go to the top of the page
 
+Quote Post
   
Digioso
post Oct 27 2011, 10:17 PM
Post #3


Level 2
Group Icon

Group: Member
Posts: 20
Type: Event Designer
RM Skill: Skilled




In your case you could create two Short Sword weapons with the same stats in the database.
Then you have two different weapons and can upgrade them separately.

Using only one weapon and having different levels there is not possible. (Or at least that is how I see it - I'm still only beginning with scripting, though...)

The problem here is that all weapons in RPG Maker VX are based on what you specify in the database.
Have a look at the screenshot. As you can see I have two Clubs in my inventory.
I can't see any way on how to split them up into two entries and handle them separately (eg making one Level 2 and the other one Level 4).
Attached File(s)
Attached File  digioso_weapons2.JPG ( 45.29K ) Number of downloads: 16
 


__________________________
Leg dich nie mit einem BAOD an, oder du bist selber dran.

Das Leben ist grausam.
Wenn es mal nicht grausam ist, ist es grausamer.

Go to the top of the page
 
+Quote Post
   
Digioso
post Oct 30 2011, 12:50 AM
Post #4


Level 2
Group Icon

Group: Member
Posts: 20
Type: Event Designer
RM Skill: Skilled




Just a small update:

1.1 - 30.10.2011
You now can use multiple lines when you want to set the name or description.
I'm replacing the newlines you'd normally have with nothing so that they're not
shown in the game anymore.
However to change the name you have to use $Digioso_weapons.set_name(weapon_id, "Name...")
instead of $data_weapons[weapon_id].name = "Name..."

I updated the script and the demo in the first post with version 1.1.


Edit:
Aww, everybody who downloaded the demo in the last 30 minutes should download it again.
The demo had the settings I'm using in my game, which are not really working with the demo.
I uploaded a fixed demo now.

This post has been edited by Digioso: Oct 30 2011, 01:16 AM


__________________________
Leg dich nie mit einem BAOD an, oder du bist selber dran.

Das Leben ist grausam.
Wenn es mal nicht grausam ist, ist es grausamer.

Go to the top of the page
 
+Quote Post
   
Digioso
post Nov 7 2011, 11:13 PM
Post #5


Level 2
Group Icon

Group: Member
Posts: 20
Type: Event Designer
RM Skill: Skilled




Another update. This time it's something major. So far the script was pretty much useless because all changes done by it were lost after saving and reloading your game. I just found out yesterday that the game doesn't take care of saving custom script data by itself and that it's my job to take care of this. Well, I did now. I updated my website and the first posting with the newest version.
Sorry for this. sad.gif


__________________________
Leg dich nie mit einem BAOD an, oder du bist selber dran.

Das Leben ist grausam.
Wenn es mal nicht grausam ist, ist es grausamer.

Go to the top of the page
 
+Quote Post
   
Digioso
post Dec 3 2011, 05:26 AM
Post #6


Level 2
Group Icon

Group: Member
Posts: 20
Type: Event Designer
RM Skill: Skilled




Updated to 1.3
It is now possible to change the icon of a weapon as well. And you can put the current icon into a game variable.


__________________________
Leg dich nie mit einem BAOD an, oder du bist selber dran.

Das Leben ist grausam.
Wenn es mal nicht grausam ist, ist es grausamer.

Go to the top of the page
 
+Quote Post
   
Shaddow
post Dec 21 2011, 12:53 PM
Post #7


The Eventer Inventor
Group Icon

Group: Local Mod
Posts: 1,250
Type: Event Designer
RM Skill: Masterful
Rev Points: 90




This is extremely awesome and strongly reminds me of Suikoden, which I love, I wish my current game style could use this. I plan to use it in my next game because it is so awesome, just wanted to say keep up the good work!


__________________________




I support these projects! -------------





Go to the top of the page
 
+Quote Post
   
Digioso
post Dec 21 2011, 01:03 PM
Post #8


Level 2
Group Icon

Group: Member
Posts: 20
Type: Event Designer
RM Skill: Skilled




Thanks. Glad you like it. smile.gif


__________________________
Leg dich nie mit einem BAOD an, oder du bist selber dran.

Das Leben ist grausam.
Wenn es mal nicht grausam ist, ist es grausamer.

Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 23rd May 2013 - 07:07 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker