Group: Member
Posts: 71
Type: Developer
RM Skill: Advanced
I've used this script for about an hour and a half now, and I'm quite pleased with it. However, for other actors that join your party later, it is problematic. They can't actually use the high leveled weapons they wear, so if you try to buy something stronger you can't equip it. Then you go to reequip the one you just had and... you can't equip that either. I need a way to set weapon ranks when the character joins the party. I have looked over the script a few dozen times and I can't particularly figure it out. I know it has something to do with $game_actor, but it's stumping me on how to change it because the solutions I've tried have been... less than successful.
Here is the script.
Script
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
#-------------------------------------------------------------------------- # * 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
This post has been edited by DrakeOneil: Jan 5 2012, 04:09 AM
0 being the index of the party member (0-3), 1 being the second weapon skill, "C" the rank I'm setting it to, and 700 is the amount of exp necessary for that actor to use that weapon.