I’m trying to create an RPG-esque game, complete with randomly selected enemies to fight, and I figured the best way to go about it would be to copy enemies into the player’s location, then remove them when I’m done with them. I’ve tried this in two ways, and both have some pretty big flaws.
First of all, I tried using Dynamic Objects to simply clone the enemy. However, the problem with this is that there seems to be no way to “delete” a cloned object. It can be removed from play, but it seems to remain in memory, as the interpreter freezes up after a number of clones roughly equal to the dynamic memory allocation have been created. While the dynamic memory allocation can be set very high, having this problem be at all possible in the first place seems like bad form.
The second way I tried was to have a mostly blank table defining some enemies and then populating the table during play, so that clearing an entry from the table would hopefully completely remove the enemy, but it seems defining something with a table only works when the source is interpreted, so I don’t think that would work.
I can think of a workaround, but it becomes significantly messier when applied to other uses, such as disposable items the player can carry multiple of. So I was wondering if someone could suggest a way to temporarily copy an object and then discard it when done with it, including reclaiming the dynamic memory it uses. Failing that, some suggestions on how to handle this sort of thing would be nice.