Yes, I do this on my chars.
- Go to your statedef 40
- Remove the anim from it (optional, if you don't the AI will be "ducking" randomly)
- Add a changestate back to state 0, the trigger should be "!Time" and "AIlevel" and a variable (or an invisible explod, or an invisible projectile) that you'll set in the CMD.
- If you removed the animation from the statedef, re-add it via changeanim, AFTER the changestate. It should look like this:
;Jumping
[Statedef 40]
type = S
physics = S
movetype = I
;Anim = 40
ctrl = 0
VelSet = 0, 0
sprpriority = 1
facep2 = 1
[State 40, Prevent AI from Randomly jump]
type = ChangeState
trigger1 = !Time && AILevel && !NumProjID(40)
value = 0
ctrl = 1
[State 40, ChangeAnim]
type = ChangeAnim
trigger1 = !Time
value = 40
Now, in the CMD, set the variable/explod/projectile. I like to do it via projectile. If you do it as a variable, you need to turn it off in state 40 as soon as the character enters the state, AFTER the changestate to state 0. The trick is to set the variable/explod/projectile for 1 tick only.
[State -1, Jump Flag]
type = Projectile
ProjID = 40
projanim = 1
projremovetime = 1
triggerAll = AILevel && NumEnemy
triggerAll = RoundState = 2 && StateType != A
triggerAll = ctrl || (StateNo = [100,101])
Add the AI triggers for when you want the AI to jump.
trigger1 = P2StateType = S && P2MoveType = A || Random < 10
trigger1 = !(EnemyNear, ctrl) && P2MoveType != H
trigger1 = Random < (100 * (AILevel ** 2 / 64.0))
trigger2 = EnemyNear, MoveType = A && P2BodyDist x < 160 && EnemyNear, HitDefAttr = SC, AT
trigger2 = Random < (250 * (AILevel ** 2 / 64.0))
trigger3 = P2StateType = C && (P2BodyDist x = [40,100]); && P2MoveType != A
trigger3 = Random < (250 * (AILevel ** 2 / 64.0))
Now you add the changestate, but the trigger should only check for the variable/explod/projectile.
[State -1, Jump]
type = ChangeState
value = 40
triggerAll = AILevel && NumEnemy
triggerAll = RoundState = 2 && StateType != A
triggerAll = ctrl || (StateNo = [100,101])
trigger1 = NumProjID(40)
There is probably a better way to do it but this is my method. Hope it helps! :]