Attacks based on chance?

Started by Darkstalker X, September 14, 2010, 06:22:53 PM

Previous topic - Next topic

Darkstalker X

Yeah, I want to make an attack that occurs when a certain state is done, under a low chance. I've done all the work in the cns, and now I just want to know how to have that happen in the cmd. At first I thought "Maybe random ><=(var), or random%(var)" but it's not as easy. I've also tried switching around with the ctrl, and it just does the move relentlessly after the round starts.

Any ideas?

Cyanide

Define EXACTLY when you want the attack to occur, is it part of another attack? Or does it randomly happen next time you do the attack that activated it or does it happen randomly when you're just standing there? You either need to retain it with a variable or just use a really low random trigger.


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.

Darkstalker X

It's an independent attack that happens under a low chance when doing either a light or a strong punch. So how would this code be? this is my basic idea:

[State -1, Attack]
type = Changestate
value = 1400
triggerall = Statetype !=A
triggerall = var(59) !=1(This is the AI)
triggerall = ctrl
trigger1 = stateno = 200||stateno = 210
trigger1 = random%(5)

Cyanide

random%5 is a 20% chance basically. Every time random resolves 5 (i may have this a little backwards but bear with me) you have it occur. So, 5, 10, 15 etc will trigger it. Something MORE reasonable

random < 10, that's a 1% chance to occur. 10*100 = 1000 which is how many values are in the random trigger at 0-999. Lower than 10 and you get 0.# chances which is probably a bit low. random < 50 would be a decent value.


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.

Cybaster

Quote from: Cyanide on September 16, 2010, 01:31:44 AM
random%5 is a 20% chance basically. Every time random resolves 5 (i may have this a little backwards but bear with me) you have it occur. So, 5, 10, 15 etc will trigger it. Something MORE reasonable
Well, not exactly, but your explanation gives the good result, so it's not a big issue.
Anyway, for people interested in a more theoretical and formal explanation, the % operation in Mugen is the modulo operation, which finds the remainder of the division of one number by another.

For example : 17%3 finds the rest of the division of 17 by 3. As 17 = 3*5 + 2, I get 17%3 = 2.

Darkstalker X

*shakes head lightly, showing signs of frustration*

Apparently the cmd is right but... now I can't figure out whether it's something related to the cmd or the cns.

My guess is that to make the cns respond to that, I'd set up a changestate controller in the end of 200 and 210 (light and strong punches respectively.) What would that controller look like? Here is my guess:

;CNS controller
[State 200 (or 210)]
type = ChangeState
trigger1 = time = 0
trigger1 = random < 200
value = 1400
ctrl = 0

;CMD
[State -1, attack]
type = Changestate
value = 1400
triggerall = Statetype !=A
triggerall = var(59) !=1
triggerall = ctrl
triggerall = random < 200
trigger1 = stateno = 200||stateno = 210

I really need to pull this thing correctly to advance.

Rajaa Retired

If you are attacking, then ctrl as a trigger will most likely never allow that changestate to trigger. You may need to remove that.

If you don't care what what moment the move is activated when you are in statedef 200 or statedef 210, then you can pretty much leave that changestate the way it is. In negative states, however, random<200 will occur more often than you think, better to make it 50 or less.

There is no reason why you can't just add the changestates triggered by random into the states you want them to activate. You should know that "time=0" is at the very beginning of the state not at the very end. End of a animation is at the end of an animation, which is usually the end of a state, so it's safe to use "animtime=0." I'm sure you see this located in the changestates already present in your statedefs 200 ad 210.

Darkstalker X

Well done, all I needed was to take away the ctrl trigger.

Thanks for the support everyone.