GW Magical Weapons
Version: 1.2
Author: Mr G W
Date: (DD/MM/YYYY) - 30/8/2011
Version History
- <Version 1.2> 2011.8.30 - Tag can now be used to give enemies magical attacks.
- <Version 1.1> 2011.8.18 - Fixed a crash when a enemy used a normal attack.
- <Version 1.0> 2011.8.12 - Original Release
Planned Future Versions
- Nothing. Suggest something...
Description
Allows weapons to deal magical damage on normal attack, so it uses SPI instead of ATK and DEF. Works with YEM RES stat.
This is similar to Magic Weapons in Fire Emblem, such as Runesword or Fire Lance.
Features
- Allows creation of magical weapons.
- If using Dual Weapons and one weapon is magical and the other isn't, it will do "hybrid" damage, offensively uses both ATK and SPI and defensively uses DEF and SPI (or RES).
Screenshots
None.
Instructions
Place where it says Materials.
Use the <magical> tag to make a weapon magical.
Script
=begin
==================================================================================================
==================================================================================================
Magical Weapons
Version 1.2
By Mr G W - Rmrk.net
Date (DD/MM/YYYY) - 30/8/2011
<Version 1.2> 2011.8.30 - Tag can now be used to give enemies magical attacks.
<Version 1.1> 2011.8.18 - Fixed a crash when a enemy used a normal attack.
<Version 1.0> 2011.8.12 - Original Release
Allows creation of magic weapons, weapons that use your spirit (and resistance
stat, if using YEM stats) instead of attack and defense.
Use the <magical> tag to make a weapon magical.
If using Dual Weapons and one weapon is magical and the other isn't,
it will do "hybrid" damage, offensively uses both ATK and SPI and defensively
uses DEF and SPI (or RES).
The <magical> tag can also be used to give an enemy a magical attack.
Since enemies do not have weapons, the <hybrid> tag can be used to give the
enemy a mixed attack, which is equivalent to the use of two weapons,
1 magical and the other not.
Place below those scripts.
==================================================================================================
==================================================================================================
Compatibility:
This script overrides make_attack_damage_value.
This script will not work if another script is placed below this one that also
overrides the same method. If this script is placed below instead, the other
script will not work. If another script aliases this method, place it below
this script.
Any script that overrides make_attack_damage_value may not work with this or vice versa.
=end
$imported = {} if $imported == nil
$imported["GWMagicWeapons"] = true
class Game_Battler
def make_attack_damage_value(attacker)
damage = damage_calc(attacker)
damage = 0 if damage < 0 # if negative, make 0
damage *= elements_max_rate(attacker.element_set) # elemental adjustment
damage /= 100
if damage == 0 # if damage is 0,
damage = rand(2) # half of the time, 1 dmg
elsif damage > 0 # a positive number?
@critical = (rand(100) < attacker.cri) # critical hit?
@critical = false if prevent_critical # criticals prevented?
damage *= 3 if @critical # critical adjustment
end
damage = apply_variance(damage, 20) # variance
damage = apply_guard(damage) # guard adjustment
@hp_damage = damage # damage HP
end
def damage_calc(attacker)
damage = attacker.atk * 4 - self.def * 2 # base calculation
if attacker.actor? == false #Enemies
damage = attacker.spi * 2 - self.spi * 1 if attacker.enemy.magical == true and $imported["RES Stat"] == false
damage = attacker.spi * 2 - self.res * 1 if attacker.enemy.magical == true and $imported["RES Stat"] == true
damage = ((attacker.atk * 4 - self.def * 2) + (attacker.spi * 2 - self.spi * 1))/2 if attacker.enemy.hybrid == true and $imported["RES Stat"] == false
damage = ((attacker.atk * 4 - self.def * 2) + (attacker.spi * 2 - self.res * 1))/2 if attacker.enemy.hybrid == true and $imported["RES Stat"] == true
end
return damage unless attacker.actor?
if attacker.weapons[0] != nil and attacker.weapons[1] == nil #Using only weapon 0
return damage unless attacker.weapons[0].magical == true
damage = attacker.spi * 2 - self.spi * 1 if $imported["RES Stat"] == false
damage = attacker.spi * 2 - self.res * 1 if $imported["RES Stat"] == true
elsif attacker.weapons[0] == nil and attacker.weapons[1] != nil #Using only weapon 1
return damage unless attacker.weapons[1].magical == true
damage = attacker.spi * 2 - self.spi * 1 if $imported["RES Stat"] == false
damage = attacker.spi * 2 - self.res * 1 if $imported["RES Stat"] == true
elsif attacker.weapons[0] != nil and attacker.weapons[1] != nil #Using both weapons
return damage unless attacker.weapons[0].magical == true or attacker.weapons[1].magical == true
if attacker.weapons[0].magical == attacker.weapons[1].magical #Both weapons are magical: Deal magic damage only
damage = attacker.spi * 2 - self.spi * 1 if $imported["RES Stat"] == false
damage = attacker.spi * 2 - self.res * 1 if $imported["RES Stat"] == true
elsif attacker.weapons[0].magical != attacker.weapons[1].magical #One weapon is magical, the other isnt. Deals damage based on both stats.
damage = ((attacker.atk * 4 - self.def * 2) + (attacker.spi * 2 - self.spi * 1))/2 if $imported["RES Stat"] == false
damage = ((attacker.atk * 4 - self.def * 2) + (attacker.spi * 2 - self.res * 1))/2 if $imported["RES Stat"] == true
end #If
end #If
return damage
end #Def
end #Class
class RPG::BaseItem
def magical
self.note.scan(/<magical>/i){
return true}
return false
end
end
class RPG::Enemy
def magical
self.note.scan(/<magical>/i){
return true}
return false
end
def hybrid
self.note.scan(/<hybrid>/i){
return true}
return false
end
end
You can also get it from the attachment.
Credit
- Mr G W
- Yanfly - For the YEM Battle Stats
Thanks
- Yanfly - For the YEM Battle Stats
- Others who made scripts - I've been learning on my own, so other scripts help me understand how RGSS works.
Support
Just post here. If i don't answer, it's because I can't be on.
Any errors or glitches, feel free to post.
Known Compatibility Issues
This script overrides make_attack_damage_value.
This script will not work if another script is placed below this one that also
overrides the same method. If this script is placed below instead, the other
script will not work. If another script aliases this method, place it below
this script.
Any script that overrides make_attack_damage_value may not work with this or vice versa.
Demo
None.
Author's Notes
Older scripts are kept for whatever reason you want.
Restrictions
For commercial use, contact me first. You can use this script how you want as long as you credit.