Help - Search - Members - Calendar
Full Version: Weapons by ranks
RPG RPG Revolution Forums > Scripting > Script Submissions > RGSS2-Submissions
332211
Weapons by ranks Script


Author - uresk or 332211 (me)
Release Date - 21/July/08
Requires - Tagnote 2.0 (or above) by Queex
Latest version: 1.2 (12th of August 08)

Introduction
With this script then weapons one character can equip depend on their ranking of that type of weapon rather than the character's class.
Note: It can be customized to depend on both.

Features
[Show/Hide] version 1.0
- weapons depend on rankings
- any number of ranks can be set
- can be changed so that weapons depend both on the calss and rank of the characte
- inserted menu option "Rankings" (changable), to access the rankings easily

[Show/Hide] version 1.1
- access rankings from the menu

[Show/Hide] version 1.2
- ranking for unarmed fight
- ranks affect attack damage output
- ranks affect critical chance


Script
[Show/Hide] Version 1.2
CODE

################################################################################
# Script: Weapons by ranks
# Version: 1.2
# Author: uresk (AKA 332211)
# Requires: Tagnote 2.0+ (by Queex)
################################################################################
#
# Customize: RANKS
# RANKS = [lowest to highest]
# RANKS = ["None","Rookie","Master"]
#
# Customize: $exp_ranks
# $exp_ranks = [0, exp needed for rank 1, exp for rank 2...]
# $exp_ranks = [0,100,5000,10000]
#
# Customize: EXP_rate
# regular experience multiplier:
# Ex: You kill Rat and win 13 exp, exp for ranks will be 13 * EXP_rate
# EXP_rate = number
#
# Customize: $weapon_skills
# names of your skills in weapons; must be one word
# $weapon_skills = ["Swords","Bows","Staffs"]
#
# Change_Damage = true
# True: the actor's rank will afect regular attack damage
# False: nothing happens
#
# Damage_multiplier = [0.75, 1, 1.25]
# Ex: If Ralph is a rookie using swords damage will be reduced to 3/4.
# Ex_2: If ralph is a Master damage will be multiplied by 5/4
#
# Change_crit = true
# True: the actor's rank will afect regular critical chance
# False: nothing happens
#
# Added_crit = [0, 2, 4]
# Ex: If Ralph's a rookie no bonus critical but if he is a master
# the chance for critical will go up by 4%
#
# Critical_Adjustment = 3
# Critical damage multiplier
# Critical damage = damage * Critical_Adjustment
#
# Customize: Class_Limit
# True: a hero can only equip weapons assigned for his class
# False: a hero can equip every weapon, regardless of his class
#
################################################################################
#
# Database
# In the notes field of a weapon write down <mastery Swords> or <mastery Bows>
# to determine weapon 'type' and <rank None>,<rank Rookie> to choose the rank
# needed to equip that weapon.
#
################################################################################
#==============================================================================#
# ** Begin Configuration
#==============================================================================#

module Vocab
Rank_Up = "%s is a %s using %s." #message for when rank goes up
#%s - actor name; new rank; rank type
Show_in_Menu = true #true: rankings can be show in the Menu
#false: rankings are not shown in the menu
#and must be called with '$scene = Scene_weapon_by_ranks.new'
Menu_Ranks = "Rankings" #word that shows up in the menu
end

module Ranks
RANKS = ["None","Rookie","Master"] #ranks from lowest to highest1
$exp_ranks = [0,10,50] #defines experience
#needed for each rank
EXP_rate = 2 #experience multiplier
$weapon_skills = ["Unarmed","Swords", "Bows", "Staffs"]
Unarmed_tag_id = 0 #"unarmed name positon
Change_Damage = true #the actor's rank will afect regular attack damage
Damage_multiplier = [0.75,1,1.25] #damage multiplier
Change_crit = true #the actor's rank will afect regular critical chance
Added_crit = [0, 2, 4] #critical chance = regular critical + Added_critical
Critical_Adjustment = 3 #critical damage multiplier
Class_Limit = true #if true: can only equip weapons checked in the class
#Equippable Weapons list.
#false: can equip every weapon, only depending on the rank
end
#==============================================================================#
# ** End Configuration #
# unless you know what you're doing, don't change the script from here on!
#==============================================================================#

#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles actors. It's used within the Game_Actors class
# ($game_actors) and referenced by the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler

