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

Can the call DestroyGroup() function work on arrays?

Status
Not open for further replies.
Level 3
Joined
Apr 25, 2013
Messages
38
So would this work?
  • Do Multiple ActionsFor each (Integer A) from 1 to 12, do (Actions)
    • Loop - Actions
      • Set AIntroUnits[(Integer A)] = (Units owned by (Player((Integer A))) matching (((Matching unit) is A structure) Equal to (==) False))
      • Unit Group - Pick every unit in AIntroUnits[(Integer A)] and do (Actions)
        • Loop - Actions
          • Unit - Change ownership of (Picked unit) to Neutral Passive and Retain color
  • Wait 60.00 seconds
    • Do Multiple ActionsFor each (Integer A) from 1 to 12, do (Actions)
      • Loop - Actions
        • Unit Group - Pick every unit in AIntroUnits[(Integer A)] and do (Actions)
          • Loop - Actions
            • Unit - Change ownership of (Picked unit) to (Player((Integer A))) and Retain color
        • Custom script: call DestroyGroup(udg_AIntroUnits[(Integer A)])
To put this into context the intro of our map lasts 60 seconds. Because of people using 3rd part programs to pause the game during traditional intro cinematic we opted to simply convert the units to neutral passive, then give them back after the 60 seconds along with starting Gold. Feedback, as always, is much appreciated!
 
Level 3
Joined
Apr 25, 2013
Messages
38
Nope, it should be
  • Custom script: call DestroyGroup(udg_AIntroUnits[bj_forLoopAIndex])
Or don't use the (Integer A) and use your own integer:
  • For each (Integer LoopInt) from 1 to 12, do (Actions)
    • Loop - Actions
  • Custom script: call DestroyGroup(udg_AIntroUnits[udg_LoopInt])


Would there be a benefit from using my own integer variable as in your second suggestion?

edit: here is the revised Trigger, everything look good?

  • Do Multiple ActionsFor each (Integer A) from 1 to 12, do (Actions)
    • Loop - Actions
      • Set AIntroUnits[(Integer A)] = (Units owned by (Player((Integer A))) matching (((Matching unit) is A structure) Equal to (==) False))
      • Unit Group - Pick every unit in AIntroUnits[(Integer A)] and do (Actions)
        • Loop - Actions
          • Unit - Change ownership of (Picked unit) to Neutral Passive and Retain color
  • Wait 60.00 seconds
    • Do Multiple ActionsFor each (Integer A) from 1 to 12, do (Actions)
      • Loop - Actions
        • Unit Group - Pick every unit in AIntroUnits[(Integer A)] and do (Actions)
          • Loop - Actions
            • Unit - Change ownership of (Picked unit) to (Player((Integer A))) and Retain color
        • Custom script: call DestroyGroup(udg_AIntroUnits[bj_forLoopAIndex])
 
Level 23
Joined
Feb 6, 2014
Messages
2,466
Would there be a benefit from using my own integer variable as in your second suggestion?

In your case, yeah it's better to use your own integer because (Integer A) is converted into a function call that returns the global integer bj_forLoopAIndex. So everytime you use (Integer A), you're already calling a function unlike when you use an integer, it will only have a lookup at the variable which is much faster than a function call.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
In your case, yeah it's better to use your own integer because (Integer A) is converted into a function call that returns the global integer bj_forLoopAIndex. So everytime you use (Integer A), you're already calling a function unlike when you use an integer, it will only have a lookup at the variable which is much faster than a function call.
Which only makes a difference if the trigger is performance critical such as a 0.03 periodic trigger. If it only fires once it is better to use whichever you find more convenient or can more easily maintain.

Be aware that the "Wait" action is not the most accurate and the more accurate Wait Game Time action leaks a handle reference.
 
Level 7
Joined
Oct 19, 2015
Messages
286
I don't quite understand how this helps with the problem of people pausing the game, though.
 
Level 3
Joined
Apr 25, 2013
Messages
38
I don't quite understand how this helps with the problem of people pausing the game, though.

This allows us to take away player control for 60 seconds, avoiding the Cinematic function. The program also broke
  • Cinematic - Disable user control for (All players)
. There was a player intent on trolling our map and some others with intro cinematic that would use the program, break the cinematic and pause the game (forcing all other players to alt+F4 because they couldn't access pause). I downloaded the program to test things like that disable user control and one game I hosted I gloriously broke the cinematic after he had paused it, unpaused it and kicked him. Everyone was ecstatic!

For a time then we simply removed the intro, but after finding that program broke all trigger functions that could remove user control I stumbled on the idea of transferring ownership to neutral passive and switching back after 60 seconds. Anyone can unpause cause they are not stuck in a cinematic. And the map definitely needs an introduction period!

That is because of the "Wait" action. To fix that you need to use either a timed event trigger or a timer, both of which do correctly pause when the game pauses and correctly scale with game speed.

Either of those can be done as we have a timer or I could easily break those functions off to a timed event trigger.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Anyone can unpause cause they are not stuck in a cinematic. And the map definitely needs an introduction period!
Introductions are great but should always be skippable via escape. If you are new you should of course watch them but after watching them your 100th time they are a bit boring.

Either of those can be done as we have a timer or I could easily break those functions off to a timed event trigger.
I might have misunderstood your problem the first time. I thought it was that the wait still counted down while paused. The best way to stop trolling is to not let them troll and giving the units to neutral and not turning cinematic mode on sounds the best approach.
 
Level 7
Joined
Oct 19, 2015
Messages
286
Can't you use something like this:
  • AntiPause
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Game - Unpause the game
I just tested it and the trigger will run even if the game is paused.
 
Status
Not open for further replies.
Top