Weapon Powers
Alright, so... I know there are many scripts about weapon powers out there, but I wrote something for use within my project. Please feel free to use it the way you'd like to.
Features:
- A new parameter: Weapon Power (WP). Define each weapon and armor's 'weapon power' by note-tagging in the database.
- Rewrite performance considerations by factoring the weapon power into the equation, meaning that when we select 'optimize', weapon power will also be considered.
Here's the code. As always, insert it below the materials section above Main. Place it on top of scripts that will depend on 'wp'.
# WEAPON POWERS# ------------------------ oichidan | 2017# Originally intended for use within #TMoJ RPG# Description# This script adds a new property 'wp' in the RPG::Weapon class. Each weapon and armor will now# have weapon power parameter specified by note-tagging in the database. The weapon power will also# be factored when optimizing equipment and can be used in damage equations as well.# This script is meant to be used in RPG Maker VX Ace.# Notetags (Place it in weapon and armors)# 1. <WEAPON POWER: xx># Sets the weapon/armor 'weapon power' to xx.# We can also use weapon_power, WP, wp, WEP, wep, and weapon power, # case insensitive, instead of WEAPON POWER in the notetag format above.# Usage# 1. Obtain the equipment by using (Game_Actor).equips[0] for the weapon, [1] for the second slot# (if dual-wield), and other numbers you're using as to place your equipment slots.# For example, in a damage equation: a.equips[0] refers to the topmost weapon equipped# (in case you're using 'vanilla' RPG Maker VX Ace, that is, the equipment slots have yet to# be modified).# 2. Reference the weapon power with the 'wp' or 'power' property.# a.equips[0].wp refers to the weapon power equipped in the topmost equipment slot of the actor.# REMINDER: the 'wp' parameter will be invalid if:# - The weapon power has not been set# - The actor is not equipping any weapons# At such cases, exceptions will raise.# Note: The 'wp' property is read-write, meaning that you -can- change its value mid-game.# Here's the script. Feel free to use it the way you'd love to.# There are still errors here and there, but if this eventually comes of use, I'm glad.# You are not required to credit me at anyway, and you're free to use it in commercial games.# But if you do, I'd really appreciate it. Credit me as 'oichidan' or 'Aldian Hudaya',# and the copy of the game would be much appreciated, too.# Cheers! -oichidan | Aldian Hudaya# -------------------------------------------------------------------------------------module DataManager class <<self; alias load_database_wp load_database; end def self.load_database load_database_wp load_notetags_wp end def self.load_notetags_wp for weapon in $data_weapons next if weapon.nil? weapon.load_notetag_wp end for armor in $data_armors next if armor.nil? armor.load_notetag_wp end end endclass RPG::Weapon < RPG::EquipItem attr_accessor :wp alias :power :wp def load_notetag_wp wep = 0 self.note.split(/[\r\n]+/).each { |line| case line when /<(:WEAPON_POWER|weapon_power|WP|wp|WEP|wep|WEAPON POWER|weapon power):[ ](\d+)>/i wep = $2.to_i @wp = wep end } end # Overwrite: Performance def performance self.wp + params[2] + params[4] + params.inject(0) {|r, v| r += v} end endclass RPG::Armor < RPG::EquipItem attr_accessor :wp alias :power :wp def load_notetag_wp wep = 0 self.note.split(/[\r\n]+/).each { |line| case line when /<(:WEAPON_POWER|weapon_power|WP|wp|WEP|wep|WEAPON POWER|weapon power):[ ](\d+)>/i wep = $2.to_i @wp = wep end } end # Overwrite: Performance def performance self.wp + params[0] + params[1] + params[3] + params.inject(0) {|r, v| r += v} endend
Some damage formulas created by using weapon power (though creativity -is- limitless):
# Some damage formulas using the 'wp' property and the weapon power script. # Inspired heavily by Final Fantasy Tactics: War of The Lions (Square Enix).# Place the damage formula below in the damage formula textbox in the database.# Reminder: - Set the weapon power for each weapon accordingly.# There are many a thousand ways or more to implement different skills for different weapons,# or at least different formula for different kinds of weapon attacks. The formulas presented# below are merely things that might inspire you in creating damage formulas that differs for each# weapon.# For the other hand in a dual-wield weapon, a.equips[0] becomes a.equips[1].# KNIFE, LONGBOW(a.atk + a.agi) / 2 * a.equips[0].wp# SWORD, CROSSBOWa.atk * a.equips[0].wp# FLAIL, AXErand(a.atk) * a.equips[0].wp # rand(x) means to generate a random number from 0 to x.# NINJATOa.agi * a.equips[0].wp# STAFFa.mat * a.equips[0].wp# PISTOLa.equips[0].wp**2 # The same as a.equips[0].wp * a.equips[0].wp# BOOK(a.mat + a.atk) / 2 * a.equips[0].wp# The possibilities are limitless!
The comments box below are open for further discussions. Ideas, suggestions, critiques and feedback are always welcome! <3
-
1



3 Comments
Recommended Comments