07-05-2005, 01:00 PM
Weapon Levelling Script v1.1
Created by: GoldenShadow
Jul 5 2005
Special thanks: Cloud_Strife & SepirothSpawn511
NOTE «Where to put this scriptfile?»
Put 'em between all the other Game stuff in the editor left list.
Also load it like the other $game stuff in Scene_Title#command_new_game
Also save it.... load it blablabla
Hope you like it!
(This works great with dragonslayers AP System.)
If you got errors about either the demo or the script, please post it, thanks.
DEMO
WPN_LVL_DEMO_V1.1.rar (Size: 203.44 KB / Downloads: 2)
Created by: GoldenShadow
Jul 5 2005
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
No support is given. If you are the owner of the thread, please contact administration.
Special thanks: Cloud_Strife & SepirothSpawn511
NOTE «Where to put this scriptfile?»
Put 'em between all the other Game stuff in the editor left list.
Also load it like the other $game stuff in Scene_Title#command_new_game
Also save it.... load it blablabla
Hope you like it!
(This works great with dragonslayers AP System.)
Code:
#==============================================================================
# <> 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 :-)
#------------------------------------------------------------------------------
# * 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_weappns[]
#--------------------------------------------------------------------------
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 = false # Set to true if you want to use the breaks
BREAK_SOUND_ENABLE = false # Hear a sound when broken?
BREAK_SOUND = "Audio/SE/093-Attack05" # The broken sound
USE_POWER_UP = false # True if you want your weapon power up each level
REPAIR_ON_LVLUP = false # 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)
#--------------------------------------------------------------------------
# ● 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)
# 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)
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_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
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
end
# FINAL UPDATE: October 11th 2005 @ 6:07 PM (SID06) [Don't modify this]
If you got errors about either the demo or the script, please post it, thanks.
DEMO
WPN_LVL_DEMO_V1.1.rar (Size: 203.44 KB / Downloads: 2)