1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  4. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  5. Units have been turned into heroes in our latest Icon Contest! Vote for the best icon set at the Icon Contest #18 Poll!
    Dismiss Notice
  6. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  7. The raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    Dismiss Notice
  8. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Easevent

Discussion in 'Graveyard' started by MapperMalte, Nov 7, 2009.

  1. MapperMalte

    MapperMalte

    Joined:
    Nov 4, 2007
    Messages:
    326
    Resources:
    5
    Maps:
    2
    Spells:
    2
    JASS:
    1
    Resources:
    5
    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.

    Code (vJASS):

    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: Nov 7, 2009
  2. Viikuna

    Viikuna

    Joined:
    Aug 6, 2008
    Messages:
    430
    Resources:
    0
    Resources:
    0
    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 ).
     
  3. MapperMalte

    MapperMalte

    Joined:
    Nov 4, 2007
    Messages:
    326
    Resources:
    5
    Maps:
    2
    Spells:
    2
    JASS:
    1
    Resources:
    5
    Well, I agree with you that this is not very useful.
    Just for SpellEvents.
    This can just registry one trigger per id and event, so you don't need orders.
     
  4. Cheezeman

    Cheezeman

    Joined:
    Aug 19, 2008
    Messages:
    437
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    What I miss is a header, because I can't tell how to use it.
    Probably because I havn't used textmacros and structs too much.

    Could you tell me about the pro/cons of your system (compared to mine?)
     
  5. MapperMalte

    MapperMalte

    Joined:
    Nov 4, 2007
    Messages:
    326
    Resources:
    5
    Maps:
    2
    Spells:
    2
    JASS:
    1
    Resources:
    5
    call RegistrySpellStartEvent(SpellId,code action) is an example.
    This saves the trigger in a table with the index spellId.
    If the spell is casted, the trigger referring to the table is casted.
     
  6. azlier

    azlier

    Joined:
    Oct 3, 2008
    Messages:
    354
    Resources:
    4
    JASS:
    4
    Resources:
    4
    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.
     
  7. MapperMalte

    MapperMalte

    Joined:
    Nov 4, 2007
    Messages:
    326
    Resources:
    5
    Maps:
    2
    Spells:
    2
    JASS:
    1
    Resources:
    5
    Ty,
    most things done.
     
  8. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    3,662
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
    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.
     
  9. MapperMalte

    MapperMalte

    Joined:
    Nov 4, 2007
    Messages:
    326
    Resources:
    5
    Maps:
    2
    Spells:
    2
    JASS:
    1
    Resources:
    5
    Me not either. Just submitted it because I am an asshole ans wanted to show sb. how useless his system is, because he did not want to accept it. I wonder why this has not been graveyarded much earlier.