RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Weapon Leveling Script Help *cough* blizzard *cough*

0 Members and 3 Guests are viewing this topic.

***
Rep:
Level 88
Menu & Battle System Guru
Alright, so I am trying to edit this script so that when a weapon reaches a certain interval (area of levels ex: levels 1-5) the character will learn a new skill(s).

Here's the script (btw the interval part is all set up...its near the end of the script, I just need to know how to get the character to gain the skill when the interval is reached):

Code: [Select]
#==============================================================================
#  <> Game_Weapons & Game_Weapon
#  ==> You can delete all the comments except the copyright and creator info. Thanks.
#  ==> Do not rip, repost or any other way of reproducing without proper credit. Thanks.
#  ShadowClan Technologies © 2003-2005 - All rights reserved. Creation Asylum rules :-)
#------------------------------------------------------------------------------
# Put (below) in Scene_Battle 2 so weapon can gain exp
# ************************************************
#       wpn = enemy.exp / 2
#       for i in 0...$game_party.actors.size
#         unless $game_party.actors[i].weapon_id == nil or $game_party.actors[i].weapon_id == 0
#           $game_weapons[$game_party.actors[i].weapon_id].gain_exp(wpn)
#         end
#       end
# ************************************************

# * You could choose anything to make, but you chose THIS! Why?!
# Because a friend of mine requested it and I found it a challenge.
# Actually, I wanted it to make earlier but I thought nah it's too hard for me...
# But a couple of days ago, I though what the hell, I'll take my chances!
# I began scripting and voilà, this is what it has become!
# It's actually better than some of those japanese scripts,
# so hahaha in your face, you smart japanese people!! (Respect though)
# If this script still misses something, please tell me and I will
# add it plus your name as a contributer of course. Thanks in advance.
#
# * Something to keep in mind
# This is a stand alone script and doesn't require anything else to be imported.
# I didn't make any windows or scenes with this so you're on your own!
# Why didn't I make it? I don't have the time right now -- I'm creating my game first!
# It just happen to be that I needed a script like this one... heh... cool..
#
# * Okay... but what does it do? What's the point?
# It allows the weapons to have their own status.
# So that it also gains EXP and levels up.
# You can set each weapon (unfortunely only by their IDs)
# to have each their own stuff like maximum level and etc.
# This makes it more variable and thus more fun to deal with!
# Wait... what you say? You want it to apply on armors too?
# All you do is copy this whole thing and replace everything
# that says 'weapon' to 'armor' and replace $data_weapons
# to $data_armors and atk to pdef or something...
#
# * How do I use this?
# In the Scene_Title at command_new_game, just add
#
# $game_weapons = Game_Weapons.new
#
# underneath all the other $game stuff.
# From that point on you can use it.
# Don't forget to put it in Scene_Save and Scene_Load too!
#
# * You mean I have to set up for EVERY weapon status?!
# Actually, yes, but I'll teach you a very quick way of doing faster:
# Go to your events page in an event and search in Page 4 for
# the Call Script button and add this:
#
# $game_weapons = Game_Weapons.new
# for id in 1...$data_weapons.size
#   $game_weapons[id].setup(id)
# end
#
# This sets for all weapons their own status.
# You can later modify a weapon just by using setup again
# but with your own initial status (see below).
#
# * I want a weapon with my own initial status! How do I do that?
# Type in Call Script of somewhere in a scene:
#
# $game_weapons[WeaponID].setup(ID, level, exp, break, broke, next_exp, expvar, max_level,
# break_add, max_break, atk_up)
#
# Quick Reference:
# ID              : Well, the weapon ID duh
# level           : The initial level for the weapon (Use only integers [numbers])
# exp            : Initially needed EXP to level it up (Default: 300)
# break          : % of break to the weapon (Default: 0)
# broke         : If it's initially broken true/false (Default: false)
# next_exp     : Needed EXP to level it up initially (Default: 300)
# expvar        : This calculates the EXP needed (expvar * level = next exp) (Default: 300)
# max_level   : Maximum level for that particular weapon (Default: 100)
# break_add  : Amount of pnts. added to break of that weapon (Default: 1)
# max_break  : Maximum break % for that particular weapon (Default: 100)
# atk_up        : Added attack power to weapon each level gained (optional) (Default: 1)
#
# * How do I check status?
# When defined $game_weapons, just use:
# $game_weapons[weapon_ID].*
# where the * can be:
# level - Returns the current weapon level
# exp - Returns the current weapon exp
# next_exp - Returns the current needed exp for next level
# break_amount - Returns the % of break
# level_up - Returns true if it's leveled up or false if it isn't. (optional)
# class - The rank of the weapon (optional)
# id - Returns the ID nothing special, you won't even use it...
# weapon_broke? - Returns true if weapon broke or false if not
# stored_atk - The original attack power of the weapon
# repair - To restore the break amount (see below).
#
# * What is the Break? (Optional)
# Break means just the crumbling of the weapon as you gain levels with it.
# The higher the break the less attack power it'll have.
# You can set up where the break starts and how many % the max. break is.
# If the weapon attack reaches 0, it's useless and breaks apart.
# The syntax for it is: (original weapon ATK / 100) * Break% = weapon ATK
# To restore it's attack power to the original and to restore
# the break% to initial state, you'd use: $game_weapons[weapon_id].repair
#
# * TODO LIST:
# - Make every weapon, no matter if IDs or names match, have own status!
# - Make 'em to have their own skills you can use
# - Perhaps you have suggestions??
#
# That would end the little explaining for now. I -really- hope you like this script.
#--------------------------------------------------------------------------------------------------------------------------
# * Suggestions? ==> Post, PM or email me: invincible_p0wer_@hotmail.com (no spam plz)
# * Created by: GoldenShadow
# * Credits: Cloud_Strife_1989 (Power Up idea, thanks man)
# * Note: If you use this, please state that you used my script in case ppl think I copied you!
#=============================================================
module SC # Please leave this untouched, thanks.
  RXSC_WPNS = "Weapons Script: Ver. 1.1"
