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

Making certain GUI codes MUI

Status
Not open for further replies.
Level 6
Joined
Aug 5, 2017
Messages
251
Hey. I know a few maps with custom races got away with this, like the Fel Horde map and High Elves map.
I want to turn some GUI codes into MUI codes. I'm sort of good at making GUI codes. MUI is difficult. I get the start, but I'm lost at the rest.
  • Impending Crystal ON
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units of type Crystal Golem) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Percentage life of (Picked unit)) Less than or equal to 50.00
            • Then - Actions
              • Unit - Add Impending Crystal (Book) to (Picked unit)
              • Player - Disable Impending Crystal (Book) for (Owner of (Picked unit))
            • Else - Actions
  • Impending Crystal OFF
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup=true
      • Unit Group - Pick every unit in (Units of type Crystal Golem) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Percentage life of (Picked unit)) Greater than 50.00
            • Then - Actions
              • Unit - Remove Impending Crystal (Book) from (Picked unit)
            • Else - Actions
An a different example. The first trigger is a bit modified.
  • Divine Reward ON
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacked unit)) Equal to Archangel
    • Actions
      • Set Divine_Reward_Chance = (Random integer number between 1 and 100)
      • Unit Group - Pick every unit in (Units of type Archangel) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of (Picked unit)) Equal to (Max mana of (Picked unit))
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Divine_Reward_Chance Less than or equal to 40
                • Then - Actions
                  • Unit - Add Archangel (Damage) to (Picked unit)
                  • Unit - Add Archangel (Book) to (Picked unit)
                  • Player - Disable Archangel (Book) for (Owner of (Picked unit))
                • Else - Actions
            • Else - Actions
  • Divine Reward OFF
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup=true
      • Unit Group - Pick every unit in (Units of type Archangel) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of (Picked unit)) Not equal to (Max mana of (Picked unit))
            • Then - Actions
              • Unit - Remove Archangel (Damage) from (Picked unit)
              • Unit - Remove Archangel (Book) from (Picked unit)
            • Else - Actions
For the most part, I need a value, an index to be exact, that allows the caster to use index+1 if it happens to cast the same spell, but the rest I don't know. Can anyone help me with this?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,540
Can you explain these spells in greater detail?

At the moment it's hard to tell how you want them to work. Like when you cast an ability does it turn these triggers On/Off? I see you're using a Unit Group for Unit's of Type Crystal Golem/Archangel, do you want this to be the Casting Unit instead?

Also, in Impending Crystal ON you forgot to put "Custom script: set bj_wantDestroyGroup=true" above Pick Every Unit.

Anyway, there's multiple ways to make a spell MUI in GUI.
My personal favorite is: GUI Unit Indexer 1.4.0.0
And in addition to that use this method whenever necessary: Visualize: Dynamic Indexing
 
Last edited:
Level 6
Joined
Aug 5, 2017
Messages
251
Here:
Impending Crystal: The damage of the crystals of the crystal golem powers it up. At half health or less, the golem is covered in an aura. receiving 10 armor and has its damage increased by 25.
If you want to know about Divine Reward also:
Divine Reward: As a reward for having all of his mana. the archangel will receive a 40% chance to have his attack damage increased by 15 and movement speed by 20%. This is removed if the mana is getting low.
I thought set bj_wantDestroyGroup=true should have been placed at the trigger when it deactivates. Okay. If you say so.
I want to turn certain GUI spells into MUI, not backwards.
I'm not sure if I want to do it. I want my MUI spells to be easy, not complicated. Even easy, it's still difficult.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,540
GUI = The drag and drop style triggers that the Trigger Editor uses by default
MUI = Multiple Unit Instanceable

So when I say GUI I just mean using non-Jass triggers in the Trigger Editor. So when this is all said and done the triggers will be made in GUI, and will be MUI compatible.

And "set bj_wantDestroyGroup=true" marks the next group that you create for removal (after it's done being used). And since Pick every unit creates a Group, you want to use "set bj_wantDestroyGroup=true" before it. This will remove (destroy) the group from the game's memory and help with map performance. Think of it like throwing away the wrapper after you're done eating a candy bar, the wrapper is no longer of any use to us. In this case, the wrapper is the group that we just finished using.

Anyway, I can create some MUI examples of these for you. Just give me a little while to finish them.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,540
I'm curious, are there ability requirements for these triggers to happen? In other words, does the Crystal Golem have to level up and learn Impending Crystal?

And yes, I'm sure you can learn a lot from this and apply it to all of your spells. It seems challenging at first but eventually it will all just click.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,540
Alright, well now that I fully understand what you're trying to do it's sort of funny... These spells are already MUI, and will work just fine with multiple units.

There are some optimizations I can offer you though:

You don't need the Impending Crystal OFF trigger. You can use Impending Crystal ON for both effects.
  • Impending Crystal ON
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup=true
      • Unit Group - Pick every unit in (Units of type Crystal Golem) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Percentage life of (Picked unit)) Less than or equal to 50.00
            • Then - Actions
              • -------- ADD IMPENDING CRYSTAL ABILITY --------
              • -------- DISABLE IMPENDING CRYSTAL ABILITY --------
            • Else - Actions
              • -------- REMOVE IMPENDING CRYSTAL ABILITY --------
              • -------- IF IT HAS A BUFF YOU MAY WANT TO REMOVE THAT AS WELL --------
Divine Reward doesn't require you to pick every unit. You already have access to the Attacked Archangel, so make the Actions/Conditions revolve around the Attacked unit:
  • Divine Reward ON
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacked unit)) Equal to Archangel
      • (Level of Archangel (Damage) for (Attacked unit)) Equal to 0
      • (Percentage mana of (Attacked unit)) Equal to 100.00
    • Actions
      • Set Variable Divine_Reward_Chance = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Divine_Reward_Chance Less than or equal to 40
        • Then - Actions
          • -------- ADD ABILITIES --------
          • -------- DISABLE ABILITIES --------
        • Else - Actions
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,540
A non-MUI spell is one that breaks when multiple units use the spell. Something like this:
  • Non-MUI Example
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Fireball
    • Actions
      • Set Variable Fireball_Caster = (Casting unit)
      • Wait 5.00 seconds
      • Unit - Kill Fireball_Caster
Seems fine right? But what happens if ANOTHER unit casts Fireball before the first unit's "Wait 5.00 seconds" has finished? See the problem?

Fireball_Caster can only ever be set to ONE unit at a time. Therefore if a different unit casts this spell it will become the "new" Fireball_Caster and get killed once the other unit's "Wait" is finished.

For example:
Unit A casts Fireball and becomes Fireball_Caster
2.00 seconds pass
Unit B casts Fireball and becomes Fireball_Caster
3.00 seconds pass
Unit B is killed INSTEAD of Unit A because Unit A is no longer the Fireball_Caster
2.00 seconds pass
No unit is killed because Unit B is already dead

The reason your spells are MUI is because you're using "Pick every unit of type" to loop through ALL of the Crystal Golems. So if there are 10 Crystal Golems then the trigger will run for all 10 of them, checking the Life of each individual Golem to see if it should add the damage/armor to it.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,540
Are you asking if that would work in general? Or for your specific abilities.

Because your abilities are fine as they're now, that would actually make them have worse performance because you're now looping through EVERY unit (potentially 100s) instead of just a few Crystal Golems.

Like I said, the way to make a spell MUI depends on how the spell works.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,540
Like I said before, you're not converting GUI to MUI.

GUI just means that you're not using code like this:
vJASS:
call KillUnit(GetTriggerUnit())

MUI just means that the spell won't break if multiple units use the spell. A GUI spell can be MUI as well, it's not one or the other, they're two different types of things.

Anyway, here is an MUI version of that Fireball spell I posted earlier:
  • Fireball MUI
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Fireball
    • Actions
      • -------- Setup Index variables to make the spell MUI --------
      • Set VariableSet Fireball_Index1 = (Fireball_Index1 + 1)
      • Set VariableSet Fireball_Caster[Fireball_Index1] = (Casting unit)
      • Wait 5.00 seconds
      • Set VariableSet Fireball_Index2 = (Fireball_Index2 + 1)
      • Unit - Kill Fireball_Caster[Fireball_Index2]
      • -------- --------
      • -------- This resets the Index variables back to 0 once all units have finished casting the spell --------
      • -------- This is done to fix a very unlikely but still possible issue. Indexes have a limit of ~32000, so it's nice to reset them when possible --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Fireball_Index2 Equal to Fireball_Index1
        • Then - Actions
          • Set VariableSet Fireball_Index1 = 0
          • Set VariableSet Fireball_Index2 = 0
          • Game - Display to (All players) for 30.00 seconds the text: All units have fini...
        • Else - Actions
I admit this isn't the best example as this trigger didn't actually require any variables to be MUI (You can use Triggering Unit between Waits), but I sort of set myself up for this with my previous example so I figured I'd just stick with it.
 

Attachments

  • MUI Fireball Example.w3m
    18.4 KB · Views: 25
Level 6
Joined
Aug 5, 2017
Messages
251
Now I have a problem with the codes below:
  • Horn of Power ON
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Horn of Power (youngling)
    • Actions
      • Custom script: set bj_wantDestroyGroup=true
      • Unit Group - Pick every unit in (Units of type Nerubian Youngling) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Horn of Power ) Equal to True
            • Then - Actions
              • Unit - Add Youngling (Armor) to (Picked unit)
            • Else - Actions
  • Horn of Power OFF
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup=true
      • Unit Group - Pick every unit in (Units of type Nerubian Youngling) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Horn of Power ) Equal to False
            • Then - Actions
              • Unit - Remove Youngling (Armor) from (Picked unit)
            • Else - Actions
I know Uncle. I should have used 1 trigger for this, but this is how it worked, but with a side-effect: when a youngling casts a spell, it doesn't get armor, but if a second one casts the spell, the first caster will receive the armor, as long as the buff is on. Is there a way to fix this? Also, optional, but the research that allows the younglings to cast Horn of Power also allows the buildings to gain 2 extra armor. It works when the buildings are in-game, but if I create a new barracks, then those won't get armor. I'll probably need a variable here, but also, is there a way to fix this?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,540
Edit #2:
Uploaded an example map:
Make sure you configure the variables in the Setup trigger to match your own stuff.
  • Horn of Power Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Configure these variables to use your map's abilities/units/buffs --------
      • Set VariableSet HornOfPower_Ability = Animate Dead
      • Set VariableSet HornOfPower_Armor = Attribute Bonus
      • Set VariableSet HornOfPower_Buff = Aerial Shackles
      • Set VariableSet HornOfPower_UnitType = Footman
  • Cast Horn of Power
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to HornOfPower_Ability
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Horn of Power Timer <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Horn of Power Timer <gen>
        • Else - Actions
      • Wait 0.00 seconds
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units of type HornOfPower_UnitType) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff HornOfPower_Buff) Equal to True
              • (Level of HornOfPower_Armor for (Picked unit)) Equal to 0
            • Then - Actions
              • Unit - Add HornOfPower_Armor to (Picked unit)
              • Set VariableSet HornOfPower_TurnOff = (HornOfPower_TurnOff + 1)
            • Else - Actions
  • Horn of Power Timer
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units of type HornOfPower_UnitType) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff HornOfPower_Buff) Equal to True
              • (Level of HornOfPower_Ability for (Picked unit)) Equal to 0
            • Then - Actions
              • Unit - Add HornOfPower_Ability to (Picked unit)
              • Set VariableSet HornOfPower_TurnOff = (HornOfPower_TurnOff + 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) has buff HornOfPower_Buff) Equal to False
                  • (Level of HornOfPower_Ability for (Picked unit)) Not equal to 0
                • Then - Actions
                  • Unit - Remove HornOfPower_Ability from (Picked unit)
                  • Set VariableSet HornOfPower_TurnOff = (HornOfPower_TurnOff - 1)
                • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HornOfPower_TurnOff Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
 

Attachments

  • Horn of Power Example.w3m
    17.8 KB · Views: 26
Last edited:
Level 6
Joined
Aug 5, 2017
Messages
251
The research should allows the building to receive 2 armor.
I was thinking of giving the armor after the research to the building when it's and while it's summoned and then make a new trigger that gives Horn of Power that gives the youngling and only to younglings the ability.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,540
I'm still not following.

"Research for building = 2 and Horn of Power on younglings = 3."

2 and 3 what?

Edit: I think I understand now. Can't you use Scroll of Protection instead of a trigger to add Armor to these units? Roar could work as well I think.
 
Last edited:
Status
Not open for further replies.
Top