=begin
#===============================================================================
Title: Dynamic Weapon Animations
Author: Hime
Date: Mar 23, 2014
URL:
--------------------------------------------------------------------------------
** Change log
Mar 23, 2014
- Initial release
--------------------------------------------------------------------------------
** Terms of Use
* Free to use in non-commercial projects
* Contact me for commercial use
* No real support. The script is provided as-is
* Will do bug fixes, but no compatibility patches
* Features may be requested but no guarantees, especially if it is non-trivial
* Credits to Hime Works in your project
* Preserve this header
--------------------------------------------------------------------------------
** Description
This script allows you to dynamically determine a weapon's animation.
When using a skill or item, you can choose to show a "normal attack"
animation. This will tell the engine to use the animation that you have
selected for the weapon.
However, sometimes this is not enough. You might want a single weapon to show
different animations depending on factors such as the current state or who
the actor is.
For example, you might have a normal slash animation, but if you have an
ice enchantment state, you might want to play an ice slash animation, and
if you have a fire enchantment state, you might want to play a fire slash
animation.
By using dynamic weapon animations, you can use formulas to determine which
animation will be played based on a variety of conditions.
--------------------------------------------------------------------------------
** Installation
In the script editor, place this script below Materials and above Main
--------------------------------------------------------------------------------
** Usage
To specify an animation formula for a weapon, note-tag it with
FORMULA
Where the formula is any valid formula that returns the ID of the animation
that you want to use.
The following formula variables are available:
a - the user
p - game party
t - game troop
s - game switches
v - game variables
To use the weapon's animation, your skill or item must use "normal attack"
animation.
Remember that your formula must always return an ID. There is no default ID.
#===============================================================================
=end
$imported = {} if $imported.nil?
$imported[:TH_DynamicWeaponAnimations] = true
#===============================================================================
# ** Configuration
#===============================================================================
module TH
module Dynamic_Weapon_Animations
Ext_Regex = /(.*?)<\/animation[-_ ]formula>/im
end
end
#===============================================================================
# ** Rest of script
#===============================================================================
module RPG
class Weapon < EquipItem
def weapon_animation_formula
load_notetag_dynamic_weapon_animations unless @weapon_animation_formula
return @weapon_animation_formula
end
def load_notetag_dynamic_weapon_animations
@weapon_animation_formula = ""
res = self.note.match(TH::Dynamic_Weapon_Animations::Ext_Regex)
if res
@weapon_animation_formula = res[1]
end
end
def eval_weapon_animation(a, p=$game_party, t=$game_troop, v=$game_variables, s=$game_switches)
eval(self.weapon_animation_formula)
end
end
end
class Game_Actor < Game_Battler
#-----------------------------------------------------------------------------
# Replaced
#-----------------------------------------------------------------------------
def atk_animation_id1
if dual_wield?
return weapons[0].eval_weapon_animation(self) if weapons[0]
return weapons[1] ? 0 : 1
else
return weapons[0] ? weapons[0].eval_weapon_animation(self) : 1
end
end
#-----------------------------------------------------------------------------
# Replaced
#-----------------------------------------------------------------------------
def atk_animation_id2
if dual_wield?
return weapons[1] ? weapons[1].eval_weapon_animation(self) : 0
else
return 0
end
end
end