end

#--------------------------------------------------------------------------
# ? Game_Weapons
#     This is what you use when checking stuff
#-------------------------------------------------------------------------
class Game_Weapons
  #--------------------------------------------------------------------------
  # ? This is the array for the weapon data
  #--------------------------------------------------------------------------
  attr_accessor :data            # Stored weapon data
  #--------------------------------------------------------------------------
  # ? Initiating the store array and others just in case!
  #--------------------------------------------------------------------------
  def initialize
    $data_weapons = load_data("Data/Weapons.rxdata")
    $data_armors   = load_data("Data/Armors.rxdata") # In case you'd use this
    @data = []
  end
  #--------------------------------------------------------------------------
  # ? Don't bug this, or else you won't use $game_weapons[]
  #--------------------------------------------------------------------------
  def [](weapon_id)
    if weapon_id > $data_weapons.size
      return
    else
      if @data[weapon_id] == nil
        @data[weapon_id] = Game_Weapon.new(weapon_id)
      end
      return @data[weapon_id]
    end
  end
end

#--------------------------------------------------------------------------
# ? Game_Weapon
#     This is where the data is set up for the weapon
#-------------------------------------------------------------------------
class Game_Weapon
  #--------------------------------------------------------------------------
  # ? Something for the optionals
  #--------------------------------------------------------------------------
  USE_BREAK = true # Set to true if you want to use the breaks
  BREAK_SOUND_ENABLE = true # Hear a sound when broken?
  BREAK_SOUND = "Audio/SE/093-Attack05" # The broken sound
  USE_POWER_UP = true # True if you want your weapon power up each level
  REPAIR_ON_LVLUP = true # If weapons repairs auto on level up
  #--------------------------------------------------------------------------
  # ? Essential attributes
  #--------------------------------------------------------------------------
  attr_accessor :weapon_id              # Weapon ID
  attr_accessor :weapon_level           # Weapon level
  attr_accessor :weapon_exp             # Weapon exp
  attr_accessor :weapon_break_amount    # Weapon break
  attr_accessor :weapon_broke           # true/false if weapon broke
  attr_accessor :weapon_class           # Weapon ranking
  attr_accessor :weapon_next_exp        # Weapon next EXP
  attr_accessor :weapon_level_up        # Weapon level up? (true/false)
  attr_accessor :weapon_element         # Weapon Element
  #--------------------------------------------------------------------------
  # ? Initialize, which sets up data of the weapon through the ID
  #--------------------------------------------------------------------------
  def initialize(weapon_id, level = 1, exp = 300, break_amount = 0,
    broke = false, next_exp = 300, expvar = 300, max_level = 100,
    break_add = 1, max_break = 100, atk_up = 1, weapon_element = $data_weapons[weapon_id].element_set)
    # Setup the weapon with the specified parameters and data
    setup(weapon_id, level, exp, break_amount, broke, next_exp, expvar, max_level,
    break_add, max_break, atk_up, weapon_element)
  end
  #--------------------------------------------------------------------------
  # ? Setup for weapon as initial status
  #     Complete reference on the stuff like weapon_id, level, exp etc.
  #     Is located in the beginning of this script at topic:
  #     "I want a weapon with my own initial status! How do I do that?"
  #--------------------------------------------------------------------------
  def setup(weapon_id, level, exp, break_amount,  broke, next_exp, expvar, max_level,
    break_add, max_break, atk_up, weapon_element)
    @weapon_id = weapon_id
    @weapon_level = level # Initial level for the weapon
    @weapon_exp = exp # Initial EXP for the weapon
    @weapon_break_amount = break_amount # Initial % break for the weapon
    @weapon_broke = broke # If the weapon is broken intially
    @weapon_next_exp = next_exp # Initial needed EXP for the weapon
    @weapon_exp_var = expvar # The EXP is calculated through this * level = needed exp
    @weapon_max_level = max_level # Maximum level that can be achieved
    @weapon_break_add = break_add # This is the number added to break each level!
    @weapon_max_break = max_break # Maximum amount of break
    @weapon_level_up = false # You cant level it up in the begin right?
    @weapon_attack = $data_weapons[weapon_id].atk # Store original attack (atk)
    @weapon_initial_break = 0 # This is the initial %. Must be changed here!
    @weapon_atk_up = atk_up # Amount of attack power added to weapon at level up
    @weapon_element = weapon_element
    reform_class # Sets up the class, but you can also use @weapon_class = "Class"
  end
  #--------------------------------------------------------------------------
  # ? ID to return of weapon when asked
  #--------------------------------------------------------------------------
  def id
    return @weapon_id
  end
  #--------------------------------------------------------------------------
  # ? Level of weapon (Min. 1, Max. 100)
  #--------------------------------------------------------------------------
  def level
    amount = [[@weapon_max_level, 1].min, @weapon_level].max
    return amount
  end
  #--------------------------------------------------------------------------
  # ? Return total gained EXP
  #--------------------------------------------------------------------------
  def exp
    return @weapon_exp
  end
  #--------------------------------------------------------------------------
  # ? Return EXP needed for next level
  #--------------------------------------------------------------------------
  def next_exp
    return @weapon_next_exp
  end
  #--------------------------------------------------------------------------
  # ? Returns percetage of the break of weapon
  #    Break amount is just how broken the sword is like reality
  #--------------------------------------------------------------------------
  def break_amount
    amount = [[@weapon_max_break, 0].max, @weapon_initial_break].min
    return amount
  end
  #--------------------------------------------------------------------------
  # ? Returns true or false if weapon is broken
  #--------------------------------------------------------------------------
  def weapon_broke?
    return @weapon_broke
  end
  #--------------------------------------------------------------------------
  # ? Repairing the weapon so that Break% is initial and attack is restored
  #--------------------------------------------------------------------------
  def repair
    @weapon_break_amount = @weapon_initial_break # Return it to initial %
    $data_weapons[@weapon_id].atk = @weapon_attack # Return original atk
  end
  #--------------------------------------------------------------------------
  # ? Gaining EXP (Use this like in battle or something)
  #       n : a number that will be added to EXP but
  #            removed from next EXP
  #    This number may be a negetive (example: -22)
  #    That would only remove it from EXP and also from Next EXP.
  #--------------------------------------------------------------------------
  def gain_exp(n)
     if n.is_a?(Integer)
        @weapon_level_up = false
        @weapon_exp += n
        @weapon_next_exp -= n
        if USE_BREAK == true
          @weapon_break_amount += @weapon_break_add # Amount added to break
          weapon_break
        end
    else
      return
    end
    if @weapon_next_exp <= 0
      @weapon_level += 1 # Amount of level added
      @weapon_level_up = true # Set to true when level up
      if REPAIR_ON_LVLUP == true
        repair
      end
      if USE_POWER_UP == true
        @weapon_attack += @weapon_atk_up
        $data_weapons[@weapon_id].atk += @weapon_atk_up
      end
      @weapon_next_exp = @weapon_exp_var * @weapon_level
      reform_class
    end
  end
  #--------------------------------------------------------------------------
  # ? Reforms the class when a level is gained to determine
  #    the new ranking for the weapon, add or modify as pleased
  #--------------------------------------------------------------------------
  def reform_class
    if @weapon_level >= 0 and @weapon_level < 5
      @weapon_class = "Dull"
    elsif @weapon_level >= 5 and @weapon_level < 15
      @weapon_class = "Practice Weapon"
    elsif @weapon_level >= 15 and @weapon_level < 25
      @weapon_class = "Fence Weapon"
    elsif @weapon_level >= 25 and @weapon_level < 35
      @weapon_class = "Excellent Weapon"
    elsif @weapon_level >= 35 and @weapon_level < 45
      @weapon_class = "Veteran Weapon"
    elsif @weapon_level >= 45 and @weapon_level < 55
      @weapon_class = "Elite Weapon"
    elsif @weapon_level >= 55 and @weapon_level < 65
      @weapon_class = "High-Risk Weapon"
    elsif @weapon_level >= 65 and @weapon_level < 75
      @weapon_class = "Renegade"
    elsif @weapon_level >= 75 and @weapon_level < 85
      @weapon_class = "Masterful Weapon"
    elsif @weapon_level >= 85 and @weapon_level < 95
      @weapon_class = "Supreme Weapon"
    elsif @weapon_level > 95
      @weapon_class = "Ultima Weapon"
    else
      @weapon_class = "???"
    end
    return @weapon_class
  end
  #--------------------------------------------------------------------------
  # ? Make the weapon weaker
  #--------------------------------------------------------------------------
  def weapon_break
    @amount = $data_weapons[@weapon_id].atk / @weapon_max_break
    $data_weapons[@weapon_id].atk -= (@amount * @weapon_break_amount)
    if $data_weapons[@weapon_id].atk <= 0
      if BREAK_SOUND_ENABLE == true
        Audio.se_play(BREAK_SOUND, 100, 100)
      end
      return @weapon_broke = true
    end
  end
  #--------------------------------------------------------------------------
  # ? This returns the original attack base of the weapon
  #--------------------------------------------------------------------------
  def stored_attack
    return @weapon_attack
  end
  #--------------------------------------------------------------------------
  # ? This would manually change the ATK UP each level if enabled
  #--------------------------------------------------------------------------
  def atk_up=(up)
    if up.is_a?(Numeric)
      @weapon_atk_up = up
    else
      return
    end
  end
  def weapon_element
    return @weapon_element
  end
