[SOLVED] How do I spawn 3 criminals out of 10 people?

Get help using Construct 2

Post » Wed May 20, 2015 11:24 pm

Hello, thank you for reading!

What I wanted to do is spawn 10 people at random times, but 3 of them should be criminals.

For that, I created a sprite called "People" and gave it a boolean called "Criminal" and on spawn it's decided (randomly) if it's a criminal or not.
The spawns are limited by a global variable (invites) that is set by the difficulty and with each spawn it decreases by 1 until it reaches 0 ( so it doesnt spawn anything )


The problem is: I've tried many things but sometimes the criminal count is wrong, sometimes it spawns more people than it should, it never gets what I want.. Can you help me?

( I know the code is messy, sorry about that :roll: )
Last edited by illugion on Thu May 21, 2015 1:06 am, edited 2 times in total.
B
7
S
1
Posts: 11
Reputation: 447

Post » Thu May 21, 2015 12:39 am

Why you don't use 2 sprites one for people and the other for criminals?
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,155

Post » Thu May 21, 2015 12:49 am

I wanted them to be basically the same (same appearance, animations etc), the criminals would do just little things that the people wouldn't. So I thought it would save code and resources if I just did it like this
B
7
S
1
Posts: 11
Reputation: 447

Post » Thu May 21, 2015 1:01 am

First line look suspiciously. Difficulty = 0 is all time true so all globals are every tick set to what you put in actions.
B
9
S
3
G
3
Posts: 36
Reputation: 2,433

Post » Thu May 21, 2015 1:03 am

Yes ! That was actually what was making the infinite spawn! I got it all solved now after trying for some while, thanks a lot guys!
B
7
S
1
Posts: 11
Reputation: 447


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 11 guests