Name | Type | is_array | initial_value |
areaofeffect | real | Yes | |
boolean | boolean | No | |
C_AoE | integer | No | |
C_AoE_A | real | No | |
C_Caster | unit | Yes | |
C_CasterPosition | location | No | |
C_Damage | real | No | |
C_DamageArea_int | integer | No | |
C_DamagePoints | location | No | |
C_DamageUnits | group | No | |
C_Index | integer | Yes | |
C_IndexMaxSize | integer | No | |
C_IndexSize | integer | No | |
C_Integer | integer | No | |
C_Loop | integervar | No | |
C_RealDamage | real | No | |
C_RealShardAmount | real | Yes | |
C_SFX_SpellPathString | string | No | |
C_ShardAmount | real | No | |
caster | unit | No | |
DA_Base_Damage | real | No | |
DA_Casting_Unit | unit | No | |
DA_Damage_Group | group | No | |
DA_Dummy_Ability_Fire | abilcode | No | |
DA_Dummy_Ability_Slow | abilcode | No | |
DA_Dummy_Ability_Stunn | abilcode | No | |
DA_Dummy_Ability_Water | abilcode | No | |
DA_Hero_Ability_Level | integer | No | |
DA_Loop_Distance | real | No | |
DA_Loop_Location | location | No | |
DA_Number_of_Charges | integer | No | |
DA_Owner_of_Caster | player | No | |
DA_Radius_AoE | real | No | |
DA_Radius_Level_AoE | real | No | |
DA_Targeted_Location | location | No | |
damage | real | Yes | |
DarknessBoss | unit | No | |
DarknessGateTimer | timer | No | |
DarknessGateTimerWindow | timerdialog | No | |
DarknessSoul | destructable | No | |
DarknessSoulEffect01 | effect | No | |
DarknessSoulEffect02 | effect | No | |
DarknessSoulItem | item | No | |
DarknessSoulText | texttag | No | |
DarknessSoulTimer | timer | No | |
DarknessSoulTimerWindow | timerdialog | No | |
Difficulty | dialog | No | |
Easy | button | No | |
Effect01 | effect | No | |
Effect02 | effect | No | |
Effect03 | effect | No | |
Effect04 | effect | No | |
Effect05 | effect | No | |
Effect06 | effect | No | |
Effect07 | effect | No | |
Effect08 | effect | No | |
Effect09 | effect | No | |
Effect10 | effect | No | |
Effect11 | effect | No | |
FacelessGroup | group | No | |
FireBoss | unit | No | |
FireBossEffect01 | effect | No | |
FireBossEffect02 | effect | No | |
FireBossEffect03 | effect | No | |
FireBossEffect04 | effect | No | |
FireBossEffect05 | effect | No | |
FireBossEffect06 | effect | No | |
FireGateTimer | timer | No | |
FireGateTimerWindow | timerdialog | No | |
FireSoul | destructable | No | |
FireSoulEffect01 | effect | No | |
FireSoulEffect02 | effect | No | |
FireSoulItem | item | No | |
FireSoulText | texttag | No | |
FireSoulTimer | timer | No | |
FireSoulTimerWindow | timerdialog | No | |
FirstCinematicSkip | boolean | No | |
FrostBoss | unit | No | |
FrostBossEffect | effect | No | |
FrostRevenant01 | unit | No | |
FrostRevenant02 | unit | No | |
FrostRevenant03 | unit | No | |
FrostRevenant04 | unit | No | |
FrostRevenant05 | unit | No | |
FrostRevenant06 | unit | No | |
FrostSoul | destructable | No | |
FrostSoulEffect01 | effect | No | |
FrostSoulEffect02 | effect | No | |
FrostSoulItem | item | No | |
FrostSoulText | texttag | No | |
FrostSoulTimer | timer | No | |
FrostSoulTimerWindow | timerdialog | No | |
GatherSoulEffect01 | effect | No | |
GatherSoulEffect02 | effect | No | |
GatherSoulEffect03 | effect | No | |
GatherSoulEffect04 | effect | No | |
GhostBoss | unit | No | |
GhostFight | dialog | No | |
GhostGateTimer | timer | No | |
GhostGateTimerWindow | timerdialog | No | |
GhostMaster | unit | No | |
GhostMaster02 | unit | No | |
GhostMaster03 | unit | No | |
GhostMaster04 | unit | No | |
GhostSoul | destructable | No | |
GhostSoulEffect01 | effect | No | |
GhostSoulEffect02 | effect | No | |
GhostSoulItem | item | No | |
GhostSoulText | texttag | No | |
GhostSoulTimer | timer | No | |
GhostSoulTimerWindow | timerdialog | No | |
Ghoul01 | unit | No | |
Golem01 | unit | No | |
Golem02 | unit | No | |
Golem03 | unit | No | |
GreaterVoidwalkers | group | No | |
handle | integer | No | |
Hard | button | No | |
hashtable | hashtable | No | |
HealingItem01Effect | effect | No | |
HealingItem02Effect | effect | No | |
HealingItem03Effect | effect | No | |
LavaSpawn01 | unit | No | |
LavaSpawn02 | unit | No | |
LavaSpawn03 | unit | No | |
LavaSpawn04 | unit | No | |
LavaSpawn05 | unit | No | |
LavaSpawn06 | unit | No | |
LavaSpawn07 | unit | No | |
LavaSpawn08 | unit | No | |
LavaSpwans | group | No | |
Leak_Point | location | No | |
level | integer | No | |
LF_A_Decrease | real | Yes | |
LF_Alpha | real | Yes | |
LF_B | real | Yes | |
LF_CountInteger | integer | Yes | |
LF_Debug | boolean | Yes | |
LF_G | real | Yes | |
LF_Lightning | lightning | Yes | |
LF_R | real | Yes | |
light | lightning | No | |
Magwina | unit | No | |
Magwina02 | unit | No | |
MagwinaCreatingEffect | effect | No | |
MagwinaEffect01 | effect | No | |
MagwinaEffect02 | effect | No | |
MagwinaEffect03 | effect | No | |
MAINQUEST1 | quest | No | |
MAINQUEST2 | quest | No | |
MAINQUEST3 | quest | No | |
MAINQUEST4 | quest | No | |
manaburn | boolean | No | |
MQ1REQ1 | questitem | No | |
MQ1REQ2 | questitem | No | |
MQ1REQ3 | questitem | No | |
MQ1REQ4 | questitem | No | |
MQ1REQ5 | questitem | No | |
MQ1REQ6 | questitem | No | |
MQ1REQ7 | questitem | No | |
MQ1REQ8 | questitem | No | |
MudGolem01 | unit | No | |
MudGolem02 | unit | No | |
MudGolem03 | unit | No | |
MudGolems | group | No | |
Necromancer01 | unit | No | |
Necromancer02 | unit | No | |
Necromancer03 | unit | No | |
Normal | button | No | |
orderid | string | No | |
OW_Ability | abilcode | No | |
OW_Angle | real | No | |
OW_Caster | unit | Yes | |
OW_Counter | integer | Yes | |
OW_Degrees | real | No | |
OW_Distance | real | No | |
OW_Effect | unit | No | |
OW_Index | integer | Yes | |
OW_Integ | integervar | Yes | |
OW_Load_HashTable | boolean | No | |
OW_Owner | player | Yes | |
OW_Point_1 | location | No | |
OW_Point_2 | location | No | |
OW_Point_3 | location | No | |
OW_Stop_Cast | boolean | Yes | |
OW_Table | hashtable | No | |
OW_Times | integer | No | |
point1 | location | No | |
point2 | location | No | |
Revenants | group | No | |
Seabert | unit | No | |
SF_AoE | real | No | |
SF_Caster | unit | No | |
SF_ChainProc | integer | No | |
SF_Integer | integer | Yes | |
SF_Loc | location | Yes | |
SF_Loc1 | location | Yes | |
SF_Real | real | No | |
SkeletonWarriors | group | No | |
SpawnedUnit01 | unit | No | |
SpawnedUnit02 | unit | No | |
SpawnedUnit03 | unit | No | |
SpawnedUnit04 | unit | No | |
SpawnedUnit05 | unit | No | |
SpawnedUnit06 | unit | No | |
SpawnEffect01 | effect | No | |
SpawnEffect02 | effect | No | |
SpawnEffect03 | effect | No | |
SpawnEffect04 | effect | No | |
SpawnEffect05 | effect | No | |
SpawnEffect06 | effect | No | |
SpawnEffect07 | effect | No | |
SpawnEffect08 | effect | No | |
SpawnEffect09 | effect | No | |
SpawnEffect10 | effect | No | |
SpawnEffect11 | effect | No | |
SpawnEffect12 | effect | No | |
SpawnEffect13 | effect | No | |
SpawnEffect14 | effect | No | |
SpawnEffect15 | effect | No | |
SpawnEffect16 | effect | No | |
SpawnEffect17 | effect | No | |
SpawnEffect18 | effect | No | |
SpawnEffect19 | effect | No | |
SpawnEffect20 | effect | No | |
SpawnEffect21 | effect | No | |
SpawnEffect22 | effect | No | |
SpawnEffect23 | effect | No | |
SpawnEffect24 | effect | No | |
SpawnEffect25 | effect | No | |
SpawnEffect26 | effect | No | |
stormgroup | group | No | |
target | unit | No | |
Temp_Point01 | location | No | |
TrapCinematicSkip | boolean | No | |
unitsfx | string | No | |
VileTemptress | group | No | |
VileTemptress01 | unit | No | |
VileTemptress02 | unit | No | |
VileTemptress03 | unit | No | |
VileTemptress04 | unit | No | |
Voidwalker01 | unit | No | |
Voidwalker02 | unit | No | |
Voidwalker03 | unit | No | |
Voidwalker04 | unit | No | |
Voidwalker05 | unit | No | |
Voidwalker06 | unit | No | |
Voidwalker07 | unit | No | |
Voidwalker08 | unit | No | |
Voidwalkers | group | No |
//TESH.scrollpos=0
//TESH.alwaysfold=0
library AutoFly /* v1.0.0.1
-Credits to Magtheridon96 and Bribe for code update
-Credits to Azlier for original
-thehelper.net/forums/showthread.php/139729-AutoFly
*************************************************************************************
*
* Makes SetUnitFlyHeight possible
*
*************************************************************************************
*
* */uses/*
*
* */ UnitIndexer /* hiveworkshop.com/forums/jass-functions-413/unit-indexer-172090/
*
************************************************************************************/
private function i takes nothing returns boolean
return UnitAddAbility(GetIndexedUnit(), 'Amrf') and UnitRemoveAbility(GetIndexedUnit(), 'Amrf')
endfunction
private module Init
private static method onInit takes nothing returns nothing
call RegisterUnitIndexEvent(Condition(function i), UnitIndexer.INDEX)
endmethod
endmodule
private struct Inits extends array
implement Init
endstruct
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library UnitIndexer /* v4.0.2.7
*************************************************************************************
*
* Assigns unique indexes to units via unit user data.
*
*************************************************************************************
*
* */uses/*
*
* */ WorldBounds /* hiveworkshop.com/forums/jass-functions-413/snippet-worldbounds-180494/
* */ Event /* hiveworkshop.com/forums/submissions-414/snippet-event-186555/
*
************************************************************************************
*
* SETTINGS
*/
globals
constant integer ABILITIES_UNIT_INDEXER = 'A001'
endglobals
/*
************************************************************************************
*
* Functions
*
* function RegisterUnitIndexEvent takes boolexpr codeToRegister, Event unitIndexEvent returns nothing
* function TriggerRegisterUnitIndexEvent takes trigger triggerToRegister, Event unitIndexEvent returns nothing
*
* function GetUnitById takes integer index returns unit
* - Returns unit given a unit index
* function GetUnitId takes unit u returns integer
* - Returns unit index given a unit
*
* function IsUnitIndexed takes unit u returns boolean
* function IsUnitDeindexing takes unit u returns boolean
*
* function GetIndexedUnitId takes nothing returns integer
* function GetIndexedUnit takes nothing returns unit
*
************************************************************************************
*
* module UnitIndexStructMethods
* static method operator [] takes unit u returns thistype
* - Return GetUnitUserData(u)
*
* readonly unit unit
* - The indexed unit of the struct
*
************************************************************************************
*
* module UnitIndexStruct extends UnitIndexStructMethods
*
* - A pseudo module interface that runs a set of methods if they exist and provides
* - a few fields and operators. Runs on static ifs to minimize code.
*
* readonly boolean allocated
* - Is unit allocated for the struct
*
* Interface:
*
* - These methods don't have to exist. If they don't exist, the code
* - that calls them won't even be in the module.
*
* private method index takes nothing returns nothing
* - called when a unit is indexed and passes the filter.
* -
* - thistype this: Unit's index
* private method deindex takes nothing returns nothing
* - called when a unit is deindexed and is allocated for struct
* -
* - thistype this: Unit's index
* private static method filter takes unit unitToIndex returns boolean
* - Determines whether or not to allocate struct for unit
* -
* - unit unitToIndex: Unit being filtered
*
************************************************************************************
*
* struct UnitIndexer extends array
*
* - Controls the unit indexer system.
*
* static constant Event UnitIndexer.INDEX
* static constant Event UnitIndexer.DEINDEX
* - Don't register functions and triggers directly to the events. Register them via
* - RegisterUnitIndexEvent and TriggerRegisterUnitIndexEvent.
*
* static boolean enabled
* - Enables and disables unit indexing. Useful for filtering out dummy units.
*
************************************************************************************
*
* struct UnitIndex extends UnitIndexStructMethods
*
* - Constrols specific unit indexes.
*
* method lock takes nothing returns nothing
* - Locks an index. When an index is locked, it will not be recycled
* - when the unit is deindexed until all locks are removed. Deindex
* - events still fire at the appropriate times, the index just doesn't
* - get thrown into the recycler.
* method unlock takes nothing returns nothing
* - Unlocks an index.
*
************************************************************************************/
globals
private trigger q=CreateTrigger()
private trigger l=CreateTrigger()
private unit array e
private integer r=0
private integer y=0
private integer o=0
private boolean a=false
private integer array n
private integer array p
private integer array lc
endglobals
function GetIndexedUnitId takes nothing returns integer
return o
endfunction
function GetIndexedUnit takes nothing returns unit
return e[o]
endfunction
//! runtextmacro optional UNIT_LIST_LIB()
private struct PreLoader extends array
public static method run takes nothing returns nothing
call DestroyTimer(GetExpiredTimer())
set a=true
endmethod
public static method eval takes trigger t returns nothing
local integer f=n[0]
local integer d=o
loop
exitwhen 0==f
if (IsTriggerEnabled(t)) then
set o=f
if (TriggerEvaluate(t)) then
call TriggerExecute(t)
endif
else
exitwhen true
endif
set f=n[f]
endloop
set o=d
endmethod
public static method evalb takes boolexpr c returns nothing
local trigger t=CreateTrigger()
local thistype f=n[0]
local integer d=o
call TriggerAddCondition(t,c)
loop
exitwhen 0==f
set o=f
call TriggerEvaluate(t)
set f=n[f]
endloop
call DestroyTrigger(t)
set t=null
set o=d
endmethod
endstruct
//! runtextmacro optional UNIT_EVENT_MACRO()
private module UnitIndexerInit
private static method onInit takes nothing returns nothing
local integer i=15
local boolexpr bc=Condition(function thistype.onLeave)
local boolexpr bc2=Condition(function thistype.onEnter)
local group g=CreateGroup()
local player p
set INDEX=CreateEvent()
set DEINDEX=CreateEvent()
call TriggerRegisterEnterRegion(q,WorldBounds.worldRegion,bc2)
loop
set p=Player(i)
call TriggerRegisterPlayerUnitEvent(l,p,EVENT_PLAYER_UNIT_ISSUED_ORDER,bc)
call SetPlayerAbilityAvailable(p,ABILITIES_UNIT_INDEXER,false)
call GroupEnumUnitsOfPlayer(g,p,bc2)
exitwhen 0==i
set i=i-1
endloop
call DestroyGroup(g)
set bc=null
set g=null
set bc2=null
set p=null
call TimerStart(CreateTimer(),0,false,function PreLoader.run)
endmethod
endmodule
struct UnitIndex extends array
method lock takes nothing returns nothing
debug if (null!=e[this]) then
set lc[this]=lc[this]+1
debug else
debug call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"UNIT INDEXER ERROR: ATTEMPT TO LOCK NULL INDEX")
debug endif
endmethod
method unlock takes nothing returns nothing
debug if (0<lc[this]) then
set lc[this]=lc[this]-1
if (0==lc[this] and null==e[this]) then
set n[this]=y
set y=this
endif
debug else
debug call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"UNIT INDEXER ERROR: ATTEMPT TO UNLOCK UNLOCKED INDEX")
debug endif
endmethod
method operator unit takes nothing returns unit
return e[this]
endmethod
static method operator [] takes unit whichUnit returns thistype
return GetUnitUserData(whichUnit)
endmethod
endstruct
struct UnitIndexer extends array
readonly static Event INDEX
readonly static Event DEINDEX
static boolean enabled=true
private static method onEnter takes nothing returns boolean
local unit Q=GetFilterUnit()
local integer i
local integer d=o
if (enabled and Q!=e[GetUnitUserData(Q)] and 0==GetUnitUserData(Q)) then
if (0==y) then
set r=r+1
set i=r
else
set i=y
set y=n[y]
endif
call UnitAddAbility(Q,ABILITIES_UNIT_INDEXER)
call UnitMakeAbilityPermanent(Q,true,ABILITIES_UNIT_INDEXER)
call SetUnitUserData(Q,i)
set e[i]=Q
static if not LIBRARY_UnitList then
if (not a)then
set p[i]=p[0]
set n[p[0]]=i
set n[i]=0
set p[0]=i
endif
else
set p[i]=p[0]
set n[p[0]]=i
set n[i]=0
set p[0]=i
call GroupAddUnit(g,e[i])
endif
set o=i
call FireEvent(INDEX)
set o=d
endif
set Q=null
return false
endmethod
private static method onLeave takes nothing returns boolean
static if LIBRARY_UnitEvent then
implement optional UnitEventModule
else
local unit u=GetFilterUnit()
local integer i=GetUnitUserData(u)
local integer d=o
if (0==GetUnitAbilityLevel(u,ABILITIES_UNIT_INDEXER) and u==e[i]) then
static if not LIBRARY_UnitList then
if (not a)then
set n[p[i]]=n[i]
set p[n[i]]=p[i]
endif
else
set n[p[i]]=n[i]
set p[n[i]]=p[i]
call GroupRemoveUnit(g,e[i])
endif
set o=i
call FireEvent(DEINDEX)
set o=d
if (0==lc[i]) then
set n[i]=y
set y=i
endif
set e[i]=null
endif
set u=null
endif
return false
endmethod
implement UnitIndexerInit
endstruct
//! runtextmacro optional UNIT_EVENT_MACRO_2()
function RegisterUnitIndexEvent takes boolexpr c,integer ev returns nothing
call RegisterEvent(c, ev)
if (not a and ev==UnitIndexer.INDEX and 0!=n[0]) then
call PreLoader.evalb(c)
endif
endfunction
function TriggerRegisterUnitIndexEvent takes trigger t,integer ev returns nothing
call TriggerRegisterEvent(t,ev)
if (not a and ev == UnitIndexer.INDEX and 0!=n[0]) then
call PreLoader.eval(t)
endif
endfunction
function GetUnitById takes integer W returns unit
return e[W]
endfunction
function GetUnitId takes unit u returns integer
return GetUnitUserData(u)
endfunction
function IsUnitIndexed takes unit u returns boolean
return u==e[GetUnitUserData(u)]
endfunction
function IsUnitDeindexing takes unit u returns boolean
return IsUnitIndexed(u) and 0==GetUnitAbilityLevel(u,ABILITIES_UNIT_INDEXER)
endfunction
module UnitIndexStructMethods
static method operator [] takes unit u returns thistype
return GetUnitUserData(u)
endmethod
method operator unit takes nothing returns unit
return e[this]
endmethod
endmodule
module UnitIndexStruct
implement UnitIndexStructMethods
static if thistype.filter.exists then
static if thistype.index.exists then
static if thistype.deindex.exists then
readonly boolean allocated
else
method operator allocated takes nothing returns boolean
return filter(e[this])
endmethod
endif
else
method operator allocated takes nothing returns boolean
return filter(e[this])
endmethod
endif
elseif (thistype.index.exists) then
static if thistype.deindex.exists then
readonly boolean allocated
else
method operator allocated takes nothing returns boolean
return this==GetUnitUserData(e[this])
endmethod
endif
else
method operator allocated takes nothing returns boolean
return this==GetUnitUserData(e[this])
endmethod
endif
static if thistype.index.exists then
private static method onIndexEvent takes nothing returns boolean
static if thistype.filter.exists then
if (filter(e[o])) then
static if thistype.deindex.exists then
set thistype(o).allocated=true
endif
call thistype(o).index()
endif
else
static if thistype.deindex.exists then
set thistype(o).allocated=true
endif
call thistype(o).index()
endif
return false
endmethod
endif
static if thistype.deindex.exists then
private static method onDeindexEvent takes nothing returns boolean
static if thistype.filter.exists then
static if thistype.index.exists then
if (thistype(o).allocated) then
set thistype(o).allocated=false
call thistype(o).deindex()
endif
else
if (filter(e[o])) then
call thistype(o).deindex()
endif
endif
else
static if thistype.index.exists then
set thistype(o).allocated=false
endif
call thistype(o).deindex()
endif
return false
endmethod
endif
static if thistype.index.exists then
static if thistype.deindex.exists then
private static method onInit takes nothing returns nothing
call RegisterUnitIndexEvent(Condition(function thistype.onIndexEvent),UnitIndexer.INDEX)
call RegisterUnitIndexEvent(Condition(function thistype.onDeindexEvent),UnitIndexer.DEINDEX)
endmethod
else
private static method onInit takes nothing returns nothing
call RegisterUnitIndexEvent(Condition(function thistype.onIndexEvent),UnitIndexer.INDEX)
endmethod
endif
elseif thistype.deindex.exists then
private static method onInit takes nothing returns nothing
call RegisterUnitIndexEvent(Condition(function thistype.onDeindexEvent),UnitIndexer.DEINDEX)
endmethod
endif
endmodule
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library_once Event /* v2.0.0.1
************************************************************************************
*
* Functions
*
* function CreateEvent takes nothing returns integer
* function TriggerRegisterEvent takes trigger t, integer ev returns nothing
*
************************************************************************************
*
* struct Event extends array
*
* static method create takes nothing returns thistype
* method registerTrigger takes trigger t returns nothing
* method register takes boolexpr c returns nothing
* method fire takes nothing returns nothing
*
************************************************************************************/
globals
private real q=0
endglobals
struct Event extends array
private static integer w=0
private static trigger array e
static method create takes nothing returns thistype
set w=w+1
set e[w]=CreateTrigger()
return w
endmethod
method registerTrigger takes trigger t returns nothing
call TriggerRegisterVariableEvent(t,SCOPE_PRIVATE+"q",EQUAL,this)
endmethod
method register takes boolexpr c returns nothing
call TriggerAddCondition(e[this],c)
endmethod
method fire takes nothing returns nothing
set q=0
set q=this
call TriggerEvaluate(e[this])
endmethod
endstruct
function CreateEvent takes nothing returns Event
return Event.create()
endfunction
function TriggerRegisterEvent takes trigger t,Event ev returns nothing
call ev.registerTrigger(t)
endfunction
function RegisterEvent takes boolexpr c,Event ev returns nothing
call ev.register(c)
endfunction
function FireEvent takes Event ev returns nothing
call ev.fire()
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library Table /* made by Bribe, special thanks to Vexorian & Nestharus, version 4.1.0.1.
One map, one hashtable. Welcome to NewTable 4.1.0.1
This newest iteration of Table introduces the new HashTable struct.
You can now instantiate HashTables which enables the use of large
parent and large child keys, just like a standard hashtable. Previously,
the user would have to instantiate a Table to do this on their own which -
while doable - is something the user should not have to do if I can add it
to this resource myself (especially if they are inexperienced).
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
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 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")
//New textmacro to allow table.integer[] syntax for compatibility with textmacros that might desire it.
//! runtextmacro NEW_ARRAY_BASIC("Integer", "Integer", "integer")
//! 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 integerm
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) //return this.integer[key]
endmethod
//set tb[389034] = 8192
method operator []= takes integer key, Table tb returns nothing
call SaveInteger(ht, this, key, tb) //set this.integer[key] = tb
endmethod
//set b = tb.has(2493223)
method has takes integer key returns boolean
return HaveSavedInteger(ht, this, key) //return this.integer.has(key)
endmethod
//call tb.remove(294080)
method remove takes integer key returns nothing
call RemoveSavedInteger(ht, this, key) //call this.integer.remove(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
//NEW: Added in Table 4.0. A fairly simple struct but allows you to do more
//than that which was previously possible.
struct HashTable extends array
//Enables myHash[parentKey][childKey] syntax.
//Basically, it creates a Table in the place of the parent key if
//it didn't already get created earlier.
method operator [] takes integer index returns Table
local Table t = Table(this)[index]
if t == 0 then
set t = Table.create()
set Table(this)[index] = t //whoops! Forgot that line. I'm out of practice!
endif
return t
endmethod
//You need to call this on each parent key that you used if you
//intend to destroy the HashTable or simply no longer need that key.
method remove takes integer index returns nothing
local Table t = Table(this)[index]
if t != 0 then
call t.destroy()
call Table(this).remove(index)
endif
endmethod
//Added in version 4.1
method has takes integer index returns boolean
return Table(this).has(index)
endmethod
//HashTables are just fancy Table indices.
method destroy takes nothing returns nothing
call Table(this).destroy()
endmethod
//Like I said above...
static method create takes nothing returns thistype
return Table.create()
endmethod
endstruct
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
//============================================================================
// SpellEffectEvent
// - Version 1.1.0.0
//
// API
// ---
// RegisterSpellEffectEvent(integer abil, code onCast)
//
// Requires
// --------
// RegisterPlayerUnitEvent: hiveworkshop.com/forums/showthread.php?t=203338
//
// Optional
// --------
// Table: hiveworkshop.com/forums/showthread.php?t=188084
//
library SpellEffectEvent requires RegisterPlayerUnitEvent, optional Table
//============================================================================
private module M
static if LIBRARY_Table then
static Table tb
else
static hashtable ht = InitHashtable()
endif
static method onCast takes nothing returns nothing
static if LIBRARY_Table then
call TriggerEvaluate(.tb.trigger[GetSpellAbilityId()])
else
call TriggerEvaluate(LoadTriggerHandle(.ht, 0, GetSpellAbilityId()))
endif
endmethod
private static method onInit takes nothing returns nothing
static if LIBRARY_Table then
set .tb = Table.create()
endif
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_EFFECT, function thistype.onCast)
endmethod
endmodule
//============================================================================
private struct S extends array
implement M
endstruct
//============================================================================
function RegisterSpellEffectEvent takes integer abil, code onCast returns nothing
static if LIBRARY_Table then
if not S.tb.handle.has(abil) then
set S.tb.trigger[abil] = CreateTrigger()
endif
call TriggerAddCondition(S.tb.trigger[abil], Filter(onCast))
else
if not HaveSavedHandle(S.ht, 0, abil) then
call SaveTriggerHandle(S.ht, 0, abil, CreateTrigger())
endif
call TriggerAddCondition(LoadTriggerHandle(S.ht, 0, abil), Filter(onCast))
endif
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
/**************************************************************
*
* RegisterPlayerUnitEvent
* v5.1.0.1
* By Magtheridon96
*
* I would like to give a special thanks to Bribe, azlier
* and BBQ for improving this library. For modularity, it only
* supports player unit events.
*
* Functions passed to RegisterPlayerUnitEvent must either
* return a boolean (false) or nothing. (Which is a Pro)
*
* Warning:
* --------
*
* - Don't use TriggerSleepAction inside registered code.
* - Don't destroy a trigger unless you really know what you're doing.
*
* API:
* ----
*
* - function RegisterPlayerUnitEvent takes playerunitevent whichEvent, code whichFunction returns nothing
* - Registers code that will execute when an event fires.
* - function RegisterPlayerUnitEventForPlayer takes playerunitevent whichEvent, code whichFunction, player whichPlayer returns nothing
* - Registers code that will execute when an event fires for a certain player.
* - function GetPlayerUnitEventTrigger takes playerunitevent whichEvent returns trigger
* - Returns the trigger corresponding to ALL functions of a playerunitevent.
*
**************************************************************/
library RegisterPlayerUnitEvent // Special Thanks to Bribe and azlier
globals
private trigger array t
endglobals
function RegisterPlayerUnitEvent takes playerunitevent p, code c returns nothing
local integer i = GetHandleId(p)
local integer k = 15
if t[i] == null then
set t[i] = CreateTrigger()
loop
call TriggerRegisterPlayerUnitEvent(t[i], Player(k), p, null)
exitwhen k == 0
set k = k - 1
endloop
endif
call TriggerAddCondition(t[i], Filter(c))
endfunction
function RegisterPlayerUnitEventForPlayer takes playerunitevent p, code c, player pl returns nothing
local integer i = 16 * GetHandleId(p) + GetPlayerId(pl)
if t[i] == null then
set t[i] = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(t[i], pl, p, null)
endif
call TriggerAddCondition(t[i], Filter(c))
endfunction
function GetPlayerUnitEventTrigger takes playerunitevent p returns trigger
return t[GetHandleId(p)]
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library Stack /* v1.0.0.7
************************************************************************************
*
* */uses/*
*
* */ ErrorMessage /* hiveworkshop.com/forums/submissions-414/snippet-error-message-239210/
*
************************************************************************************
*
* module Stack
*
* Description
* -------------------------
*
* NA
*
* Fields
* -------------------------
*
* readonly static integer sentinel
*
* readonly thistype first
* readonly thistype next
*
* Methods
* -------------------------
*
* static method create takes nothing returns thistype
* method destroy takes nothing returns nothing
* - May only destroy stacks
*
* method push takes nothing returns thistype
* method pop takes nothing returns nothing
*
* method clear takes nothing returns nothing
*
* debug static method calculateMemoryUsage takes nothing returns integer
* debug static method getAllocatedMemoryAsString takes nothing returns string
*
************************************************************************************/
module Stack
private static thistype collectionCount = 0
private static thistype nodeCount = 0
debug private boolean isNode
debug private boolean isCollection
private thistype _next
method operator next takes nothing returns thistype
debug call ThrowError(this == 0, "Stack", "next", "thistype", this, "Attempted To Go Out Of Bounds.")
debug call ThrowError(not isNode, "Stack", "next", "thistype", this, "Attempted To Read Invalid Node.")
return _next
endmethod
private thistype _first
method operator first takes nothing returns thistype
debug call ThrowError(this == 0, "Stack", "first", "thistype", this, "Attempted To Read Null Stack.")
debug call ThrowError(not isCollection, "Stack", "first", "thistype", this, "Attempted To Read Invalid Stack.")
return _first
endmethod
static method operator sentinel takes nothing returns integer
return 0
endmethod
private static method allocateCollection takes nothing returns thistype
local thistype this = thistype(0)._first
if (0 == this) then
debug call ThrowError(collectionCount == 8191, "Stack", "allocateCollection", "thistype", 0, "Overflow.")
set this = collectionCount + 1
set collectionCount = this
else
set thistype(0)._first = _first
endif
return this
endmethod
private static method allocateNode takes nothing returns thistype
local thistype this = thistype(0)._next
if (0 == this) then
debug call ThrowError(nodeCount == 8191, "Stack", "allocateNode", "thistype", 0, "Overflow.")
set this = nodeCount + 1
set nodeCount = this
else
set thistype(0)._next = _next
endif
return this
endmethod
static method create takes nothing returns thistype
local thistype this = allocateCollection()
debug set isCollection = true
set _first = 0
return this
endmethod
method push takes nothing returns thistype
local thistype node = allocateNode()
debug call ThrowError(this == 0, "Stack", "push", "thistype", this, "Attempted To Push On To Null Stack.")
debug call ThrowError(not isCollection, "Stack", "push", "thistype", this, "Attempted To Push On To Invalid Stack.")
debug set node.isNode = true
set node._next = _first
set _first = node
return node
endmethod
method pop takes nothing returns nothing
local thistype node = _first
debug call ThrowError(this == 0, "Stack", "pop", "thistype", this, "Attempted To Pop Null Stack.")
debug call ThrowError(not isCollection, "Stack", "pop", "thistype", this, "Attempted To Pop Invalid Stack.")
debug call ThrowError(node == 0, "Stack", "pop", "thistype", this, "Attempted To Pop Empty Stack.")
debug set node.isNode = false
set _first = node._next
set node._next = thistype(0)._next
set thistype(0)._next = node
endmethod
private method getBottom takes nothing returns thistype
set this = _first
loop
exitwhen _next == 0
set this = _next
endloop
return this
endmethod
method clear takes nothing returns nothing
debug local thistype node = _first
debug call ThrowError(this == 0, "Stack", "clear", "thistype", this, "Attempted To Clear Null Stack.")
debug call ThrowError(not isCollection, "Stack", "clear", "thistype", this, "Attempted To Clear Invalid Stack.")
static if DEBUG_MODE then
loop
exitwhen node == 0
set node.isNode = false
set node = node._next
endloop
endif
if (_first == 0) then
return
endif
set getBottom()._next = thistype(0)._next
set thistype(0)._next = _first
set _first = 0
endmethod
method destroy takes nothing returns nothing
debug call ThrowError(this == 0, "Stack", "destroy", "thistype", this, "Attempted To Destroy Null Stack.")
debug call ThrowError(not isCollection, "Stack", "destroy", "thistype", this, "Attempted To Destroy Invalid Stack.")
static if DEBUG_MODE then
debug call clear()
debug set isCollection = false
else
if (_first != 0) then
set getBottom()._next = thistype(0)._next
set thistype(0)._next = _first
endif
endif
set _first = thistype(0)._first
set thistype(0)._first = this
endmethod
static if DEBUG_MODE then
static method calculateMemoryUsage takes nothing returns integer
local thistype start = 1
local thistype end = 8191
local integer count = 0
loop
exitwhen integer(start) > integer(end)
if (integer(start) + 500 > integer(end)) then
return count + checkRegion(start, end)
else
set count = count + checkRegion(start, start + 500)
set start = start + 501
endif
endloop
return count
endmethod
private static method checkRegion takes thistype start, thistype end returns integer
local integer count = 0
loop
exitwhen integer(start) > integer(end)
if (start.isNode) then
set count = count + 1
endif
if (start.isCollection) then
set count = count + 1
endif
set start = start + 1
endloop
return count
endmethod
static method getAllocatedMemoryAsString takes nothing returns string
local thistype start = 1
local thistype end = 8191
local string memory = null
loop
exitwhen integer(start) > integer(end)
if (integer(start) + 500 > integer(end)) then
if (memory != null) then
set memory = memory + ", "
endif
set memory = memory + checkRegion2(start, end)
set start = end + 1
else
if (memory != null) then
set memory = memory + ", "
endif
set memory = memory + checkRegion2(start, start + 500)
set start = start + 501
endif
endloop
return memory
endmethod
private static method checkRegion2 takes thistype start, thistype end returns string
local string memory = null
loop
exitwhen integer(start) > integer(end)
if (start.isNode) then
if (memory == null) then
set memory = I2S(start)
else
set memory = memory + ", " + I2S(start) + "N"
endif
endif
if (start.isCollection) then
if (memory == null) then
set memory = I2S(start)
else
set memory = memory + ", " + I2S(start) + "C"
endif
endif
set start = start + 1
endloop
return memory
endmethod
endif
endmodule
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library ErrorMessage /* v1.0.1.4
*************************************************************************************
*
* Issue Compliant Error Messages
*
************************************************************************************
*
* debug function ThrowError takes boolean expression, string libraryName, string functionName, string objectName, integer objectInstance, string description returns nothing
* - In the event of an error the game will be permanently paused
*
* debug function ThrowWarning takes boolean expression, string libraryName, string functionName, string objectName, integer objectInstance, string description returns nothing
*
************************************************************************************/
static if DEBUG_MODE then
private struct Fields extends array
static constant string COLOR_RED = "|cffff0000"
static constant string COLOR_YELLOW = "|cffffff00"
static string lastError = null
endstruct
private function Pause takes nothing returns nothing
call PauseGame(true)
endfunction
private function ThrowMessage takes string libraryName, string functionName, string objectName, integer objectInstance, string description, string errorType, string color returns nothing
local string str
local string color_braces = "|cff66FF99"
local string orange = "|cffff6600"
set str = "->\n-> " + color_braces + "{|r " + "Library" + color_braces + "(" + orange + libraryName + color_braces + ")"
if (objectName != null) then
if (objectInstance > 0) then
set str = str + "|r.Object" + color_braces + "(" + orange + objectName + color_braces + " (|rinstance = " + orange + I2S(objectInstance) + color_braces + ") )" + "|r." + "Method" + color_braces + "(" + orange + functionName + color_braces + ")"
else
set str = str + "|r.Object" + color_braces + "(" + orange + objectName + color_braces + ")|r." + "Method" + color_braces + "(" + orange + functionName + color_braces + ")"
endif
else
set str = str + "|r." + "Function" + color_braces + "(" + orange + functionName + color_braces + ")"
endif
set str = str + color_braces + " }|r " + "has thrown an exception of type " + color_braces + "(" + color + errorType + color_braces + ")|r."
set Fields.lastError = str + "\n->\n" + "-> " + color + description + "|r\n->"
endfunction
function ThrowError takes boolean expression, string libraryName, string functionName, string objectName, integer objectInstance, string description returns nothing
if (Fields.lastError != null) then
set objectInstance = 1/0
endif
if (expression) then
call ThrowMessage(libraryName, functionName, objectName, objectInstance, description, "Error", Fields.COLOR_RED)
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60000,Fields.lastError)
call TimerStart(CreateTimer(), 0, true, function Pause)
set objectInstance = 1/0
endif
endfunction
function ThrowWarning takes boolean expression, string libraryName, string functionName, string objectName, integer objectInstance, string description returns nothing
if (Fields.lastError != null) then
set objectInstance = 1/0
endif
if (expression) then
call ThrowMessage(libraryName, functionName, objectName, objectInstance, description, "Warning", Fields.COLOR_YELLOW)
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60000,Fields.lastError)
set Fields.lastError = null
endif
endfunction
endif
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library_once WorldBounds /* v2.0.0.0
************************************************************************************
*
* struct WorldBounds extends array
* readonly static integer maxX
* readonly static integer maxY
* readonly static integer minX
* readonly static integer minY
* readonly static integer centerX
* readonly static integer centerY
* readonly static rect world
* readonly static region worldRegion
*
************************************************************************************/
private module WorldBoundInit
private static method onInit takes nothing returns nothing
set world=GetWorldBounds()
set maxX=R2I(GetRectMaxX(world))
set maxY=R2I(GetRectMaxY(world))
set minX=R2I(GetRectMinX(world))
set minY=R2I(GetRectMinY(world))
set centerX=R2I((maxX+minX)/2)
set centerY=R2I((minY+maxY)/2)
set worldRegion=CreateRegion()
call RegionAddRect(worldRegion,world)
endmethod
endmodule
struct WorldBounds extends array
readonly static integer maxX
readonly static integer maxY
readonly static integer minX
readonly static integer minY
readonly static integer centerX
readonly static integer centerY
readonly static rect world
readonly static region worldRegion
implement WorldBoundInit
endstruct
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library CTL /* v1.2.0.3
*************************************************************************************
*
* 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 start takes nothing returns nothing
call A32(rctl32)
endmethod
static method stop takes nothing returns nothing
call SR32(rctl32)
endmethod
static method ectl32 takes nothing returns boolean
endmodule
module CT32End
return false
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
scope DarkMatter
/*
~* Dark Matter *~
version 2.1
Created by: Dalvengyr aka Quilnez
Copyright 2015
This resource is copyright protected.
Don't redistribute without permission.
You are free to edit, use, remake, etc.
but don't remove the copyright notes
above.
*/
/* *\
Configuration
\* */
globals
/* I. General settings */
// Dummy unit's raw code at Object Editor
private constant integer DUMMY_OBJECT_ID = 'h004'
// Main spell's raw code at Object Editor
private constant integer SPELL_OBJECT_ID = 'A002'
// General decay time for special effects
private constant real SFX_DECAY_TIME = 5.0
// General units' hit z offset. Used for 3D collision
private constant real UNITS_HIT_Z_OFFSET = 50.0
/* II. Orb settings
(Orb is an object at the center of spell area)
*/
// Model's file path
private constant string ORB_SFX = "war3mapImported\\BlackHole.mdx"
// Flying height
private constant real ORB_HEIGHT_Z = 0.0
// Scale/size
private constant real ORB_SCALE = 1.0
// How bad range between victims and the orb can affect the absorb power
private constant real ORB_POWER_FACTOR = 0.375
/* III. Swirl settings
(Swirl consists of objects which swirl around the main orb)
*/
// Raw code at Object Editor
private constant integer SWIRL_WAVE_OBJECT_ID = 'h003'
// Animation speed
private constant real SWIRL_TIME_SCALE = 0.1
// Flying height
private constant real SWIRL_HEIGHT_Z = 100.0
// Scale/size
private constant real SWIRL_SCALE = 1.25
/* IV. Particle settings
(Particles are missiles that are periodically released by the orb)
*/
// Model file path
private constant string PARTICLE_SFX = "Abilities\\Weapons\\AvengerMissile\\AvengerMissile.mdl"
// Starting fly height when launched
private constant real PARTICLE_LAUNCH_Z = 100.0
// Scale/size
private constant real PARTICLE_SCALE = 0.2
// Turn rate
private constant real PARTICLE_TURN_SPEED = 0.1
// Max range between particle at target to hit the target
private constant real PARTICLE_HIT_RADIUS = 70.0
// If false, each particle can only hits one target
private constant boolean PARTICLE_PIERCING = false
// Dealt damage setting
private constant attacktype PARTICLE_ATTACK_TYPE = ATTACK_TYPE_NORMAL
private constant damagetype PARTICLE_DAMAGE_TYPE = DAMAGE_TYPE_NORMAL
endglobals
/* V. Dynamic settings
(Allows you to set dynamic values based on parameters)
*/
// Number of created wave to swirl around the orb
private constant function SwirlCount takes integer level returns integer
return 9
endfunction
// Range/distance from the orb to the created waves
private constant function SwirlRadius takes integer level returns real
return 125.0
endfunction
// Rotation speed of waves, in radians
private constant function SwirlRotation takes integer level returns real
return 0.09
endfunction
// Move speed of each particle
private constant function ParticleSpeed takes integer level returns real
return 5.0
endfunction
// Minimum delay before the orb releases another particle
private constant function ParticleSpawnDelayMin takes integer level returns real
return 0.0
endfunction
// Maximum delay before the orb releases another particle
private constant function ParticleSpawnDelayMax takes integer level returns real
return 0.5
endfunction
// The absorbtion power
private constant function OrbPower takes integer level returns real
return 15.0
endfunction
// Dealt damage when particle hits a target
private constant function Damage takes integer level returns real
return 90.0
endfunction
// Maximum range between the orb and targets to absorb them
private constant function AoE takes integer level returns real
return 400.0
endfunction
// Duration of the spell
private constant function Duration takes integer level returns real
return 15.0
endfunction
// Maximum missile count launched to each target
private constant function MaxCount takes integer level returns integer
return 99
endfunction
// Classifications of targets that can be affected by this spell.
private constant function SpellTargets takes unit target, player caster returns boolean
return IsUnitEnemy(target, caster) and not IsUnitType(target, UNIT_TYPE_STRUCTURE)
endfunction
// You can add any additional effects to the target here
// This function is executed right before the damage is dealt to
// the target
private module DarkMatterDamageEvent
static method onDamage takes unit caster, unit target returns nothing
endmethod
endmodule
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
globals
private constant real INTERVAL = 0.0312500
private location Loc = Location(0, 0)
private group Group = CreateGroup()
private unit Checker = null
endglobals
// Native declaration
native UnitAlive takes unit id returns boolean
// Reset ground unit's position without interrupting orders
private function UnstuckUnit takes unit whichUnit returns nothing
if IsUnitType(whichUnit, UNIT_TYPE_GROUND) then
call SetUnitPosition(Checker, GetUnitX(whichUnit), GetUnitY(whichUnit))
call SetUnitX(whichUnit, GetUnitX(Checker))
call SetUnitY(whichUnit, GetUnitY(Checker))
endif
endfunction
private function GetLocZ takes real x, real y returns real
call MoveLocation(Loc, x, y)
return GetLocationZ(Loc)
endfunction
private function SetUnitZ takes unit u, real z returns nothing
call SetUnitFlyHeight(u, z - GetLocZ(GetUnitX(u), GetUnitY(u)), 0)
endfunction
// Stack used to contain waves
private struct Swirl extends array
unit unit
implement Stack
endstruct
private struct Tornado extends array
Swirl swirl
integer count
real distance
real angle
real rotation
real space
real x
real y
real z
static constant real TAU = 2*bj_PI
method terminate takes nothing returns nothing
local Swirl node = .swirl.first
// Kill all waves
loop
exitwhen node == 0
call KillUnit(node.unit)
set node.unit = null
set node = node.next
endloop
call .swirl.destroy()
call destroy()
endmethod
implement CTL
local real a
local real x2
local real y2
local integer i
local Swirl node
implement CTLExpire
set i = .count
set node = .swirl.first
set .angle = .angle + .rotation
// Iterate update nodes' angles/rotations
loop
exitwhen i <= 0
set a = .angle+.space*i
set x2 = .x+.distance*Cos(a)
set y2 = .y+.distance*Sin(a)
call SetUnitX(node.unit, x2)
call SetUnitY(node.unit, y2)
call SetUnitFacing(node.unit, a*bj_RADTODEG)
call SetUnitZ(node.unit, .z + SWIRL_HEIGHT_Z)
set node = node.next
set i = i - 1
endloop
implement CTLEnd
static method spawn takes player p, integer count, real x, real y, real dist, real rot returns thistype
local thistype this = create()
local integer i = 0
local real a
local real x2
local real y2
local Swirl node
// Allocate stack for waves
set .swirl = Swirl.create()
// Angle difference between each wave
set .space = TAU/count
set .angle = GetRandomReal(-bj_PI, bj_PI)
set .distance = dist
set .rotation = rot
set .count = count
set .x = x
set .y = y
set .z = GetLocZ(x, y) + ORB_HEIGHT_Z
// Create the waves and store into the stack
loop
exitwhen i >= count
// Allocate new node to the stack
set node = .swirl.push()
set a = .angle+.space*i
set x2 = x+dist*Cos(a)
set y2 = y+dist*Sin(a)
set node.unit = CreateUnit(p, SWIRL_WAVE_OBJECT_ID, x2, y2, a*bj_RADTODEG)
call SetUnitScale(node.unit, SWIRL_SCALE, 1, 1)
call SetUnitTimeScale(node.unit, SWIRL_TIME_SCALE)
if SWIRL_HEIGHT_Z > 0 then
static if not LIBRARY_AutoFly then
if UnitAddAbility(node.unit, 'Amrf') and UnitRemoveAbility(node.unit, 'Amrf') then
endif
endif
call SetUnitZ(node.unit, .z + SWIRL_HEIGHT_Z)
endif
set i = i + 1
endloop
return this
endmethod
endstruct
private keyword DarkMatter
// Launch 3D homing missile
private struct SimpleMissile extends array
effect sfx
player owner
group targets
unit caster
unit target
unit missile
real x
real y
real z
real dc
real dx
real damage
real turn
real angle
real speed
method terminate takes nothing returns nothing
// Group is only created if piercing is true
static if PARTICLE_PIERCING then
call DestroyGroup(.targets)
set .targets = null
endif
call DestroyEffect(.sfx)
call UnitApplyTimedLife(.missile, 'BTLF', SFX_DECAY_TIME)
call destroy()
// Remove leaks
set .missile = null
set .target = null
set .caster = null
set .sfx = null
endmethod
implement optional DarkMatterDamageEvent
implement CTL
local real a
local real v
local real h
local real d
local real x
local real y
local unit u
local unit t
local integer rand
implement CTLExpire
set .dc = .dc + .speed
set .x = .x + .speed * Cos(.angle)
set .y = .y + .speed * Sin(.angle)
// Parabola equation
set v = 4 * (.dx-.dc) * (.dc/.dx) + PARTICLE_LAUNCH_Z
// If not supposed to dead yet
if v > 0 and .x < WorldBounds.maxX and .x > WorldBounds.minX and .y < WorldBounds.maxY and .y > WorldBounds.minY and UnitAlive(.caster) then
call SetUnitX(.missile, .x)
call SetUnitY(.missile, .y)
call SetUnitFlyHeight(.missile, v, 0)
// Adjust the angle to face the target
set a = Atan2(GetUnitY(.target)-.y, GetUnitX(.target)-.x)
if Cos(.angle - a) < Cos(.turn) then
if Sin(a - .angle) >= 0 then
set .angle = .angle + .turn
else
set .angle = .angle - .turn
endif
else
set .angle = a
endif
// Determine one random target from all possible targets
static if not PARTICLE_PIERCING then
set t = null
set rand = 0
endif
// Iterates all units around the missile
call GroupEnumUnitsInRange(Group, .x, .y, PARTICLE_HIT_RADIUS, null)
loop
set u = FirstOfGroup(Group)
exitwhen u == null
call GroupRemoveUnit(Group, u)
if UnitAlive(u) and SpellTargets(u, owner) then
set x = GetUnitX(u)
set y = GetUnitY(u)
set h = GetUnitFlyHeight(u) + UNITS_HIT_Z_OFFSET - v
set d = SquareRoot((.x-x)*(.x-x)+(.y-y)*(.y-y))
// 3D spherical collision
if SquareRoot(d*d+h*h) <= PARTICLE_HIT_RADIUS then
static if PARTICLE_PIERCING then
if not IsUnitInGroup(u, .targets) then
static if thistype.onDamage.exists then
call thistype.onDamage(.caster, u)
endif
call UnitDamageTarget(.caster, u, .damage, false, false, PARTICLE_ATTACK_TYPE, PARTICLE_DAMAGE_TYPE, null)
call GroupAddUnit(.targets, u)
endif
else
// Quite effective to obtain random unit from a group
set rand = rand + 1
if GetRandomInt(1, rand) == 1 then
set t = u
endif
endif
endif
endif
endloop
static if not PARTICLE_PIERCING then
// If a target is found
if t != null then
static if thistype.onDamage.exists then
call thistype.onDamage(.caster, t)
endif
call UnitDamageTarget(.caster, t, .damage, false, false, PARTICLE_ATTACK_TYPE, PARTICLE_DAMAGE_TYPE, null)
call terminate()
set t = null
endif
endif
else
call terminate()
endif
implement CTLEnd
static method launch takes DarkMatter source, unit target returns thistype
local thistype this = create()
local real x = GetUnitX(target)
local real y = GetUnitY(target)
set .target = target
set .caster = source.caster
set .owner = source.owner
// Launch from random location nearby the orb
set .x = source.x + GetRandomReal(-source.tornado.distance, source.tornado.distance)
set .y = source.y + GetRandomReal(-source.tornado.distance, source.tornado.distance)
set .angle = GetRandomReal(-bj_PI, bj_PI)
set .missile = CreateUnit(.owner, DUMMY_OBJECT_ID, .x, .y, .angle*bj_RADTODEG)
set .sfx = AddSpecialEffectTarget(PARTICLE_SFX, .missile, "origin")
set .turn = PARTICLE_TURN_SPEED
set .damage = source.damage
set .speed = source.speed
set .dx = source.aoe
set .dc = 0
// Create group if only piercing is true
static if PARTICLE_PIERCING then
set .targets = CreateGroup()
endif
static if not LIBRARY_AutoFly then
if UnitAddAbility(.missile, 'Amrf') and UnitRemoveAbility(.missile, 'Amrf') then
endif
endif
call SetUnitFlyHeight(.missile, PARTICLE_LAUNCH_Z, 0)
call SetUnitScale(.missile, PARTICLE_SCALE, 1, 1)
return this
endmethod
endstruct
// Main spell's struct
private struct DarkMatter extends array
unit orb
unit caster
group targets
Tornado tornado
integer hitx
player owner
effect sfx
real aspd
real aspdo
real aspdx
real speed
real damage
real power
real aoe
real duration
real x
real y
real delay
real delayx
real rotation
real amount
static if LIBRARY_Table then
static TableArray Ht
else
static hashtable Ht
endif
static constant real HP = bj_PI/2
method terminate takes nothing returns nothing
local unit u
// Turn all remaining units' collision back to on
loop
set u = FirstOfGroup(.targets)
exitwhen u == null
call GroupRemoveUnit(.targets, u)
call SetUnitPathing(u, true)
call UnstuckUnit(u)
static if LIBRARY_Table then
call Ht[this].integer.remove(GetHandleId(u))
else
call RemoveSavedInteger(Ht, GetHandleId(u), 0)
endif
endloop
call .tornado.terminate()
call DestroyEffect(.sfx)
call DestroyGroup(.targets)
call UnitApplyTimedLife(.orb, 'BTLF', SFX_DECAY_TIME)
call destroy()
// Remove leaks
set .targets = null
set .caster = null
set .orb = null
set .sfx = null
endmethod
implement CTL
local group g
local boolean b
local integer hand
local integer rand = 0
local unit t = null
local unit u
local real d
local real x
local real y
local real h
local real a
local real pow
implement CTLExpire
if .duration > INTERVAL and UnitAlive(.caster) then
set .duration = .duration - INTERVAL
// Iterate through all units around the orb (within aoe).
call GroupEnumUnitsInRange(Group, .x, .y, .aoe, null)
loop
set u = FirstOfGroup(Group)
exitwhen u == null
call GroupRemoveUnit(Group, u)
if UnitAlive(u) and SpellTargets(u, owner) then
set x = GetUnitX(u)
set y = GetUnitY(u)
set d = SquareRoot((.x-x)*(.x-x)+(.y-y)*(.y-y))
// Power is affected by distance between orb and the target.
set pow = .power - .power*(d/.aoe)*ORB_POWER_FACTOR
// Calculate target angle.
set a = Atan2(.y-y, .x-x)-(HP*(d/.aoe))*.rotation
if not IsUnitInGroup(u, .targets) then
call GroupAddUnit(.targets, u)
call SetUnitPathing(u, false)
endif
if .aspd <= INTERVAL then
static if LIBRARY_Table then
set b = Ht[this].integer[GetHandleId(u)] < .hitx
else
set b = LoadInteger(Ht, this, GetHandleId(u)) < .hitx
endif
if b then
set rand = rand + 1
if GetRandomInt(1, rand) == 1 then
set t = u
endif
endif
endif
if d > pow then
call SetUnitX(u, x + pow * Cos(a))
call SetUnitY(u, y + pow * Sin(a))
else
call SetUnitX(u, .x)
call SetUnitY(u, .y)
endif
endif
endloop
// Iterates all affected units which have
// escaped the spell area and turn their
// collision on.
set g = .targets
set .targets = CreateGroup()
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g, u)
set x = GetUnitX(u)
set y = GetUnitY(u)
if SquareRoot((.x-x)*(.x-x)+(.y-y)*(.y-y)) > .aoe then
call SetUnitPathing(u, true)
call UnstuckUnit(u)
static if LIBRARY_Table then
call Ht[this].integer.remove(GetHandleId(u))
else
call RemoveSavedInteger(Ht, this, GetHandleId(u))
endif
else
call GroupAddUnit(.targets, u)
endif
endloop
if .aspd > INTERVAL then
set .aspd = .aspd - INTERVAL
elseif t != null then
// Launch missile if a random target is found
set .aspd = GetRandomReal(.aspdo, .aspdx)
call SimpleMissile.launch(this, t)
set hand = GetHandleId(t)
static if LIBRARY_Table then
set Ht[this].integer[hand] = Ht[this].integer[hand] + 1
else
call SaveInteger(Ht, this, hand, LoadInteger(Ht, this, hand) + 1)
endif
set t = null
endif
// Remove leaks
call DestroyGroup(g)
set g = null
else
call terminate()
endif
implement CTLEnd
static method onCast takes nothing returns nothing
local thistype this = create()
local integer l
set .caster = GetTriggerUnit()
set .owner = GetTriggerPlayer()
set .x = GetSpellTargetX()
set .y = GetSpellTargetY()
set .targets = CreateGroup()
set l = GetUnitAbilityLevel(.caster, SPELL_OBJECT_ID)
set .orb = CreateUnit(.owner, DUMMY_OBJECT_ID, .x, .y, 270)
set .sfx = AddSpecialEffectTarget(ORB_SFX, .orb, "origin")
set .duration = Duration(l)
set .power = OrbPower(l)
set .aoe = AoE(l)
set .rotation = SwirlRotation(l)
set .tornado = Tornado.spawn(.owner, SwirlCount(l), .x, .y, SwirlRadius(l), .rotation)
// Get the rotation direction
set .rotation = .rotation/RAbsBJ(.rotation)
set .speed = ParticleSpeed(l)
set .damage = Damage(l)
set .hitx = MaxCount(l)
set .aspdx = ParticleSpawnDelayMax(l)
set .aspdo = ParticleSpawnDelayMin(l)
set .aspd = GetRandomReal(.aspdo, .aspdx)
call SetUnitScale(.orb, ORB_SCALE, 1, 1)
if ORB_HEIGHT_Z > 0 then
static if not LIBRARY_AutoFly then
if UnitAddAbility(.orb, 'Amrf') and UnitRemoveAbility(.orb, 'Amrf') then
endif
endif
call SetUnitFlyHeight(.orb, ORB_HEIGHT_Z, 0)
endif
endmethod
static if not LIBRARY_SpellEffectEvent then
private static method check takes nothing returns boolean
if GetSpellAbilityId() == SPELL_OBJECT_ID then
call thistype.onCast()
endif
return false
endmethod
endif
static method onInit takes nothing returns nothing
local trigger t
static if LIBRARY_SpellEffectEvent then
call RegisterSpellEffectEvent(SPELL_OBJECT_ID, function thistype.onCast)
else
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function thistype.check))
endif
static if LIBRARY_Table then
set Ht = TableArray[0x2000]
else
set Ht = InitHashtable()
endif
set Checker = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'uabo', 0, 0, 0)
call PauseUnit(Checker, true)
call ShowUnit(Checker, false)
endmethod
endstruct
endscope