...Spawn powerups randomly from infinite enemies

Get help using Construct 2

Post » Thu Jun 13, 2013 11:22 pm

Hi,

So here is the scenario:

I have four different types of enemies in my game. The enemies spawning are infinite. When I kill a random enemy, I want the enemy to spawn a random powerup.

I am able to spawn random powerups, but cannot figure out how to make it fall from a random enemy when the enemies keep spawning infinitely.

I don't think the Compare Two Values would work because the count is infinite, so cant put a First Value and Second Value... unless I am mistaken.

Please Help.

Thanks.
B
5
S
1
Posts: 38
Reputation: 839

Post » Fri Jun 14, 2013 5:08 am

If it's spawning from the enemy that was just killed, then when you do the action that destroys the enemy, spawn the powerup then.

I'm not totally sure if that is what you are asking or not. I was a bit confused :).
B
100
S
31
G
11
Posts: 1,552
Reputation: 21,497

Post » Fri Jun 14, 2013 9:39 am

Hi.

Yeah, that is what I am aiming for. When the monster dies, it spawns a new object, which is the random powerup. But, I don't want a powerup to spawn on every death. It has to be random. I don't have the monsters in array. Every monster is a unique one.

So, I have:
Monster A, Monster B, Monster C, Monster D.

All the monsters spawn infinitely. Is there a way I can do a collective "random powerup spawn at any death", even though the monsters are not in an array?

The problem I am facing is since the monsters spawning is infinite, I am not able to give percentage for the powerup drops. :(
B
5
S
1
Posts: 38
Reputation: 839

Post » Fri Jun 14, 2013 10:28 am

Hey! I found a workaround for it!! Finally!!!

Since when any enemy dies, they use a common Smoke sprite, I just made the powerup spawn randomly from the smoke at random seconds.
B
5
S
1
Posts: 38
Reputation: 839

Post » Mon Mar 20, 2017 6:00 am

how to do it?
B
4
Posts: 1
Reputation: 202

Post » Mon Mar 20, 2017 9:39 am

Just answered something similar to this on another thread;

Using global variables:

Code: Select all
Global Variable XXXX

event - On enemy death -> Set XXXX to Round(Random(0,100))
event - if XXXX => 50 -> CreateObject.YOUR.POWERUP.HERE    (so if the variable is greater or equal to 50, spawn a powerup)
                                          Set XXXX to 0  (and reset the variable to be safe it only spawns 1)


So what you have is 1 variable that you randomise between 0 and 100 on the enemy death.
If you then check if it's greater than or equal to 50, this will give a 50% chance for spawning a powerup.
Best to always reset it to 0 after you've spawned one to avoid any chance of accidentally spawning 2.
B
9
S
2
Posts: 66
Reputation: 827


Return to How do I....?

Who is online

Users browsing this forum: oosyrag, pcprice76 and 8 guests