#============================================================================== # Crystal Engine - Weapon Levels #------------------------------------------------------------------------------ # Current Version: 1.00 #============================================================================== $imported ||= {} $imported["CE-WeaponLevels"] = true =begin This script sets up so that actors have proficiancy levels for all weapon types and certain armor types (for shields). Weapons (and shields) can level up. These levels effect the damge dealt for weapons. For shields they affect the damage reduced when using Mr. Bubble's Shield Blocking script. ------------------------------------------------------------------------------- Notetags: Skill Notes # Signifies to factor in your weapon level (attacking automatically has this trait) Item Notes # Signifies to factor in your weapon level =end module CRYSTAL module FF2 module WEAPONS #------------------------------------------------------------------------ # * Max Level for a Given Weapon Type #------------------------------------------------------------------------ MAX_RANK = 16 #------------------------------------------------------------------------ # * Weapon EXP Needed for a Level Up #------------------------------------------------------------------------ EXP_FOR_RANK = 100 #------------------------------------------------------------------------ # * Armor Types That Have a Level (these are your shields) #------------------------------------------------------------------------ SHIELD_ATYPES = [5, 6] #------------------------------------------------------------------------ # * Does an Attack Need to Connect in Order to Cause an Increase #------------------------------------------------------------------------ HIT_REQUIRED = true #------------------------------------------------------------------------ # * Barehanded Term #------------------------------------------------------------------------ BAREHANDED_TERM = "Barehanded" #------------------------------------------------------------------------ # * Message for a Level Up #------------------------------------------------------------------------ LEVEL_MESSAGE = "%s's %s Level Increased!" #------------------------------------------------------------------------ # * Modified Damage Formula #------------------------------------------------------------------------ DAMAGE_FORMULA = "%s * [(weapon_level / 2.0), 1].max" #------------------------------------------------------------------------ # * Modified Block Reduction Value Formula #------------------------------------------------------------------------ BLOCK_VALUE_FORMULA = "%s" #------------------------------------------------------------------------ # * Modified Block Reduction Rate Formula #------------------------------------------------------------------------ BLOCK_REDUCTION_FORMULA = "%s" #------------------------------------------------------------------------ # * Modified Block Change Rate Formula #------------------------------------------------------------------------ BLOCK_CHANCE_FORMULA = "%s * [(shield_level / 2.0), 1].max" #------------------------------------------------------------------------ # * Modified Block Change Rate Formula #------------------------------------------------------------------------ CRITICAL_BLOCK_FORMULA = "%s * [(shield_level / 2.0), 1].max" WEAPON_ICONS = { 0 => 116, 1 => 144, 2 => 145, 3 => 146, 4 => 147, 5 => 148, 6 => 149, 7 => 150, 8 => 151, 9 => 152, 10 => 153 } SHIELD_ICONS = { 5 => 160, 6 => 161, } WEAPON_LEVEL_FORMAT = "%s Lv. %s" end end end #============================================================================== # Editing beyond this point may cause stone, zombie, mist frenzy, and/or toad, # so edit at your own risk. #============================================================================== module CRYSTAL module CHECK #-------------------------------------------------------------------------- # * Checks if you have a certain script installed #-------------------------------------------------------------------------- def self.require(self_name, script, site = "http://crystalnoel42.wordpress.com") unless $imported["CE-BasicModule"] msg = "The script '#{self_name}' requires the latest\n" msg += "version of 'Crystal Engine - Basic Module' to work properly\n" msg += "Go to http://crystalnoel42.wordpress.com/ to download this script." raise SyntaxError.new(msg) end unless $imported[script] msg = "The script '#{self_name}' requires the latest\n" msg += "version of #{scripts_list(script)} to work properly\n" msg += "Go to #{site} to download this script." raise SyntaxError.new(msg) end end require("Crystal Engine - Weapon Levels", "CE-BasicModule") #-------------------------------------------------------------------------- # * Script Name Guide #-------------------------------------------------------------------------- class </i end end #============================================================================== # ** RPG::UsableItem::Damage #------------------------------------------------------------------------------ # The data class for damage. #============================================================================== class RPG::UsableItem::Damage #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :skill_id # The skill id for the damage attr_accessor :item_id # The item id for the damage #-------------------------------------------------------------------------- # * Evaluate Damage #-------------------------------------------------------------------------- alias eval_ce_ff2_weapon_levels_rpg_usableitem_damage eval def eval(a, b, v) value = eval_ce_ff2_weapon_levels_rpg_usableitem_damage(a, b, v) if a.actor? && !a.no_advancement? if (@skill_id && $data_skills[@skill_id].weapon_based) || (@item_id && $data_skills[@item_id].weapon_based) formula = CRYSTAL::FF2::WEAPONS::DAMAGE_FORMULA if a.weapons.empty? weapon_levels = a.weapon_levels[:weapons][0] else levels = [] a.weapons.each do |weapon| levels.push(a.weapon_levels[:weapons][weapon.wtype_id]) end weapon_level = levels.max end value = Kernel.eval(sprintf(formula, value)) end end value end end #============================================================================== # ** RPG::Skill #------------------------------------------------------------------------------ # The data class for skills. #============================================================================== class RPG::Skill < RPG::UsableItem #-------------------------------------------------------------------------- # * Is the Attack Weapon Based #-------------------------------------------------------------------------- def weapon_based @id == 1 || super end end #============================================================================== # ** Vocab #------------------------------------------------------------------------------ # This module defines terms and messages. It defines some data as constant # variables. Terms in the database are obtained from $data_system. #============================================================================== module Vocab #-------------------------------------------------------------------------- # * Weapon Types #-------------------------------------------------------------------------- def self.wtype(wtype_id) $data_system.weapon_types[wtype_id] end #-------------------------------------------------------------------------- # * Armor Types #-------------------------------------------------------------------------- def self.atype(atype_id) $data_system.armor_types[atype_id] end end #============================================================================== # ** DataManager #------------------------------------------------------------------------------ # This module manages the database and game objects. Almost all of the # global variables used by the game are initialized by this module. #============================================================================== module DataManager #-------------------------------------------------------------------------- # * Load Database #-------------------------------------------------------------------------- class <= CRYSTAL::FF2::WEAPONS::EXP_FOR_RANK user.weapon_exp[:weapons][0] = 0 user.increased_weapons[:weapons].push(0) end else user.equips.each do |equip| next if equip.nil? if equip.is_a?(RPG::Weapon) next if user.weapon_levels[:weapons][equip.wtype_id] == CRYSTAL::FF2::WEAPONS::MAX_RANK user.weapon_exp[:weapons][equip.wtype_id] += CRYSTAL::FF2::PROCESSOR.rank_based_eval(user, self) if user.weapon_exp[:weapons][equip.wtype_id] >= CRYSTAL::FF2::WEAPONS::EXP_FOR_RANK user.weapon_exp[:weapons][equip.wtype_id] = 0 user.increased_weapons[:weapons].push(equip.wtype_id) end elsif equip.is_a?(RPG::Armor) next unless CRYSTAL::FF2::WEAPONS::SHIELD_ATYPES.include?(equip.atype_id) next if user.weapon_levels[:armors][equip.atype_id] == CRYSTAL::FF2::WEAPONS::MAX_RANK user.weapon_exp[:armors][equip.atype_id] += CRYSTAL::FF2::PROCESSOR.rank_based_eval(user, self) if user.weapon_exp[:armors][equip.atype_id] >= CRYSTAL::FF2::WEAPONS::EXP_FOR_RANK user.weapon_exp[:armors][equip.atype_id] = 0 user.increased_weapons[:armors].push(equip.atype_id) end end end end end end #============================================================================== # ** Game_Actor #------------------------------------------------------------------------------ # This class handles actors. It is used within the Game_Actors class # ($game_actors) and is also referenced from the Game_Party class ($game_party). #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :weapon_exp attr_accessor :increased_weapons attr_accessor :weapon_levels #-------------------------------------------------------------------------- # * Setup #-------------------------------------------------------------------------- alias setup_ce_ff2_weapon_levels setup def setup(actor_id) setup_ce_ff2_weapon_levels(actor_id) return if no_advancement? @weapon_exp = {} @weapon_exp[:weapons] = [0] * $data_system.weapon_types.size @weapon_exp[:armors] = {} CRYSTAL::FF2::WEAPONS::SHIELD_ATYPES.each do |atype| @weapon_exp[:armors][atype] = 0 end @weapon_levels = {} @weapon_levels[:weapons] = [1] * $data_system.weapon_types.size @weapon_levels[:armors] = {} CRYSTAL::FF2::WEAPONS::SHIELD_ATYPES.each do |atype| @weapon_levels[:armors][atype] = 1 end @increased_weapons = {:weapons => [], :armors => []} end #-------------------------------------------------------------------------- # * Shields #-------------------------------------------------------------------------- def shields armors.select {|armor| CRYSTAL::FF2::WEAPONS::SHIELD_ATYPES == armor.atype_id } end end