How do I set a timed enemy attack?

Get help using Construct 2

Post » Tue Jan 16, 2018 2:23 am

Hello people, I'm working on a "survival shooting game" kinda The House of the Dead mixed with Splatterhouse vibe :mrgreen: So far so good until I had to make the enemies attacks :( At start of layout I start an enemies time behavior called [attack] of 5 seconds set that:

[on Timer "attack"]
[For Each Enemy]-> they flash and the system sustract 05 from the player health

All that works fine, the problem is that I wanted one of the enemies to be the "leader" so if you don't defeat that one the others just keep respawning :twisted: And there is were I'm having trouble :x
The game itself it's just a little more than a draft at this point, I will change a lot of elements for the final release, but only if I manage to get this working right since is a crucial mechanic for my game :cry:

This is what I got for now:
http://satanicalmassacrewip.bitballoon.com/

And this is the capx:
http://www.mediafire.com/file/12zhap8wt ... e%2001.zip

You will see the problem with the timer is disabled (under the "enemies 01" inside Enemies Group) if that timer is not activated the enemies stop attacking, if is activated the player health doesn't stop depleting (when it's supposed to sustract just 5)

Already thanks to anyone that could point me what I'm doing wrong since I always tend to overcomplicate things in the games I make :P
B
14
S
2
Posts: 10
Reputation: 758

Post » Tue Jan 16, 2018 4:23 am

Why did you include 94Mb of backups into this zip?!

You can try something like this:
Add an instance variable "IsLeader" to your Enemies family. Set it to "True" for one instance which will be the leader.

When the leader is killed, destroy it and all other enemies.

If you don't want to destroy other enemies after leader's death, set a global variable LeaderIsDead=1.
When non-leader enemy is killed , check if LeaderIsDead=1 and destroy enemy.
If LeaderIsDead=0, instead of destroying the enemy, set it invisible. Start "Respawn" timer.

On Timer "Respawn" : Set Health=100, Set Visible

Also, you have a bunch of almost identical events for enemy1, enemy2, enemy3, why don't you use Enemies family in these events?
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
17
S
9
G
129
Posts: 1,805
Reputation: 68,935

Post » Tue Jan 16, 2018 3:45 pm

dop2000 wrote:Why did you include 94Mb of backups into this zip?!

You can try something like this:
Add an instance variable "IsLeader" to your Enemies family. Set it to "True" for one instance which will be the leader.

When the leader is killed, destroy it and all other enemies.

If you don't want to destroy other enemies after leader's death, set a global variable LeaderIsDead=1.
When non-leader enemy is killed , check if LeaderIsDead=1 and destroy enemy.
If LeaderIsDead=0, instead of destroying the enemy, set it invisible. Start "Respawn" timer.

On Timer "Respawn" : Set Health=100, Set Visible

Also, you have a bunch of almost identical events for enemy1, enemy2, enemy3, why don't you use Enemies family in these events?


Yeah, it worked! :D I didn't know the capx could work without the files :P I noticed that even if now everything works fine all the enemies attacks at the same time :| That's sucks :? Is there a way to set the "attack" timer into a random time between 5 and 10 seconds for example? (Edit: I just remembered how it's done :D )
B
14
S
2
Posts: 10
Reputation: 758


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], Kyledfrank and 66 guests