Killing 1 enemy destroys everything?

Get help using Construct 2

Post » Thu May 01, 2014 8:22 am

So here's this glitch that is really bothering me. Sometimes, when I kill an enemy, almost every other enemy dies. But that's the problem. Almost.
I'd understand if all the enemies would die, because the code looks like this:

https://www.dropbox.com/s/3ew3mfr4ziw3x ... emcode.png

(There's also an hpMissile variable, which is basically deducted from when you hit something with a missile, but I didn't use it.)

And it's easy to assume that in the action, C2 thinks that it needs to destroy all the instances of the "Hurtables" family, and not the one that was specified in the condition, aka got its health to less than 0. But in this case, only a select few die, while some enemies are still alive (huge success?), which makes no sense. Here's a video:

http://www.youtube.com/watch?v=n13l1qRfV1A

Thank you.
HARMLESS SIGNATURE THAT IS VIEWED BY OTHERS AS OFFENSIVE AND CONTROVERSIAL
B
14
S
3
G
3
Posts: 356
Reputation: 4,377

Post » Thu May 01, 2014 8:30 am

What is the 'hpMissle' variable for, what other events change that?
Otherwise, try adding a for each. I doubt it would work for something like this, but it might if your 'Hurtables' have different hp values.
B
42
S
14
G
3
Posts: 165
Reputation: 5,115

Post » Thu May 01, 2014 9:15 am

Also, here's the capx (All the basic enemy hp code is located in the "Common Sense" group).

https://www.dropbox.com/s/nwnozh79qnucu ... er085.capx

@Sumyjkl

The hpMissile variable is there for times when I want to create an enemy that is impossible to kill with regular weapons, but dies from 1 missile shot, aka hp=9999999, hpMissile= 1.
I'll try the For Each now.
HARMLESS SIGNATURE THAT IS VIEWED BY OTHERS AS OFFENSIVE AND CONTROVERSIAL
B
14
S
3
G
3
Posts: 356
Reputation: 4,377

Post » Thu May 01, 2014 9:37 am

The for each seems to work, not sure why since it only seems to be instance problems when it does the same thing to everything.
instance damage for each.png
You do not have the required permissions to view the files attached to this post.
B
42
S
14
G
3
Posts: 165
Reputation: 5,115

Post » Thu May 01, 2014 10:03 am

The For Each helped! I didn't include the hurting itself into the loop, though.
But it's really strange the glitch even occurred, So umm, @Ashley ? This might be interesting.
HARMLESS SIGNATURE THAT IS VIEWED BY OTHERS AS OFFENSIVE AND CONTROVERSIAL
B
14
S
3
G
3
Posts: 356
Reputation: 4,377

Post » Thu May 01, 2014 11:48 am

Your events are wrong: 'hp <= 0 or hpMissile <= 0' is true every tick, and 'Wait' does not block the events. So if it waits for 1 second, it will be true every tick for 1 second (about 60 ticks). That means it queues up 60 waits and executes 'Destroy' 60 times. I guess executing 'Destroy' repeatedly is not what you're after.
Scirra Founder
B
387
S
230
G
87
Posts: 24,248
Reputation: 192,228

Post » Thu May 01, 2014 12:26 pm

@Ashley the Wait is usually and in this case 0 seconds. Does that still cause glitches?
HARMLESS SIGNATURE THAT IS VIEWED BY OTHERS AS OFFENSIVE AND CONTROVERSIAL
B
14
S
3
G
3
Posts: 356
Reputation: 4,377

Post » Thu May 01, 2014 1:49 pm

I'm not sure, why would you want to wait at all before destroying it? Since it's a variable wait time, when it's nonzero you'll still see that problem. It's just not a pattern of events that you should be using.
Scirra Founder
B
387
S
230
G
87
Posts: 24,248
Reputation: 192,228

Post » Thu May 01, 2014 3:16 pm

Thank you very much.
HARMLESS SIGNATURE THAT IS VIEWED BY OTHERS AS OFFENSIVE AND CONTROVERSIAL
B
14
S
3
G
3
Posts: 356
Reputation: 4,377


Return to How do I....?

Who is online

Users browsing this forum: Lancifer, Yahoo [Bot] and 4 guests