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

Is there a way to create MUI Timers? OR MUI wait?

Status
Not open for further replies.
Level 17
Joined
Jun 2, 2009
Messages
1,141
Here is the trigger for 1 Computer slot. I have created 10 times for 10 computers without timers. Because if i will create timer and replace it with wait, i have to create 10 timer windows.

Is anybody knows how to make it "better" (less triggers) because if it is possible, i will create new behavior for AI Controlled Heroes and i don't want to create 20 triggers for every behavior. But i will to if we can make it with 1 trigger.

  • DevilHerodanKacP2
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) is in ReaperHerolariPlayer) Equal to True
      • (Attacked unit) Equal to zU_AIHero[2]
      • zBool_AIFallBackHERO[2] Equal to False
      • ((Attacked unit) is in zUG_RegenDevil) Equal to False
      • ((Attacked unit) is in CHANNEL) Equal to False
    • Actions
      • Set xINT_TEMP[2] = (Level of (Attacking unit))
      • Set xINT_TEMP2[2] = (Level of (Attacked unit))
      • Set xINT_TEMP3[2] = (xINT_TEMP[2] - xINT_TEMP2[2])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • xINT_TEMP3[2] Greater than or equal to 3
        • Then - Actions
          • Set zBool_AIFallBackHERO[2] = True
          • Set TempPoint = ((Position of (Attacked unit)) offset by 800.00 towards ((Angle from (Position of (Attacking unit)) to (Center of PreviousTarget[2])) - 0.00) degrees)
          • Unit - Order (Attacked unit) to Move To TempPoint
          • Custom script: call RemoveLocation (udg_TempPoint)
          • Wait 4.00 seconds
          • Set zBool_AIFallBackHERO[2] = False
          • Set TempGroup = (Units within 800.00 of (Position of (Attacked unit)) matching (((Matching unit) is in zUG_CreepsDevil) Equal to True))
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in TempGroup) Greater than or equal to 1
                • Then - Actions
                  • Unit - Order zU_AIHero[(Player number of (Owner of (Attacked unit)))] to Attack-Move To (Center of NextTarget[2])
                  • Custom script: call DestroyGroup (udg_TempGroup)
                • Else - Actions
                  • Custom script: call DestroyGroup (udg_TempGroup)
        • Else - Actions
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,558
You shouldn't be using the Pick Every Unit function in your trigger and you shouldn't be Destroying the Group like that. Do this instead:
  • DevilHerodanKacP2
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) is in ReaperHerolariPlayer) Equal to True
      • (Attacked unit) Equal to zU_AIHero[2]
      • zBool_AIFallBackHERO[2] Equal to False
      • ((Attacked unit) is in zUG_RegenDevil) Equal to False
      • ((Attacked unit) is in CHANNEL) Equal to False
    • Actions
      • Set xINT_TEMP[2] = (Level of (Attacking unit))
      • Set xINT_TEMP2[2] = (Level of (Attacked unit))
      • Set xINT_TEMP3[2] = (xINT_TEMP[2] - xINT_TEMP2[2])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • xINT_TEMP3[2] Greater than or equal to 3
        • Then - Actions
          • Set zBool_AIFallBackHERO[2] = True
          • Set TempPoint = ((Position of (Attacked unit)) offset by 800.00 towards ((Angle from (Position of (Attacking unit)) to (Center of PreviousTarget[2])) - 0.00) degrees)
          • Unit - Order (Attacked unit) to Move To TempPoint
          • Custom script: call RemoveLocation (udg_TempPoint)
          • Wait 4.00 seconds
          • Set zBool_AIFallBackHERO[2] = False
          • Set TempGroup = (Units within 800.00 of (Position of (Attacked unit)) matching (((Matching unit) is in zUG_CreepsDevil) Equal to True))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in TempGroup) Greater than or equal to 1
            • Then - Actions
              • Unit - Order zU_AIHero[(Player number of (Owner of (Attacked unit)))] to Attack-Move To (Center of NextTarget[2])
            • Else - Actions
          • Custom script: call DestroyGroup (udg_TempGroup)
Also, it looks like this trigger can be simplified to use the Player Number of the Owner of the (Attacked unit) instead of [2]. This would allow you to use one trigger for every single Computer Player. You could also use the Shadowing method to ease this process and help with performance by storing the Player Number as a local integer variable: local udg_

I'm not sure what you mean about the Timer Windows thing. You don't need to create Timer Windows in order to use Timers, they're simply an extra feature that allows you to display the Timer in-game. Also, if you want to use an Array of Timers you need to manually set the Array Size in the Variable Editor, otherwise it won't work: Timer arrays and Hashtables

Lastly, you're leaking 5 Points. Anywhere you see the words "Center of" or "Position of" there's a Memory Leak. Here's an example of how you would manage the leaks in the Point with Polar Offset function:
  • Set TempPointA = (Position of (Attacked unit))
  • Set TempPointB = (Position of (Attacking unit))
  • Set TempPointC = (Center of PreviousTarget[2])
  • Set TempPointD = TempPointA offset by 800.00 towards ((Angle from TempPointB to TempPointC degrees))
  • Unit - Order (Attacked unit) to Move To TempPointD
  • Custom script: call RemoveLocation (udg_TempPointA)
  • Custom script: call RemoveLocation (udg_TempPointB)
  • Custom script: call RemoveLocation (udg_TempPointC)
  • Custom script: call RemoveLocation (udg_TempPointD)
  • Wait 4.00 seconds
