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

Problem in trigger (About player groups)

Status
Not open for further replies.
Level 8
Joined
Mar 5, 2011
Messages
199
The Player group does not work...




  • Gurathar Died
    • Events
      • Unit - Gurathar 0081 <gen> Dies
    • Conditions
    • Actions
      • Set GuratharDeath = (Position of (Dying unit))
      • Sound - Play UtherReturns <gen>
      • Game - Display to (All players) for 5.00 seconds the text: |c0020C000Gurathar:...
      • Item - Create Cheese at GuratharDeath
      • Player Group - Pick every player in Main_PlayerGroup and do (Actions)
        • Loop - Actions
          • Player - Add 300 to (Picked player) Current gold
      • Custom script: call RemoveLocation (udg_GuratharDeath)
      • Custom script: call DestroyForce (udg_Main_PlayerGroup)
 
Level 8
Joined
Mar 5, 2011
Messages
199
I don't see where you assign a value to the force (player group) variable; is it in other trigger? If yes, then post that trigger too.

Here:

  • Map Initilization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • -------- Gold Set --------
          • Player - Set (Player((Integer A))) Current gold to 500
          • -------- Food cap --------
          • Player - Set (Player((Integer A))) Food cap to 5
          • -------- Setting Main_PlayerGroup --------
          • Player Group - Add (Player((Integer A))) to Main_PlayerGroup
          • -------- Allies --------
          • Player - Make Player 5 (Yellow) treat (Player((Integer A))) as an Ally
          • For each (Integer B) from 1 to 4, do (Actions)
            • Loop - Actions
              • Player - Make (Player((Integer A))) treat (Player((Integer B))) as an Ally with shared vision
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • -------- Enemy --------
          • Player - Make (Player((Integer A))) treat Player 6 (Orange) as an Enemy
          • Player - Make Player 6 (Orange) treat (Player((Integer A))) as an Enemy
      • -------- Hide in Post Game --------
      • Player - Hide Player 5 (Yellow) in the post-game score screen
      • Player - Hide Player 6 (Orange) in the post-game score screen
      • -------- Bounty --------
      • Player - Turn Gives bounty On for Player 6 (Orange)
      • Player - Turn Gives bounty On for Neutral Hostile
      • -------- Doors --------
      • Destructible - Make Dungeon Gate (Horizontal) 0077 <gen> Invulnerable
      • Destructible - Make Dungeon Gate (Horizontal) 0080 <gen> Invulnerable
      • -------- Camera --------
      • Camera - Change camera smoothing factor to 6.00
      • Player Group - Pick every player in Main_PlayerGroup and do (Actions)
        • Loop - Actions
          • Player - Limit training of Heroes to 1 for (Picked player)
          • Camera - Lock camera target for (Picked player) to Agility Tavern 0001 <gen>, offset by (0.00, 0.00) using Default rotation
      • -------- In Game --------
      • Game - Set the time of day to 18.00
      • Game - Set game speed to Fastest
      • Game - Lock the game speed
      • Player - Disable sleeping for all creeps
      • Environment - Change water tinting color to (100.00%, 100.00%, 100.00%) with 35.00% transparency
      • Custom script: call DestroyForce (udg_Main_PlayerGroup)
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
I don't see where you assign a value to the force (player group) variable; is it in other trigger? If yes, then post that trigger too.
Which players should that force contain? The trigger you posted just shows the action related to the force.
Do you, somewhere in your triggers do something like: Set MainPlayerGroup = (Some Players)
or do you use actions that add players to the group?
 
Level 8
Joined
Mar 5, 2011
Messages
199
the Main_PlayerGroup contains the 4 players who will play, i added them in the map initialization trigger using the action "Player Group - Add (Player((Integer A))) to Main_PlayerGroup". I used one of the 4 players to test if its working. So I killed Gurathar but my current gold did not increase
 
Level 7
Joined
Apr 11, 2011
Messages
173
You are doing it wrong which is why...

Edit: nvm ppl are quite fast or I took awhile....

Tho by destroying the player group, your destroying what you did to it meaning there is nothing in that playergroup for it was destroyed/cleaned which I suggest removing...
If you continually use it all the way through the map then there is no need to destroy it but if you don't then on the last trigger you use it with, you should destroy it.


Example below and it is working.
 

Attachments

  • hmm.w3x
    18.1 KB · Views: 41

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,204
In short it is because there is no existing force assigned to the global variable. If you want to keep the force then simply do not destroy it. It will only leak if you lose all pointers to the force eg by assigning the global variable to a new force object without deallocating it.

Sadly WC3 does not have such a good garbage collection system.
 
Level 11
Joined
May 31, 2008
Messages
698
I don't understand.... So when will I use call DestroyForce?

when you no longer need the group, or when you want to set it to a different set of players.

For example, if you had a trigger that runs every 5 seconds and sets group 1 to all players who are still in the game, you would first destroy the group (to reset it) and then set the group to the players in the game.

If you destroy the group right after you set it to something that defeats the purpose of setting it to something in the first place, unless you use it somewhere in between setting it and destroying it.
You shouldnt destroy a group in one trigger when you want to use it again in another trigger.
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
I don't understand.... So when will I use call DestroyForce?
If you're going to use the player group through whole game, don't destroy it at all. It's not leaking, it's 1 group assigned to a variable.
the Main_PlayerGroup contains the 4 players who will play, i added them in the map initialization trigger using the action "Player Group - Add (Player((Integer A))) to Main_PlayerGroup". I used one of the 4 players to test if its working. So I killed Gurathar but my current gold did not increase
Sorry, didn't notice it D:
 
Level 11
Joined
May 31, 2008
Messages
698
So I can use it again in another trigger without using call DestroyForce?

Yes.
If you destroy the force, you wont be able to use it again at all until you set the force again. DestroyForce pretty much just resets the force so theres no players in it, you use it in order to prevent leaks. But if you set it only once, then dont destroy it lol
 
Status
Not open for further replies.
Top