include TAGNOTE #include TagNote
include Ranks #get custom defenitions

attr_accessor :weapon_skill_rank #set object

alias initialize_with_ranks initialize #reset actor initialize def

def initialize(actor_id)
initialize_with_ranks(actor_id) #do regular initialize
@weapon_skill_rank = [] #clear weapon_skill_rank
for i in 0...$weapon_skills.size do #sets starting rank
@weapon_skill_rank[i] = RANKS[0] #as the 1st Rank
end
@ws_exp = [] #clear ws_exp
end

alias gain_w_exp gain_exp #redefining gain_exp

def gain_exp(exp, show)
gain_w_exp(exp, show) # do regular exp_gain
if @weapon_id != 0 # if weilding a weapon
if has_tag?($data_weapons[@weapon_id].note,"mastery") == true #checks for weapon tag
ws = get_tag($data_weapons[@weapon_id].note,"mastery")
@ws_i = $weapon_skills.index(ws) #turn weapon type into index
end
else
@ws_i = Unarmed_tag_id
end
if @ws_exp[@ws_i] != nil
then $exp_temp = @ws_exp[@ws_i] + exp * EXP_rate #calcs experience
else #if it's the first time
$exp_temp.to_i #calcs experience
$exp_temp = exp * EXP_rate
end
@ws_exp.delete_at(@ws_i) #deletes old experience
@ws_exp.insert @ws_i,$exp_temp #replaces with new experience value
rank_index = RANKS.index(@weapon_skill_rank[@ws_i]) #weapon rank --> rank index
for i in 1...$exp_ranks.size do # compares experience with exp need to the next rank
if $exp_ranks[i] <= $exp_temp # if exp needed < current exp
if rank_index >= i # and the rank index is not lower
then next # goes to the next rank
else @weapon_skill_rank[@ws_i] = RANKS[i] #else assigns new rank
end
ws = $weapon_skills[Unarmed_tag_id] if ws == nil
text = sprintf(Vocab::Rank_Up,actor.name,RANKS[i],ws) #prints
$game_message.texts.push('\.' + text) #rank up message
end
end
end

alias can_equip? equippable? #redefining equippable

def equippable?(item)
if item.is_a?(RPG::Weapon) # if it is a weapon
can_equip = [] # hero can be unarmed
if has_tag?(item.note,"rank") # gets weapon rank from
then rank = get_tag(item.note,"rank") end # the notes field
rank_num = RANKS.index(rank) # rank into index
if has_tag?(item.note,"mastery") # checks if has mastery tag
then ws = get_tag(item.note,"mastery") # gets rank type
@ws_i = $weapon_skills.index(ws) # rank type index
actor_rank = @weapon_skill_rank[@ws_i] # gets actor rank on that type
rank_id = RANKS.index(actor_rank) # turn actor rank into index
if rank_id != nil and rank_num != nil # if both index aren't nil
then if rank_id >= rank_num # compares them
then can_equip.push(item.id) end # if actor rank higher (or nil)
end # then can be equipped
else can_equip.push(item.id) # or weapon has no mastery
end # then can be equipped
if Ranks::Class_Limit == true #extra: if Class Limit is true
then can_equip = can_equip & self.class.weapon_set end
return can_equip.include?(item.id)

elsif item.is_a?(RPG::Armor) #regular equip method for armors
return false if two_swords_style and item.kind == 0
return self.class.armor_set.include?(item.id)
end
return false
end
end

class Game_Battler

include TAGNOTE
include Ranks

alias wbr_make_attack_damage_value make_attack_damage_value

