• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Hash and multiboard cant store computer players

Status
Not open for further replies.
Level 5
Joined
Aug 24, 2010
Messages
133
I'm trying to add computer players (I've tried both numbered and neutral) to a multiboard and array, but the name field is always blank, and whenever I try to reference it in the hash it returns null. Can anyone please help me add non-user players to multiboards and hashes.

  • Set temp_int = 1
  • Player Group - Add Neutral Hostile to pg2
  • Player Group - Pick every player in pg2 and do (Actions)
    • Loop - Actions
      • Multiboard - Set the text for multiboard item in column temp_int, row 1 to (Name of (Picked player))
      • Hashtable - Save (temp_int) as (Player number of (Picked player)) of 111 in hash
      • Set temp_int = (temp_int + 1)
 
Make sure pg2 is an existing force. Check in the variables editor and make sure that its default value is "Empty force" (or something similar). If you destroyed the force before, then you should create it before you add players to it, e.g.:
  • Set temp_int = 1
  • Custom script: set udg_pg2 = CreateForce()
  • Player Group - Add Neutral Hostile to pg2
  • Player Group - Pick every player in pg2 and do (Actions)
    • Loop - Actions
      • Multiboard - Set the text for multiboard item in column temp_int, row 1 to (Name of (Picked player))
      • Hashtable - Save (temp_int) as (Player number of (Picked player)) of 111 in hash
      • Set temp_int = (temp_int + 1)
 
Level 5
Joined
Aug 24, 2010
Messages
133
It works fine for all user controlled players, just not for computer controlled players. Could it be they can't be in the same group? In the multiboard it does leave a space for where the computer player should be but it doesn't put anything there.
 
Level 5
Joined
Aug 24, 2010
Messages
133
  • Player Group - Pick every player in (All players) and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Picked player) slot status) Equal to Is playing
        • Then - Actions
          • Player Group - Add (Picked player) to pg2
        • Else - Actions
I've also tried these as stand alone triggers to add them too.

  • Player Group - Add Player 2 (Blue) to pg2
  • Player Group - Add Neutral Hostile to pg2
 
post these triggers (but also with events/conditions): you create multiboard .. you add to group .. you add to multiboard.

Maybe the row doesnt exist? Or display a text message of the player, when he gets added to your group, then you definitly know he is there.

And in general you can try to work with debug messages, you can enclose the issue.
 
Level 5
Joined
Aug 24, 2010
Messages
133
The row does exist, so I know that the player is added.

