by rld » Thu Oct 08, 2009 8:46 am
Yeah, I think the main problem is that you are recreating a creature that has HP=0 and that ACK has internally marked as 'dead'. Even if you keep the same instance number, you are restoring a dead creature to the map which I'm sure will cause the ACK code difficulties since it wasn't expecting that creature to be there.
One interesting trick I found that might be useful to you: When a macro 'teleports' the player by setting LOC[X], LOC[Y], or the other location variables, ACK reloads the room that the player is in after the teleport. However, this reload will occur even if the player is still in the same room, for instance, if the macro executes
SET LOC[X]=LOC[X]-1
without otherwise changing the player's location. It will also occur if the macro writes to one of the location variables, even if the player's location doesn't actually change:
SET LOC[X]=LOC[X]
The reason that this is useful is that when the room is reloaded, any 'wandering monster' locations in the room are checked and you have a chance of new wandering monsters being generated.
This is very easy to try out; in an existing game, set one of the 'extra' commands in the config editor to run a macro that sets LOC[X]=LOC[X]. Then, in a room, place a 'wandering monster' with 100% odds of reappearing. When you go in that room, trigger the extra command; a new wandering monster will appear in that spot each time you trigger it, as long as there is not already a creature there.
(If you wanted, you could make a really nasty 'trap room' this way by placing several squares around the edge of the room that had 100% wandering creatures, and then having squares in the room (or a step macro that ran while the player was in the room) trigger a reload with LOC[X]=LOC[X]. As the player walked through the room, more and more creatures would spawn as the old ones stepped off the squares and headed for the player, and the player would be surrounded.)
But back to your issue. I think the way that you could do this would be to run a step macro in the room, and set a flag when one of the creatures was killed (using the creature's death macro). When this flag was set, the step macro would reload the room by setting LOC[X]=LOC[X]. In each of the four corners of the room, place a 'wandering monster' for each of the four monster types you want to recreate. Surround these monsters with opaque obstacles so they can't move and so the player can't see them. When a reload occurs, these monster squares will be 'replenished' with your creatures, if they are not already there.
Then, the step macro would resurrect them as follows. When the flag for one of the creatures is set, do a reload. X number of turns later, use MAPCHKD/MAPTAKE to get that creature's instance number (from the 'wandering monster' square) and remove the creature, then use MAPADD/MAPSETD to copy it to your desired destination. The instance number will be different each time, as new creatures are being created. You may want to have a different 'resurrection spot' for each creature in case the player manages to kill more than one at once with an area weapon.
Yeah, I think the main problem is that you are recreating a creature that has HP=0 and that ACK has internally marked as 'dead'. Even if you keep the same instance number, you are restoring a dead creature to the map which I'm sure will cause the ACK code difficulties since it wasn't expecting that creature to be there.
One interesting trick I found that might be useful to you: When a macro 'teleports' the player by setting LOC[X], LOC[Y], or the other location variables, ACK reloads the room that the player is in after the teleport. However, this reload will occur even if the player is still in the same room, for instance, if the macro executes
SET LOC[X]=LOC[X]-1
without otherwise changing the player's location. It will also occur if the macro writes to one of the location variables, even if the player's location doesn't actually change:
SET LOC[X]=LOC[X]
The reason that this is useful is that when the room is reloaded, any 'wandering monster' locations in the room are checked and you have a chance of new wandering monsters being generated.
This is very easy to try out; in an existing game, set one of the 'extra' commands in the config editor to run a macro that sets LOC[X]=LOC[X]. Then, in a room, place a 'wandering monster' with 100% odds of reappearing. When you go in that room, trigger the extra command; a new wandering monster will appear in that spot each time you trigger it, as long as there is not already a creature there.
(If you wanted, you could make a really nasty 'trap room' this way by placing several squares around the edge of the room that had 100% wandering creatures, and then having squares in the room (or a step macro that ran while the player was in the room) trigger a reload with LOC[X]=LOC[X]. As the player walked through the room, more and more creatures would spawn as the old ones stepped off the squares and headed for the player, and the player would be surrounded.)
But back to your issue. I think the way that you could do this would be to run a step macro in the room, and set a flag when one of the creatures was killed (using the creature's death macro). When this flag was set, the step macro would reload the room by setting LOC[X]=LOC[X]. In each of the four corners of the room, place a 'wandering monster' for each of the four monster types you want to recreate. Surround these monsters with opaque obstacles so they can't move and so the player can't see them. When a reload occurs, these monster squares will be 'replenished' with your creatures, if they are not already there.
Then, the step macro would resurrect them as follows. When the flag for one of the creatures is set, do a reload. X number of turns later, use MAPCHKD/MAPTAKE to get that creature's instance number (from the 'wandering monster' square) and remove the creature, then use MAPADD/MAPSETD to copy it to your desired destination. The instance number will be different each time, as new creatures are being created. You may want to have a different 'resurrection spot' for each creature in case the player manages to kill more than one at once with an area weapon.