Trigger chance

Started by xcd222, April 13, 2016, 04:51:31 AM

Previous topic - Next topic

xcd222

Straight to the point, how do I make a trigger that is affected by chance only? Lets say 50% it will trigger and 50% it won't trigger. Is it even possible?

ESFAndy011

Use random in your trigger. You can input an interval of values anywhere between 0 and 999 (999 being 100%).

Example:

[State 0, PlaySnd]
type = PlaySnd
trigger1 = random < 500    ;You could also use random = [0,499] or random > 499. This would be 50%
value = s200, 5            ;Grunt sound or whatever at 50% chance of playing


If I want 60%, then it'd be an interval minor than 600 in total. You get the idea.
Quote from: Millie, &quot;Ozy and Millie&quot;"I think there are really three types of people: "Glass is half-full" sorts of people, "Glass is half-empty" sorts of people,
and people who will spit into the glass until that's fixed."

xcd222

Quote from: ESFAndy011 on April 13, 2016, 06:56:19 AM
Use random in your trigger. You can input an interval of values anywhere between 0 and 999 (999 being 100%).

Example:

[State 0, PlaySnd]
type = PlaySnd
trigger1 = random < 500    ;You could also use random = [0,499] or random > 499. This would be 50%
value = s200, 5            ;Grunt sound or whatever at 50% chance of playing


If I want 60%, then it'd be an interval minor than 600 in total. You get the idea.

I finally did it, however when the sound triggers, it will make a weird sound that it keeps like resetting multiple times after lets say the action is done. Its like Goku says "K-K-K-K-K-K-K-K-K-K-K-KAMEHA!!".

Odb718

Add a timer check to make it only happen once.

    [State 0, PlaySnd]
    type = PlaySnd
    triggerall = time = 11   ;change this to what you need
    trigger1 = random < 500    ;You could also use random = [0,499] or random > 499. This would be 50%
    value = s200, 5            ;Grunt sound or whatever at 50% chance of playing
vVv Gouken718 vVv SabreTooth718 vVv


xcd222

Thanks again for the help Odb718, the second time you helped me in 2 days. Also appreciate your help Andy.