Strange behavior with infinite timers (FIXED)
Posted: Wed Aug 31, 2011 7:31 pm
I'm this | | close to completely ditch GE's built-in timers and use variable timers, but before that I decided it wouldn't hurt to ask about this most peculiar behavior of actors with infinite timers...
Here's more or less the problem I'm having. I have attached the latest version of my game prototype, and in the "enemy_prototype" actor, you'll notice two timers are created, a "HurtTimeout" that only happens once when they get "hurt" (Collide with "player_attack"), and an "AttackInterval" which is periodic and infinite (One inside and outside of script, in case that was the problem, it wasn't ). So far so good, the enemies turn around and shoot at my general direction with every AttackInterval timer event, for now the bullets do nothing but to destroy themselves when colliding against a wall (A "solid" actor) or after they've been traveling for some time. You'll also notice the "enemy_prototype" creates by itself two more actors, an instance of "healthbar" and "health_display_numbers" that display the enemy's health graphically and textually (Along with some other information, and yes, I just read about activation events, and indeed I believe I could pass their cloneindex numbers more efficiently, though I'm open to any more ideas as to how associate them with their parent / creator so they get destroyed along with it. Would something like "if(!creator) DestroyActor(clonename);" work without so much hassle?). Now this is when things get freaky.
Upon exiting the room, and thus the activation region in which all "enemy_prototype" instances were, when re-entering, they don't seem to "respawn" if I have killed them before. Moreover, their "healthbar" and "health_display_numbers" actors don't get created for some reason. However, removing the CreateTimer event restores what I assume is normal behavior (They "respawn" when entering their corresponding activation region and "healthbar" and "health_display_numbers" get created correctly). Any ideas on what I could be doing wrong?
PS: Also, some of you might be able to notice I'm using some snippets of code I've seen around these forums, among them pyro's method for collisions, lcl's (I believe?) anti-moonwalk, Bee-Ant's dialog system (With a few tweaks) and such. Thank you all!
Here's more or less the problem I'm having. I have attached the latest version of my game prototype, and in the "enemy_prototype" actor, you'll notice two timers are created, a "HurtTimeout" that only happens once when they get "hurt" (Collide with "player_attack"), and an "AttackInterval" which is periodic and infinite (One inside and outside of script, in case that was the problem, it wasn't ). So far so good, the enemies turn around and shoot at my general direction with every AttackInterval timer event, for now the bullets do nothing but to destroy themselves when colliding against a wall (A "solid" actor) or after they've been traveling for some time. You'll also notice the "enemy_prototype" creates by itself two more actors, an instance of "healthbar" and "health_display_numbers" that display the enemy's health graphically and textually (Along with some other information, and yes, I just read about activation events, and indeed I believe I could pass their cloneindex numbers more efficiently, though I'm open to any more ideas as to how associate them with their parent / creator so they get destroyed along with it. Would something like "if(!creator) DestroyActor(clonename);" work without so much hassle?). Now this is when things get freaky.
Upon exiting the room, and thus the activation region in which all "enemy_prototype" instances were, when re-entering, they don't seem to "respawn" if I have killed them before. Moreover, their "healthbar" and "health_display_numbers" actors don't get created for some reason. However, removing the CreateTimer event restores what I assume is normal behavior (They "respawn" when entering their corresponding activation region and "healthbar" and "health_display_numbers" get created correctly). Any ideas on what I could be doing wrong?
PS: Also, some of you might be able to notice I'm using some snippets of code I've seen around these forums, among them pyro's method for collisions, lcl's (I believe?) anti-moonwalk, Bee-Ant's dialog system (With a few tweaks) and such. Thank you all!