YesNoOk
avatar

AI not doing autocombo. (Read 1487 times)

Started by Trackiest head, January 25, 2021, 02:49:23 PM
Share this topic:
AI not doing autocombo.
#1  January 25, 2021, 02:49:23 PM
  • **
  • Too many revolutions
    • Spain
    • Marcus-22@hotmail.es
Hi everyone.

I'm currently overhauling my character's AI and right now I'm trying to have my AI perform his autocombo (performed by the human player by mashing X) but so far I'm struggling to get it right.

This is how the coding currently is like.

Code:
;Combo 1
[State 205, autocombo 4]
type = ChangeState
triggerall = AILevel
triggerall = ctrl
triggerall = roundstate = 2
triggerall = statetype = S
triggerall = movetype != H
triggerall = p2bodydist y > -10
triggerall = p2statetype != L
triggerall = stateno = 204
triggerall = movecontact
trigger1 = p2bodydist x = [0,50]
value = 205

[State 204, autocombo 3]
type = ChangeState
triggerall = AILevel
triggerall = ctrl
triggerall = roundstate = 2
triggerall = movetype != H
triggerall = statetype = S
triggerall = p2bodydist y > -10
triggerall = p2statetype != L
trigger1 = stateno = 203
trigger1 = movecontact
value = 204

[State 203, autocombo 2]
type = ChangeState
triggerall = AILevel
triggerall = ctrl
triggerall = roundstate = 2
triggerall = statetype = S
triggerall = p2bodydist y > -10
triggerall = p2statetype != L
trigger1 = stateno = 200
trigger1 = movecontact
value = 203

[State 200, autocombo 1]
type = ChangeState
triggerall = AILevel
triggerall = ctrl
triggerall = roundstate = 2
triggerall = statetype = S
triggerall = p2statetype != L
triggerall = p2bodydist y > -10
trigger1 = random < ailevel * 4
trigger1 = stateno = 200
trigger2 = p2bodydist x < 50
value = 200

And in most cases it only makes my character use his light punch, without ever continuing with the other parts of the combo.

The closest I got to its intended effect is by erasing all triggerall = ctrl from the states, however this has the side effect of allowing him to combo out of hitstun.

Is there another way to get this done?
Last Edit: January 30, 2021, 06:17:23 PM by Trackiest head
Re: AI not doing autocombo.
#2  January 25, 2021, 06:34:28 PM
  • avatar
  • *
I'm seeing a couple of things here.

1) Ctrl is a check that the AI needs (strictly) ctrl to do the move (which attack states usually do not have), but if the autocombo works off of movecontact (like 200 && movecontact), you should leave it out.
2) What do you want the P2BodyDist Y to do? If you want the AI to pass a check whether P2 is on the ground, it may be simpler to use P2StateType != A (is not in the air), or P2StateType = S (P2 is in standing specifically, useful for when the attack may miss a crouching opponent otherwise).
3) Stateno 200 can be called off of itself. This can lead to weird loops.

Other than that, the original random is up to AI level (8) *4, which means it it may be called in 1/3 of all cases if your AI level is max. While that is perfectly fine, you may want to set this higher for testing purposes.
Last Edit: January 25, 2021, 06:44:06 PM by Swanky
Re: AI not doing autocombo.
#3  January 25, 2021, 09:25:31 PM
  • **
  • Too many revolutions
    • Spain
    • Marcus-22@hotmail.es
1. I said it in the OP, if those crtl’s aren’t there then my character becomes able to attack while receiving hits from the enemy, hence why they are in there, they are mandatory.

2.yes, he will mostly use his normal punches while the opponent is on the ground but also if the opponent is jumping yet in vertical range for the attack. I haven’t done it yet but he will not autocombo a crouching or grounded opponent.

3.this is provisional since the idea is that they AI uses his light punch thrice before proceeding to the three later portions of the autocombo.
Re: AI not doing autocombo.
#4  January 25, 2021, 09:54:38 PM
  • avatar
  • *
1. I said it in the OP, if those crtl’s aren’t there then my character becomes able to attack while receiving hits from the enemy, hence why they are in there, they are mandatory.

2.yes, he will mostly use his normal punches while the opponent is on the ground but also if the opponent is jumping yet in vertical range for the attack. I haven’t done it yet but he will not autocombo a crouching or grounded opponent.

3.this is provisional since the idea is that they AI uses his light punch thrice before proceeding to the three later portions of the autocombo.


1) Needs triggerall = Movetype != H to check AI is not in a hitstate in all AI patterns. With that ctrl check can be used when it is necessary.
2) Probably needs two separate triggers for that to reliably work, one with the condition on the ground, and one for when p2 is in the air and at a set height, P2Dist Y = [-50,-10], for example

trigger1 = P2StateType = A
trigger1 = (p2bodydist x < 50) && (P2BodyDist Y = [-50,-25] ; fiddle around with the optimal values when the opponent is hittable
trigger1 = stateno = xx && movehit

3) That is better handled via variable where each hit adds 1 to the variable, otherwise the character will loop the attack ad infinitum.
The first subsequent attack of the autoattack should have the variable condition trigger(x) = stateno = 200 && var(3)>=3

(This might need additional checks for handling and resetting to 0, mind me)

[state -1]
type = Varset
triggerall = var(59)>0
trigger1 = !numenemy
trigger2 = numenemy
trigger2 = enemynear,movetype!=H
v = 3 (example variable)
value = 0

[state -1]
type = Varadd
trigger1 = stateno = 200 && movehit
v = 3
value = 1

Then add the variable check to the stateno. Should read something like this

[State 200, autocombo 1]
type = ChangeState
triggerall = AILevel
triggerall = MoveType != H
triggerall = roundstate = 2
triggerall = statetype = S
triggerall = p2statetype != L
trigger1 = ctrl
trigger1 = P2bodydist X < 50
trigger1 = random < ailevel * 6 ;(set higher chance for first hit)
trigger2 = P2StateType != A
trigger2 = random < ailevel * 4
trigger2 = stateno = 200 && var(3)<= 2
trigger2 = p2bodydist x < 50
value = 200
Last Edit: January 25, 2021, 10:41:46 PM by Swanky
Re: AI not doing autocombo.
#5  January 27, 2021, 03:47:06 AM
  • **
  • Your Successor in Netherrealm Service!!!
    • USA
@Trackiest head One of easiest way to do this is to put the Ai Command code in the Statedef of the move prior. For Example in Statedef 200  will paste Ai command code 203 as Change State for Ai only.  The random trigger will take care whether Ai will do the command more or less.
Your Successor in Netherrealm service!!!
https://imgur.com/a/dr3t6r2
Re: AI not doing autocombo.
#6  January 30, 2021, 06:17:11 PM
  • **
  • Too many revolutions
    • Spain
    • Marcus-22@hotmail.es
Okay, what I've done now is do everything above, except I've raised the random < ailevel * 4 to 36 and now I've coded in several more attacks and full combo routines and so far it's taking the intended shape.