end
# FINAL UPDATE: October 11th 2005 @ 6:07 PM (SID06) [Don't modify this]

I tried using something like this:
   def reform_class
    if @weapon_level >= 0 and @weapon_level < 5
      @weapon_class = "Dull"
      if weapon_id = 1
      skill_ids.push(29)
      if weapon_id = 2
      skill_ids.push(33)

but nothing worked.....
« Last Edit: February 17, 2007, 05:59:31 PM by blazinhandle »

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
The changes would have to be in this section -

Code: [Select]
  def gain_exp(n)
     if n.is_a?(Integer)
        @weapon_level_up = false
        @weapon_exp += n
        @weapon_next_exp -= n
        if USE_BREAK == true
          @weapon_break_amount += @weapon_break_add # Amount added to break
          weapon_break
        end
    else
      return
    end
    if @weapon_next_exp <= 0
      @weapon_level += 1 # Amount of level added
      @weapon_level_up = true # Set to true when level up
      if REPAIR_ON_LVLUP == true
        repair
      end
      if USE_POWER_UP == true
        @weapon_attack += @weapon_atk_up
        $data_weapons[@weapon_id].atk += @weapon_atk_up
      end
      @weapon_next_exp = @weapon_exp_var * @weapon_level
      reform_class
    end
  end