def make_attack_damage_value(attacker)
damage = attacker.atk * 4 - self.def * 2 # base calculation
damage = 0 if damage < 0 # if negative, make 0
damage *= elements_max_rate(attacker.element_set) # elemental adjustment
damage /= 100
if attacker.is_a? Game_Actor
@actor = attacker
if @actor.equips[0] != nil
if Change_Damage == true and has_tag?(@actor.equips[0].note,"mastery")
mastery = get_tag(attacker.equips[0].note,"mastery")
mastery_index = $weapon_skills.index(mastery)
actor_rank = @actor.weapon_skill_rank[mastery_index]
rank_index = RANKS.index(actor_rank)
end
else
rank_index = Unarmed_tag_id
damage *= Damage_multiplier[rank_index]
damage = damage.truncate
end
end
if damage == 0 # if damage is 0,
damage = rand(2) # half of the time, 1 dmg
elsif damage > 0 # a positive number?
if attacker.is_a? Game_Actor
@actor = attacker
if @actor.equips[0] != nil
if Change_crit == true and has_tag?(@actor.equips[0].note,"mastery")
mastery = get_tag(attacker.equips[0].note,"mastery")
mastery_index = $weapon_skills.index(mastery)
actor_rank = @actor.weapon_skill_rank[mastery_index]
rank_index = RANKS.index(actor_rank)
end
else
rank_index = Unarmed_tag_id
@critical = (rand(100) < attacker.cri + Added_crit[rank_index]) #critical hit?(rank)
end
else
@critical = (rand(100) < attacker.cri) # critical hit?(regular)
end
@critical = false if prevent_critical # criticals prevented?
damage *= Critical_Adjustment if @critical # critical adjustment
end
damage = apply_variance(damage, 20) # variance
damage = apply_guard(damage) # guard adjustment
@hp_damage = damage # damage HP
end
end

class Scene_weapon_by_ranks < Scene_Base
#--------------------------------------------------------------------------
# * Object Initialization
# actor_index : actor index
#--------------------------------------------------------------------------
def initialize(actor_index = 0)
@actor_index = actor_index
end
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
def start
super
create_menu_background
@actor = $game_party.members[@actor_index]
@status_window = Window_Ranks.new(@actor)
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
@status_window.dispose
end
#--------------------------------------------------------------------------
# * Return to Original Screen
#--------------------------------------------------------------------------
def return_scene
$scene = Scene_Menu.new(3)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
update_menu_background
@status_window.update
if Input.trigger?(Input::cool.gif
Sound.play_cancel
return_scene
elsif Input.trigger?(Input::R)
Sound.play_cursor
next_actor
elsif Input.trigger?(Input::L)
Sound.play_cursor
prev_actor
end
super
end
#--------------------------------------------------------------------------
# * Next Actor
#--------------------------------------------------------------------------
def next_actor
@actor_index += 1
@actor_index %= $game_party.members.size
$scene = Scene_weapon_by_ranks.new(@actor_index)
end
#--------------------------------------------------------------------------
# * Previous Actor
#--------------------------------------------------------------------------
def prev_actor
@actor_index += $game_party.members.size - 1
@actor_index %= $game_party.members.size
$scene = Scene_weapon_by_ranks.new(@actor_index)
end
end


class Window_Ranks < Window_Base

include TAGNOTE #includes tagnote
include Ranks
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 0, 544, 416)
@actor = actor
refresh
end

def refresh
self.contents.clear
draw_actor_name(@actor, 4, 0)
draw_actor_face(@actor, 8, 32)
draw_actor_level(@actor, 8, 136)
draw_weapons(8, 160)
draw_weapon_skills(222, 40)
end

#--------------------------------------------------------------------------
# * Draw Weapon(s)
# x : Draw spot X coordinate
# y : Draw spot Y coordinate
#--------------------------------------------------------------------------
def draw_weapons(x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y + WLH, 120, WLH, "Weapon:")
draw_item_name(@actor.equips[0], x, y + WLH * 2)
self.contents.font.color = system_color
self.contents.draw_text(x, y + WLH * 3, 120, WLH, "Type:")
self.contents.font.color = normal_color
if @actor.equips[0] != nil
if has_tag?(@actor.equips[0].note,"mastery") == true
@skill = get_tag(@actor.equips[0].note,"mastery")
end
else
@skill = $weapon_skills[Unarmed_tag_id]
end
self.contents.draw_text( x, y + WLH * 4, 120, WLH, @skill)
self.contents.font.color = system_color
self.contents.draw_text(x, y + WLH * 5, 120, WLH, "Rank:")
self.contents.font.color = normal_color
if @actor.equips[0] != nil
then if has_tag?(@actor.equips[0].note,"rank") == true
then rank = get_tag(@actor.equips[0].note,"rank")
self.contents.draw_text( x, y + WLH * 6, 120, WLH, rank)
end
end
end


#--------------------------------------------------------------------------
# * Draw Weapon Skills
# x : Draw spot X coordinate
# y : Draw spot Y coordinate
#--------------------------------------------------------------------------
def draw_weapon_skills(x, y)
for i in 0...$weapon_skills.size do
if $weapon_skills[i] == @skill #goes through weapon types
then self.contents.font.color = system_color #if matches the current weapon type
else self.contents.font.color = normal_color #has a different color
end

