- Joined
- Jan 18, 2007
- Messages
- 59
This system allows u not only to damage units over time but also to create special effects and to make the damage non stackable! These are the features of the system
So Pros:
1) System uses structs and not cache
2) System allows u to create speciall effects
3) System allows u to make it non-stackable
Cons:
1) System uses JassNewgenPack
2) System requires CSData+CSSafety
Download DamageUnitOverTime
So Pros:
1) System uses structs and not cache
2) System allows u to create speciall effects
3) System allows u to make it non-stackable
Cons:
1) System uses JassNewgenPack
2) System requires CSData+CSSafety
JASS:
library DamageTargetOverTime uses CSSafety
private struct data
unit c
unit u
timer t
real dmg
boolean attack
boolean ranged
damagetype DamageType
attacktype AttackType
weapontype WeaponType
real runned
real duration
real howoften
integer Buff
string Effect
string where
string stack
effect e
static method create takes unit c, unit u, real dmg, boolean attack, boolean ranged, attacktype AttackType, damagetype DamageType, weapontype WeaponType, real duration, real howoften, string stack,integer Buff, string Effect, string where returns data
local data dat = data.allocate()
local data d = GetCSData(u)
if stack!=null and stack==d.stack then
call data.destroy(d)
endif
set dat.t = NewTimer()
set dat.u = u
set dat.c = c
set dat.dmg = dmg
set dat.attack=attack
set dat.ranged=ranged
set dat.AttackType=AttackType
set dat.DamageType=DamageType
set dat.WeaponType=WeaponType
set dat.duration = duration
set dat.howoften=howoften
set dat.Buff=Buff
set dat.Effect=Effect
set dat.where=where
set dat.stack=stack
set dat.runned=0
if (Effect!=null or Effect!="") and (where!=null or where!="") then
set dat.e=AddSpecialEffectTarget(Effect,u,where)
endif
call SetCSData(dat.t,dat)
call SetCSData(u,dat)
return dat
endmethod
method onDestroy takes nothing returns nothing
call DestroyEffect(.e)
call ReleaseTimer(.t)
endmethod
endstruct
private function Child takes nothing returns nothing
local timer t = GetExpiredTimer()
local data dat = GetCSData(t)
set dat.runned=dat.runned+dat.howoften
if dat.runned>=dat.duration or GetUnitState(dat.u,UNIT_STATE_LIFE)<=.405 or (dat.Buff!=0 and GetUnitAbilityLevel(dat.u,dat.Buff)==0) then
call data.destroy(dat)
else
call DestroyEffect(dat.e)
set dat.e=AddSpecialEffectTarget(dat.Effect,dat.u,dat.where)
call UnitDamageTarget(dat.c, dat.u, dat.dmg, dat.attack, dat.ranged, dat.AttackType, dat.DamageType, dat.WeaponType)
endif
set t = null
endfunction
function SetAttackType takes unit target, attacktype AttackType returns nothing
local data dat = GetCSData(target)
set dat.AttackType=AttackType
endfunction
function SetDamageType takes unit target, damagetype DamageType returns nothing
local data dat = GetCSData(target)
set dat.DamageType=DamageType
endfunction
function SetDamage takes unit target, real amount returns nothing
local data dat = GetCSData(target)
set dat.dmg=amount
endfunction
function SetDuration takes unit target, real duration returns nothing
local data dat = GetCSData(target)
set dat.duration=duration
endfunction
function SetEffect takes unit target, string Effect, string where returns nothing
local data dat = GetCSData(target)
set dat.Effect = Effect
set dat.where = where
endfunction
function DamageOverBuffEx takes unit whichUnit, unit target, real amount, boolean attack, boolean ranged, attacktype AttackType, damagetype DamageType, weapontype WeaponType, real howoften,integer Buff,string stack, string Effect, string where returns nothing
call TimerStart(data.create(whichUnit, target,amount,attack,ranged, AttackType, DamageType,WeaponType, 9999999, howoften,stack, Buff,Effect, where).t, howoften, true, function Child)
endfunction
function DamageOverBuff takes unit whichUnit, unit target, real amount, attacktype AttackType, damagetype DamageType, integer Buff, real howoften returns nothing
call TimerStart(data.create(whichUnit, target,amount,true,false, AttackType, DamageType, null, 99999999, howoften,null,Buff,"","").t, howoften, true, function Child)
endfunction
function DamageOverTimeEx takes unit whichUnit, unit target, real amount, boolean attack, boolean ranged, attacktype AttackType, damagetype DamageType, weapontype WeaponType, real duration, real howoften,string stack, string Effect, string where returns nothing
call TimerStart(data.create(whichUnit, target,amount,attack,ranged, AttackType, DamageType,WeaponType, duration, howoften,stack,0, Effect, where).t, howoften, true, function Child)
endfunction
function DamageOverTime takes unit whichUnit, unit target, real amount, attacktype AttackType, damagetype DamageType, real duration, real howoften returns nothing
call TimerStart(data.create(whichUnit, target,amount,true,false, AttackType, DamageType, null, duration, howoften,null,0,"","").t, howoften, true, function Child)
endfunction
endlibrary
Last edited: