• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Is this MUI done correctly?

Status
Not open for further replies.
Level 12
Joined
Feb 5, 2018
Messages
521
  • Agjold and Sveld
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) has an item of type |c00540081Agjold & Sveld|r) Equal to True
      • ((Attacking unit) is A Hero) Equal to True
    • Actions
      • -------- Start of Indexing --------
      • Set AjgoldMUI_1 = (AjgoldMUI_1 + 1)
      • -------- Start of Dynamic Indexing --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AjgoldMUI_1 Greater than AgjoldMax_Index
        • Then - Actions
          • Set AgjoldMUI_2[AjgoldMUI_1] = AjgoldMUI_1
          • Set AgjoldMax_Index = AjgoldMUI_1
        • Else - Actions
      • For each (Integer AgjoldMUI_3) from 1 to AjgoldMUI_1, do (Actions)
        • Loop - Actions
          • Set AjgoldTemp = AgjoldMUI_2[AgjoldMUI_3]
          • Set Ajgold_AOE[AjgoldTemp] = 1200.00
          • Set AgjoldAndSveld_Attacker[AjgoldTemp] = (Attacking unit)
          • Set AgjoldAndSveld_FireNova[AjgoldTemp] = (Random integer number between 1 and 100)
          • Set AgjoldAndSveld_FrostTomb[AjgoldTemp] = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AgjoldAndSveld_FireNova[AjgoldTemp] Less than or equal to 7
        • Then - Actions
          • Set AgjoldAndSveld_TempLoc = (Position of AgjoldAndSveld_Attacker[AjgoldTemp])
          • Unit - Create 1 DummyUnit for (Owner of AgjoldAndSveld_Attacker[AjgoldTemp]) at AgjoldAndSveld_TempLoc facing Default building facing degrees
          • Set AgjoldAndSveld_TempUnit[AjgoldTemp] = (Last created unit)
          • Unit - Hide AgjoldAndSveld_TempUnit[AjgoldTemp]
          • Unit - Turn collision for AgjoldAndSveld_TempUnit[AjgoldTemp] Off
          • Unit - Add a 3.00 second Generic expiration timer to AgjoldAndSveld_TempUnit[AjgoldTemp]
          • Unit - Add Fire Nova (Fan of Knives) to AgjoldAndSveld_TempUnit[AjgoldTemp]
          • Unit - Order AgjoldAndSveld_TempUnit[AjgoldTemp] to Night Elf Warden - Fan Of Knives
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AgjoldAndSveld_FrostTomb[AjgoldTemp] Less than or equal to 4
        • Then - Actions
          • Set AgjoldAndSveld_TempLoc = (Position of AgjoldAndSveld_Attacker[AjgoldTemp])
          • Set AgjoldAndSveld_UnitGroup = (Units within Ajgold_AOE[AjgoldTemp] of AgjoldAndSveld_TempLoc matching ((((Matching unit) is A flying unit) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of AgjoldAndSveld_Attacker[AjgoldT
          • Unit Group - Pick every unit in AgjoldAndSveld_UnitGroup and do (Actions)
            • Loop - Actions
              • Set AgjoldAndSveld_FT_Target[AjgoldTemp] = (Picked unit)
              • Set AgjoldAndSveld_TempLoc2 = (Position of AgjoldAndSveld_FT_Target[AjgoldTemp])
              • Unit - Create 1 DummyUnit for (Owner of AgjoldAndSveld_Attacker[AjgoldTemp]) at AgjoldAndSveld_TempLoc2 facing Default building facing degrees
              • Set AgjoldAndSveld_TempUnit[AjgoldTemp] = (Last created unit)
              • Unit - Turn collision for AgjoldAndSveld_TempUnit[AjgoldTemp] Off
              • Unit - Hide AgjoldAndSveld_TempUnit[AjgoldTemp]
              • Unit - Add a 0.50 second Generic expiration timer to AgjoldAndSveld_TempUnit[AjgoldTemp]
              • Unit - Add Frost Tomb (Storm Bolt) to AgjoldAndSveld_TempUnit[AjgoldTemp]
              • Unit - Order AgjoldAndSveld_TempUnit[AjgoldTemp] to Human Mountain King - Storm Bolt AgjoldAndSveld_FT_Target[AjgoldTemp]
        • Else - Actions
      • -------- ---Recycling Indexes--- --------
      • Set AgjoldMUI_2[AgjoldMUI_3] = AgjoldMUI_2[AjgoldMUI_1]
      • Set AgjoldMUI_2[AjgoldMUI_1] = AjgoldTemp
      • Set AjgoldMUI_1 = (AjgoldMUI_1 - 1)
      • Set AgjoldMUI_3 = (AgjoldMUI_3 - 1)
      • Custom script: call RemoveLocation (udg_AgjoldAndSveld_TempLoc)
      • Custom script: call RemoveLocation (udg_AgjoldAndSveld_TempLoc2)
      • Custom script: call DestroyGroup (udg_AgjoldAndSveld_UnitGroup)
The idea is that every attacking hero with the *Item* has own *Integer*, otherwise the item will proc too much if everyone uses the same integer at the same time.
Sorry for the messy variable names :)
PS. I know there are guides for this, but I just need to be absolutely sure.
 
Level 39
Joined
Feb 27, 2007
Messages
5,038
It's... really hard to read and parse because of your variable names. In the future I would pick a simple prefix for a spell/system (in this case maybe AgSv_ or AaS_ or just AS_) and descriptive variable names that follow. How are MUI_1, MUI_2, and MUI_3 different/used differently? For things like TempLoc or TempGroup you just need 1 (or maybe 2) version of that variable for your whole map that you use in every trigger, not 1 TempWhatever variable per trigger. The idea of those TempWhatevers is that they are only allocated during triggers and are nearly instantly removed (no waits) so they are not going to get messed up if other triggers use them (no 2 triggers can run at the exact same time).

That aside this looks much, much more complicated than it should be. As I understand, on an attack this item has a 7% chance to cast Fire Nova and a 4% chance to cast Frost Tomb on every enemy within 1200, correct? None of that requires any 'time' to make happen so there is no need to worry about indexing here or any MUI problems. I don't understand what you're saying about integers and each player having their own because there's nothing you're actually storing here in the spell, just assigning variables to be used instantly. If for some reason you need to store an integer per unit, you can actually do something very smart here and use the item's custom value to store that integer. Usually we don't want to use units' custom value because that messes up unit indexer systems, but item CV is generally unused by anything so you can appropriate it for your purposes. The trigger ideally should look something like this:

  • Events
    • Unit - A unit is attacked
  • Conditions
    • ((Attacking Unit) is a Hero) equal to true
    • ((Attacking unit) has an item of type |c00540081Agjold & Sveld|r) Equal to True
  • Actions
    • Set TempUnit = (Attacking Unit)
    • Set TempLoc = (Position of TempUnit)
    • Set TempPlayer = (Owner of TempUnit)
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • (Random integer number between 1 and 100) less than or equal to FIRE_NOVA_CHANCE //could use a variable or hardcode 7 here
      • Then - Actions
        • Unit - Create 1 DummyUnit for TempPlayer at TempLoc facing Default building facing degrees
        • Set TempDummy = (last created unit)
        • Unit - Add a 1.00 second generic expiration timer to TempDummy //3.00 is fine it just doesn't need to be that long
        • Unit - Add Fire Nova (Fan of Knives) to TempDummy
        • Unit - Order TempDummy to Night Elf Warden - Fan of Knives
      • Else - Actions
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • (Random integer number between 1 and 100) less than or equal to FROST_TOMB_CHANCE //could use a variable or hardcode 4 here
      • Then - Actions
        • Set TempGroup = (Units within FROST_TOMB_AOE of TempLoc matching ((((Matching unit) is A flying unit) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of TempPlayer) equal to true))
        • Unit Group - Pick every unit in TempGroup and do (Actions)
          • Loop - Actions
            • Unit - Create 1 DummyUnit for TempPlayer at TempLoc facing Default building facing degrees
            • Set TempDummy = (last created unit)
            • Unit - Add a 1.00 second generic expiration timer to TempDummy
            • Unit - Add Frost Tomb (Storm Bolt) to TempDummy
            • Unit - Order TempDummy to Human Mountain King - Storm Bolt (Picked Unit)
        • Custom script: call DestroyGroup(udg_TempGroup)
      • Else - Actions
    • Custom script: call RemoveLocation(udg_TempLoc)
I noticed you're turning collision off for your dummies and then hiding them. Did you not give them locust or ghost (visible) in the OE? These abilities disable collision. Locust makes it so players can't select the unit. This will save you a lot of time. Finally, the "unit is attacked" event is total ass and should never be used. It fires when the attack begins, not when it connects, so you can repeatedly trigger the event by attacking a unit and then ordering your attacker to stop which runs the event right before the attack is aborted with the stop. Instead you should use a simple Damage Detection System (DDS); there are many you can find here in the resources section but as a suggestion this one seems to be pretty good: Physical Damage Detection for GUI v1.3.0.0 Make sure you read the system documentation.
 
Level 12
Joined
Feb 5, 2018
Messages
521
Yea I was worried about that if multiple units attacks at the same time they all use the same integer roll, which I thought would somehow increase the chance of the proc?
Originally the trigger had no MUI at all and was almost identical to this only that it was using locals to prevent globals running wild with other globals.

I didn't know it worked like that, that's why I probably (once again) made something in a way more difficult way than it should have been.

I knew about the spam S(stop) to make "a unit is attacked" event run more often. I will look into the DDS system.

Also thanks for pointing out that you only need one or two TempWhatevers per map. Man If you could see the triggers I made and how many variables I have made for every spell or skill that runs trough a trigger. :D
One of the reasons I did something like this, is that I wanted to learn and understand dynamic indexing and rather than copy+paste it from another spell or guide I just wanted to try something out for myself.
Last if I were in a position where I needed to use the saved integers, would this pile of MUI's do the trick, for a spell with initial cast and a loop trigger?

Also in the future I will make the variable names into something more easier for ones eye to read.
Thank you for your reply! :)
 
Level 39
Joined
Feb 27, 2007
Messages
5,038
Last if I were in a position where I needed to use the saved integers, would this pile of MUI's do the trick, for a spell with initial cast and a loop trigger?
I honestly don't know because I couldn't understand what you were trying to do. I think this tutorial lays out dynamic indexing very well if you haven't already seen it: Visualize: Dynamic Indexing
I was worried about that if multiple units attacks at the same time they all use the same integer roll
The attacks will never, ever trigger events at the exact same time (down to the millisecond); the game simply doesn't allow that to happen. Even if two units faced a target unit directly (so they don't turn) from exactly the same distance away and were group ordered by a player to attack that target unit such that they attacked exactly in sync, the "unit is attacked" trigger would run the whole time through for unit A and then run the whole time through for unit B.
Also in the future I will make the variable names into something more easier for ones eye to read.
I suggest better naming for your sake too, not just anyone else you might share the code with. It'll make it easier for you to debug what you're doing yourself.
 
Level 12
Joined
Feb 5, 2018
Messages
521
The attacks will never, ever trigger events at the exact same time (down to the millisecond); the game simply doesn't allow that to happen. Even if two units faced a target unit directly (so they don't turn) from exactly the same distance away and were group ordered by a player to attack that target unit such that they attacked exactly in sync, the "unit is attacked" trigger would run the whole time through for unit A and then run the whole time through for unit B.

Alright, thank you for all the help :) I really learned something from your replies. <3
+Rep
 
Status
Not open for further replies.
Top