Name | Type | is_array | initial_value |
HASH | hashtable | No |
//TESH.scrollpos=0
//TESH.alwaysfold=0
Creates a vortex of fire energy that absorbs health of nearby enemy units, when the fire stops spinning, it flies up in the air and back to the ground which deals huge damage and summons a fire elemental.
Fire elemental lasts 15 seconds.
|cffffcc00Level 1|r - 30 damage per touch.
|cffffcc00Level 2|r - 40 damage per touch.
|cffffcc00Level 3|r - 50 damage per touch.
|cffffcc00Level 4|r - 60 damage per touch.
|cffffcc00Level 5|r - 70 damage per touch.
Ground impact deals 2x damage per level plus 30.
[jass]
library FireVortex /* v1.6
*************************************************************************************
*
* by mckill2009
*
*************************************************************************************
*
* */ uses /*
*
* */ Table /* www.hiveworkshop.com/forums/jass-resources-412/snippet-new-table-188084
* */ CTL /* www.hiveworkshop.com/forums/jass-resources-412/snippet-constant-timer-loop-32-a-201381/index7.html#post2389697
*
*************************************************************************************
*
* Installation:
* - Import/copy the required libraries and FireVortex code to your map
* - Import/copy the custom ability and unit to your map and change the SPELL_ID and FIRE_ID if needed
* - You may view the raw ID of the objects by pressing CTRL+D in the object editor
* - You may play with the configurables below
*
*************************************************************************************/
globals
/********************************************************
* Configurables: default and recommended settings
*********************************************************/
//change raw id if needed
private constant integer SPELL_ID = 'A000'
//change raw id if needed
private constant integer FIRE_ID = 'h000'
//uses default lava spawn level 2, this is totally optional
private constant integer ELEMENTAL_ID = 'nlv2'
//the effect when fire lands the ground
private constant string EXPLODE_SFX = "Objects\\Spawnmodels\\Undead\\UDeathSmall\\UDeathSmall.mdl"
//the damage aoe when fire lands the ground
private constant real EXPLODE_AOE_DAMAGE = 150.
//the damage aoe when fire is spinning
private constant real TOUCH_AOE_DAMAGE = 80.
//max fly height
private constant real FLY_HEIGHT = 500.
//the fly or up speed
private constant real FLY_SPEED = 15.
//the impact to the ground speed, this is added to the impactDamage
private constant real DROP_SPEED = 30.
//how fast the fire be created
private constant real CREATION_DELAY = 0.5
//the higher the number, the faster
private constant real SPIN_SPEED = 0.07 //in radians
//allows the creation of a unit, see ELEMENTAL_ID
private constant boolean ENABLE_ELEMENTAL_CREATION = true
//set to false for elemental to live until dies
//ENABLE_ELEMENTAL_CREATION should be true also
private constant boolean ELEMENTAL_HAS_TIMER = true
private attacktype ATK = ATTACK_TYPE_MAGIC
private damagetype DMG = DAMAGE_TYPE_MAGIC
/********************************************************
* Non-configurables
********************************************************/
private real CreationGap
private Table sp
private group TempG = CreateGroup()
endglobals
/********************************************************
* Configurables
*********************************************************/
private function GetDamage takes integer level returns real
return (10 * level + 20.)
endfunction
private function GetFireCount takes integer level returns integer
return 2 * level + 2
endfunction
private function GetElementalTimer takes integer level returns real
return 15.
endfunction
/********************************************************
* End of configurables
*********************************************************/
private function UnitAlive takes unit u returns boolean
return not IsUnitType(u, UNIT_TYPE_DEAD)
endfunction
struct FireSpin extends array
unit fire
real angle
real damage
real impactDamage
real duration
real dist
real height
real elementalLife
real x
real y
boolean direction
boolean fly
group g
implement CTL
local unit first
local real xFire
local real yFire
implement CTLExpire
if .fire==null then
call .destroy()
else
set xFire = GetUnitX(.fire)
set yFire = GetUnitY(.fire)
if .duration > 0 then
set .duration = .duration - 0.03125
if .direction then
set .angle = .angle + SPIN_SPEED
else
set .angle = .angle - SPIN_SPEED
endif
call SetUnitX(.fire, .x+.dist*Cos(.angle))
call SetUnitY(.fire, .y+.dist*Sin(.angle))
call GroupEnumUnitsInRange(TempG, xFire, yFire, TOUCH_AOE_DAMAGE, null)
loop
set first = FirstOfGroup(TempG)
exitwhen first==null
if UnitAlive(first) and IsUnitEnemy(first, GetOwningPlayer(.fire)) then
call UnitDamageTarget(.fire, first, .damage, false, false, ATK, DMG, null)
endif
call GroupRemoveUnit(TempG, first)
endloop
else
if .fly then
set .height = .height + FLY_SPEED
if .height > FLY_HEIGHT then
set .fly = false
endif
else
set .height = .height - DROP_SPEED
endif
call SetUnitFlyHeight(.fire, .height, 0)
if 0 > .height then
call DestroyEffect(AddSpecialEffect(EXPLODE_SFX, xFire, yFire))
call GroupEnumUnitsInRange(TempG, xFire, yFire, EXPLODE_AOE_DAMAGE, null)
loop
set first = FirstOfGroup(TempG)
exitwhen first==null
if UnitAlive(first) and IsUnitEnemy(first, GetOwningPlayer(.fire)) then
call UnitDamageTarget(.fire, first, .impactDamage, false, false, ATK, DMG, null)
endif
call GroupRemoveUnit(TempG, first)
endloop
static if ENABLE_ELEMENTAL_CREATION then
set first = CreateUnit(GetOwningPlayer(.fire), ELEMENTAL_ID, xFire, yFire, 0)
call UnitAddType(first, UNIT_TYPE_SUMMONED)
static if ELEMENTAL_HAS_TIMER then
call UnitApplyTimedLife(first, 'BTLF', .elementalLife)
endif
set first = null
endif
call KillUnit(.fire)
set .fire = null
endif
endif
endif
implement CTLEnd
static method spin takes unit f, real damage, real x, real y, real el returns nothing
local thistype this = create()
local integer id = GetHandleId(f)
set .fire = f
set .direction = false
if sp.boolean[id] then
set .direction = true
endif
set .duration = GetRandomReal(7, 12)
set .elementalLife = el
set .fly = true
set .height = GetUnitFlyHeight(f)
set .x = x
set .y = y
set .angle = Atan2(GetUnitY(f)-y, GetUnitX(f)-x)
set .dist = SquareRoot((GetUnitX(f)-x)*(GetUnitX(f)-x)+(GetUnitY(f)-y)*(GetUnitY(f)-y))
set .impactDamage = (damage*2)+(DROP_SPEED*2)
set .damage = damage*0.3125
call UnitAddAbility(f, 'Arav')
endmethod
endstruct
private struct FireVortexCast extends array
player p
real a
real damage
real elementalLife
real delay
real down
real up
real x
real y
integer count
integer index
boolean check
boolean directionUp
boolean directionDown
group g
static thistype DATA
private static method startSpinning takes nothing returns nothing
local thistype this = DATA
call FireSpin.spin(GetEnumUnit(), this.damage, this.x, this.y, this.elementalLife)
endmethod
implement CTL
local unit fire
local integer id
implement CTLExpire
if .count > .index then
set .delay = .delay + 0.03125
if .delay > CREATION_DELAY then
set .delay = 0
set .index = .index + 1
if .check then
set .check = false
set fire = CreateUnit(.p, FIRE_ID, .x+.up*Cos(.a), .y+.up*Sin(.a), 0)
set .up = .up - CreationGap
set id = GetHandleId(fire)
if .directionUp then
set .directionUp = false
set sp.boolean[id] = true
else
set .directionUp = true
endif
else
set .check = true
set fire = CreateUnit(.p, FIRE_ID, .x+.down*Cos(.a), .y+.down*Sin(.a), 0)
set .down = .down + CreationGap
set id = GetHandleId(fire)
if .directionDown then
set .directionDown = false
set sp.boolean[id] = true
else
set .directionDown = true
endif
endif
set sp.real[id] = .a
call GroupAddUnit(.g, fire)
set fire = null
endif
else
set DATA = this
call ForGroup(.g, function thistype.startSpinning)
call DestroyGroup(.g)
set .p = null
set .g = null
call .destroy()
endif
implement CTLEnd
static method run takes unit u, real x, real y returns nothing
local thistype this = create()
local integer level = GetUnitAbilityLevel(u, SPELL_ID)
set .p = GetTriggerPlayer()
set .a = Atan2(GetUnitY(u)-y, GetUnitX(u)-x)
set .damage = GetDamage(level)
set .elementalLife = GetElementalTimer(level)
set .delay = 0
set .down = CreationGap
set .up = -CreationGap
set .x = x
set .y = y
set .count = GetFireCount(level)
set .index = 0
set .check = true
set .directionUp = true
set .directionDown = true
set .g = CreateGroup()
endmethod
static method cast takes nothing returns boolean
if GetSpellAbilityId()==SPELL_ID then
call thistype.run(GetTriggerUnit(), GetSpellTargetX(), GetSpellTargetY())
endif
return false
endmethod
static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function thistype.cast))
set t = null
set CreationGap = TOUCH_AOE_DAMAGE + 20.
set sp = Table.create()
endmethod
endstruct
endlibrary
[/jass]
[hidden=Changelogs]
v1.6
- Converted to vJass and has added description
v1.5
- Multiple creation of fire instead of 5 only (customable)
- Dead units filtered
- Button position changed
- Code fully optimized
v1.4
- Added condition on mechanical units
- Codes reduced
- Functions have Condition & Action
v1.3
- Variables nulled
- Code optimized
- Hahtable setup inside code
v1.2
- Converted to JASS
- Description completely changed
- Smooth rotating vortex
v1.1
- Codes Reduced
- HP damage changed from 'Set life to #' to 'Unit - Damage Target'
[/hidden]
[hidden=Credits]
CTL by Nesthsurus
Table by Bribe
[/hidden]
//TESH.scrollpos=0
//TESH.alwaysfold=0
library TimerUtils initializer init
//*********************************************************************
//* TimerUtils (red+blue+orange flavors for 1.24b+) 2.0
//* ----------
//*
//* To implement it , create a custom text trigger called TimerUtils
//* and paste the contents of this script there.
//*
//* To copy from a map to another, copy the trigger holding this
//* library to your map.
//*
//* (requires vJass) More scripts: htt://www.wc3c.net
//*
//* For your timer needs:
//* * Attaching
//* * Recycling (with double-free protection)
//*
//* set t=NewTimer() : Get a timer (alternative to CreateTimer)
//* set t=NewTimerEx(x) : Get a timer (alternative to CreateTimer), call
//* Initialize timer data as x, instead of 0.
//*
//* ReleaseTimer(t) : Relese a timer (alt to DestroyTimer)
//* SetTimerData(t,2) : Attach value 2 to timer
//* GetTimerData(t) : Get the timer's value.
//* You can assume a timer's value is 0
//* after NewTimer.
//*
//* Multi-flavor:
//* Set USE_HASH_TABLE to true if you don't want to complicate your life.
//*
//* If you like speed and giberish try learning about the other flavors.
//*
//********************************************************************
//================================================================
globals
//How to tweak timer utils:
// USE_HASH_TABLE = true (new blue)
// * SAFEST
// * SLOWEST (though hash tables are kind of fast)
//
// USE_HASH_TABLE = false, USE_FLEXIBLE_OFFSET = true (orange)
// * kinda safe (except there is a limit in the number of timers)
// * ALMOST FAST
//
// USE_HASH_TABLE = false, USE_FLEXIBLE_OFFSET = false (red)
// * THE FASTEST (though is only faster than the previous method
// after using the optimizer on the map)
// * THE LEAST SAFE ( you may have to tweak OFSSET manually for it to
// work)
//
private constant boolean USE_HASH_TABLE = true
private constant boolean USE_FLEXIBLE_OFFSET = false
private constant integer OFFSET = 0x100000
private integer VOFFSET = OFFSET
//Timers to preload at map init:
private constant integer QUANTITY = 256
//Changing this to something big will allow you to keep recycling
// timers even when there are already AN INCREDIBLE AMOUNT of timers in
// the stack. But it will make things far slower so that's probably a bad idea...
private constant integer ARRAY_SIZE = 8190
endglobals
//==================================================================================================
globals
private integer array data[ARRAY_SIZE]
private hashtable ht
endglobals
//It is dependent on jasshelper's recent inlining optimization in order to perform correctly.
function SetTimerData takes timer t, integer value returns nothing
static if(USE_HASH_TABLE) then
// new blue
call SaveInteger(ht,0,GetHandleId(t), value)
elseif (USE_FLEXIBLE_OFFSET) then
// orange
static if (DEBUG_MODE) then
if(GetHandleId(t)-VOFFSET<0) then
call BJDebugMsg("SetTimerData: Wrong handle id, only use SetTimerData on timers created by NewTimer")
endif
endif
set data[GetHandleId(t)-VOFFSET]=value
else
// new red
static if (DEBUG_MODE) then
if(GetHandleId(t)-OFFSET<0) then
call BJDebugMsg("SetTimerData: Wrong handle id, only use SetTimerData on timers created by NewTimer")
endif
endif
set data[GetHandleId(t)-OFFSET]=value
endif
endfunction
function GetTimerData takes timer t returns integer
static if(USE_HASH_TABLE) then
// new blue
return LoadInteger(ht,0,GetHandleId(t) )
elseif (USE_FLEXIBLE_OFFSET) then
// orange
static if (DEBUG_MODE) then
if(GetHandleId(t)-VOFFSET<0) then
call BJDebugMsg("SetTimerData: Wrong handle id, only use SetTimerData on timers created by NewTimer")
endif
endif
return data[GetHandleId(t)-VOFFSET]
else
// new red
static if (DEBUG_MODE) then
if(GetHandleId(t)-OFFSET<0) then
call BJDebugMsg("SetTimerData: Wrong handle id, only use SetTimerData on timers created by NewTimer")
endif
endif
return data[GetHandleId(t)-OFFSET]
endif
endfunction
//==========================================================================================
globals
private timer array tT[ARRAY_SIZE]
private integer tN = 0
private constant integer HELD=0x28829022
//use a totally random number here, the more improbable someone uses it, the better.
private boolean didinit = false
endglobals
private keyword init
//==========================================================================================
// I needed to decide between duplicating code ignoring the "Once and only once" rule
// and using the ugly textmacros. I guess textmacros won.
//
//! textmacro TIMERUTIS_PRIVATE_NewTimerCommon takes VALUE
// On second thought, no.
//! endtextmacro
function NewTimerEx takes integer value returns timer
if (tN==0) then
if (not didinit) then
//This extra if shouldn't represent a major performance drawback
//because QUANTITY rule is not supposed to be broken every day.
call init.evaluate()
set tN = tN - 1
else
//If this happens then the QUANTITY rule has already been broken, try to fix the
// issue, else fail.
debug call BJDebugMsg("NewTimer: Warning, Exceeding TimerUtils_QUANTITY, make sure all timers are getting recycled correctly")
set tT[0]=CreateTimer()
static if( not USE_HASH_TABLE) then
debug call BJDebugMsg("In case of errors, please increase it accordingly, or set TimerUtils_USE_HASH_TABLE to true")
static if( USE_FLEXIBLE_OFFSET) then
if (GetHandleId(tT[0])-VOFFSET<0) or (GetHandleId(tT[0])-VOFFSET>=ARRAY_SIZE) then
//all right, couldn't fix it
call BJDebugMsg("NewTimer: Unable to allocate a timer, you should probably set TimerUtils_USE_HASH_TABLE to true or fix timer leaks.")
return null
endif
else
if (GetHandleId(tT[0])-OFFSET<0) or (GetHandleId(tT[0])-OFFSET>=ARRAY_SIZE) then
//all right, couldn't fix it
call BJDebugMsg("NewTimer: Unable to allocate a timer, you should probably set TimerUtils_USE_HASH_TABLE to true or fix timer leaks.")
return null
endif
endif
endif
endif
else
set tN=tN-1
endif
call SetTimerData(tT[tN],value)
return tT[tN]
endfunction
function NewTimer takes nothing returns timer
return NewTimerEx(0)
endfunction
//==========================================================================================
function ReleaseTimer takes timer t returns nothing
if(t==null) then
debug call BJDebugMsg("Warning: attempt to release a null timer")
return
endif
if (tN==ARRAY_SIZE) then
debug call BJDebugMsg("Warning: Timer stack is full, destroying timer!!")
//stack is full, the map already has much more troubles than the chance of bug
call DestroyTimer(t)
else
call PauseTimer(t)
if(GetTimerData(t)==HELD) then
debug call BJDebugMsg("Warning: ReleaseTimer: Double free!")
return
endif
call SetTimerData(t,HELD)
set tT[tN]=t
set tN=tN+1
endif
endfunction
private function init takes nothing returns nothing
local integer i=0
local integer o=-1
local boolean oops = false
if ( didinit ) then
return
else
set didinit = true
endif
static if( USE_HASH_TABLE ) then
set ht = InitHashtable()
loop
exitwhen(i==QUANTITY)
set tT[i]=CreateTimer()
call SetTimerData(tT[i], HELD)
set i=i+1
endloop
set tN = QUANTITY
else
loop
set i=0
loop
exitwhen (i==QUANTITY)
set tT[i] = CreateTimer()
if(i==0) then
set VOFFSET = GetHandleId(tT[i])
static if(USE_FLEXIBLE_OFFSET) then
set o=VOFFSET
else
set o=OFFSET
endif
endif
if (GetHandleId(tT[i])-o>=ARRAY_SIZE) then
exitwhen true
endif
if (GetHandleId(tT[i])-o>=0) then
set i=i+1
endif
endloop
set tN = i
exitwhen(tN == QUANTITY)
set oops = true
exitwhen not USE_FLEXIBLE_OFFSET
debug call BJDebugMsg("TimerUtils_init: Failed a initialization attempt, will try again")
endloop
if(oops) then
static if ( USE_FLEXIBLE_OFFSET) then
debug call BJDebugMsg("The problem has been fixed.")
//If this message doesn't appear then there is so much
//handle id fragmentation that it was impossible to preload
//so many timers and the thread crashed! Therefore this
//debug message is useful.
elseif(DEBUG_MODE) then
call BJDebugMsg("There were problems and the new timer limit is "+I2S(i))
call BJDebugMsg("This is a rare ocurrence, if the timer limit is too low:")
call BJDebugMsg("a) Change USE_FLEXIBLE_OFFSET to true (reduces performance a little)")
call BJDebugMsg("b) or try changing OFFSET to "+I2S(VOFFSET) )
endif
endif
endif
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library RespawnSystem /* v1.0
*************************************************************************************
*
* by mckill2009
*
*************************************************************************************
*
* Respawns the same unit(s) at the same point and facing angle with customable effects and delay.
*
*************************************************************************************
*
* */ uses /* and credits
*
* */ Table /* by Bribe, www.hiveworkshop.com/forums/jass-resources-412/snippet-new-table-188084
* */ TimerUtils /* by Vexorian, www.wc3c.net/showthread.php?t=101322
*
*************************************************************************************
*
* API:
* static method register takes unit u returns nothing
* - Simple registry with no custom effect, delay and player owner
* static method registerEx takes unit u, real delay, string sfx, player pl returns nothing
* - Allows you to customize the delay, effect and player owner
* static method remove takes unit u returns nothing
* - Removes unit from spawning again
*
*************************************************************************************/
globals
/*
* This setting is only used by the static register
*/
private constant real FIXED_DELAY = 5
private constant string FIXED_SFX = ""
/*
*
*/
private Table chk
private TableArray rs
endglobals
struct RespawnSystem
integer id
private static method respawnNow takes nothing returns nothing
local timer t = GetExpiredTimer()
local thistype this = GetTimerData(t)
local unit u = CreateUnit(rs[5].player[.id], chk[.id], rs[0].real[.id], rs[1].real[.id], rs[2].real[.id])
local integer uID = GetHandleId(u)
if rs[4].string[.id] != "" then
call DestroyEffect(AddSpecialEffectTarget(rs[4].string[.id], u, "origin"))
endif
set chk[uID] = GetUnitTypeId(u)
set rs[0].real[uID] = rs[0].real[.id]
set rs[1].real[uID] = rs[1].real[.id]
set rs[2].real[uID] = rs[2].real[.id]
set rs[3].real[uID] = rs[3].real[.id]
set rs[4].string[uID] = rs[4].string[.id]
set rs[5].player[uID] = rs[5].player[.id]
set u = null
call ReleaseTimer(t)
call chk.remove(.id)
call .destroy()
set t = null
endmethod
private static method death takes nothing returns boolean
local thistype this
local integer uID = GetHandleId(GetTriggerUnit())
if chk.has(uID) then
set this = allocate()
set .id = uID
call TimerStart(NewTimerEx(this), rs[3].real[uID], false, function thistype.respawnNow)
endif
return false
endmethod
private static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(t,function thistype.death)
set t = null
set chk = Table.create()
set rs = TableArray[0x2000]
endmethod
/*****************************************************************
* API:
******************************************************************/
static method register takes unit u returns nothing
local integer dummyID
local integer uID = GetHandleId(u)
set chk[uID] = GetUnitTypeId(u)
set rs[0].real[uID] = GetUnitX(u)
set rs[1].real[uID] = GetUnitY(u)
set rs[2].real[uID] = GetUnitFacing(u)
set rs[3].real[uID] = FIXED_DELAY
set rs[4].string[uID] = FIXED_SFX
set rs[5].player[uID] = GetOwningPlayer(u)
endmethod
static method registerEx takes unit u, real delay, string sfx, player pl returns nothing
local integer dummyID
local integer uID = GetHandleId(u)
set chk[uID] = GetUnitTypeId(u)
set rs[0].real[uID] = GetUnitX(u)
set rs[1].real[uID] = GetUnitY(u)
set rs[2].real[uID] = GetUnitFacing(u)
set rs[3].real[uID] = delay
set rs[4].string[uID] = sfx
if pl==null then
set rs[5].player[uID] = GetOwningPlayer(u)
else
set rs[5].player[uID] = pl
endif
endmethod
static method remove takes unit u returns nothing
call chk.remove(GetHandleId(u))
endmethod
endstruct
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library CTL /* v1.2.0.2
*************************************************************************************
*
* CTL or Constant Timer Loop provides a loop for constant merged timers of timeout .03125
*
* Similar to T32 but pauses timer when no structs have instances and removes structs
* from timer trigger when those structs have no instances.
*
* This can also create new timers after destroying a previous timer and generates less
* code in the module. It also generates no triggers so long as the module is implemented
* at the top of the struct.
*
************************************************************************************
*
* module CTL
*
* Allows creation/destruction of timers in a struct. Provides instancing of those timers.
*
* - static method create takes nothing returns thistype
* - method destroy takes nothing returns nothing
*
* CTL (optional)
* local variables, code before running any timers
* CTLExpire (not optional)
* timer code
* CTLNull (optional)
* null any locals, runs after all timers
* CTLEnd (not optional)
*
* module CT32
*
* Converts struct into a timer group. Allows the timer group to be started and stopped.
* Instancing and looping through active timers is up to the user.
*
* - static method start takes nothing returns nothing
* - static method stop takes nothing returns nothing
*
* CT32 (not optional)
* timer code
* CT32End (not optional)
*
* struct TimerGroup32 extends array
*
* Allows for the creation of timer groups. Timer instancing and looping is entirely up
* to the user.
*
* - static method create takes code func returns thistype
* - method destroy takes nothing returns nothing
* - method start takes nothing returns nothing
* - method stop takes nothing returns nothing
*
************************************************************************************/
globals
private integer tgc = 0 //timer group count
private integer array tgr //timer group recycler
private integer ic=0 //instance count
private integer tc=0 //timer count
private integer array rf //root first
private integer array n //next
private integer array p //previous
private integer array th //timer head
private integer array ns //next stack
private trigger t=CreateTrigger()
private timer m=CreateTimer()
private triggercondition array ct
private conditionfunc array rc
private boolean array e32 //enabled
private integer array i32r //ct32 recycler
private integer i32cr = 0 //ct32 count recycler
private boolean array ir32 //is recycling
private boolean array id32 //is destroying
endglobals
private function E takes nothing returns nothing
local integer i=ns[0]
set ns[0]=0
loop
exitwhen 0==i
if (0==p[i]) then
if (0==n[i]) then
call TriggerRemoveCondition(t,ct[th[i]])
set ct[th[i]]=null
set tc=tc-1
set rf[th[i]]=0
else
set rf[th[i]]=n[i]
set p[n[i]]=0
endif
else
set p[n[i]]=p[i]
set n[p[i]]=n[i]
endif
set n[i]=n[0]
set n[0]=i
set i=ns[i]
endloop
loop
exitwhen 0 == i32cr
set i32cr = i32cr - 1
set i = i32r[i32cr]
if (not e32[i]) then
call TriggerRemoveCondition(t,ct[i])
set ct[i] = null
if (id32[i]) then
set tgr[i] = tgr[0]
set tgr[0] = i
set id32[i] = false
endif
set ir32[i] = false
endif
endloop
if (0==tc) then
call PauseTimer(m)
else
call TriggerEvaluate(t)
endif
endfunction
private function CT takes integer r returns integer
local integer i
local integer f
if (0==n[0]) then
set i=ic+1
set ic=i
else
set i=n[0]
set n[0]=n[i]
endif
set th[i]=r
set ns[i]=-1
set f=rf[r]
if (0==f) then
set n[i]=0
set p[i]=0
set rf[r]=i
set ct[r]=TriggerAddCondition(t,rc[r])
//set ct[r] = null
if (0==tc) then
call TimerStart(m,.031250000,true,function E)
endif
set tc=tc+1
else
set n[i]=f
set p[i]=0
set p[f]=i
set rf[r]=i
endif
return i
endfunction
private function DT takes integer t returns nothing
debug if (0>ns[t]) then
set ns[t]=ns[0]
set ns[0]=t
debug else
debug call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"TIMER LOOP ERROR: ATTEMPT TO DESTROY NULL TIMER")
debug endif
endfunction
private function A takes code c returns integer
local integer i = tgr[0]
if (0 == i) then
set i = tgc + 1
set tgc = i
else
set tgr[0] = tgr[i]
endif
set rc[i]=Condition(c)
return i
endfunction
private function A32 takes integer i returns nothing
if (not (e32[i] or id32[i])) then
if (ir32[i]) then
set ir32[i] = false
else
set ct[i] = TriggerAddCondition(t, rc[i])
endif
if (0 == tc) then
call TimerStart(m,.031250000,true,function E)
endif
set tc = tc + 1
set e32[i] = true
endif
endfunction
private function SR32 takes integer i returns nothing
if (e32[i]) then
if (not (ir32[i] or id32[i])) then
set i32r[i32cr] = i
set i32cr = i32cr + 1
set ir32[i] = true
endif
set e32[i] = false
set tc = tc - 1
endif
endfunction
private function DT32 takes integer i returns nothing
if (not id32[i]) then
if (not ir32[i]) then
set ir32[i] = true
set tc = tc - 1
set i32r[i32cr] = i
set i32cr = i32cr + 1
set e32[i] = false
endif
set id32[i] = true
endif
endfunction
private keyword r
private keyword e
module CTL
static integer rctl32
static method create takes nothing returns thistype
return CT(rctl32)
endmethod
method destroy takes nothing returns nothing
call DT(this)
endmethod
static method ectl32 takes nothing returns boolean
local thistype this=rf[rctl32]
endmodule
module CTLExpire
implement CTL
loop
exitwhen 0==this
endmodule
module CTLNull
set this=n[this]
endloop
endmodule
module CTLEnd
implement CTLNull
return false
endmethod
private static method onInit takes nothing returns nothing
set rctl32 = A(function thistype.ectl32)
endmethod
endmodule
module CT32
static integer rctl32
static method ectl32 takes nothing returns boolean
endmodule
module CT32End
return false
endmethod
static method start takes nothing returns nothing
call A32(rctl32)
endmethod
static method stop takes nothing returns nothing
call SR32(rctl32)
endmethod
private static method onInit takes nothing returns nothing
set rctl32 = A(function thistype.ectl32)
endmethod
endmodule
struct TimerGroup32 extends array
static method create takes code c returns thistype
return A(c)
endmethod
method destroy takes nothing returns nothing
call DT32(this)
endmethod
method start takes nothing returns nothing
call A32(this)
endmethod
method stop takes nothing returns nothing
call SR32(this)
endmethod
endstruct
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library Table /* made by Bribe, special thanks to Vexorian & Nestharus, version 3.1.0.1
One map, one hashtable. Welcome to NewTable 3.1
This library was originally called NewTable so it didn't conflict with
the API of Table by Vexorian. However, the damage is done and it's too
late to change the library name now. To help with damage control, I
have provided an extension library called TableBC, which bridges all
the functionality of Vexorian's Table except for 2-D string arrays &
the ".flush(integer)" method. I use ".flush()" to flush a child hash-
table, because I wanted the API in NewTable to reflect the API of real
hashtables (I thought this would be more intuitive).
API
------------
struct Table
| static method create takes nothing returns Table
| create a new Table
|
| method destroy takes nothing returns nothing
| destroy it
|
| method flush takes nothing returns nothing
| flush all stored values inside of it
|
| method remove takes integer key returns nothing
| remove the value at index "key"
|
| method operator []= takes integer key, $TYPE$ value returns nothing
| assign "value" to index "key"
|
| method operator [] takes integer key returns $TYPE$
| load the value at index "key"
|
| method has takes integer key returns boolean
| whether or not the key was assigned
|
----------------
struct TableArray
| static method operator [] takes integer array_size returns TableArray
| create a new array of Tables of size "array_size"
|
| method destroy takes nothing returns nothing
| destroy it
|
| method flush takes nothing returns nothing
| flush and destroy it
|
| method operator size takes nothing returns integer
| returns the size of the TableArray
|
| method operator [] takes integer key returns Table
| returns a Table accessible exclusively to index "key"
*/
globals
private integer less = 0 //Index generation for TableArrays (below 0).
private integer more = 8190 //Index generation for Tables.
//Configure it if you use more than 8190 "key" variables in your map (this will never happen though).
private hashtable ht = InitHashtable()
private key sizeK
private key listK
endglobals
private struct dex extends array
static method operator size takes nothing returns Table
return sizeK
endmethod
static method operator list takes nothing returns Table
return listK
endmethod
endstruct
private struct handles extends array
method has takes integer key returns boolean
return HaveSavedHandle(ht, this, key)
endmethod
method remove takes integer key returns nothing
call RemoveSavedHandle(ht, this, key)
endmethod
endstruct
private struct agents extends array
method operator []= takes integer key, agent value returns nothing
call SaveAgentHandle(ht, this, key, value)
endmethod
endstruct
//! textmacro NEW_ARRAY_BASIC takes SUPER, FUNC, TYPE
private struct $TYPE$s extends array
method operator [] takes integer key returns $TYPE$
return Load$FUNC$(ht, this, key)
endmethod
method operator []= takes integer key, $TYPE$ value returns nothing
call Save$FUNC$(ht, this, key, value)
endmethod
method has takes integer key returns boolean
return HaveSaved$SUPER$(ht, this, key)
endmethod
method remove takes integer key returns nothing
call RemoveSaved$SUPER$(ht, this, key)
endmethod
endstruct
private module $TYPE$m
method operator $TYPE$ takes nothing returns $TYPE$s
return this
endmethod
endmodule
//! endtextmacro
//! textmacro NEW_ARRAY takes FUNC, TYPE
private struct $TYPE$s extends array
method operator [] takes integer key returns $TYPE$
return Load$FUNC$Handle(ht, this, key)
endmethod
method operator []= takes integer key, $TYPE$ value returns nothing
call Save$FUNC$Handle(ht, this, key, value)
endmethod
endstruct
private module $TYPE$m
method operator $TYPE$ takes nothing returns $TYPE$s
return this
endmethod
endmodule
//! endtextmacro
//Run these textmacros to include the entire hashtable API as wrappers.
//Don't be intimidated by the number of macros - Vexorian's map optimizer is
//supposed to kill functions which inline (all of these functions inline).
//! runtextmacro NEW_ARRAY_BASIC("Real", "Real", "real")
//! runtextmacro NEW_ARRAY_BASIC("Boolean", "Boolean", "boolean")
//! runtextmacro NEW_ARRAY_BASIC("String", "Str", "string")
//! runtextmacro NEW_ARRAY("Player", "player")
//! runtextmacro NEW_ARRAY("Widget", "widget")
//! runtextmacro NEW_ARRAY("Destructable", "destructable")
//! runtextmacro NEW_ARRAY("Item", "item")
//! runtextmacro NEW_ARRAY("Unit", "unit")
//! runtextmacro NEW_ARRAY("Ability", "ability")
//! runtextmacro NEW_ARRAY("Timer", "timer")
//! runtextmacro NEW_ARRAY("Trigger", "trigger")
//! runtextmacro NEW_ARRAY("TriggerCondition", "triggercondition")
//! runtextmacro NEW_ARRAY("TriggerAction", "triggeraction")
//! runtextmacro NEW_ARRAY("TriggerEvent", "event")
//! runtextmacro NEW_ARRAY("Force", "force")
//! runtextmacro NEW_ARRAY("Group", "group")
//! runtextmacro NEW_ARRAY("Location", "location")
//! runtextmacro NEW_ARRAY("Rect", "rect")
//! runtextmacro NEW_ARRAY("BooleanExpr", "boolexpr")
//! runtextmacro NEW_ARRAY("Sound", "sound")
//! runtextmacro NEW_ARRAY("Effect", "effect")
//! runtextmacro NEW_ARRAY("UnitPool", "unitpool")
//! runtextmacro NEW_ARRAY("ItemPool", "itempool")
//! runtextmacro NEW_ARRAY("Quest", "quest")
//! runtextmacro NEW_ARRAY("QuestItem", "questitem")
//! runtextmacro NEW_ARRAY("DefeatCondition", "defeatcondition")
//! runtextmacro NEW_ARRAY("TimerDialog", "timerdialog")
//! runtextmacro NEW_ARRAY("Leaderboard", "leaderboard")
//! runtextmacro NEW_ARRAY("Multiboard", "multiboard")
//! runtextmacro NEW_ARRAY("MultiboardItem", "multiboarditem")
//! runtextmacro NEW_ARRAY("Trackable", "trackable")
//! runtextmacro NEW_ARRAY("Dialog", "dialog")
//! runtextmacro NEW_ARRAY("Button", "button")
//! runtextmacro NEW_ARRAY("TextTag", "texttag")
//! runtextmacro NEW_ARRAY("Lightning", "lightning")
//! runtextmacro NEW_ARRAY("Image", "image")
//! runtextmacro NEW_ARRAY("Ubersplat", "ubersplat")
//! runtextmacro NEW_ARRAY("Region", "region")
//! runtextmacro NEW_ARRAY("FogState", "fogstate")
//! runtextmacro NEW_ARRAY("FogModifier", "fogmodifier")
//! runtextmacro NEW_ARRAY("Hashtable", "hashtable")
struct Table extends array
// Implement modules for intuitive syntax (tb.handle; tb.unit; etc.)
implement realm
implement booleanm
implement stringm
implement playerm
implement widgetm
implement destructablem
implement itemm
implement unitm
implement abilitym
implement timerm
implement triggerm
implement triggerconditionm
implement triggeractionm
implement eventm
implement forcem
implement groupm
implement locationm
implement rectm
implement boolexprm
implement soundm
implement effectm
implement unitpoolm
implement itempoolm
implement questm
implement questitemm
implement defeatconditionm
implement timerdialogm
implement leaderboardm
implement multiboardm
implement multiboarditemm
implement trackablem
implement dialogm
implement buttonm
implement texttagm
implement lightningm
implement imagem
implement ubersplatm
implement regionm
implement fogstatem
implement fogmodifierm
implement hashtablem
method operator handle takes nothing returns handles
return this
endmethod
method operator agent takes nothing returns agents
return this
endmethod
//set this = tb[GetSpellAbilityId()]
method operator [] takes integer key returns Table
return LoadInteger(ht, this, key)
endmethod
//set tb[389034] = 8192
method operator []= takes integer key, Table tb returns nothing
call SaveInteger(ht, this, key, tb)
endmethod
//set b = tb.has(2493223)
method has takes integer key returns boolean
return HaveSavedInteger(ht, this, key)
endmethod
//call tb.remove(294080)
method remove takes integer key returns nothing
call RemoveSavedInteger(ht, this, key)
endmethod
//Remove all data from a Table instance
method flush takes nothing returns nothing
call FlushChildHashtable(ht, this)
endmethod
//local Table tb = Table.create()
static method create takes nothing returns Table
local Table this = dex.list[0]
if this == 0 then
set this = more + 1
set more = this
else
set dex.list[0] = dex.list[this]
call dex.list.remove(this) //Clear hashed memory
endif
debug set dex.list[this] = -1
return this
endmethod
// Removes all data from a Table instance and recycles its index.
//
// call tb.destroy()
//
method destroy takes nothing returns nothing
debug if dex.list[this] != -1 then
debug call BJDebugMsg("Table Error: Tried to double-free instance: " + I2S(this))
debug return
debug endif
call this.flush()
set dex.list[this] = dex.list[0]
set dex.list[0] = this
endmethod
//! runtextmacro optional TABLE_BC_METHODS()
endstruct
//! runtextmacro optional TABLE_BC_STRUCTS()
struct TableArray extends array
//Returns a new TableArray to do your bidding. Simply use:
//
// local TableArray ta = TableArray[array_size]
//
static method operator [] takes integer array_size returns TableArray
local Table tb = dex.size[array_size] //Get the unique recycle list for this array size
local TableArray this = tb[0] //The last-destroyed TableArray that had this array size
debug if array_size <= 0 then
debug call BJDebugMsg("TypeError: Invalid specified TableArray size: " + I2S(array_size))
debug return 0
debug endif
if this == 0 then
set this = less - array_size
set less = this
else
set tb[0] = tb[this] //Set the last destroyed to the last-last destroyed
call tb.remove(this) //Clear hashed memory
endif
set dex.size[this] = array_size //This remembers the array size
return this
endmethod
//Returns the size of the TableArray
method operator size takes nothing returns integer
return dex.size[this]
endmethod
//This magic method enables two-dimensional[array][syntax] for Tables,
//similar to the two-dimensional utility provided by hashtables them-
//selves.
//
//ta[integer a].unit[integer b] = unit u
//ta[integer a][integer c] = integer d
//
//Inline-friendly when not running in debug mode
//
method operator [] takes integer key returns Table
static if DEBUG_MODE then
local integer i = this.size
if i == 0 then
call BJDebugMsg("IndexError: Tried to get key from invalid TableArray instance: " + I2S(this))
return 0
elseif key < 0 or key >= i then
call BJDebugMsg("IndexError: Tried to get key [" + I2S(key) + "] from outside TableArray bounds: " + I2S(i))
return 0
endif
endif
return this + key
endmethod
//Destroys a TableArray without flushing it; I assume you call .flush()
//if you want it flushed too. This is a public method so that you don't
//have to loop through all TableArray indices to flush them if you don't
//need to (ie. if you were flushing all child-keys as you used them).
//
method destroy takes nothing returns nothing
local Table tb = dex.size[this.size]
debug if this.size == 0 then
debug call BJDebugMsg("TypeError: Tried to destroy an invalid TableArray: " + I2S(this))
debug return
debug endif
if tb == 0 then
//Create a Table to index recycled instances with their array size
set tb = Table.create()
set dex.size[this.size] = tb
endif
call dex.size.remove(this) //Clear the array size from hash memory
set tb[this] = tb[0]
set tb[0] = this
endmethod
private static Table tempTable
private static integer tempEnd
//Avoids hitting the op limit
private static method clean takes nothing returns nothing
local Table tb = .tempTable
local integer end = tb + 0x1000
if end < .tempEnd then
set .tempTable = end
call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
else
set end = .tempEnd
endif
loop
call tb.flush()
set tb = tb + 1
exitwhen tb == end
endloop
endmethod
//Flushes the TableArray and also destroys it. Doesn't get any more
//similar to the FlushParentHashtable native than this.
//
method flush takes nothing returns nothing
debug if this.size == 0 then
debug call BJDebugMsg("TypeError: Tried to flush an invalid TableArray instance: " + I2S(this))
debug return
debug endif
set .tempTable = this
set .tempEnd = this + this.size
call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
call this.destroy()
endmethod
endstruct
endlibrary
//TESH.scrollpos=3
//TESH.alwaysfold=0
library FireVortex /* v1.6
*************************************************************************************
*
* by mckill2009
*
*************************************************************************************
*
* */ uses /*
*
* */ Table /* www.hiveworkshop.com/forums/jass-resources-412/snippet-new-table-188084
* */ CTL /* www.hiveworkshop.com/forums/jass-resources-412/snippet-constant-timer-loop-32-a-201381/index7.html#post2389697
*
*************************************************************************************
*
* Installation:
* - Import/copy the required libraries and FireVortex code to your map
* - Import/copy the custom ability and unit to your map and change the SPELL_ID and FIRE_ID if needed
* - You may view the raw ID of the objects by pressing CTRL+D in the object editor
* - You may play with the configurables below
*
*************************************************************************************/
globals
/********************************************************
* Configurables: default and recommended settings
*********************************************************/
//change raw id if needed
private constant integer SPELL_ID = 'A000'
//change raw id if needed
private constant integer FIRE_ID = 'h000'
//uses default lava spawn level 2, this is totally optional
private constant integer ELEMENTAL_ID = 'nlv2'
//the effect when fire lands the ground
private constant string EXPLODE_SFX = "Objects\\Spawnmodels\\Undead\\UDeathSmall\\UDeathSmall.mdl"
//the damage aoe when fire lands the ground
private constant real EXPLODE_AOE_DAMAGE = 150.
//the damage aoe when fire is spinning
private constant real TOUCH_AOE_DAMAGE = 80.
//max fly height
private constant real FLY_HEIGHT = 500.
//the fly or up speed
private constant real FLY_SPEED = 15.
//the impact to the ground speed, this is added to the impactDamage
private constant real DROP_SPEED = 30.
//how fast the fire be created
private constant real CREATION_DELAY = 0.5
//the higher the number, the faster
private constant real SPIN_SPEED = 0.07 //in radians
//allows the creation of a unit, see ELEMENTAL_ID
private constant boolean ENABLE_ELEMENTAL_CREATION = true
//set to false for elemental to live until dies
//ENABLE_ELEMENTAL_CREATION should be true also
private constant boolean ELEMENTAL_HAS_TIMER = true
private attacktype ATK = ATTACK_TYPE_MAGIC
private damagetype DMG = DAMAGE_TYPE_MAGIC
/********************************************************
* Non-configurables
********************************************************/
private real CreationGap
private Table sp
private group TempG = CreateGroup()
endglobals
/********************************************************
* Configurables
*********************************************************/
private function GetDamage takes integer level returns real
return (10 * level + 20.)
endfunction
private function GetFireCount takes integer level returns integer
return 2 * level + 2
endfunction
private function GetElementalTimer takes integer level returns real
return 15.
endfunction
/********************************************************
* End of configurables
*********************************************************/
private function UnitAlive takes unit u returns boolean
return not IsUnitType(u, UNIT_TYPE_DEAD)
endfunction
struct FireSpin extends array
unit fire
real angle
real damage
real impactDamage
real duration
real dist
real height
real elementalLife
real x
real y
boolean direction
boolean fly
group g
implement CTL
local unit first
local real xFire
local real yFire
implement CTLExpire
if .fire==null then
call .destroy()
else
set xFire = GetUnitX(.fire)
set yFire = GetUnitY(.fire)
if .duration > 0 then
set .duration = .duration - 0.03125
if .direction then
set .angle = .angle + SPIN_SPEED
else
set .angle = .angle - SPIN_SPEED
endif
call SetUnitX(.fire, .x+.dist*Cos(.angle))
call SetUnitY(.fire, .y+.dist*Sin(.angle))
call GroupEnumUnitsInRange(TempG, xFire, yFire, TOUCH_AOE_DAMAGE, null)
loop
set first = FirstOfGroup(TempG)
exitwhen first==null
if UnitAlive(first) and IsUnitEnemy(first, GetOwningPlayer(.fire)) then
call UnitDamageTarget(.fire, first, .damage, false, false, ATK, DMG, null)
endif
call GroupRemoveUnit(TempG, first)
endloop
else
if .fly then
set .height = .height + FLY_SPEED
if .height > FLY_HEIGHT then
set .fly = false
endif
else
set .height = .height - DROP_SPEED
endif
call SetUnitFlyHeight(.fire, .height, 0)
if 0 > .height then
call DestroyEffect(AddSpecialEffect(EXPLODE_SFX, xFire, yFire))
call GroupEnumUnitsInRange(TempG, xFire, yFire, EXPLODE_AOE_DAMAGE, null)
loop
set first = FirstOfGroup(TempG)
exitwhen first==null
if UnitAlive(first) and IsUnitEnemy(first, GetOwningPlayer(.fire)) then
call UnitDamageTarget(.fire, first, .impactDamage, false, false, ATK, DMG, null)
endif
call GroupRemoveUnit(TempG, first)
endloop
static if ENABLE_ELEMENTAL_CREATION then
set first = CreateUnit(GetOwningPlayer(.fire), ELEMENTAL_ID, xFire, yFire, 0)
call UnitAddType(first, UNIT_TYPE_SUMMONED)
static if ELEMENTAL_HAS_TIMER then
call UnitApplyTimedLife(first, 'BTLF', .elementalLife)
endif
set first = null
endif
call KillUnit(.fire)
set .fire = null
endif
endif
endif
implement CTLEnd
static method spin takes unit f, real damage, real x, real y, real el returns nothing
local thistype this = create()
local integer id = GetHandleId(f)
set .fire = f
set .direction = false
if sp.boolean[id] then
set .direction = true
endif
set .duration = GetRandomReal(7, 12)
set .elementalLife = el
set .fly = true
set .height = GetUnitFlyHeight(f)
set .x = x
set .y = y
set .angle = Atan2(GetUnitY(f)-y, GetUnitX(f)-x)
set .dist = SquareRoot((GetUnitX(f)-x)*(GetUnitX(f)-x)+(GetUnitY(f)-y)*(GetUnitY(f)-y))
set .impactDamage = (damage*2)+(DROP_SPEED*2)
set .damage = damage*0.3125
call UnitAddAbility(f, 'Arav')
endmethod
endstruct
private struct FireVortexCast extends array
player p
real a
real damage
real elementalLife
real delay
real down
real up
real x
real y
integer count
integer index
boolean check
boolean directionUp
boolean directionDown
group g
static thistype DATA
private static method startSpinning takes nothing returns nothing
local thistype this = DATA
call FireSpin.spin(GetEnumUnit(), this.damage, this.x, this.y, this.elementalLife)
endmethod
implement CTL
local unit fire
local integer id
implement CTLExpire
if .count > .index then
set .delay = .delay + 0.03125
if .delay > CREATION_DELAY then
set .delay = 0
set .index = .index + 1
if .check then
set .check = false
set fire = CreateUnit(.p, FIRE_ID, .x+.up*Cos(.a), .y+.up*Sin(.a), 0)
set .up = .up - CreationGap
set id = GetHandleId(fire)
if .directionUp then
set .directionUp = false
set sp.boolean[id] = true
else
set .directionUp = true
endif
else
set .check = true
set fire = CreateUnit(.p, FIRE_ID, .x+.down*Cos(.a), .y+.down*Sin(.a), 0)
set .down = .down + CreationGap
set id = GetHandleId(fire)
if .directionDown then
set .directionDown = false
set sp.boolean[id] = true
else
set .directionDown = true
endif
endif
set sp.real[id] = .a
call GroupAddUnit(.g, fire)
set fire = null
endif
else
set DATA = this
call ForGroup(.g, function thistype.startSpinning)
call DestroyGroup(.g)
set .p = null
set .g = null
call .destroy()
endif
implement CTLEnd
static method run takes unit u, real x, real y returns nothing
local thistype this = create()
local integer level = GetUnitAbilityLevel(u, SPELL_ID)
set .p = GetTriggerPlayer()
set .a = Atan2(GetUnitY(u)-y, GetUnitX(u)-x)
set .damage = GetDamage(level)
set .elementalLife = GetElementalTimer(level)
set .delay = 0
set .down = CreationGap
set .up = -CreationGap
set .x = x
set .y = y
set .count = GetFireCount(level)
set .index = 0
set .check = true
set .directionUp = true
set .directionDown = true
set .g = CreateGroup()
endmethod
static method cast takes nothing returns boolean
if GetSpellAbilityId()==SPELL_ID then
call thistype.run(GetTriggerUnit(), GetSpellTargetX(), GetSpellTargetY())
endif
return false
endmethod
static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function thistype.cast))
set t = null
set CreationGap = TOUCH_AOE_DAMAGE + 20.
set sp = Table.create()
endmethod
endstruct
endlibrary