How do I randomly generate specific numbers?

Get help using Construct 2

» Fri Nov 28, 2014 5:47 pm

I have a waypoint system set up I would like to do, to move enemies around, without the pathfinding behavior.

When they collide with specific waypoints, it will change their direction based on a number value.

The problem is, I don't want it to always choose all 4 random numbers. Sometimes, I would want it to pick a random number out of 2 numbers, or 3 numbers, so how would I do that?

I know how to randomly generate the 4 numbers, but what would I do if I wanted it to set it to either 0, or 2? Or 1 and 4, or 0,1 and 4?

thanks!
B
4
S
1
Posts: 78
Reputation: 756

» Fri Nov 28, 2014 6:08 pm

Try choose(n0,n1,n2), or just use int(random(4)) would get 0-3 which you can reference 0 do this, 1 do foo, etc.
B
175
S
50
G
199
Posts: 8,625
Reputation: 124,026

» Fri Nov 28, 2014 6:21 pm

two different options (event 1 or events 2 and 3)
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

» Fri Nov 28, 2014 6:23 pm

Hexxiss wrote:. The problem is, I don't want it to always choose all 4 random numbers. Sometimes, I would want it to pick a random number out of 2 numbers, or 3 numbers, so how would I do that?

I know how to randomly generate the 4 numbers, but what would I do if I wanted it to set it to either 0, or 2? Or 1 and 4, or 0,1 and 4?

thanks!

use instance variables for enemy..
var=1 ..choose(1,4)
var=2 ..choose(0,3)
...........
B
67
S
24
G
7
Posts: 1,519
Reputation: 11,094