More specifically, here -

Code: [Select]
if @weapon_next_exp <= 0
      @weapon_level += 1 # Amount of level added
      @weapon_level_up = true # Set to true when level up
      if REPAIR_ON_LVLUP == true
        repair
      end
      if USE_POWER_UP == true
        @weapon_attack += @weapon_atk_up
        $data_weapons[@weapon_id].atk += @weapon_atk_up
      end
      @weapon_next_exp = @weapon_exp_var * @weapon_level
      reform_class
    end

Right after

Code: [Select]
@weapon_level_up = true # Set to true when level up

Add something along the lines of -

Code: [Select]
for actor in actors
     if actor.equiped_weapon.id == weapon_id
          if @weapon_level == x
               actor.learn_skill(skill_id_1)
          elsif @weapon_level == y
               actor.learn_skill(skill_id_2)
          elsif @weapon_level == z
               actor.learn_skill(skill_id_3)
          end
     end
end

Or something like that. I forgot the method names -_- . LOL
« Last Edit: February 17, 2007, 09:04:40 PM by Tsunokiette »
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

*****
Ancient Mummy
Rep:
Level 90
God i wish i could script=/ i probly can cuz it doesnt seem that hard to me but understanding is something differnet :)

any ways that would be a nice script  ;D

***
Rep:
Level 88
Menu & Battle System Guru
hmmmm, i tried it. no luck tho, i got an error undefined 'actors' as soon as the actor gained enough exp to gain a level.

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
hmmmm, i tried it. no luck tho, i got an error undefined 'actors' as soon as the actor gained enough exp to gain a level.

