- Joined
- Nov 4, 2007
- Messages
- 337
Well, there was just submitted 'NewSpell'.
I made something similar with more functionality a couple weeks ago.
So this allows you to registry events easier and more efficient.
The good thing about this: If you registry spell events (ability, action), no conditions at all have to be checked.
I made something similar with more functionality a couple weeks ago.
So this allows you to registry events easier and more efficient.
The good thing about this: If you registry spell events (ability, action), no conditions at all have to be checked.
JASS:
library UnitEavents initializer Init requires Table
//! textmacro SpellEvent takes takes NAME, EVENTTYPE
globals
private Table $NAME$Registry
private integer $NAME$regCount = 0
private trigger array $NAME$Data
private trigger $NAME$Fire
endglobals
function Registry$NAME$Event takes code action, integer ID returns nothing
set $NAME$regCount = $NAME$regCount + 1
set $NAME$Data[$NAME$regCount] = CreateTrigger()
call TriggerAddCondition($NAME$Data[$NAME$regCount],action)
set $NAME$Registry[ID] = $NAME$regCount
endfunction
function Destroy$NAME$Event takes integer ID returns nothing
set $NAME$Data[$NAME$Registry[ID]] = $NAME$Data[$NAME$regCount]
set $NAME$regCount = $NAME$regCount - 1
call $NAME$Registry.flush(ID)
endfunction
private function Fire$NAME$Registries takes nothing returns nothing
call TriggerExecute($NAME$Data[$NAME$Registry[GetSpellAbilityId()]])
endfunction
private function Init$NAME$Events takes nothing returns nothing
set $NAME$Registry = Table.create()
set $NAME$Fire = CreateTrigger()
call TriggerAddAction($NAME$Fire,function Fire$NAME$Registries)
call TriggerRegisterAnyUnitEventBJ( $NAME$Fire, $EVENTTYPE$ )
endfunction
//! endtextmacro
//! runtextmacro SpellEvent("SpellEffect","EVENT_PLAYER_UNIT_SPELL_EFFECT")
//! runtextmacro SpellEvent("SpellStart","EVENT_PLAYER_UNIT_SPELL_CAST")
//! runtextmacro SpellEvent("SpellStop","EVENT_PLAYER_UNIT_SPELL_ENDCAST")
private function Init takes nothing returns nothing
call InitSpellStartEvents()
call InitSpellStopEvents()
call InitSpellEffectEvents()
endfunction
endlibrary
Last edited: