See below.
If you look at the Categories on EQ2 Wikia (this example being Quick Strike) you will notice the Category (target) and the spell "type" right after that. In this example, it is DD / DOT.
I propose that we make our generic Spell Scripts named similar to these categories - ie., dd_dot.lua for generic Direct-Damage + DOT spells. Inside the script, we can pass different parameters to determine what types of damage we're dealing.
For DD / DOT spells, you would pass 6 params: DDType, DDMin, DDMax, EffectType, EffectMin, EffectMax, for example. For straight DD, you only need the first 3... and the script is designed to check if EffectType ~= nil and skip that code. Remember, dd_dot.lua is only for damage.
For Scatman's example of a Triple Shot damage, we should be able to use the same script, only passing an extra param for the number of strikes, rather than create 3 scripts for single, double, or triple shots. As for the increasing damage done by these types of damage, we can perform additional math.random() in tick() using the last minimum value so the illusion is that the shots are getting stronger. Double or Triple shots could be mimicked in tick(), you think Scat? If so, we simply set the call_frequency to the expected delay between shots, and set a duration so it ends after the 3rd shot (for triple shot). Then in the spell_data, you pass the first 3 params as the initial damage, and the 4th param as "triple" (string). Now the generic DD/DOT script will SpellDamage() the first 3 params, then tick() the next 2. This is just one idea, and I haven't tried it yet.
The only thing we need on the server is to abort the entire script of a Miss occurs, which I do not believe we handle in LUA Scripts.
Some naming examples:
dd_dot.lua
dd_heal.lua
buff.lua
taunt.lua
etc...
An example generic dd_dot.lua:
[code]function cast(Caster, Target, DDType, MinDDVal, MaxDDVal, EffectType, MinEffectVal, MaxEffectVal)
-- DD component
if MaxDDVal ~= nil and MinDDVal < MaxDDVal then
SpellDamage(Target, DDType, math.random(MinDDVal, MaxDDVal))
else
SpellDamage(Target, DDType, MinDDVal)
end
-- Effect component - only process this code if there is an EffectType param
if EffectType ~= nil then
-- Determine if there is a range to effect values
if MaxEffectVal ~= nil and MinEffectVal < MaxEffectVal then
EffectValue = math.random(MinEffectVal, MaxEffectVal)
else
EffectValue = MinEffectVal
end
SpellDamage(Target, EffectType, EffectValue)
end
end
function tick(Caster, Target, DDType, MinDDVal, MaxDDVal, EffectType, MinEffectVal, MaxEffectVal)
if MaxEffectVal ~= nil and MinEffectVal < MaxEffectVal then
SpellDamage(Target, EffectType, math.random(MinEffectVal, MaxEffectVal))
else
SpellDamage(Target, EffectType, MinEffectVal)
end
end[/code]
spell_data for this script is: 0, 1, 5, 8, 1, 1
A script I created for testing to handle both DD and Heal-self:
[code]
function cast(Caster, Target, DDType, MinDDVal, MaxDDVal, EffectType, MinEffectVal, MaxEffectVal)
-- DD component
if MaxDDVal ~= nil and MinDDVal < MaxDDVal then
SpellDamage(Target, DDType, math.random(MinDDVal, MaxDDVal))
else
SpellDamage(Target, DDType, MinDDVal)
end
-- Effect component - only process this code if there is an EffectType param
if EffectType ~= nil then
-- Determine if there is a range to effect values
if MaxEffectVal ~= nil and MinEffectVal < MaxEffectVal then
EffectValue = math.random(MinEffectVal, MaxEffectVal)
else
EffectValue = MinEffectVal
end
-- Determine EffectType - either a DamageType or a String value passed as param 4
if EffectType == "heal" then
ModifyHP(Caster, EffectValue)
else
SpellDamage(Target, EffectType, EffectValue)
end
end
end
function tick(Caster, Target, DDType, MinDDVal, MaxDDVal, EffectType, MinEffectVal, MaxEffectVal)
if MaxEffectVal ~= nil and MinEffectVal < MaxEffectVal then
EffectValue = math.random(MinEffectVal, MaxEffectVal)
else
EffectValue = MinEffectVal
end
if EffectType == "heal" then
ModifyHP(Caster, EffectValue)
else
SpellDamage(Target, EffectType, EffectValue)
end
end[/code]
spell_data for this script could be either
: 0, 1, 5, 8, 1, 1 or
: 0, 1, 5, "heal", 2
...where the 4th param is a string "heal" telling the script it is not a DOT, but a heal for 2. You can see how flexible this is (pause for a moment of Lethal-worship here), though the more generic our scripts are, the more complex they become.
Conclusion: I am no longer chasing the dream that we'll need only 10 spell scripts for every spell in the game (hahah) and I believe if we categorize the spells properly, we can still maintain a minimal number of scripts.
What do you say?
See below for update to how Spells load as of Jan 28, 2010.