Since there's a Wait you'll have to Set/Use/Remove some of these Points again to clean up the rest of the Memory Leaks.
 
Last edited:
Level 17
Joined
Jun 2, 2009
Messages
1,141
You shouldn't be using the Pick Every Unit function in your trigger and you shouldn't be Destroying the Group like that. Do this instead:
  • DevilHerodanKacP2
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) is in ReaperHerolariPlayer) Equal to True
      • (Attacked unit) Equal to zU_AIHero[2]
      • zBool_AIFallBackHERO[2] Equal to False
      • ((Attacked unit) is in zUG_RegenDevil) Equal to False
      • ((Attacked unit) is in CHANNEL) Equal to False
    • Actions
      • Set xINT_TEMP[2] = (Level of (Attacking unit))
      • Set xINT_TEMP2[2] = (Level of (Attacked unit))
      • Set xINT_TEMP3[2] = (xINT_TEMP[2] - xINT_TEMP2[2])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • xINT_TEMP3[2] Greater than or equal to 3
        • Then - Actions
          • Set zBool_AIFallBackHERO[2] = True
          • Set TempPoint = ((Position of (Attacked unit)) offset by 800.00 towards ((Angle from (Position of (Attacking unit)) to (Center of PreviousTarget[2])) - 0.00) degrees)
          • Unit - Order (Attacked unit) to Move To TempPoint
          • Custom script: call RemoveLocation (udg_TempPoint)
          • Wait 4.00 seconds
          • Set zBool_AIFallBackHERO[2] = False
          • Set TempGroup = (Units within 800.00 of (Position of (Attacked unit)) matching (((Matching unit) is in zUG_CreepsDevil) Equal to True))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in TempGroup) Greater than or equal to 1
            • Then - Actions
              • Unit - Order zU_AIHero[(Player number of (Owner of (Attacked unit)))] to Attack-Move To (Center of NextTarget[2])
            • Else - Actions
          • Custom script: call DestroyGroup (udg_TempGroup)
Also, it looks like this trigger can be simplified to use the Player Number of the Owner of the (Attacked unit) instead of [2]. This would allow you to use one trigger for every single Computer Player. You could also use the Shadowing method to ease this process and help with performance by storing the Player Number as a local integer variable: local udg_

I'm not sure what you mean about the Timer Windows thing. You don't need to create Timer Windows in order to use Timers, they're simply an extra feature that allows you to display the Timer in-game. Also, if you want to use an Array of Timers you need to manually set the Array Size in the Variable Editor, otherwise it won't work: Timer arrays and Hashtables

Lastly, you're leaking 5 Points. Anywhere you see the words "Center of" or "Position of" there's a Memory Leak. Here's an example of how you would manage the leaks in the Point with Polar Offset function:
  • Set TempPointA = (Position of (Attacked unit))
  • Set TempPointB = (Position of (Attacking unit))
  • Set TempPointC = (Center of PreviousTarget[2])
  • Set TempPointD = TempPointA offset by 800.00 towards ((Angle from TempPointB to TempPointC degrees))
  • Unit - Order (Attacked unit) to Move To TempPointD
  • Custom script: call RemoveLocation (udg_TempPointA)
  • Custom script: call RemoveLocation (udg_TempPointB)
  • Custom script: call RemoveLocation (udg_TempPointC)
  • Custom script: call RemoveLocation (udg_TempPointD)
  • Wait 4.00 seconds
Since there's a Wait you'll have to Set/Use/Remove some of these Points again to clean up the rest of the Memory Leaks.
I am sorry just realized that someone posted this.
Yes i have a lot of leaks. And you are right, i can use player number of owner of unit but this is 1 of 10 triggers because of here

Wait 4.00 seconds
Set zBool_AIFallBackHERO[2] = False

When i make it like this, it will works?

Wait 4.00 seconds
Set zBool_AIFallBackHERO[player number of attacked unit bla bla] = False

By the way my main question was: "how to create mui timer or wait"
I want to use wait function or make it stop and work after few seconds but i don't want to create 10 timers or 10 triggers for this. Is that possible?

Here is the quick example.

  • Untitled Trigger 005
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Unit - Move (Attacked unit) instantly to (Center of Region 000 <gen>)
      • Wait 4.00 seconds
      • Unit - Move (Attacked unit) instantly to (Center of Region 001 <gen>)
Is it gonna work without any problems? If yes, i don't need mui timer or wait.
But if no, i have to learn how to. I have checked timer arrays and hashtables but sadly it is Jass. I cannot read it.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,558
Every time the unit is attacked it will create a new instance of that trigger. These instances all run separately. This may or may not cause problems, it depends on the timing of things.

Timers are very limited in GUI so you'll have to use Jass or a system that simplifies them that's GUI friendly. You can't really avoid this.

I would try to get a version of Warcraft 3 that actually works but I'm sure you have your reason for using an old broken patch.
 
Status
Not open for further replies.
Top