The wait ruins the MUI.
Basically you do this:
set LS_Caster[1] = Unit
(Do something)
Unit - remove ability from LS_Caster[1]
BUT, if 2 instances run in those 20 seconds:
Set LS_Caster[1] = unit
(Do something)
Set LS_Caster[2] = Unit
(Do something)
Unit - remove ability from LS_Caster[2]
Unit - remove ability from LS_Caster[2]
Because the LS_Times is a global variable and will always stay the same, it is not MUI.
Methods of making this MUI:
- The easiest: JASS. Yes, this is the easiest method. All you need to do is create a LOCAL variable and you've got your MUI.
- The most general for GUI: Hashtables. Hashtables requires you to create another trigger which is looped. You also need to store a few variables inside the hashtable.
- The hardest: Indexing. Indexing (if done well) is harder than hashtables. Of course, once you've got a standard indexing setup it's always the same - the problem is you don't have one
Let's start with JASS.
-
lava shield on
-
Events
-
Unit - A unit Starts the effect of an ability
-
Conditions
-
(Ability being cast) Equal to Lava Shield
-
Actions
-
Custom script: local unit caster = GetSpellAbilityUnit()
-
Custom script: call UnitAddAbility(caster, 'Apxf')
-
Wait 20.00 seconds
-
Custom script: call UnitRemoveAbility(caster, 'Apxf')
-
Custom script: set u = null
That's it
Because of the nature of local variables, this is MUI.
Local variables cannot be overwritten, so basically every time the spell is cast, a new variable "caster" will be created.
The 'Apxf' is the default rawcode of Phoenix Fire.
If you used a custom ability instead of Phoenix Fire, then press CTRL + D in the object editor and check the rawcode of your spell.
This is the hashtable method:
-
Hashtable Init
-
Events
-
Conditions
-
Actions
-
Hashtable - Create a hashtable
-
Set SpellTable = (Last created hashtable)
-
Spell Cast
-
Events
-
Unit - A unit Starts the effect of an ability
-
Conditions
-
Actions
-
Set HandleID = (Key (Triggering unit))
-
Unit - Add Phoenix Fire to (Triggering unit)
-
Hashtable - Save 0.00 as 0 of HandleID in SpellTable
-
Hashtable - Save 20.00 as 1 of HandleID in SpellTable
-
Unit Group - Add (Triggering unit) to SpellGroup
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Spell Loop <gen> is on) Equal to False
-
Then - Actions
-
Trigger - Turn on Spell Loop <gen>
-
Else - Actions
-
Spell Loop
-
Events
-
Time - Every 0.25 seconds of game time
-
Conditions
-
Actions
-
Unit Group - Pick every unit in SpellGroup and do (Actions)
-
Loop - Actions
-
Set HandleID = (Key (Picked unit))
-
Hashtable - Save ((Load 0 of HandleID from SpellTable) + 0.25) as 0 of HandleID in SpellTable
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Load 0 of HandleID from SpellTable) Greater than or equal to (Load 1 of HandleID from SpellTable)
-
Then - Actions
-
Unit - Remove Phoenix Fire from (Picked unit)
-
Unit Group - Remove (Picked unit) from SpellGroup
-
Hashtable - Clear all child hashtables of child HandleID in SpellTable
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(SpellGroup is empty) Equal to True
-
Then - Actions
-
Trigger - Turn off (This trigger)
-
Else - Actions
-
Else - Actions
Absolutely futile to add so much code, isn't it?
Just pick the JASS method, really...
And I highly advice you to learn some JASS in the meanwhile ^^