Quote
Or something like that. I forgot the method names -_- . LOL

It's not legit code.
If you tried something different (meaning you figured out what I said wasn't going to work) can you post the exact code you used in that section? I'll try to fix it.
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

***
Rep:
Level 88
Menu & Battle System Guru
hmmmm, i tried it. no luck tho, i got an error undefined 'actors' as soon as the actor gained enough exp to gain a level.

Quote
Or something like that. I forgot the method names -_- . LOL

It's not legit code.
If you tried something different (meaning you figured out what I said wasn't going to work) can you post the exact code you used in that section? I'll try to fix it.


I tried using something like this:

  for actor in actors
     if actor.equiped_weapon.id == 1
          if @weapon_level == 1
               actor.learn_skill(2)
          elsif @weapon_level == 5
               actor.learn_skill(3)
          elsif @weapon_level == 15
               actor.learn_skill(4)
          end
     end
  end

i got an undefined actors error when i did that
« Last Edit: February 17, 2007, 11:47:53 PM by blazinhandle »

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
Oh. I feel stupid now. Sorry 'bought that xD lol.

for actor in actors

should be -

for actor in $game_party.actors
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

***
Rep:
Level 88
Menu & Battle System Guru
Oh. I feel stupid now. Sorry 'bought that xD lol.

for actor in actors

should be -

for actor in $game_party.actors

lol, okay now we're making some progress, but i'm now getting an undefined "equiped" error

***
Rep:
Level 88
Menu & Battle System Guru
lol, okay now we're making some progress, but i'm now getting an undefined "equiped" error


alright, i changed it to look like this:

     for actor in $game_party.actors
        if actor.weapon_id == 1
          if @weapon_level >= 1
            actor.learn_skill(2)
          elsif @weapon_level == 5
            actor.learn_skill(3)
          elsif @weapon_level == 15
            actor.learn_skill(4)
          end
        end
      end

and it worked! but the next time i battled, i went to attack the enemy and got this error: "script game_battler 3 line 349: nomethoderror occured undefined 'each' for 1:fixnum"

damn, it worked fine until the next battle too...what is going wrong???
« Last Edit: February 19, 2007, 12:33:15 AM by blazinhandle »

***
Rep:
Level 88
Menu & Battle System Guru
im sorry for the bump but im completely stumped