Difference between revisions of "LUA:Spells"

(New page: == The LUA Scripting System: Spells == Describe purpose, examples, our chosen folder structure for script storage. Back to LUA)
 
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
{{PageHeaderChild|LUA|Spell Scripts}}
 
== The LUA Scripting System: Spells ==
 
== The LUA Scripting System: Spells ==
 
Describe purpose, examples, our chosen folder structure for script storage.
 
Describe purpose, examples, our chosen folder structure for script storage.
  
[[Developer:LUA_Functions | Back to LUA]]
+
 
 +
Spells are controlled by (mainly) 3 tables: spell_tiers, spells and spell_classes and can be used to create all manner of spells.
 +
 
 +
 
 +
It would be wise to have a read over [[Spells]]
 +
 
 +
 
 +
There are 3 main functions in a spell: cast, remove and tick. You should get familiar with these and how they are used.
 +
 
 +
<pre>
 +
function cast(Caster, Target, DamageType, Damage)
 +
 
 +
end
 +
 
 +
function remove(Caster, Target)
 +
 
 +
end
 +
 
 +
function tick(Caster, Target, DDType, MinDDVal, MaxDDVal, EffectType, MinEffectVal, MaxEffectVal)
 +
    SpellDamage(Target, 6, 30)
 +
end
 +
</pre>
 +
 
 +
== Examples ==
 +
 
 +
HP Buff
 +
<pre>
 +
--main process function
 +
function cast(Caster, Target, DamageType, Damage)
 +
SetMaxHP(Target, (GetMaxHP(Target) + 50))
 +
end
 +
 
 +
function tick(Caster, Target, DDType, MinDDVal, MaxDDVal, EffectType, MinEffectVal, MaxEffectVal)
 +
 
 +
end
 +
 
 +
function remove(Caster, Target)
 +
SetMaxHP(Target, (GetMaxHP(Target) - 50))
 +
end
 +
</pre>
 +
 
 +
Heal
 +
<pre>
 +
--main process function
 +
function cast(Caster, Target, DamageType, Damage)
 +
-- syntax for SpellDamage is Target, DamageType, and Damage
 +
--SpellDamage(Target, DamageType, Damage)
 +
ModifyHP(Caster, 20)
 +
end
 +
 
 +
function remove(Caster, Target)
 +
end
 +
</pre>
 +
 
 +
Runspeed
 +
<pre>
 +
function cast(Caster, Target, DamageType, Damage)
 +
SetSpeed(Player, 100)
 +
end
 +
 
 +
function remove(Caster, Target)
 +
        SetSpeed(Player, 1)
 +
end
 +
</pre>
 +
 
 +
== Precast ==
 +
This function will be called when you try to cast a spell, it is unique as it requires it to return a true or false.  You can do special checks here to see if you can cast the spell, this is in addition to normal checks the server core does, returning true means you can cast the spell, false mean you can't.  In addition you can return an error code id (defined in spells.h) to display why the spell failed to cast.
 +
 
 +
Flanking
 +
<pre>
 +
function precast(Caster, Target)
 +
    return IsFlanking(Target, Caster)
 +
end
 +
</pre>
 +
 
 +
Not on epic, as well as a custom error code
 +
<pre>
 +
function precast(Caster, Target)
 +
    return (not IsEpic(Target)), 43
 +
end
 +
</pre>
 +
 
 +
 
 +
[[LUA|Back to LUA]]

Latest revision as of 16:37, 14 June 2016

LUA - Spell Scripts

Return to: LUA | Tutorials | Portal | Forum | Project Manager | Bug Tracker

The LUA Scripting System: Spells

Describe purpose, examples, our chosen folder structure for script storage.


Spells are controlled by (mainly) 3 tables: spell_tiers, spells and spell_classes and can be used to create all manner of spells.


It would be wise to have a read over Spells


There are 3 main functions in a spell: cast, remove and tick. You should get familiar with these and how they are used.

function cast(Caster, Target, DamageType, Damage)

end

function remove(Caster, Target)

end

function tick(Caster, Target, DDType, MinDDVal, MaxDDVal, EffectType, MinEffectVal, MaxEffectVal)
    SpellDamage(Target, 6, 30)
end

Examples

HP Buff

--main process function
function cast(Caster, Target, DamageType, Damage)
	SetMaxHP(Target, (GetMaxHP(Target) + 50))
end

function tick(Caster, Target, DDType, MinDDVal, MaxDDVal, EffectType, MinEffectVal, MaxEffectVal)

end

function remove(Caster, Target)
	SetMaxHP(Target, (GetMaxHP(Target) - 50))
end

Heal

--main process function
function cast(Caster, Target, DamageType, Damage)
	-- syntax for SpellDamage is Target, DamageType, and Damage
	--SpellDamage(Target, DamageType, Damage)
	ModifyHP(Caster, 20) 
end

function remove(Caster, Target)
end

Runspeed

function cast(Caster, Target, DamageType, Damage)
	SetSpeed(Player, 100)
end

function remove(Caster, Target)
        SetSpeed(Player, 1)
end

Precast

This function will be called when you try to cast a spell, it is unique as it requires it to return a true or false. You can do special checks here to see if you can cast the spell, this is in addition to normal checks the server core does, returning true means you can cast the spell, false mean you can't. In addition you can return an error code id (defined in spells.h) to display why the spell failed to cast.

Flanking

function precast(Caster, Target)
    return IsFlanking(Target, Caster)
end

Not on epic, as well as a custom error code

function precast(Caster, Target)
    return (not IsEpic(Target)), 43
end


Back to LUA