I tried to clean it up a bit and add a few comments.
I know it leaks a lot and it's not written very efficiently but I'll change that once all the glitches are taken out.

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set startregions[1] = start 1 <gen>
      • Set startregions[2] = start 2 <gen>
      • Set startregions[3] = start 3 <gen>
      • Set startregions[4] = start 4 <gen>
      • Set startregions[5] = start 5 <gen>
      • Melee Game - Use melee time of day (for all players)
      • Set temp_point = ((Position of Done 0005 <gen>) offset by (-60.00, 0.00))
      • Floating Text - Create floating text that reads Done at temp_point with Z offset 0.00, using font size 16.00, color (10.00%, 10.00%, 10.00%), and 0.00% transparency
      • Set temp_int = 0
      • -------- This part adds the players to the group pg2 --------
      • -------- Later on when I start making AI, 'all players controlled by users' will be changed to 'all players' --------
      • Player Group - Pick every player in (All players controlled by a User player) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) slot status) Equal to Is playing
            • Then - Actions
              • Player Group - Add (Picked player) to pg2
              • Player - Set (Picked player) Current gold to 600
              • Player - Turn Gives bounty On for (Picked player)
              • Game - Force (Picked player) to press the key A
              • Player - Make Neutral Passive treat (Picked player) as an Ally
              • Visibility - Create an initially Enabled visibility modifier for (Picked player) emitting Visibility across books <gen>
              • Set vismod[(Player number of (Picked player))] = (Last created visibility modifier)
            • Else - Actions
      • Set pgalive = pg2
      • Set playercolour[1] = |c00ff0303
      • Set playercolour[2] = |c000042ff
      • Set playercolour[3] = |c001ce6b9
      • Set playercolour[4] = |c00540081
      • Set playercolour[5] = |c00fffc01
      • Set playercolour[6] = |c00feba0e
      • Set playercolour[7] = |c0020c000
      • Set playercolour[8] = |c00e55bb0
      • Set playercolour[9] = |c00959697
      • Set playercolour[10] = |c007EBFF1
      • Set playercolour[11] = |c00106246
      • Set playercolour[12] = |c004E2A04
      • Set playercolour[13] = |c00000000
  • point
    • Events
      • Player - Player 1 (Red) types a chat message containing -pt as An exact match
      • Player - Player 1 (Red) types a chat message containing -points as An exact match
    • Conditions
      • modelocked Equal to False
    • Actions
      • Set pt = True
      • Set modelocked = True
      • Hashtable - Create a hashtable
      • Set hash = (Last created hashtable)
      • Multiboard - Create a multiboard with ((Number of players in pg2) + 1) columns and ((Number of players in pg2) + 2) rows, titled Points
      • Set multiboard = (Last created multiboard)
      • For each (Integer A) from 1 to (Number of players in pg2), do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to (Number of players in pg2), do (Actions)
            • Loop - Actions
              • Multiboard - Set the text for multiboard item in column ((Integer A) + 1), row ((Integer B) + 1) to 0
          • Multiboard - Set the text for (Last created multiboard) item in column ((Integer A) + 1), row ((Integer A) + 1) to -
      • Multiboard - Set the width for multiboard item in column 0, row 0 to 8.00% of the total screen width
      • Multiboard - Set the display style for multiboard item in column 0, row 0 to Show text and Hide icons
      • Multiboard - Set the text for multiboard item in column 1, row ((Number of players in pg2) + 2) to Max Life
      • Trigger - Turn on damage counter <gen>
      • Trigger - Turn on respawn1 <gen>
      • Trigger - Turn on respawn2 <gen>
      • Trigger - Turn on respawn3 <gen>
      • Trigger - Turn on respawn4 <gen>
      • Trigger - Turn on respawn5 <gen>
      • -------- If anyone knows if its possible to get the index number of a variable for an expiring timer that would be nice. I guess I'd just have to use a hash table. --------
      • Trigger - Turn on hero death <gen>
      • Trigger - Turn on hero lvls <gen>
      • Set temp_int = 2
      • Player Group - Pick every player in pg2 and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Color of (Picked player)) Equal to Red
            • Then - Actions
              • Set temp_int2 = 1
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Color of (Picked player)) Equal to Blue
            • Then - Actions
              • Set temp_int2 = 2
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Color of (Picked player)) Equal to Teal
            • Then - Actions
              • Set temp_int2 = 3
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Color of (Picked player)) Equal to Purple
            • Then - Actions
              • Set temp_int2 = 4
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Color of (Picked player)) Equal to Yellow
            • Then - Actions
              • Set temp_int2 = 5
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Color of (Picked player)) Equal to Orange
            • Then - Actions
              • Set temp_int2 = 6
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Color of (Picked player)) Equal to Green
            • Then - Actions
              • Set temp_int2 = 7
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Color of (Picked player)) Equal to Pink
            • Then - Actions
              • Set temp_int2 = 8
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Color of (Picked player)) Equal to Gray
            • Then - Actions
              • Set temp_int2 = 9
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Color of (Picked player)) Equal to Light Blue
            • Then - Actions
              • Set temp_int2 = 10
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Color of (Picked player)) Equal to Dark Green
            • Then - Actions
              • Set temp_int2 = 11
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Color of (Picked player)) Equal to Brown
            • Then - Actions
              • Set temp_int2 = 12
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Color of (Picked player)) Equal to Black
            • Then - Actions
              • Set temp_int2 = 13
            • Else - Actions
          • -------- Heres where the names are added to the multiboard. --------
          • Multiboard - Set the text for multiboard item in column 1, row temp_int to (playercolour[temp_int2] + ((Name of (Picked player)) + |r))
          • Multiboard - Set the text for multiboard item in column temp_int, row 1 to (playercolour[temp_int2] + ((Name of (Picked player)) + |r))
          • Multiboard - Set the text for multiboard item in column temp_int, row ((Number of players in pg2) + 2) to (String((Integer((Max life of heroling[(Player number of (Picked player))])))))
          • Hashtable - Save (temp_int + 0) as (Player number of (Picked player)) of 111 in hash
          • Set temp_int = (temp_int + 1)
      • Multiboard - Hide multiboard
      • Multiboard - Show multiboard
  • elapsed
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Trigger - Add to damage counter <gen> the event (Unit - heroling[1] Takes damage)
      • Trigger - Add to damage counter <gen> the event (Unit - heroling[2] Takes damage)
      • Trigger - Add to damage counter <gen> the event (Unit - heroling[3] Takes damage)
      • Trigger - Add to damage counter <gen> the event (Unit - heroling[4] Takes damage)
      • Visibility - Disable black mask
      • Player - Disable citadel Spell Book for Neutral Passive
      • Destructible - Pick every destructible in (Playable map area) and do (Actions)
        • Loop - Actions
          • Destructible - Make (Picked destructible) Invulnerable
          • Set plantsometrees[temp_int] = (Picked destructible)
          • Set temp_int = (temp_int + 1)
      • Countdown Timer - Start gametimer as a One-shot timer that will expire in 30.00 seconds
      • Set temp_int = 0
      • For each (Integer A) from 1 to (Number of players in (All players controlled by a User player)), do (Actions)
        • Loop - Actions
          • Set pg[(Integer A)] = (Player((Integer A)))
      • Player Group - Pick every player in pg2 and do (Actions)
        • Loop - Actions
          • Player - Disable citadel Spell Book for (Picked player)
          • Player - Disable berserk Spell Book for (Picked player)
          • Selection - Select Help 0006 <gen> for (Picked player)
          • Set temp_int = (temp_int + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • temp_int Equal to 1
        • Then - Actions
          • -------- Here's where the test computer is added to pg2 --------
          • Player - Turn Gives bounty On for Player 2 (Blue)
          • Player Group - Add Player 2 (Blue) to pg2
          • Player - Set name of Player 2 (Blue) to Test
          • Game - Display to (All players) the text: Single player detec...
          • Trigger - Run test <gen> (ignoring conditions)
        • Else - Actions
  • damage counter
    • Events
    • Conditions
    • Actions
      • -------- Here is where the multiboard is updated for damage dealt. --------
      • -------- At the moment, when damage is taken from the computer added from test, all the rows in the column get changed to the damage taken, so from that I conclude, when it's loading the damage source from the hash it's returning 0--------
      • Hashtable - Save ((Damage taken) + (Load (Player number of (Triggering player)) of (Player number of (Owner of (Damage source))) from hash)) as (Player number of (Triggering player)) of (Player number of (Owner of (Damage source))) in hash
      • Multiboard - Set the text for multiboard item in column (Load (Player number of (Triggering player)) of 111 from hash), row (Load (Player number of (Owner of (Damage source))) of 111 from hash) to (String((Integer((Load (Player number of (Triggering player)) of (Player number of (Owner of (Damage source))) from hash)))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Damage source)) Equal to Player 1 (Red)
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[2])
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[3])
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[4])
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[5])
        • Then - Actions
          • Game - Display to (All players) the text: ((Name of Player 1 (Red)) + has won.|n|nHost may now restart the map.)
          • Unit - Pause all units
          • Set re = True
          • Player Group - Pick every player in pg2 and do (Actions)
            • Loop - Actions
              • Visibility - Create an initially Enabled visibility modifier for (Picked player) emitting Visibility across (Playable map area)
              • Set vismod2[(Player number of (Picked player))] = (Last created visibility modifier)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Damage source)) Equal to Player 2 (Blue)
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[1])
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[3])
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[4])
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[5])
        • Then - Actions
          • Game - Display to (All players) the text: ((Name of Player 2 (Blue)) + has won.|n|nHost may now restart the map.)
          • Unit - Pause all units
          • Set re = True
          • Player Group - Pick every player in pg2 and do (Actions)
            • Loop - Actions
              • Visibility - Create an initially Enabled visibility modifier for (Picked player) emitting Visibility across (Playable map area)
              • Set vismod2[(Player number of (Picked player))] = (Last created visibility modifier)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Damage source)) Equal to Player 3 (Teal)
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[1])
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[2])
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[4])
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[5])
        • Then - Actions
          • Game - Display to (All players) the text: ((Name of Player 3 (Teal)) + has won.|n|nHost may now restart the map.)
          • Unit - Pause all units
          • Set re = True
          • Player Group - Pick every player in pg2 and do (Actions)
            • Loop - Actions
              • Visibility - Create an initially Enabled visibility modifier for (Picked player) emitting Visibility across (Playable map area)
              • Set vismod2[(Player number of (Picked player))] = (Last created visibility modifier)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Damage source)) Equal to Player 4 (Purple)
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[1])
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[2])
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[3])
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[5])
        • Then - Actions
          • Game - Display to (All players) the text: ((Name of Player 4 (Purple)) + has won.|n|nHost may now restart the map.)
          • Unit - Pause all units
          • Set re = True
          • Player Group - Pick every player in pg2 and do (Actions)
            • Loop - Actions
              • Visibility - Create an initially Enabled visibility modifier for (Picked player) emitting Visibility across (Playable map area)
              • Set vismod2[(Player number of (Picked player))] = (Last created visibility modifier)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Damage source)) Equal to Player 5 (Yellow)
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[1])
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[2])
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[3])
          • (Load (Player number of Player 1 (Red)) of (Player number of (Owner of (Damage source))) from hash) Greater than or equal to (Max life of heroling[4])
        • Then - Actions
          • Game - Display to (All players) the text: ((Name of Player 5 (Yellow)) + has won.|n|nHost may now restart the map.)
          • Unit - Pause all units
          • Set re = True
          • Player Group - Pick every player in pg2 and do (Actions)
            • Loop - Actions
              • Visibility - Create an initially Enabled visibility modifier for (Picked player) emitting Visibility across (Playable map area)
              • Set vismod2[(Player number of (Picked player))] = (Last created visibility modifier)
        • Else - Actions
 
