Leon 55 Report post Posted January 17, 2007 All right, you see, I made a Weapon Level script many moons ago. Well, I upgraded it for use in my game. Well, given what is added, I thought I would make it more of a public script. Just remember, if I find out you used it and didn't give credit, I will create a virtual world of hell for you. :rolleyes: lol. Just messing, just give me credit. it's all I ask, y'know? Anyway, Here is the script + Features. please PLEASE PLEASE! ask if you have any questions or comments. This hasn't been tested with any battle systems other than the default battle system. Original Features: Customizable starting and max levels for each script. Attack increases based on weapon power. You can call the scene showing all the weapons and levels using: $scene = Scene_WeaponLeve.new You can set up weapon exp gain based on a default number, monster, or weapon. It will only show weapons that oyu have experience for, not if it has been equipped. New Features: Weapon's can have a % chance of using a skill instead of attacking. You can increase weapon hit %. You can increase critical hit %. Ammunition has been added. Each weapon can have it's own unique ammo, but no weapon can have more than one type of ammunition. Script: #=================================== # Leon's Weapon Level system #---------------------------------------------------------------------- # Version 1 #=================================== #=================================== # Leon's Ammo Script #---------------------------------------------------------------------- =begin Change Game_Battler, Scene_Battle for if you have 0 Also to remove one if you attack with a bow. hash: bow_id => item_id twin bow id as constant. =end =begin Script Description: Each actor is skilled in a weapon rather than a weapon type. So they may be proficient in the Iron Sword, but not Steel Sword. Features: 1. Customizable beginning and max levels for all actors, as a group or individually. 2. Attack goes up based upon weapon level 3. A window shows weapon level and exp bar. 4. You can set weapon gain based on enemy, weapon, or default. 5. It only shows weapons that the actor has experience in. Instructions: 1. Place this script above main. 2. Set the modules the way you want to below. 3. Search (using Ctrl + F) for Leon_Edit for the final place to edit. Compatibility with SDK: Unknown How to use Call Script... To add a weapon level for a weapon: x being actor's number, y being the weapon's id, z being the number of levels to add $game_actors[x].weapon_level[y] += z To add to exp to the current equipped weapon: x being actor's number, y being the exp to add $game_actors[x].weapon_exp[@weapon_id] += y To add to the max level for an actor's weapon: x being actor's number y being the weapon's id z being the max level $game_actors[x].weapon_max[y] == z =end module Weapon_Level #-------------------------------------------------------------------- # Set exp for each level # For example: 75 total weapon exp for level 2, 225 for level 3 # 525 for level 4, etc... # Weapon_level => to next level #-------------------------------------------------------------------- Exp ={ 1 => 50, 2 => 125, 3 => 300, 4 => 500, 5 => 725, 6 => 1000, 7 => 1300, 8 => 1750, 9 => 2500, 10 => 3500, 11 => 5000 } #-------------------------------------------------------------------- # Increase % to attack per level # weapon_level => % #-------------------------------------------------------------------- Weapon_Bonus = { 2 => 10, 3 => 15, 4 => 20, 5 => 25, 6 => 30, 7 => 35, 8 => 40, 9 => 45, 10 => 50 } #-------------------------------------------------------------------- # Set default start level for weapons #-------------------------------------------------------------------- Default_Start = 1 #-------------------------------------------------------------------- # Set default max level for weapons #-------------------------------------------------------------------- Default_Max = 5 #-------------------------------------------------------------------- # Set unique start levels for weapons, default for all actors. # weapon_id => start_level #-------------------------------------------------------------------- Weapon_Start = { } #-------------------------------------------------------------------- # Set unique max levels for each weapon, default for all actors. # weapon_id => max_level #-------------------------------------------------------------------- Weapon_Max = { 1 => 7 } #-------------------------------------------------------------------- # Default gain of weapon exp per attack #-------------------------------------------------------------------- Default_Gain = 3 #-------------------------------------------------------------------- # Unique Enemy gain per attack. Adds it to the weapon's Gain. # enemy_id => exp #-------------------------------------------------------------------- Enemy_Gain = { 1 => 2 } #-------------------------------------------------------------------- # Unique Weapon gain per attack # weapon_id => exp #-------------------------------------------------------------------- Weapon_Gain ={ 1 => 200 } end #=================================== # Module #=================================== module Weapon_Skills #-------------------------------------------------------------------- # Weapon_Skill => weapon_id => [skill, %chance] # Note: Use only offensive skills, and only "Attack one" skills. #-------------------------------------------------------------------- Weapon_Skill = { 1=> [27, 50] } #-------------------------------------------------------------------- # Weapon_Hit => weapon_id => hit % #-------------------------------------------------------------------- Weapon_Hit = { 1 => 95 } #-------------------------------------------------------------------- # Weapon_Crit => weapon_id => crit % #-------------------------------------------------------------------- Weapon_Crit = { 1 => 5 } end #=================================== # Module #=================================== module Bows #-------------------------------------------------------------------- # Bows = {Bow_ID, Item_Id} #-------------------------------------------------------------------- Arrows = { 138 => 73 } end #=================================== # Game_Battler #=================================== class Game_Battler alias leon_gb_weaponlevel_attackeffect attack_effect def attack_effect(attacker) self.critical = false wep = Weapon_Skills #--------------Weapon_SKills-------------------------------- if attacker.is_a?(Game_Actor) if wep::Weapon_Hit.keys.include?(attacker.weapon_id) hit_result = (rand(100) < attacker.hit + wep::Weapon_Hit[attacker.weapon_id]) else hit_result = (rand(100) < attacker.hit) end else hit_result = (rand(100) < attacker.hit) end #--------------------------------------------------------------- hit_result = (rand(100) < attacker.hit) if hit_result == true if attacker.is_a?(Game_Actor) weps = Weapon_Level attacker.weapon_check weapon_gain = weps::Weapon_Gain[attacker.weapon_id] unless weps::Weapon_Gain.include?(attacker.weapon_id) unless weps::Enemy_Gain.include?(self.id) attacker.weapon_exp[attacker.weapon_id] += weps::Default_Gain attacker.weapon_check else attacker.weapon_exp[attacker.weapon_id] += weps::Enemy_Gain[self.id] attacker.weapon_check end else unless weps::Enemy_Gain.include?(self.id) attacker.weapon_exp[attacker.weapon_id] += (weapon_gain) attacker.weapon_check else attacker.weapon_exp[attacker.weapon_id] += (weps::Enemy_Gain[self.id] + weapon_gain) attacker.weapon_check end end end atk = [attacker.atk - self.pdef / 2, 0].max self.damage = atk * (20 + attacker.str) / 20 self.damage *= elements_correct(attacker.element_set) self.damage /= 100 if self.damage > 0 #----------------------Weapon_Skills------------------------ if attacker.is_a?(Game_Actor) if wep::Weapon_Crit.keys.include?(attacker.weapon_id) if rand(100) < 4 * attacker.dex / self.agi + wep::Weapon_Crit[attacker.weapon_id] self.damage *=2 self.critical = true end if self.guarding? self.damage /= 2 end else if rand(100) < 4 * attacker.dex / self.agi self.damage *= 2 self.critical = true end if self.guarding? self.damage /= 2 end end else if rand(100) < 4 * attacker.dex / self.agi self.damage *= 2 self.critical = true end if self.guarding? self.damage /= 2 end end #------------------------------------------------------------ if rand(100) < 4 * attacker.dex / self.agi self.damage *= 2 self.critical = true end if self.guarding? self.damage /= 2 end end if self.damage.abs > 0 amp = [self.damage.abs * 15 / 100, 1].max self.damage += rand(amp+1) + rand(amp+1) - amp end eva = 8 * self.agi / attacker.dex + self.eva hit = self.damage < 0 ? 100 : 100 - eva hit = self.cant_evade? ? 100 : hit hit_result = (rand(100) < hit) end if hit_result == true if attacker.is_a?(Game_Actor) if wep::Weapon_Skill.keys.include?(attacker.weapon_id) if skill_chance = (rand(100) < wep::Weapon_Skill[attacker.weapon_id][1]) skill = $data_skills[wep::Weapon_Skill[attacker.weapon_id][0]] $skill_variable = 1 skill_effect(attacker, skill) return end else remove_states_shock self.hp -= self.damage @state_changed = false states_plus(attacker.plus_state_set) states_minus(attacker.minus_state_set) end else remove_states_shock self.hp -= self.damage @state_changed = false states_plus(attacker.plus_state_set) states_minus(attacker.minus_state_set) end else self.damage = "Miss" self.critical = false end return true end end #=================================== # Game_Actor #=================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------- # Attribute Listings #-------------------------------------------------------------------- attr_accessor :weapon_level attr_accessor :weapon_max attr_accessor :weapon_exp attr_accessor :weapon_name attr_accessor :weapon_icon attr_accessor :weapons attr_accessor :weplev_up #-------------------------------------------------------------------- # Alias Listings #-------------------------------------------------------------------- alias leon_ga_weaponlevel_setup setup alias leon_ga_weaponlevel_baseatk base_atk def setup(actor_id) #------------------------------------------------------------------ # Leon_Edit # This sets beginning weapon levels for all actors, if you want # all actor's to be proficient with a weapon to begin with. #------------------------------------------------------------------ # weapon_id => beginning_level #------------------------------------------------------------------ @weapon_level = { } #------------------------------------------------------------------ # Changes the max weapon level for 1 weapon for all actors. #------------------------------------------------------------------ # weapon_id => weapon_max_level #------------------------------------------------------------------ @weapon_max = { 3 => 9 } #------------------------------------------------------------------ # Weapon exp. Sets it for every actor. #------------------------------------------------------------------ # weapon_id => known_exp #------------------------------------------------------------------ @weapon_exp = { 1 => 49 } @weapons = [] @weplev_up = false leon_ga_weaponlevel_setup(actor_id) weapon_check end def weapon_check weapon = $data_weapons[@weapon_id] weps = Weapon_Level unless @weapon_level.include?(@weapon_id) @weapon_level[@weapon_id] = weps::Default_Start end unless @weapon_max.include?(@weapon_id) @weapon_max[@weapon_id] = weps::Default_Max end unless @weapon_exp.include?(@weapon_id) @weapon_exp[@weapon_id] = 0 end unless @weapons.include?(@weapon_id) if @weapon_id > 0 and not weapons_learn? if @weapon_exp[@weapon_id] > 0 if @weapon_level[@weapon_id] >= 1 @weapons.push(@weapon_id) @weapons.sort! end end end end if weapon_exp[@weapon_id] >= weps::Exp[weapon_level[@weapon_id]] weapon_exp[@weapon_id] -= weps::Exp[weapon_level[@weapon_id]] weapon_level[@weapon_id] += 1 if $game_temp.in_battle @weplev_up = true else weapon_check end end if weapon_level[@weapon_id] > weapon_max[@weapon_id] weapon_level[@weapon_id] = weapon_max[@weapon_id] end if weapon_level[@weapon_id] >= weapon_max[@weapon_id] weapon_level[@weapon_id] = weapon_max[@weapon_id] end end def base_atk weps = Weapon_Level n = leon_ga_weaponlevel_baseatk if weps::Weapon_Bonus.include?(@weapon_level[@weapon_id]) bonus_atk = weps::Weapon_Bonus[@weapon_level[@weapon_id]] o = ((bonus_atk * 0.01 * n) + n) return o else return n end end def weapons_learn? return @weapons.include?(@weapon_id) end end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Window_Base #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class Window_Base def draw_bar(x, y, min, max, width = 152, height = 6, bar_color = Color.new(60, 130, 60, 255), end_color = Color.new(180, 250, 180, 255)) for i in 0..height self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255)) end for i in 1..(height - 1) r = 100 * (height - i) / height + 0 * i / height g = 100 * (height - i) / height + 0 * i / height b = 100 * (height - i) / height + 0 * i / height a = 255 * (height - i) / height + 255 * i / height self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a)) end for i in 1..( (min.to_f / max.to_f) * width - 1) for j in 1..(height - 1) r = bar_color.red * (width - i) / width + end_color.red * i / width g = bar_color.green * (width - i) / width + end_color.green * i / width b = bar_color.blue * (width - i) / width + end_color.blue * i / width a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a)) end end end end #=================================== # Scene_Battle #=================================== class Scene_Battle alias leon_weplev_sb_start_phase5 start_phase5 def update_phase4_step3 wep = Weapon_Skills if $skill_variable == 1 skill = $data_skills[wep::Weapon_Skill[@active_battler.id][0]] if @active_battler.weapon_id != nil @help_window.visible = true actor = @active_battler weapon = @active_battler.weapon_id @help_window.set_text("#{actor}'s #{weapon} used #{skill.name}!") @wait_count = 150 end skill = $data_skills[wep::Weapon_Skill[@active_battler.id][0]] @animation1_id = skill.animation1_id @animation2_id = skill.animation2_id $skill_variable = 0 end if @animation1_id == 0 @active_battler.white_flash = true else @active_battler.animation_id = @animation1_id @active_battler.animation_hit = true end @phase4_step = 4 end def update_phase4_step4 for target in @target_battlers target.animation_id = @animation2_id target.animation_hit = (target.damage != "Miss") end @wait_count = 8 @phase4_step = 5 end def make_basic_action_result # If attack if @active_battler.current_action.basic == 0 # Set anaimation ID @animation1_id = @active_battler.animation1_id @animation2_id = @active_battler.animation2_id # If action battler is enemy if @active_battler.is_a?(Game_Enemy) if @active_battler.restriction == 3 target = $game_troop.random_target_enemy elsif @active_battler.restriction == 2 target = $game_party.random_target_actor else index = @active_battler.current_action.target_index target = $game_party.smooth_target_actor(index) end end # If action battler is actor if @active_battler.is_a?(Game_Actor) bow = Bows if bow::Arrows.keys.include?(@active_battler.weapon_id) if $game_party.item_number(bow::Arrows[@active_battler.weapon_id]) >= 1 $game_party.lose_item(bow::Arrows[@active_battler.weapon_id], 1) else @help_window.set_text("Out of Arrows.") @wait_count = 75 return end end if @active_battler.restriction == 3 target = $game_party.random_target_actor elsif @active_battler.restriction == 2 target = $game_troop.random_target_enemy else index = @active_battler.current_action.target_index target = $game_troop.smooth_target_enemy(index) end if @active_battler.is_a?(Game_Actor) for actor in $game_party.actors if actor.weapon_level[actor.weapon_id] == nil actor.weapon_level[actor.weapon_id] = 1 end if actor.weapon_exp[actor.weapon_id] == nil or actor.weapon_exp[actor.weapon_id] == 0 actor.weapon_exp[actor.weapon_id] = 1 end wep = Weapon_Level if actor.weplev_up == true @help_window.visible = true Audio.me_play("Audio/ME/002-Victory02", 100, 100) weapon = $data_weapons[actor.weapon_id] @help_window.set_text("#{actor.name}'s #{weapon.name} level increased to level #{actor.weapon_level[weapon.id]}", 1) @wait_count = 150 actor.weplev_up = false end end end end # Set array of targeted battlers @target_battlers = [target] # Apply normal attack results for target in @target_battlers target.attack_effect(@active_battler) end return end # If guard if @active_battler.current_action.basic == 1 # Display "Guard" in help window @help_window.set_text($data_system.words.guard, 1) return end # If escape if @active_battler.is_a?(Game_Enemy) and @active_battler.current_action.basic == 2 # Display "Escape" in help window @help_window.set_text("Escape", 1) # Escape @active_battler.escape return end # If doing nothing if @active_battler.current_action.basic == 3 # Clear battler being forced into action $game_temp.forcing_battler = nil # Shift to step 1 @phase4_step = 1 return end end def start_phase5 # if @active_battler.is_a?(Game_Actor) for actor in $game_party.actors if actor.weapon_level[actor.weapon_id] == nil actor.weapon_level[actor.weapon_id] = 1 end if actor.weapon_exp[actor.weapon_id] == nil or actor.weapon_exp[actor.weapon_id] == 0 actor.weapon_exp[actor.weapon_id] = 1 end wep = Weapon_Level if actor.weplev_up == true @help_window.visible = true Audio.me_play("Audio/ME/002-Victory02", 100, 100) weapon = $data_weapons[actor.weapon_id] @help_window.set_text("#{actor.name}'s #{weapon.name} level increased to level #{actor.weapon_level[weapon.id]}", 1) @wait_count = 150 actor.weplev_up = false end end #end leon_weplev_sb_start_phase5 end end #---------------------------------------------------------------------- # Window_Wepinfo #---------------------------------------------------------------------- class Window_Wepinfo < Window_Base def initialize super(0, 0, 640, 64) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = $defaultfonttype self.contents.font.size = $defaultfontsize end def update(help_text) self.contents.clear self.contents.draw_text(0, 0, 618, 32, help_text) end end #---------------------------------------------------------------------- # Window_Weplev #---------------------------------------------------------------------- class Window_Weplev < Window_Selectable def initialize(actor) super(0, 64, 640, 416) @column_max = 2 self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = $defaultfonttype self.contents.font.size = $defaultfontsize @actor = actor self.index = 0 refresh end def weapon return @data[self.index] end def refresh @actor.weapon_check if self.contents != nil self.contents.dispose self.contents = nil end @data = [] for i in 0...@actor.weapons.length weapon = $data_weapons[@actor.weapons[i]] if weapon != nil @data.push(weapon) end end @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) self.contents.font.name = $defaultfonttype self.contents.font.size = $defaultfontsize for i in 0...@item_max draw_item(i) end end end def draw_item(index) weps = Weapon_Level weapon = @data[index] max = weps::Exp[@actor.weapon_level[weapon.id]] x = 4 + index % 2 * (245 + 72) y = index / 2 * 32 rect = Rect.new(x, y, self.width / @column_max - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(weapon.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y - 4, 164, 32, weapon.name, 0) if @actor.weapon_level[weapon.id] >= @actor.weapon_max[weapon.id] draw_bar(x + 28, y + 23, max, max, 160, 5, Color.new(130, 80, 80, 255), Color.new(200, 150, 150,255)) else draw_bar(x + 28, y + 23, @actor.weapon_exp[weapon.id], max, 160, 5, Color.new(130, 80, 80, 255), Color.new(200, 150, 150,255)) end self.contents.draw_text(x + 170, y, 100, 32, @actor.weapon_level[weapon.id].to_s + "/" + @actor.weapon_max[weapon.id].to_s, 2) end end #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # Scene_WeaponLevel #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- class Scene_WeaponLevel def initialize(actor_index = 0) @actor_index = actor_index end def main @actor = $game_party.actors[@actor_index] @info_window = Window_Wepinfo.new @stat_window = Window_Weplev.new(@actor) Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @info_window.dispose @stat_window.dispose end def update @info_window.update("Weapon levels and experience points.") @stat_window.update if Input.trigger?(Input::L) $game_system.se_play($data_system.cursor_se) @actor_index += $game_party.actors.size - 1 @actor_index %= $game_party.actors.size $scene = Scene_WeaponLevel.new(@actor_index) end if Input.trigger?(Input::R) $game_system.se_play($data_system.cursor_se) @actor_index += 1 @actor_index %= $game_party.actors.size $scene = Scene_WeaponLevel.new(@actor_index) end if Input.trigger?(Input::B) $scene = Scene_map.new end end end Share this post Link to post Share on other sites
EmilyAnnCoons 7 Report post Posted January 17, 2007 Cool, I wouldn't use it, though...I'll add it to the script archive tomorrow Share this post Link to post Share on other sites
Marked 197 Report post Posted January 18, 2007 Another great script. I dont know how you do it. Did you fix those bugs? Share this post Link to post Share on other sites
Leon 55 Report post Posted January 18, 2007 Bugs are eliminated. They were the product of being modified for use with my option menu. Share this post Link to post Share on other sites
Marked 197 Report post Posted January 19, 2007 Great. Not being familar with RPG's, it took me awhile to figure out what this does. I was suprised when my sword went to level 2 :lol: Share this post Link to post Share on other sites
Leon 55 Report post Posted January 19, 2007 lol. What's better than that is when it does hit level 2 or 3, check out it's attack compared to level 1 1 shadowriver reacted to this Share this post Link to post Share on other sites
frida89 0 Report post Posted July 22, 2011 Great script:) I've been looking for an easy script for Weaonlevels for a long time. Finally I've found it^^ Just a question. I want to call the scene with weapon levels, but I get an error. is it going to be $scene = Scene_WeaponLeve.new? or is it $scene = Scene_WeaponLevel.new? When using the first I get the error message : NameError occured while running script. uninitialized constant Interpeter::Scene_WeaponLeve And when using the second I get this error: Script 'Weapon levels'line 597: TypeError occured. no implicit conversion from nil to integer. What do you think I'm doing wrong? Share this post Link to post Share on other sites
frida89 0 Report post Posted July 30, 2011 Oh, I really love this script:) Makes it a lot easier to power up all character's weapons.:D I have a small problem though...:'( The weapon level ups are delayed. Sometime I don't get a levelup notice until next battle. Is this something that has to do with the script, or do I just have a lazy computer? Everything else works fine... Share this post Link to post Share on other sites
Leon 55 Report post Posted July 30, 2011 it might be the script... been years since i wrote it. Share this post Link to post Share on other sites
crow5757 0 Report post Posted February 25, 2012 I believe this to be ana amazing script but it is not compatable with other script, like my game. I have and atb script that has an error when I try to use this script at the same time. Any help? Unfortunately, I can't say where I got the atb from, because I can't remember and the script seems to be in a different language (using # 0:‘SƒXƒLƒ and stuff like that). Back on subject, I b stuck... ( just got account and this is my first reply. ) Share this post Link to post Share on other sites
BitAngel91 0 Report post Posted June 15, 2012 Hmm this script is nice but its not compatable, Try to add it as an add on to my game "THE BASIC RTAB SYSTEM" and it got an error while opening the menu and going to my Equiptment stats or characters stats to be exact. Maybe a simpliar version of this would be nice. This is really nicely made, I used a defaulted version with no moded scripts and it works great. Now if only it was compatable with other scripts this would be amazing, Anyway you can make so it ignores an bug or error and continue to work anyways. Like for example, Maybe it collides with another script, can you make so it ignores the error and just continue what it was doing and maybe over lap the other script? Share this post Link to post Share on other sites
David Jantzen 0 Report post Posted June 27, 2015 To those of you who are having issues, if you have a save before you installed the script, then that'll cause it to crash. Once you have installed the script, you have to start a new file in order to access stats and equipment. Also, can this target specific weapons for special bonuses, like having one sword that gets a 150% bonus each level up? Share this post Link to post Share on other sites