Help with the "Random" Trigger

Started by andrewobler, July 22, 2012, 05:56:00 AM

Previous topic - Next topic

andrewobler

Hello community,

I'm playing around with "Mizuchi-XI Boss" by beppu in Fighter Factory 3.  I'm trying to cause it to select a random character intro out of several ones.  Here's my code:

Code (mugen) Select

[State 190, 1]
type = ChangeState
;trigger1 = Time = 0
trigger1 = random <= 500
value = 191

[State 190, 2]
type = ChangeState
;trigger1 = Time = 0
trigger1 = random >= 501
value = 40510


In this code, "value = 191" and "value = 40510" are the different intros.  My issue is that it seems to trigger the "191" intro at a much higher rate than the other, and I'm thinking that this is caused by the "random" triggers.  I thought that once M.U.G.E.N (1.0) creates a value for the "random" trigger, it remains constant.  However, it seems here that if the first "random" value is greater than 500, and if the second value is less than 501, it goes to the next state, which is the first intro.

Can someone please reply to confirm this suspicion, and help me to create a 100% randomized selection of multiple intros?

Thanks,

Andrew

Cyanide

that's an ugly way to do it.

Random is re-evaluated each time you call it. Ignoring the fact that i can't actually trigger like this cos mugen doesn't like it

trigger1 = random < 200
trigger2 = random < 200
trigger3 = random < 200
trigger4 = random < 200

Now, you're thinking that that will never work, but the values it can pull could look similar to

trigger1 = 800
trigger2 = 60
trigger3 = 600
trigger4 = 5

You don't have to be exclusive for what does what. Now, based on the fact you only have 2 intros, what YOU need to use for your example is

changestate
time = 0
value = ifelse(random < 500, 191,40510)

If you have LOTS of intros. You need to do them either sequentially on the numbering front, or split them off for different reasons, p2name, roundno etc. Lets say you have 5 intros. The states are 191-195 For this you would do

value = 191+random%5

Which gives you a 191 + a random number between 0-4


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.

andrewobler

Thank you so much, Cyanide!

It's a good thing I came here; I probably could have been at my computer for hours pulling my hair out (literally) trying to figure this out.   :P

Again, thanks!   :D

Andrew


ade2004

Hey, sorry to bump this after so long but I've been trying to figure out random character intros and Google brought me here. I followed Cyanide's instructions and still can't get it to work.

This is in the common1.cns:

[Statedef 190]
type = S
ctrl = 0
velset = 0,0

[State 190, 2] ;Go straight to intro.
type = ChangeState
trigger1 = time = 0
value = 191+(random%3)

And this is the state for the intro:

[Statedef 191]
type = S
ctrl = 0
anim = 7000
velset = 0,0

[State 191, 1] ;Freeze animation until PreIntro is over
type = ChangeAnim
trigger1 = RoundState = 0
value = 7000

[State 191, 2] ;Assert this until you want "round 1, fight" to begin
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 191, 3] ;Change to stand state when done
type = ChangeState
trigger1 = AnimTime = 0
value = 0

The other 2 states(192 and 193) are identical, just the values with the different animations are changed.

HELP!

XGargoyle

Check that you don't have 2 statedefs 190, one in common.cns that you edited and another one inside the character (which takes priority on the first one)


XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
http://paypal.me/XGargoyle  <-- Donations welcome!

ade2004

I have just 1 statedef 190, in the common. The actual states with the different intro code are in the characters cns

ade2004

#6
Actually i take that back. I did have two statedef 190s, but it was a placeholder code that I've since deleted. Still doesn't work. The animation from statedef 191 works, but for subsequent rounds it only plays the animation from statedef 191

Basara Bogard

In my case, for this I use var(x) instead random, here's what I use usually for more than one intro:

; Introduction
[Statedef 190]
type = S
ctrl = 0
velset = 0,0

[State 180, VarRandom]
type = VarRandom
trigger1 = Time = 0
v = 11
range = 0,20

[State 180, Intro 1]
type = ChangeState
trigger1 = Time = 1
trigger1 = var(11) = [0,10]
value = 191

[State 180, Intro 2]
type = ChangeState
trigger1 = Time = 1
trigger1 = var(11) = [11,20]
value = 192

When there're more than 2 intros (or wins, also work), I make a 10X higher number for ranges, like 30 for 3 intros or 40 for 4 intros. Not necessarily you've to use those numbers in var(x), but at least for me it works

XGargoyle

You don't need to waste a variable when you can simply achieve that via a simple random


XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
http://paypal.me/XGargoyle  <-- Donations welcome!

ade2004

I appreciate the help guys.
I'm no coding expert, im only just returning to mugen after years of absence. This is actually what the pre intro code looks like in the common1.cns

[Statedef 190]
type = S
ctrl = 0
velset = 0,0

[State 5900, 1]
type = varSet
trigger1 = time = 0
var(48) = 1

[State 191, 1]
type = ChangeState
trigger1 = Time = 0
value = 0
ctrl = 0


***I should note that this is for mortal kombat project. I looked in the help folder and that variable 48 is used as an "additional indicator for round start"

Apparently those guys do things differently from "normal mugen"