# How do I randomize an event?

Get help using Construct 2

### » Tue Mar 25, 2014 3:51 pm

Example:

+ Condition A
+ Condition B
+ Condition C
+ Condition D
+ 1 out of 4 chances or 25% chance of happening
-> Action

Is there a way to make this event happen randomly on a 25% probability chance even if conditions A,B,C,D are always true?

P.S.
I am not talking about Pick random instance or pick random whatever.
B
16
S
7
Posts: 301
Reputation: 2,736

### » Tue Mar 25, 2014 4:07 pm

I suggest a random numbered variable (1-4). Condition a-b-c-d respectively would act out depending on what the variable was (a=1, b=2, etc.)

No clue how you do that in construct 2, though.
B
3
S
1
Posts: 7
Reputation: 341

### » Tue Mar 25, 2014 4:19 pm

not sure I understood you.

I'll replace the generic condition and action names with a new example using sort of pseudocode:

+Enemy is alive
+Enemy is on ground
+Enemy is not attacking
+Enemy is near player
+ 1 out of 4 chances or 25% chance of happening
->Attack

so assuming the first 4 conditions are always true, the enemy won't attack every time those 4 conditions are true. Instead, the enemy will attack if those 4 conditions are true AND randomly (randomly would have to be configurable like X out of Y chances or in percentage).
B
16
S
7
Posts: 301
Reputation: 2,736

### » Tue Mar 25, 2014 10:35 pm

Code: Select all
`+ Condition A+ Condition B+ Condition C+ Condition D+ System: random(1) < 0.25     -> Attack`
B
69
S
22
G
14
Posts: 1,488
Reputation: 16,594