Random actions

Get help using Construct 2

Post » Thu Jan 19, 2012 12:47 am

I'm working on very unpredicrable AI for my enemy characters and want them to act randomly in different situations. Simply put, I want to make the enemy to either attack or take few steps backwards when they get close to player. I can make them do that with 50/50 chance by giving them command to randomly jump into states 1 and 2 with "Random(1,2)" command.

Now I'm wondering how should change the chances between those two, making the jump into state 1 to have 75% percent chance and state 2 to 25%?

I know this is kinda difficult to explain, and I can't really upload a .capx because the project is so full of things it would take way too long to cut everything unnecessary out.

I hope someone can help me with this :)
B
15
S
5
G
4
Posts: 214
Reputation: 3,124

Post » Thu Jan 19, 2012 12:51 am

There may be more elegant solutions, but you can always (pseudo code, bare with me):

[code]set a local variable to int(random(3))
..local variable <=2
....-> Jump state = 1
..local variable = 3
....-> Jump state = 2
[/code]

It should do the trick.Kyatric2012-01-19 00:52:05
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793


Return to How do I....?

Who is online

Users browsing this forum: R0J0hound, randomly, spcsmrf and 24 guests