// o o o o o o o o o o o o o o o o o o o o o o o
// o Damage Over Time by Dynasti o Version 1.7 o
// o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o
// o How To Implement o
// o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o
// o o
// o 1. - Make sure that you opened the system in the newest version of JNGP o
// o 2. - Copy this trigger into you map o
// o o
// o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o
// o How to Use o
// o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o
// o o
// o - This system requires you to give 8 variables for it to function perfectly. o
// o Variables are: o
// o 1. - A unit that does the damage, lets call it " A " o
// o 2. - A widget that is given the damage, lets call it " B " o
// o 3. - A real value that is the damage, lets call it " D " o
// o 4. - A real value that is the time it takes to do the damage, lets call it " T " o
// o 5. - An attacktype that is used to regulate the damage, lets call it " AT " o
// o 6. - A damagetype that is used to regulate the damage, lets call it " DT " o
// o 7. - A string that is the model of the period effect, lets call it " EX " o
// o 8. - A string that is the attachment for the " EX " string, lets call it " ExAttach " o
// o o
// o The call: o
// o call DamageOverTimeEx( A , B , D , T , AT , DT , EX , ExAttach ) o
// o you have now succesfully called the function and started the damage over time. o
// o o
// o if you want something simpler and not have the effect do this: o
// o call DamageOverTime( A , B , D , T , AT , DT ) o
// o now you have done the simpler call. o
// o o
// o Tips: o
// o To not make the target " B " run away or run after you, do this: o
// o call DamageOverTimeEx( B , B , D , T , AT , DT , EX , ExAttach ) o
// o Or for the simpler call: o
// o call DamageOverTime( B , B , D , T , AT , DT ) o
// o o
// o What we now have done is set the unit that does the damage to the unit that takes the damage, " B ". o
// o This does so that the unit " B " does damage to itself and will not run away or attack any unit. o
// o NB: Damaging itself will result to bounty for the own dying unit or, no bounty at all for the killer. o
// o o
// o o
// o If for any reason you want to cancel you need to save the DOT struct as a variable in whatever you're using. o
// o o
// o First, you need to have the DOT struct variable stored as some integer to cancel a DOT. o
// o Example: o
// o [...] o
// o set SomeInteger = DamageOverTime(A, B, D, T, AT, DT, EX, ExAttach) o
// o o
// o Since function DamageOverTimeEx or DamageOverTime returns the struct to you, you can store it for later use o
// o IMPORTANT!: If you do the stopcall after the DoT has stopped you might screw up things. To do this, you o
// o can use the "check" function to check if the struct value you have stored is running and to o
// o what unit. o
// o o
// o The "Check" function: o
// o the function "IsDamageRunning takes DOT dat returns unit" will return 'null' as a value if the struct isn't o
// o running, and will return a unit handle if the struct is running. But wait, you might be thinking: o
// o What if it is another unit than the unit I started it with?! Well do this: o
// o [...] o
// o if MyUnitVariable == IsDamageRunning(StructVariable) then o
// o [your actions here] o
// o call EndDamageOverTime(StructVariable) o
// o else o
// o set StructVariable = 0 o
// o endif o
// o o
// o By doing this, it will insure you that you won't accedently end another unit's DOT effect o
// o o
// o o
// o - For more info go to: www.HiveWorkshop.com or visit www.Ngo.clan.su , user at both sites are Dynasti o
// o o
// o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o
library DOT initializer Init
globals
private constant integer FPS = 40 // This is how many times the struct loop will run in a single second. 30-40 is recomended
// DO NOT TUCH! =)
private constant real Interval = (1.0 / FPS)
endglobals
private struct DOT
unit Attacker
widget Target
real Damage
integer EndCount
attacktype AttackType
damagetype DamageType
effect Effect
static integer array Index
static integer Total = 0
static timer Tim = null
static integer Count = -2147483648 // Just a random low number, it is needed
static method Loop takes nothing returns nothing
local DOT dat
local integer i = 0
set DOT.Count = DOT.Count + 1
loop
exitwhen i >= DOT.Total
set dat = DOT.Index[i]
if DOT.Count > dat.EndCount or GetWidgetLife(dat.Target) <= .405 then
call DestroyEffect(dat.Effect)
set dat.Effect = null
set dat.Attacker = null
set dat.Target = null
set dat.AttackType = null
set dat.DamageType = null
call dat.destroy()
set DOT.Total = DOT.Total - 1
set DOT.Index[i] = DOT.Index[DOT.Total]
set i = i - 1
else
call UnitDamageTarget(dat.Attacker, dat.Target, dat.Damage, false, false, dat.AttackType, dat.DamageType, null)
endif
set i = i + 1
endloop
if DOT.Total == 0 then
call PauseTimer(DOT.Tim)
endif
endmethod
static method Start takes unit Attacker, widget Target, real Damage, real Time, attacktype AttackType, damagetype DamageType, string Effect, string EffectAttach returns DOT
local DOT dat = DOT.allocate()
set dat.Attacker = Attacker
set dat.Target = Target
set dat.AttackType = AttackType
set dat.DamageType = DamageType
if Effect != "" and Effect != null then
if EffectAttach != "" and EffectAttach != null then
set dat.Effect = AddSpecialEffectTarget(Effect, Target, EffectAttach)
endif
endif
set dat.Damage = Damage * Interval / Time
set dat.EndCount = DOT.Count + R2I(Time / Interval)
if DOT.Total == 0 then
call TimerStart(DOT.Tim, Interval, true, function DOT.Loop)
endif
set DOT.Index[DOT.Total] = dat
set DOT.Total = DOT.Total + 1
return dat
endmethod
endstruct
//=========================================================================================
function DamageOverTimeEx takes unit Attacker, widget Target, real Damage, real Time, attacktype AttackType, damagetype DamageType, string Effect, string EffectAttach returns DOT
return DOT.Start(Attacker, Target, Damage, Time, AttackType, DamageType, Effect, EffectAttach)
endfunction
function DamageOverTime takes unit Attacker, widget Target, real Damage, real Time, attacktype AttackType, damagetype DamageType returns DOT
return DOT.Start(Attacker, Target, Damage, Time, AttackType, DamageType, "", "")
endfunction
function EndDamageOverTime takes DOT dat returns nothing
set dat.EndCount = DOT.Count + 1
endfunction
function IsDamageRunning takes DOT dat returns unit
return dat.Target
endfunction
//=========================================================================================
private function Init takes nothing returns nothing
set DOT.Tim = CreateTimer()
endfunction
endlibrary