self.contents.draw_text( x, y, 200, 2 * WLH * (i + 1), $weapon_skills[i]) #draws weapon types
self.contents.draw_text( x + 200, y, 50, 2 * WLH * (i + 1), @actor.weapon_skill_rank[i]) #draws weapon ranks
end
end
end

#this is the menu redefinitions, if you're sure you are not going to use it, you can delete it.
if Vocab::Show_in_Menu == true then

class Scene_Menu < Scene_Base

alias old_create_command_window create_command_window

def create_command_window
s1 = Vocab::item
s2 = Vocab::skill
s3 = Vocab::equip
s4 = Vocab::Menu_Ranks
s5 = Vocab::status
s6 = Vocab::save
s7 = Vocab::game_end
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
@command_window.index = @menu_index
if $game_party.members.size == 0 # If number of party members is 0
@command_window.draw_item(0, false) # Disable item
@command_window.draw_item(1, false) # Disable skill
@command_window.draw_item(2, false) # Disable equipment
@command_window.draw_item(3, false) # Disable status
@command_window.draw_item(4, false) # Disable rankings
end
if $game_system.save_disabled # If save is forbidden
@command_window.draw_item(5, false) # Disable save
end
end

alias old_update_command_selection update_command_selection

def update_command_selection
if Input.trigger?(Input::cool.gif
Sound.play_cancel
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
if $game_party.members.size == 0 and @command_window.index < 5
Sound.play_buzzer
return
elsif $game_system.save_disabled and @command_window.index == 5
Sound.play_buzzer
return
end
Sound.play_decision
case @command_window.index
when 0 # Item
$scene = Scene_Item.new
when 1,2,3,4 # Skill, equipment, rankings, status
start_actor_selection
when 5 # Save
$scene = Scene_File.new(true, false, false)
when 6 # End Game
$scene = Scene_End.new
end
end
end

alias old_update_actor_selection update_actor_selection

def update_actor_selection
if Input.trigger?(Input::cool.gif
Sound.play_cancel
end_actor_selection
elsif Input.trigger?(Input::C)
$game_party.last_actor_index = @status_window.index
Sound.play_decision
case @command_window.index
when 1 # skill
$scene = Scene_Skill.new(@status_window.index)
when 2 # equipment
$scene = Scene_Equip.new(@status_window.index)
when 4 # status
$scene = Scene_Status.new(@status_window.index)
when 3 # weapons and ranks
$scene = Scene_weapon_by_ranks.new(@status_window.index)
end
end
end
end


class Scene_Status < Scene_Base

alias old_return_scene return_scene

def return_scene
$scene = Scene_Menu.new(4)
end
end

class Scene_File < Scene_Base

alias old_return_scene return_scene

def return_scene
if @from_title
$scene = Scene_Title.new
elsif @from_event
$scene = Scene_Map.new
else
$scene = Scene_Menu.new(5)
end
end
end

class Scene_End < Scene_Base

alias old_return_scene return_scene

def return_scene
$scene = Scene_Menu.new(6)
end
end
end


Customization

# Customize: RANKS
# RANKS = [lowest to highest]
# RANKS = ["None","Rookie","Master"]
#
# Customize: $exp_ranks
# $exp_ranks = [0, exp needed for rank 1, exp for rank 2...]
# $exp_ranks = [0,100,5000,10000]
#
# Customize: EXP_rate
# regular experience multiplier:
# Ex: You kill Rat and win 13 exp, exp for ranks will be 13 * EXP_rate
# EXP_rate = number
#
# Customize: $weapon_skills
# names of your skills in weapons; must be one word
# $weapon_skills = ["Swords","Bows","Staffs"]
#
# Change_Damage = true
# True: the actor's rank will afect regular attack damage
# False: nothing happens
#
# Damage_multiplier = [0.75, 1, 1.25]
# Ex: If Ralph is a rookie using swords damage will be reduced to 3/4.
# Ex_2: If ralph is a Master damage will be multiplied by 5/4
#
# Change_crit = true
# True: the actor's rank will afect regular critical chance
# False: nothing happens
#
# Added_crit = [0, 2, 4]
# Ex: If Ralph's a rookie no bonus critical but if he is a master
# the chance for critical will go up by 4%
#
# Critical_Adjustment = 3
# Critical damage multiplier
# Critical damage = damage * Critical_Adjustment
#
# Customize: Class_Limit
# True: a hero can only equip weapons assigned for his class
# False: a hero can equip every weapon, regardless of his class
#
################################################################################
#
# Database
# In the notes field of a weapon write down <mastery Swords> or <mastery Bows>
# to determine weapon 'type' and <rank None>,<rank Rookie> to choose the rank
# needed to equip that weapon.
#
################################################################################
#
#Customize: Show_in_Menu
#Show_in_Menu = true or false
#true: rankings can be show in the Menu
#false: rankings are not shown in the menu
#and must be called with '$scene = Scene_weapon_by_ranks.new'
#
#Customize: Show_in_Menu
#word that shows up in the menu
# Example: Menu_Ranks = "Rankings"

Compatibility
So far everything seems to work with all scripts.
Warn me if it isn't compatible.

Screenshot
[Show/Hide] Current Ranks Scene



DEMO
Demo 1.1


Demo 1.2



Installation
insert Above main and below Tagnote (2.0 +)

FAQ


Q: How to use the script?
A: Copy & paste in a new script page below material section and below Tagnote 2.0 or more and above main.


Credits


- me, for doing the script
- Queex for creating Tagnote - saved me a lot of trouble

Terms and Conditions


Credit me when using the script, don't make questions about what's already written in the configuration (I won't answer those)
Give credit to Queex too.
Smd1985
Thanks this is perfect for my game biggrin.gif I'll make sure to credit you
AlbinoWalken69
awesome script. needs to be cleaned up a bit but its still really good. I plan on using this in my side project. also, i havent seen u on these forums at all, are you a new scripter?
332211
This is actually my first script. Took me about 3 days to make it work (bugless I hope)
Feel free to PM any changes to simplify it. Or ad-ons I should include.
AlbinoWalken69
for a first script, this is really good. hell, its really good for a script in general. congratulations and keep up w/ the good scripting biggrin.gif
bleachx
what the problem ? when i copy the script into my game's script page
the script is all in a same line...how to make this problem disappear?
Heartofshadow
QUOTE (bleachx @ Jul 21 2008, 10:41 PM) *
what the problem ? when i copy the script into my game's script page
the script is all in a same line...how to make this problem disappear?


Are you taking the script out of the Demo Project?

If you're just copying and pasting it directly from this site to your project, that might the issue. It happens occasionally for some people(I don't know why). So what I recommend you do is download the provided Demo and take the script from the Demo's Script Editor. That way there shouldn't be any problems. You'll just have to make sure to customize the contents to your liking.

Heart of Shadow
bleachx
ok... thanks~ i know what my problem now
but i can't download the DEMO...
semajames
You might be having a issue with the formatting. Try copying the script into the program "wordpad", and then copying from wordpad to RMVX

Hope this solves your problem, as it has helped me in the past.

@332211: just a quick note, I don't think you need those hashes at the end of the sentances at the start of the script. It makes no differance having them there, but I just thaught I'd say that. Good job smile.gif
bleachx
how to make the Ranking Show on Character's Status??
332211
Now version 1.1
Set Show_in_Menu to true to enable access to weapon rankings from the menu.

Report bugs if you find them
andani
Sounds and looks pretty good. Thanks for the time and effort that you put into this script.
bleachx
Version 1.1 just the thing i m looking for , thanks!
SeaGlobe
Hi. I know no one's said anything in here for a while but it couldn't hurt to try right?

I was wondering if there's any possible way to use this script with the Advanced Crafting Script i was looking to use. So far i've put them both into my project as well as tweaked them (To my own needs) but they both seem to refuse to show on the menu. If i put this script below the crafting script it shows on the menu in the same spot as the "Crafting" would be, and when placed above it's the crafting showing in the same spot, I can't seem to win.

I've resorted to downloading them both again to see if what i had previously altered was the reason why they didn't like me but alas it repeats lol

Any solution or help would be very appreciated.
slifer644
dang, can u upload to another mirror, I can't download from rapidshare
Khev
Monster necro :/

The demo isn't reeeeeeally necessary due to the script being there.
Not to mention I don't think 332211 updates this anymore.
Zafeel
i got line 275 syntax error...please help me fix it >_<
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.