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

[Trigger] HALP! Problems with Spawning heros in a game mode . . .

Status
Not open for further replies.
Level 3
Joined
Apr 7, 2007
Messages
48
Okay so in this map, I have multiple selectable game modes. One of them is Team Deathmatch and I have a small problem. For each team only 1 hero spawns correctly and all of the other players do not ally correctly or spawn at all. Heros are selected randomly, (I'm sure that works because other modes use it) and so here is the trigger that has failed me:
  • TDM Start
    • Events
    • Conditions
    • Actions
      • Set tmp_stock = 1
      • Game - Display to (All players) for 20.00 seconds the text: |CFFFF0000Get ready...
      • Set tmp_teamplayers = Players
      • For each (Integer A) from 1 to (Number of players in tmp_teamplayers), do (Actions)
        • Loop - Actions
          • Set tmp_player = (Random player from tmp_teamplayers)
          • Player Group - Add tmp_player to RedTeam
          • Player Group - Remove tmp_player from tmp_teamplayers
          • Set tmp_player = (Random player from tmp_teamplayers)
          • Player Group - Add tmp_player to BlueTeam
          • Player Group - Remove tmp_player from tmp_teamplayers
      • Set tmp_spawn = (Center of Red Team Spawn <gen>)
      • Player Group - Pick every player in RedTeam and do (Actions)
        • Loop - Actions
          • Set tmp_player = (Picked player)
          • Player Group - Pick every player in RedTeam and do (Actions)
            • Loop - Actions
              • Player - Make tmp_player treat (Picked player) as an Ally with shared vision
          • Player Group - Pick every player in BlueTeam and do (Actions)
            • Loop - Actions
              • Player - Make tmp_player treat (Picked player) as an Enemy
          • Set tmp_rand = (Random integer number between 0 and 9)
          • Unit - Create 1 Heros[tmp_rand] for (Picked player) at tmp_spawn facing Default building facing degrees
          • Set tmp_hero = (Last created unit)
          • Hero - Create |CFFFF8A00Stock|r and give it to tmp_hero
          • Item - Set charges remaining in (Last created item) to tmp_stock
          • Unit - Change color of tmp_hero to Red
          • Camera - Pan camera for (Picked player) to tmp_spawn over 0.00 seconds
      • Set tmp_spawn = (Center of Blue Team Spawn <gen>)
      • Player Group - Pick every player in BlueTeam and do (Actions)
        • Loop - Actions
          • Set tmp_player = (Picked player)
          • Player Group - Pick every player in BlueTeam and do (Actions)
            • Loop - Actions
              • Player - Make tmp_player treat (Picked player) as an Ally with shared vision
          • Player Group - Pick every player in RedTeam and do (Actions)
            • Loop - Actions
              • Player - Make tmp_player treat (Picked player) as an Enemy
          • Set tmp_rand = (Random integer number between 0 and 9)
          • Unit - Create 1 Heros[tmp_rand] for (Picked player) at tmp_spawn facing Default building facing degrees
          • Set tmp_hero = (Last created unit)
          • Hero - Create |CFFFF8A00Stock|r and give it to tmp_hero
          • Item - Set charges remaining in (Last created item) to tmp_stock
          • Unit - Change color of tmp_hero to Blue
          • Camera - Pan camera for (Picked player) to tmp_spawn over 0.00 seconds
      • Trigger - Turn on XP Ticker <gen>
      • Trigger - Turn on TDM Death <gen>
      • Trigger - Turn on TDM Leaver <gen>
      • Trigger - Turn on Creep Spawn <gen>
      • Custom script: call RemoveLocation(udg_tmp_spawn)
One other note if anyone knows the JASS thingy to remove the playergroup leak (anything marked tmp is not needed for other tirggers). The group Players is all of the humans currently playing, and I am also 100% sure that the groups RedTeam and BlueTeam get setup properly because the first player of each team allies correctly each time.
 
Level 5
Joined
Aug 27, 2007
Messages
138
I'm not completely sure if I can fix your problem, but I'll give it a try.

-When you do the loop, make an If/Then/Else to check and see if the Integer A is odd or even. You're currently affecting two players per loop execution, when affecting one is probably a lot safer.

-There really isn't a reason to remove each player from the group in the loop. Just clear it when you're finished.

-You leak a location; tmp_spawn is set twice but removed once.

-To destroy a player group, use DestroyForce().

  • Set tmp_teamplayers = Players
-What's "Players?"

-Using tmp_rand is completely unnecessary. Integers do not need to be set as variables unless they are used more than once. Instead of setting tmp_rand, then calling Heros[tmp_rand], just do:

  • Unit - Create 1 Heros[(Random integer number between 0 and 9)] for (Picked player) at tmp_spawn facing Default building facing degrees
 
Level 3
Joined
Apr 7, 2007
Messages
48
The group Players is all of the humans currently playing,


Sorry, I know it was kinda buried at the bottom of my post.

Kinda confued about one thing: If I do not remove the player from the temporary group, can't the same player be randomly picked twice?

Just as an added bit of information: apparently the problem lies in the setup for each team Pick every player in RedTeam etc. only exceutes once. I'm also not sure if having those other Pick every player functions inside was a good idea but they appeared to work, once.
 
Status
Not open for further replies.
Top