Continuously damage enemies on overlap

Get help using Construct 2

Post » Sun Jun 23, 2013 7:21 pm

How do I set up an AOE type attack that does damage to multiple enemies at set intervals? (i.e., I lay a flame trail on the ground composed of multiple sprites, each sprite when overlapped with an enemy will do damage every second)

Overlapping fire -> spams screen, instant kills all enemies since it's every tick

Overlapping fire, For each fire instance variable/cooldown that determines when to deal damage -> only does damage to one enemy every X seconds

Overlapping fire, For each enemy instance variable/cooldown that determines when enemy takes damage -> enemies will only take damage from one fire sprite at a time

This is complicated by the fact that there are a ton of different ways to damage enemies beyond the fire. Any help would be much appreciated!
B
9
S
3
Posts: 58
Reputation: 1,566

Post » Sun Jun 23, 2013 7:30 pm

Every 1 second
For each Enemy
Enemy is overlapping Flame
.. do damage * Flame.pickedcount (if you wanted to have multiple overlapped flames do more damage)

That should work :)
B
24
S
9
G
7
Posts: 756
Reputation: 7,302

Post » Sun Jun 23, 2013 7:51 pm

Hmm okay! Thanks for your help! Works reasonably well although it looks like enemies can walk in and out of the fire without taking damage if they time it right. If I set the interval higher it creates too much spam though. =\

It also doesn't seem to work right for projectile aoe type attacks (poison cloud), probably because the attack is traveling too quickly (similar to enemies walking in and out of fire). Is there a way to fix this without just decreasing the timer? Its almost like I need a timer to start for each attack striking each enemy.
B
9
S
3
Posts: 58
Reputation: 1,566

Post » Sun Jun 23, 2013 9:02 pm

Okay here's what I did.. not sure why this is not 100% working for all hits and only some.. will figure out a mini capx to post if I don't get this working and it's not obvious to you what's wrong with it.

1) Create an array to store each unique enemy + damagesenemy pairing
2) On enemy/damagesenemy overlap, check for lastindexof(str(enemy.uid&","&damagesenemy.uid))
3) If it doesn't exist (-1), do damage
4) Then push a new row with the pairing + a timer.
5) Loop every tick to decrease all values in the array
6) Delete records that have timer go below 0.
B
9
S
3
Posts: 58
Reputation: 1,566

Post » Sun Jun 23, 2013 9:06 pm

You could also use the simpler method vee41 suggested, but add in a one-off event of "On collision."

so On collision, deduct 5hp

AND

Every second, yada yada

So the initial impact does something and the timer very simply continues doing what it was doing, but without the possibility of escaping at least SOME damage.
B
103
S
38
G
19
Posts: 962
Reputation: 17,996

Post » Sun Jun 23, 2013 9:21 pm

Yea but that can cause a double tick of damage right? On collision triggers then if the 'every X seconds' trigger is about to fire, it will tick again.
B
9
S
3
Posts: 58
Reputation: 1,566

Post » Sun Jun 23, 2013 9:25 pm

On Collision do damage and start timer. Very simple.
B
56
S
15
G
13
Posts: 826
Reputation: 17,645

Post » Sun Jun 23, 2013 9:28 pm

I'm trying to start timer with this array method.. is there another way you would suggest having a timer for a unique enemy/attack pairing?
B
9
S
3
Posts: 58
Reputation: 1,566

Post » Sun Jun 23, 2013 9:30 pm

Just use a local variable on your enemies for the timer.
I think I may be confused on what exactly it is you want.
B
56
S
15
G
13
Posts: 826
Reputation: 17,645

Post » Sun Jun 23, 2013 9:40 pm

Hmm, I think you're simplifying a bit. Trying to expand the example to include many different attack types. A single local variable on the enemy can only toggle whether it takes damage from a single source - if I dropped fire and then shot at an enemey, I'd want it to take the shot damage regardless of when the fire is damaging it.
B
9
S
3
Posts: 58
Reputation: 1,566

Next

Return to How do I....?

Who is online

Users browsing this forum: Norafaithrainbow, TRMG, Yahoo [Bot] and 21 guests