Taken damage from multiple enemys

Get help using Construct 2

Post » Sat Aug 13, 2016 7:44 am

Hello Guys !

Since a long time i try to receive from my hero damage from multiple enemy's source.

I would like to do this :

When an enemy is coming in Hero's line of sight, enemy do animation "attack" then deal his "damage" every ""his attack speed" seconde"(And subtract damage to health bar).

But ! when a second enemy is coming, this second enemy deal his damage with his attack speed. (And subtract damage to health bar)

I try lot of things with for each, array, while but always just 1 enemy deal his damage.

Image

I hope u understand my problem.

Thx for help !
Last edited by Rostes on Sat Aug 13, 2016 8:19 am, edited 2 times in total.
B
2
Posts: 4
Reputation: 158

Post » Sat Aug 13, 2016 8:08 am

Can you attach a capx file of what you did so far? It would help as I think there is possibly more than one reason why this is not working and all of them need to be fixed. And I can only guess what those issues might be.
B
15
S
6
Posts: 85
Reputation: 1,195

Post » Sat Aug 13, 2016 8:13 am

I just update with a screenshot
B
2
Posts: 4
Reputation: 158

Post » Sat Aug 13, 2016 9:50 am

I think this is because despite the "foreach" loop the events are simultaneous.

A solution :
Image
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Sat Aug 13, 2016 3:33 pm

Message: Rostes can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Thx for ur answer Coincoin.

I try ur solution but just 1 enemy is dealing damage. (-1hp/s)

I would like that all enemy in range deal their own damage with their own attack speed.

U can download my example here :

https://www.dropbox.com/s/9ejknwormov6m
2v/Example_Multiple_Enemy_Damage.capx?dl=0

My hero have to take -20hp (10x2) each second, but here he just take 10 each second.

^^ thx for help
B
2
Posts: 4
Reputation: 158

Post » Sat Aug 13, 2016 4:26 pm

Here's how I did it with timer behaviour added for enemies, turns out it is a bit more complicated than expected (not too much though). Add (repeating) timers equal to attack speed for all enemies. Basically on timer end do actions for each enemy (this is important otherwise just one enemy does the damage). Keep track of who has a timer initiated with a boolean. Stop them once enemy is out of range.

I recommend clicking between the two squares to the left to move the player there. Every 15 seconds they attack simultaneously and player HP should drop by 5+3=8.

https://www.dropbox.com/s/etpdvfta51ck9 ... .capx?dl=1
B
15
S
6
Posts: 85
Reputation: 1,195

Post » Sat Aug 13, 2016 6:18 pm

Thx pulsar ! It's work great.

And without line of sight, nice !
B
2
Posts: 4
Reputation: 158


Return to How do I....?

Who is online

Users browsing this forum: dop2000, Kyatric and 34 guests