How do I make a chance based event

0 favourites
  • 5 posts
From the Asset Store
Very simple code without excess options (15 events for server and 11 events for client)
  • 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?

  • Without knowing anything about how your game works I can only suggest that you use the random() expression

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

  • 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

  • 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..

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)