1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. The poll for our 11th Music Contest is up! Help us choose the most awesome cinematic tracks by casting a vote!
    Dismiss Notice
  3. Melee Mapping contest #3 - Poll is up! Vote for the best 4v4 melee maps!
    Dismiss Notice
  4. The 30th edition of the Modeling Contest is finally up! The Portable Buildings need your attention, so come along and have a blast!
    Dismiss Notice
  5. The Aftermath has been revealed for the 19th Terraining Contest! Be sure to check out the Results and see what came out of it.
    Dismiss Notice

GUI SpellEvent v2.1.0.0

Submitted by Magtheridon96
This bundle is marked as approved. It works and satisfies the submission rules.
This resource provides GUIers with the ability to benefit from something like SpellEffectEvent by Bribe :)
I would like to give full credit to Bribe for this system because it's entirely based on his SpellEffectEvent!

The performance gain is incredible.
What it does is use only one trigger to evaluate one spell trigger rather than a thousand.
I coded it in GUI-Jass, so it doesn't require JNGP.

The GUI-Jass idea is Bribe's as well :)
GUI creates the variables automatically, and if you use custom scripts for most of the code, it turns out to be just as efficient as Jass ^_^

Triggers
  • GUI SpellEvent
    • Events
    • Conditions
    • Actions
      • Custom script: local integer i = 1
      • -------- - --------
      • -------- Call the initialization function. --------
      • -------- - --------
      • Custom script: call ExecuteFunc("InitSpellEvent")
      • -------- - --------
      • -------- Creating the hashtable. --------
      • -------- - --------
      • Hashtable - Create a hashtable
      • Set SpellEventHash = (Last created hashtable)
      • -------- - --------
      • -------- Over here, I'm just looping through all the abilities to be registered and saving the triggers in a hashtable. --------
      • -------- - --------
      • Custom script: loop
      • Custom script: exitwhen udg_SpellEventAbility[i] == 0
      • Custom script: call SaveTriggerHandle(udg_SpellEventHash, udg_SpellEventAbility[i], 0, udg_SpellEventTrigger[i])
      • Custom script: set i = i + 1
      • Custom script: endloop
      • Custom script: endfunction
      • -------- - --------
      • -------- This function only evaluates and executes one trigger instead of evaluating a thousand triggers and executing one. --------
      • -------- - --------
      • Custom script: function OnSpell takes nothing returns boolean
      • Custom script: local trigger t = LoadTriggerHandle(udg_SpellEventHash, GetSpellAbilityId(), 0)
      • -------- - --------
      • -------- If the conditions return true, do the actions. --------
      • -------- If none of your spell triggers have conditions, you can optimize this system by deleting the 1st and 3rd custom scripts after this. --------
      • -------- - --------
      • Custom script: if TriggerEvaluate(t) then
      • Custom script: call TriggerExecute(t)
      • Custom script: endif
      • -------- - --------
      • Custom script: set t = null
      • Custom script: return false
      • Custom script: endfunction
      • -------- - --------
      • -------- This is the Initialization function of the entire system. --------
      • -------- - --------
      • Custom script: function InitSpellEvent takes nothing returns nothing
      • Custom script: local trigger t = CreateTrigger()
      • Custom script: call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
      • Custom script: call TriggerAddCondition(t, Condition(function OnSpell))
      • Custom script: set t = null
      • -------- - --------
      • -------- The only purpose of this is to automatically create the variables. --------
      • -------- - --------
      • Set SpellEventTrigger[0] = (This trigger)
      • Set SpellEventAbility[0] = Orb of Slow
      • -------- - --------


As you can see, this system is very short and easy to implement because all you have to do is:

1) Open up the trigger editor
2) Copy and paste the trigger to your map (Make sure you go to File >> Preferences and check "Create unknown variables when pasting trigger data")
3) Done!

Usage
  • SpellInit
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Set Abilities --------
      • Set SpellEventAbility[1] = Blizzard
      • Set SpellEventAbility[2] = MassTeleport
      • Set SpellEventAbility[3] = Summon Water Elemental
      • Set SpellEventAbility[4] = Holy Light
      • Set SpellEventAbility[5] = Resurrection
      • Set SpellEventAbility[6] = Divine Shield
      • -------- Set Triggers --------
      • Set SpellEventTrigger[1] = CastBlizzard <gen>
      • Set SpellEventTrigger[2] = CastMassTeleport <gen>
      • Set SpellEventTrigger[3] = CastSummonWaterElemental <gen>
      • Set SpellEventTrigger[4] = CastHolyLight <gen>
      • Set SpellEventTrigger[5] = CastResurrection <gen>
      • Set SpellEventTrigger[6] = CastDivineShield <gen>
      • -------- Run the Initialization Trigger --------
      • Trigger - Run SpellEvent GUI <gen> (ignoring conditions)


