Moderator
M
Moderator
Reviewed by Maker, GUI SpellEvent v1.0.0.0, 3rd Mar 2012
Everyone should use this for their GUI spells.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
(11 ratings)
Approved
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


-------- - --------
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)
Reviewed by Maker, GUI SpellEvent v1.0.0.0, 3rd Mar 2012
Everyone should use this for their GUI spells.
Also, the concept you follow originated in 2009 at thehelper.net and wc3c.net.
Set SpellEventAbility = MyAbility
Set SpellEventTrigger = MyTrigger
Trigger - Run GUI SpellEvent (ignoring conditions)
Set SpellEventAbility = MyAbility
Set SpellEventTrigger = MyTrigger
Trigger - Run GUI SpellEvent (ignoring conditions)
Set SpellEventAbility = MyAbility2
Set SpellEventTrigger = MyTrigger2
Trigger - Run GUI SpellEvent (ignoring conditions)
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
Everything that could've been done before, could be done here. (Including TriggerSleepAction)
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
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?
2.This is absolutely unnecessary - set SpellEventTrigger = (ThisTrigger),set SpellEventAbility = Lesser Clarity Potion
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
3) Eh sorta true but its essentially the only way to do it besides having 8192 variables, which would lag even more
-------- 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>
-------- Set Number of Abilities --------
Set SpellEventCount = 6
-------- Run the Initialization Trigger --------
Trigger - Run SpellEvent GUI <gen> (ignoring conditions)
Or I could use an array and add 1 more variable to store the number of spells :3
-------- 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>
-------- Set Number of Abilities --------
Set SpellEventCount = 6
-------- Run the Initialization Trigger --------
Trigger - Run SpellEvent GUI <gen> (ignoring conditions)
@Magtheridon96/Bribe ty
rofl, i have over 50 variable array if not more and u dont see any lagg after initilizing
sorry but u dont know how its work in wacraft or just underestimate it
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![]()
variable arrays dont matter. its the 8192 arrays that kill. I had about ~10 8192 variables in my map once and the game wouldn't run any user-defined triggers whatsoever because of a handle overload due to the array size
king_drift_alex said:So, can it now be used ?