Last edited:
Did you try to change in init trigger to pick AllPlayers instead of only users? Then this manual addition later of player 2 is not needed. (does it display the "Single player detected"?)


You could save a lot of lines, then it's more readable, for example:
  • Player Group - Pick every player in pg2 and do (Actions)
  • Loop - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Color of (Picked player)) Equal to Red
  • Then - Actions
  • Set temp_int2 = 1
  • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Color of (Picked player)) Equal to Blue
  • Then - Actions
  • Set temp_int2 = 2
  • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Color of (Picked player)) Equal to Teal
  • Then - Actions
  • Set temp_int2 = 3
  • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Color of (Picked player)) Equal to Purple
  • Then - Actions
  • Set temp_int2 = 4
  • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Color of (Picked player)) Equal to Yellow
  • Then - Actions
  • Set temp_int2 = 5
  • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Color of (Picked player)) Equal to Orange
  • Then - Actions
  • Set temp_int2 = 6
  • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Color of (Picked player)) Equal to Green
  • Then - Actions
  • Set temp_int2 = 7
  • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Color of (Picked player)) Equal to Pink
  • Then - Actions
  • Set temp_int2 = 8
  • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Color of (Picked player)) Equal to Gray
  • Then - Actions
  • Set temp_int2 = 9
  • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Color of (Picked player)) Equal to Light Blue
  • Then - Actions
  • Set temp_int2 = 10
  • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Color of (Picked player)) Equal to Dark Green
  • Then - Actions
  • Set temp_int2 = 11
  • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Color of (Picked player)) Equal to Brown
  • Then - Actions
  • Set temp_int2 = 12
  • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Color of (Picked player)) Equal to Black
  • Then - Actions
  • Set temp_int2 = 13
  • Else - Actions
-->
  • Set temp_int2 = (PlayerNumberOf(PickedPlayer))

Also your triggers are a bit hard to read because of strange indention. You copy all at once? If no: Above the "Events" you can see the name of trigger. --> just right click on the name and copy as text --> paste in TRIGGER tags.
 
Level 5
Joined
Aug 24, 2010
Messages
133
My player colour isn't fixed, so red doesn't always equal player one.
Also my bad with the indentation. I added the comments after I copied the triggers but I've fixed them now.
I have tried changing it to all sorts of things. I know for a fact though, that the computer is in the group pg2.
 
Last edited:
Status
Not open for further replies.
Top