How do I make a chance based event

Get help using Construct 2

Post » Wed Jan 20, 2016 9:45 pm

I would like for my enemies to do 1 from 3 actions when the conditions are met, not the 3 but just 1, how can I make that?
B
8
S
1
Posts: 37
Reputation: 424

Post » Thu Jan 21, 2016 6:15 am

Without knowing anything about how your game works I can only suggest that you use the random() expression
B
83
S
22
G
15
Posts: 1,039
Reputation: 15,219

Post » Thu Jan 21, 2016 3:38 pm

I would like for an AI to do 1 of 3 attacks (punching, highpunching and kicking) which requires to turn an event group on, to set an animation and play a sound, the events for an attack are

When A is released : Sprite set animation to Punch_Player, set DamageSpawningGroup active, play sound Punch

thats how an attack works in my game, I would like that when the conditions are met 1 from 3 attacks will be done, how can I make this happen? I was thinking about a time based ''randomness'' where every a timer set to 0.05 seconds will turn an event group on and another one off, + turning another 0.05 timer on and so on, so that every 0.05 seconds when the same conditions are met, there will be a different result, but I suppose this would be cpu intensive and event consuming
B
8
S
1
Posts: 37
Reputation: 424

Post » Thu Jan 21, 2016 5:53 pm

You should also take a look at the Timer behavior

Or even better, Rexrainbow's Duration plugin. It allows you to have timers running in each object, it's one of the most useful plugins IMO
B
83
S
22
G
15
Posts: 1,039
Reputation: 15,219

Post » Fri Jan 22, 2016 12:24 am

The way you explain could be done this way:

Add Global variable "Groups"

system every 0.05 seconds
> set variable Groups to : choose(1,2,3)
> set group1 deactivated
> set group2 deactivated
> set group3 deactivated
-- If variable groups is 1
> set group1 activated
-- If variable groups is 2
> set group2 activated
-- If variable groups is 1
> set group3 activated

It would probably be much easier to call a function on attack with a parameter set to choose(1,2,3) and base the attack on the parameter, but well..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: Ami Samad, CJacobsSA, ismael123, lwgames, nextogogames, SEGamestudio and 2 guests