Continuously damage enemies on overlap

0 favourites
  • 11 posts
From the Asset Store
🙌 J-BoB Damage & Hit Sound Pack comes with 585 high-quality sound effects
  • 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!

  • 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 :)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • 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.

  • 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.

  • On Collision do damage and start timer. Very simple.

  • 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?

  • Just use a local variable on your enemies for the timer.

    I think I may be confused on what exactly it is you want.

  • 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.

  • Cool it works. Hopefully this isn't too computationally intensive. My problem was not using looping 'For each attack' and 'For each enemy' before storing into the array so it was only getting one of them I assume (e.g., I use a flamethrower attack and two fire sprites tick at same time, only one was getting stored in the array)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)