• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Easevent

Level 11
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.

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:
Level 8
Joined
Aug 6, 2008
Messages
451
You should not make systems like these, unless they are to fix Blizzards fucked up event responses like SpellEvent does.

Otherwise you just post bunch of BJs, which only shortern your code by few lines and thats all.

For those other events you should provide some priorities, so people can control the order in which triggers are executed.

For example some trigger that is supposed to prevent unit from attacking allies should run before some other trigger that damages guys who attack some specific target target so you can just skip firing all those later attack thingies, because attack never really happened. ( I think Rising Dusks damage detection has some stuff like that ).
 
Level 8
Joined
Oct 3, 2008
Messages
367
I like this better than Cheezeman's system. This one shaves event handles.

Just add some support for triggerconditions, because I don't use triggeractions. And make the system use conditions internally.

Also, all functions except for registration and destruction should be privatised and the initializers should be called from a library Init function.
 
Well, plenty of these have been made but they usually fix bugs and such, like Viikuna said.
So I don't really see the point of this one, as it just looks like a bunch of wrapper functions and provides nothing really new for spell makers, except saving them a line or two. You also don't have any safety when executing triggers.

I'm going to graveyard this soon unless you have some extraordinary reply explaining why this deserves to be approved.
 
Top