Using tables to keep track of enemies alive: stuck on part of the logic?

mhedgesmhedges Raised on VCSMember Posts: 634
edited August 2015 in Working with GS (Mac)

Hello -

I've been tinkering around with the Alien Conquerors template, messing with the actors' movements and behaviors. That got me to think about how the enemies fire back at the player.

The easy solution would be to simply have a timer that would, every second, have a random actor (say, from 1 to 32) fire. But what if you've killed 17 aliens? That could be a long time between enemy shots if the randomizer keeps picking the dead ones.

I thought it would be more logical to have a table keep track of the live enemies, but I'm stuck on certain items.

  1. I have to create a table for x amount of characters. Let's use 32. One column, 32 rows, in each cell the value will be from 1 to 32.
  2. I have to have an event handler actor pick a random number from 1 to "tableRowCount", as a row will be eliminated when an enemy is killed.
  3. I have to read the tableCellValue from the row, which will not necessarily be the same as the row number. If I kill enemy #17, then there will be 31 rows left, but row #17 will now have as tableCellValue 18 (the next surviving enemy in the table).
  4. I have to create a rule within each enemy actor so that when the chosen tableCellValue is equal to its self-value (unique identifier), then that actor fires a bullet.
  5. I have to create a rule within each enemy actor that when it is hit by a bullet, it must be destroyed, but it must also eliminate its corresponding row in the table based on its value, not its row number (see #3 above).

I believe I am missing something related to the enemy itself, but at this moment am uncertain what it is - read the updated table? Other? Any ideas?

EDIT: I believe that the problem is that the enemy needs to read it value in the table before actually firing or getting destroyed. This is where I am stuck.


Sign In or Register to comment.