• 🏆 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!

GUI SpellEvent v2.1.0.0

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 ^_^

  • 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!

  • 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 =)

  • 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.

  • 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
Everyone should use this for their GUI spells.
The only tricky part is the API.

How would a GUIer create a missile?

People usually go for this approach:

  • Set MissileTargetX = 0.00
  • Set MissileTargetY = 0.00
  • Set MissileHoming = False
  • Set MissileSpeed = 700.00
  • Trigger - Run CreateMissile <gen> (ignore conditions)
But I want to develop a much better way :eek:

A single line of Jass script could be fine, but I don't find that GUI Friendly :eek:
 
I have an idea:
  • Set MissileTargetX = 0.00
  • Set MissileTargetY = 0.00
  • Set MissileHoming = False
  • Set MissileSpeed = 700.00
  • Custom script: call CreateMissile()
Triggers are way too slow :p

Why not
  • Custom script: call CreateMissile(0.00,0.00,false,700.00)
would definitely simplify the function :p
 
Level 16
Joined
Apr 4, 2011
Messages
995
How is this resource not DC'd? Honestly such an amazing resource, way better then [self=http://www.hiveworkshop.com/forums/spells-569/summon-roflcopter-v0-3-a-185808/?prev=mmr%3D6]this useless resource[/self], and will be used in way, way more maps.
 
Last edited by a moderator:
Thanks guys :D
This can't get a DC because it's not /awesome/ enough.

I do have another resource in this section worthy of a DC though ;)
The update is going to be /outstanding/

edit
Actually, I still prefer SpellEffectEvent because it's super-easy-to-use :p
I just have to call RegisterSpellEffectEvent(ABIL_CODE, function thistype.run) :D
 
Last edited:

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
How is this resource not DC'd? Honestly such an amazing resource, way better then [self=http://www.hiveworkshop.com/forums/spells-569/summon-roflcopter-v0-3-a-185808/?prev=mmr%3D6]this useless resource[/self], and will be used in way, way more maps.

Maybe we should rename Director's Cut to "Staff Favorites". Because it's apparent that people think it means "Community Favorites". If you want to see the community favorites, view the "most popular" or "highest rated" spells.

Also, easy on the language.

64540.jpg
 
Level 14
Joined
Aug 31, 2009
Messages
775
Fantastic resource.

Me and my Co-Mapper have absolutely no clue how it manages to maintain instances of things like "Triggering Unit" in our custom spells once we converted to this system format, but by god it works and we like it.

5/5 for an amazingly simple and effective system, even if we can't for the life of us work out why it works.
 
Because triggers work like this:

Code:
Trigger:
---- event
---- condition
---- action

Trigger Execution instance:
---- triggering unit
---- triggering player
---- chatstring
---- chatstringMatched
---- dyingUnit
---- killingUnit
---- damageSource
---- eventDamage
---- itemManipulated
---- unitManipulating
etc...

When Event runs:
---- create new Trigger Execution data:
-------- set triggering unit for this instance
-------- set triggering player for this instance
-------- set chatstring for this instance
-------- set chatstringMatched for this instance
-------- set dyingUnit for this instance
-------- set killingUnit for this instance
-------- set damageSource for this instance
-------- set eventDamage for this instance
-------- set itemManipulated for this instance
-------- set unitManipulating for this instance
-------- etc...
---- if conditions are true
-------- do actions

But, the above only happens when an event runs.
If we execute a trigger, it only checks the conditions and then executes the actions.

See, what I did is register 1 trigger that runs when a spell effect event occurs :D

When a spell effect runs, I run only the trigger that corresponds to your spell.

Since the trigger in my system has the data for the triggering unit and such, that data
will be the same for any trigger you use because I'm executing it, not running it by the
event, so the data doesn't change, it uses the data that the parent trigger had :D
 
Level 14
Joined
Aug 31, 2009
Messages
775
So it's been quite a few years now Mr. Magtheridon but this system of yours has withstood the test of time.

It's made it into my and co-mapper's "hall of fame" for systems, and we now use it in every single thing we make now in WCIII.

Previously we used it in a map with about 100ish custom spells, but now it's being used in a map with approximately 500 custom spells and "is attacked" triggers being used. The performance gain is pretty epic.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Damage, I recommend you check out Spell System as it is an upgraded version of this system. http://www.hiveworkshop.com/forums/spells-569/gui-spell-system-v1-5-1-0-a-273415/

Edit: for future readers, I made this little snippet which you can use to replace Magtheridon's GUI SpellEvent if you are using GUI Spell System:

JASS:
function InitSpellEvent takes nothing returns nothing
    local integer i = 1
    loop
        exitwhen udg_SpellEventAbility[i] == 0
        set udg_Spell__Ability = udg_SpellEventAbility[i]
        set udg_Spell__Trigger_OnEffect = udg_SpellEventTrigger[i]
        call TriggerExecute(gg_trg_Spell_System)
        set i = i + 1
    endloop
endfunction

function InitTrig_GUI_SpellEvent takes nothing returns nothing
    set gg_trg_GUI_SpellEvent = CreateTrigger()
    call TriggerAddAction(gg_trg_GUI_SpellEvent, function InitSpellEvent)
endfunction
 
Last edited:

Deleted member 247165

D

Deleted member 247165

Have no words to describe how cool this spell is! <3 5/5!
 
Last edited by a moderator:
Level 7
Joined
Jul 4, 2007
Messages
249
I didn't even know it affected performance having lots of the same events, so thank you for the wisdom aswell as for this wonderful solution :D

Edit: What can I do if I want to use starts the effect of an ability in general, without recognizing a certain ability? Is it possible?
For example if I'd wanna use it with a different condition
  • Events
    • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Casting unit) has an item of type |c00EED0FFTome of Experience|r) Equal to True
    • Actions
 
Last edited:

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Uhm. What does this system do? I don't understand.
It tries to solve about 20 miscellaneous issues related to spell building that - once mastered - streamlines the ability to produce spells at ease.

However, I would highly recommend the Lua version over this, as its objectives are much more easily met and don't suffer from feature bloat.

Edit: thought I was here: GUI Spell System v1.8.0.0. I had no idea this was a different thing.
 
Last edited:
Top