• 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.

Random integer is not always left out

Status
Not open for further replies.
So I have this grid made up by walls.
The player can Blink from non walled grids to another.
The idea is to create an enemy unit doing a Thunder Clap in all the non walled grinds but one. The player must then Blink to that one safe grid.

The weird thing is that sometimes it works (one grid is safe) but sometimes all non walled grids spawns an enemy unit thus the player can't escape the damage.

These triggers are just a fraction of the real ones, but this is what controls the spawning.
The reason for the "Set Temp_Integer_1 = (Temp_Integer_1 + 2)" in the first trigger is because of the walls covers 1 grid space.

  • Stage 07 Setup
    • Events
    • Conditions
    • Actions
      • -------- -------------- ----------------------- -------------- --------
      • -------- -------------- ----------------------- -------------- --------
      • -------- -------------- ----------------------- -------------- --------
      • Set Temp_Integer_1 = 1
      • For each (Integer INTEGER_007) from 1 to 49, do (Actions)
        • Loop - Actions
          • Set Temp_Point_Array_nDestroy_1[INTEGER_007] = Game_Region_Points[Temp_Integer_1]
          • Set Temp_Integer_1 = (Temp_Integer_1 + 2)
      • -------- -------------- ----------------------- -------------- --------
  • Stage 07 Execute 1
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Game_Stage_Completed Equal to False
        • Then - Actions
          • Set Temp_Integer_1 = (Random integer number between 1 and 49)
          • For each (Integer INTEGER_001) from 1 to 49, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • INTEGER_001 Equal to Temp_Integer_1
                • Then - Actions
                  • Set Temp_Unit_Array_1[Temp_Integer_1] = No unit
                • Else - Actions
                  • Unit - Create 1 Dummy Unit Frozen Blast for Player 12 (Brown) at Temp_Point_Array_nDestroy_1[INTEGER_001] facing Default building facing degrees
                  • Set Temp_Unit_Array_1[INTEGER_001] = (Last created unit)
          • -------- -------------- ----------------------- -------------- --------
 
I believe that you need Skip remaining actions in this case, within the loop, to avoid multiple occurrences of the effect.

I'm not sure I completely follow.
I want it to continue but leave that particular unit unspawned so the player can escape to that point.
If I skip, even inside the loop, every dummy unit from the random integer to end integer will leave a safe grid.

Or?
 
Create a unit in all the tiles. Then use the random integer to remove the unit in the random tile.

Hm just tried that suggestion now. I didn't see why that should be any different though.
And after testing the same problem occurs.

To avoid any confusion I have attached two pictures.
The first is where it is working as it should the other where it doesn't:
Grid working.png
Grid not working.png


Edit:
How the trigger looked while testing.

  • Stage 07 Execute 1
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Game_Stage_Completed Equal to False
        • Then - Actions
          • Set Temp_Integer_1 = (Random integer number between 1 and 49)
          • For each (Integer INTEGER_001) from 1 to 49, do (Actions)
            • Loop - Actions
              • Unit - Create 1 Dummy Unit Frozen Blast for Player 12 (Brown) at Temp_Point_Array_nDestroy_1[INTEGER_001] facing Default building facing degrees
              • Set Temp_Unit_Array_1[INTEGER_001] = (Last created unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • INTEGER_001 Equal to Temp_Integer_1
                • Then - Actions
                  • Unit - Remove Temp_Unit_Array_1[INTEGER_001] from the game
                • Else - Actions
          • -------- -------------- ----------------------- -------------- --------
 
I only see 25 spaces and not 48. Your loops are running through 48 different spots.

Hm I wonder why I haven't checked that.
A facepalm is in order.

Edit:
While it seemed obvious what the problem was, I encountered a new problem trying to fix it.
By replacing all the 49'ers with 25's the game will always skip the last two rows (rows are counted from the bottom).

Grid not working 2.png

I have stared myself blind at the triggers and can't seem to figure out why this happens.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
As I do not know how the array is packed or what you have done to the trigger I can only guess the following.

I believe that you need Skip remaining actions in this case, within the loop, to avoid multiple occurrences of the effect.
This would cause the problem since it would skip generating some of them.

If the points do not just correspond to open tiles then you will cut-off pre maturely. If this is the case you need to skip the indices that do not correspond to open tiles.

Something you do causes a thread crash at that point.
 
Status
Not open for further replies.
Top