This will register your spells to the system. When a unit casts SpellEventAbility, SpellEventTrigger will run (while checking conditions in-case you need them.)

You don't need to check what ability is being cast in your spell trigger =)

Warnings
  • You may not register more than one trigger for a spell.
    If you really want two triggers to run, then the solution would be to execute the second trigger in the first line of the first trigger's actions. Either that, or you could merge the triggers. There are no obvious examples of how two triggers registered to the spell effect event for the same spell is the only way to go.
  • Make sure you run the SpellEvent GUI trigger only once.
  • Don't touch any of the custom scripts unless instructed to do so within the comments.


Changelog
  • v1.0.0.0
    • Release
  • v1.0.0.1
    • Simplified Implementation by making all variables Auto-create.
    • Added some comments.
  • v2.0.0.0
    • The whole system is now in one trigger only.
    • Faster and better way of registering spells to the system.
    • Added more comments.
    • Fixed possible bug.
  • v2.1.0.0
    • You don't need the count variable during registration any more.


Keywords:
spell, event, effect, spells, cast, system, event engine, engine, Bribe, Nestharus, Magtheridon96, DotA, naruto, omnislash, meathook, kamehameha.
Contents

Just another Warcraft III map (Map)

Reviews
Moderator
Everyone should use this for their GUI spells.
  1. Reviewed by Maker, GUI SpellEvent v1.0.0.0, 3rd Mar 2012

    Everyone should use this for their GUI spells.
     
  2. gorillabull

    gorillabull

    Joined:
    Jul 17, 2011
    Messages:
    1,368
    Resources:
    2
    Spells:
    2
    Resources:
    2
    i dont get it
     
  3. Arhowk

    Arhowk

    Joined:
    Aug 8, 2007
    Messages:
    2,753
    Resources:
    0
    Resources:
    0
    Neither do I. What does this do besides storing ability being cast into a global
     
  4. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,004
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    If you assign "A unit starts the effects of an ability" to 400 triggers, you're creating 400 * 16 = 6400 spell effect events, and whenever a unit casts a spell, the conditions of all these 400 triggers will be evaluated (400 Trigger Evaluations :O)

    With this, there will always be only 1 trigger evaluation/trigger execution per spell cast and only 16 spell effect events!

    That's why this increases performance and keeps your FPS pretty high whenever a unit casts a spell!

    Spell-spamming should never cause as much lag as it did ever again ;)
     
  5. Deaod

    Deaod

    Joined:
    Nov 18, 2007
    Messages:
    804
    Resources:
    12
    Maps:
    1
    Spells:
    11
    Resources:
    12
    You forgot to mention that with this, there can only ever be one trigger responding to a particular spells effect. You cant have two triggers responding to the same spell.
    You can of course argue that having two triggers respond to the same spell is bad practice and id agree. But you didnt mention this limitation.

    Also, the concept you follow originated in 2009 at thehelper.net and wc3c.net.
     
  6. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,004
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    I acknowledged that, but I can't come up with any good reasons as to why someone would want two triggers to run when you cast 1 spell :/

    I will update the description with a disclaimer and solution to the problem.

    Yeah, I know the idea isn't new :3
     
  7. Quilnez

    Quilnez

    Joined:
    Oct 12, 2011
    Messages:
    3,161
    Resources:
    37
    Icons:
    2
    Tools:
    1
    Maps:
    7
    Spells:
    21
    Tutorials:
    2
    JASS:
    4
    Resources:
    37
    do you attach a spell for the example? I don't know anything to do with this (I haven't try this out yet).. :/
     
  8. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,004
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    All you need to do is remove the "A unit starts the effects of a spell" event from your spell trigger, and register your spell to the system like this:

    Trig
    • Set SpellEventAbility = MyAbility
    • Set SpellEventTrigger = MyTrigger
    • Trigger - Run GUI SpellEvent (ignoring conditions)


    And guess what, you don't even need to add conditions to check what the ability being cast is :)

    edit
    Updated.
    Now has easier implementation.
    The SpellEventAbility and SpellEventTrigger variables weren't auto-created before.
     
  9. Jay the Editor

    Jay the Editor

    Joined:
    Aug 12, 2008
    Messages:
    317
    Resources:
    6
    Icons:
    2
    Spells:
    4
    Resources:
    6
    I'm still not sure how to implement it. How if I want to register more than 1 spell?
    Set it up right after I set up the first one?
    • Set SpellEventAbility = MyAbility
    • Set SpellEventTrigger = MyTrigger
    • Trigger - Run GUI SpellEvent (ignoring conditions)
    • Set SpellEventAbility = MyAbility2
    • Set SpellEventTrigger = MyTrigger2
    • Trigger - Run GUI SpellEvent (ignoring conditions)


    EDIT: Ohh you updated it. I got it now. Thanks. Epic system :D
     
  10. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,004
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    I'm glad I cleared everything up :3
    If there's anything else that seems unclear, be sure to point that out ;)
     
  11. maddeem

    maddeem

    Joined:
    Jan 1, 2011
    Messages:
    1,209
    Resources:
    5
    Maps:
    2
    Spells:
    3
    Resources:
    5
    This is mighty useful if you want to efficientize your map ;p
    Very good work.
     
  12. Arhowk

    Arhowk

    Joined:
    Aug 8, 2007
    Messages:
    2,753
    Resources:
    0
    Resources:
    0
    Makes sense.

    The only problem i have with it is, how would i get target of ability / unit target of ability?
     
  13. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,004
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    You'd do it the same way you did before :>
     
  14. shadowvzs

    shadowvzs

    Joined:
    Nov 13, 2006
    Messages:
    1,803
    Resources:
    2
    Spells:
    2
    Resources:
    2
    this faster than useing special unit event?

    i mean compared with this

    for a=1 to 12
    if player(a-1) is playing and player(a-1) is user then
    add event udg_hero[a] cast spell
    endif
    endloop

    another side i am glad coz i waited for this, for non vjass version :D
    (i think here also cant use triggerspeel right?)
     
  15. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,004
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    I'm not going to filter out players who aren't users or aren't playing because some people could use those players for AIs and stuff :p

    Everything that could've been done before, could be done here. (Including TriggerSleepAction)
     
  16. shadowvzs

    shadowvzs

    Joined:
    Nov 13, 2006
    Messages:
    1,803
    Resources:
    2
    Spells:
    2
    Resources:
    2
    ok ok but if we talk theoritical then useing specific unit events then it is faster for rpgs where only heroes can get that abilities?

    another question it's use ability start effect right? so not begins casting an ability,right?

    i asked the triggersleep thing coz once i checked last timer RegisterPlayerUnitEvent then there was problem with wait, no? i thought this work same way jass converted to jass from vjass
     
    Last edited: Mar 4, 2012
  17. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    7,736
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    No, this doesn't have the same problem with waits, because he executes the trigger instead of evaluating it.
     
  18. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,004
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    RegisterPlayerUnitEvent had a problem with waits because I didn't want it to be 2-3x slower :p

    In this version, I'm forced to execute the trigger instead of just evaluating it because in GUI, you can't put all the code in the conditions block D:

    The speed gain would be very marginal ;p
    I don't want to complicate things and give users the ability to configure which players get registered to the system and which players don't D:
    A user who has some knowledge of Jass could do that by himself and a GUI user would only loose an amount of speed so little, even Nestharus wouldn't care =P

    Yeah, it registers triggers to the start ability effect event.
    This is because it's the most commonly used event for spells.
    You don't need a system to handle the channel and begin cast events because typically, for every 100 or so spells, you might have 5-20 that use those events, so you wouldn't gain a worthwhile amount of performance ;/

    You would gain performance, but not as much as you would with this ;P
     
  19. zv27

    zv27

    Joined:
    Aug 21, 2010
    Messages:
    296
    Resources:
    0
    Resources:
    0
    1.The system is very good...

    2.This is absolutely unnecessary - set SpellEventTrigger = (ThisTrigger),set SpellEventAbility = Lesser Clarity Potion

    3.The only thing that I personally do not like in this system is,constant repetition of the system trigger [Trigger - Run GUI SpellEvent <gen> (ignoring conditions)
    ] so I started working on this a bit and the result is excellent. Now only need one call system trigger.

    4.OMG you gave me a good idea with this!!!

    5.Sorry I forgot to say 5/5