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

Cant get Lava Shield MUI

Status
Not open for further replies.
Level 7
Joined
Jun 15, 2010
Messages
218
So im trying to learn MUI. still i cant understand it.
I got this ability Lava Shield. Can anyone tell me how to make this MUI and help me understand it. making it MPI is fine for me aswell.

  • lava shield on
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Lava Shield
    • Actions
      • Set LS_Times = (LS_Times + 1)
      • Set LS_Caster[LS_Times] = (Casting unit)
      • Unit - Add Phoenix Fire to LS_Caster[LS_Times]
      • Wait 20.00 seconds
      • Unit - Remove Phoenix Fire from LS_Caster[LS_Times]
+rep
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
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 :D

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 :D
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
      • Map initialization
    • 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... :p
And I highly advice you to learn some JASS in the meanwhile ^^
 
Level 8
Joined
Mar 26, 2009
Messages
301
ap0calypse did a pretty good job explaining all possible methods. If you don't have time for learning jass right now (personally I never had =p) just stick to individually creating triggers for all players method. (Unless, of course, each player has more than one caster for that spell; or if cooldown is shorter than the total trigger wait time)
 
Level 7
Joined
Jun 15, 2010
Messages
218
is it ectualy possible to combine jass and GUI? like using local variable from jass:
  • Custom script: local unit caster = GetSpellAbilityUnit()
and then the rest GUI, what probeley become someting like:
  • lava shield on
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Lava Shield
    • Actions
      • Custom script: Custom script: local unit caster = GetSpellAbilityUnit()
      • Unit - Add Phoenix Fire to [the_JASS_used_localunit]
      • Wait 20.00 seconds
      • Unit - Remove Phoenix Fire from [the_JASS_used_local_unit]
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Yes it is, but to do that you'll have to cheat :D

First things first:
A global variable (the variable you create with the variable editor) always has "udg_" in front of its name.
So if you create a global variable called "Caster", then it becomes "udg_Caster".

Now here's the trick:

  • 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 udg_Caster = GetSpellAbilityUnit()
      • Unit - Add Phoenix Fire to Caster
      • Wait 20.00 seconds
      • Unit - Remove Phoenix Fire from Caster
      • Custom script: set udg_Caster = null
Because you created a global variable, you can use that in regular GUI.
BUT: according to the trigger, you're creating a LOCAL variable with the exact same name.
Now you basically transformed that global variable into a local one.
Aside from that, you can still use the variable "Caster" in another trigger and it still won't mix up ^^

Don't forget to null it at the end (we do that because otherwise it will remember that unit for the entire game while you can never access it, what we call "Memory Leaks", or a piece of rubbish).
 
Level 7
Joined
Jun 15, 2010
Messages
218
omg this will make it so easy for me!! only problem i now get error

Custom script: local unit udg_Caster = GetSpellAbilityUnit() Syntax error
 
Level 7
Joined
Jun 15, 2010
Messages
218
  • lava shield on
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Lava Shield
    • Actions
      • Custom script: Custom script: local unit udg_Caster = GetSpellAbilityUnit()
      • Unit - Add Phoenix Fire to (Casting unit)
      • Wait 20.00 seconds
      • Unit - Remove Phoenix Fire from (Casting unit)
      • Custom script: Custom script: set udg_Caster = null
this is what i got now. tried it with udg_caster and udg_Caster both and both gave same error
 
Level 7
Joined
Jun 15, 2010
Messages
218
Yea i already thought someting like that. So i made this. but still same error :( what im i still doing wrong?

  • lava shield on
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Lava Shield
    • Actions
      • Custom script: Custom script: local unit udg_LS_Caster = GetSpellAbilityUnit()
      • Unit - Add Phoenix Fire to LS_Caster
      • Wait 20.00 seconds
      • Unit - Remove Phoenix Fire from LS_Caster
      • Custom script: Custom script: set udg_Caster = null
 
Level 7
Joined
Jun 15, 2010
Messages
218
O my god. im so stupid. look at Custom script. i wrote it in the Custom script:p im trying to get it to work now. I saved without error!
 
Level 7
Joined
Jun 15, 2010
Messages
218
now i have this ability where i need to get caster-position:

  • arcane explosion
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Arcane Explosion
    • Actions
      • Custom script: local location udg_Location_ArcaneExplosion = GetUnitLoc(GetTriggerUnit())
      • Unit - Create 1 Dummy (arcane explosion) for (Owner of (Triggering unit)) at Location_ArcaneExplosion facing Default building facing degrees
      • Unit - Add a 1.20 second Generic expiration timer to (Last created unit)
      • Animation - Change (Last created unit)'s size to ((75.00 + ((Real((Level of Arcane Explosion for (Triggering unit)))) x 25.00))%, (75.00 + (25.00 x (Real((Level of Arcane Explosion for (Triggering unit))))))%, (75.00 + (25.00 x (Real((Level of Arcane Explosion for (Triggering unit))))))%) of its original size
      • Unit - Set level of Arcane Explosion (Dummy) for (Last created unit) to (Level of Arcane Explosion for (Triggering unit))
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Custom script: set udg_Location_ArcaneExplosion = null
is this all correct?:D also the removal of the leak. or do i need to make it like
  • Custom script: call RemoveLocation ( udg_Location_ArcaneExplosion )
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
The first trigger could also be like this, since triggering unit uses a local variable. It will be MUI.
  • lava shield on
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Lava Shield
    • Actions
      • Unit - Add Phoenix Fire to Triggering unit
      • Wait 20.00 seconds
      • Unit - Remove Phoenix Fire from Triggering unit
Ap0c's method is good, and adviseable in more complicated triggers.


now i have this ability where i need to get caster-position:

  • arcane explosion
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Arcane Explosion
    • Actions
      • Custom script: local location udg_Location_ArcaneExplosion = GetUnitLoc(GetTriggerUnit())
      • Unit - Create 1 Dummy (arcane explosion) for (Owner of (Triggering unit)) at Location_ArcaneExplosion facing Default building facing degrees
      • Unit - Add a 1.20 second Generic expiration timer to (Last created unit)
      • Animation - Change (Last created unit)'s size to ((75.00 + ((Real((Level of Arcane Explosion for (Triggering unit)))) x 25.00))%, (75.00 + (25.00 x (Real((Level of Arcane Explosion for (Triggering unit))))))%, (75.00 + (25.00 x (Real((Level of Arcane Explosion for (Triggering unit))))))%) of its original size
      • Unit - Set level of Arcane Explosion (Dummy) for (Last created unit) to (Level of Arcane Explosion for (Triggering unit))
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Custom script: set udg_Location_ArcaneExplosion = null

You don't need to make the variable local, there's no wait or time passing between the actions.

Replace the first action with normal GUI line, and the last line with call RemoveLocation(...)
 
Status
Not open for further replies.
Top