/*Stigma System by Adiktuz
Version 2.01 Linear
Requires:
T32 - http://www.thehelper.net/forums/showthread.php/132538-Timer32
Table - http://www.hiveworkshop.com/forums/jass-resources-412/snippet-new-table-188084/
Description:
Inflicts damage every interval which increases by a set amount
You can modify the amount of damage, total duration and damage interval with each call of the function
You can also have multiple spells that use this library and supports multi-level spells
System is MUI
Also, the effect of Stigma can stack up on individual units if a spell using the system is casted unpon them successively.
the stacking effect works for every spell using stigma
How to use
just call the function:
Stigma_L.create(unit target, unit caster, real interval, real totalduration, boolean usebuff, attacktype at,
damagetype dt, real base, real increment string buffeffect, string damageeffect, string apoint, integer abil)
unit target is the unit to be afflicted by stigma
unit caster is the unit who caused the stigma
real interval is the interval in seconds in which the damage occurs
real totalduration is the duration of the stigma in seconds
For best results use reals divisible by .03
attacktype at is the attack type of the spell
damagetype dt is the damage type of the spell
real base is the base damage of the stigma (first damage is already base + increment)
real increment is the additional damage dealth by stigma per interval
string buffeffect is the effect that attaches to the unit during the duration of stigma
string damageeffect is the effect played every damage interval
string apoint is the attachment point of the effects
integer abil is the rawcode of the spell
If you need simpler functions:
Without attacktype,damagetype and damageeffect settings:
Stigma_L.simple(unit target, unit caster, real interval, real totalduration,
real base,real increment, string buffeffect, integer abil)
Further without buffeffect
Stigma_L.simpler(unit target, unit caster, real interval, real totalduration,
real base,real increment, integer abil)
Further without base
Stigma_L.simplest(unit target, unit caster, real interval, real totalduration,
real increment, integer abil)
Registering onXX events:
Stigma_L.registerDamageEvent(integer abil, code action)
-> runs when a unit is damaged
Stigma_L.registerFinishEvent(integer abil, code action)
-> runs when an instance of the stigma linear has ended
You can use Stigma_L.data to get the instance of stigma that triggered the events
*/
library StigmaLinear requires T32, Table
//Do not edit below this line unless you are sure of what you're doing
function StigmaLinearDamage takes real base, real increment returns real
return base + increment
endfunction
private module init
static method onInit takes nothing returns nothing
set thistype.onDamageTable = Table.create()
set thistype.onFinishTable = Table.create()
endmethod
endmodule
struct Stigma_L
static Table onDamageTable
static Table onFinishTable
static thistype data
unit target
unit caster
real interval
real totalduration
real timeelapsed = 0
real damagetime
attacktype at
damagetype dt
real base
real increment
string damageeffect
effect be
string apoint
integer abil
static method registerDamageEvent takes integer abil, code action returns nothing
if not onDamageTable.handle.has(abil) then
set onDamageTable.trigger[abil] = CreateTrigger()
endif
call TriggerAddCondition(onDamageTable.trigger[abil], Filter(action))
endmethod
static method registerFinishEvent takes integer abil, code action returns nothing
if not onFinishTable.handle.has(abil) then
set onFinishTable.trigger[abil] = CreateTrigger()
endif
call TriggerAddCondition(onFinishTable.trigger[abil], Filter(action))
endmethod
method finish takes nothing returns nothing
set this.target = null
set this.caster = null
set this.at = null
set this.dt = null
call DestroyEffect(this.be)
set this.be = null
call this.deallocate()
endmethod
method periodic takes nothing returns nothing
set this.timeelapsed = this.timeelapsed + T32_PERIOD
set data = this
if this.timeelapsed >= this.damagetime then
set this.damagetime = this.damagetime + this.interval
call UnitDamageTarget(this.caster, this.target, StigmaLinearDamage(this.base, this.increment), false, false, this.at, this.dt, WEAPON_TYPE_WHOKNOWS )
if onDamageTable.handle.has(this.abil) then
call TriggerEvaluate(onDamageTable.trigger[this.abil])
endif
set this.base = this.base + this.increment
call DestroyEffect(AddSpecialEffectTarget(this.damageeffect, this.target, this.apoint))
endif
if (this.timeelapsed >= this.totalduration) or (GetWidgetLife(this.target) <= .405) then
if onFinishTable.handle.has(this.abil) then
call TriggerEvaluate(onFinishTable.trigger[this.abil])
endif
call this.stopPeriodic()
call this.finish()
endif
endmethod
implement T32x
static method create takes unit target, unit caster, real interval, real totalduration, /*
*/attacktype at, damagetype dt, real base, real increment, string buffeffect, /*
*/string damageeffect, string apoint, integer abil returns thistype
local thistype stigma = .allocate()
set stigma.caster = caster
set stigma.target = target
set stigma.interval = interval
set stigma.totalduration = totalduration
set stigma.damagetime = interval
set stigma.at = at
set stigma.dt = dt
set stigma.base = base
set stigma.increment = increment
set stigma.be = AddSpecialEffectTarget(buffeffect, target, apoint)
set stigma.apoint = apoint
set stigma.damageeffect = damageeffect
set stigma.abil = abil
call stigma.startPeriodic()
return stigma
endmethod
static method simple takes unit target, unit caster, real interval, real totalduration,/*
*/real base,real increment, string buffeffect,integer abil returns thistype
return thistype.create(target,caster,interval,totalduration,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,base,increment,buffeffect,"","origin",abil)
endmethod
static method simpler takes unit target, unit caster, real interval, real totalduration,/*
*/real base,real increment, integer abil returns thistype
return thistype.create(target,caster,interval,totalduration,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,base,increment,"","","origin",abil)
endmethod
static method simplest takes unit target, unit caster, real interval, real totalduration,/*
*/real increment, integer abil returns thistype
return thistype.create(target,caster,interval,totalduration,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,increment,increment,"","","origin",abil)
endmethod
implement init
endstruct
endlibrary