YesNoOk
avatar

KFM's AI crouching infinetly (Read 2790 times)

Started by BruceHR, June 02, 2024, 08:28:43 pm
Share this topic:
KFM's AI crouching infinetly
#1  June 02, 2024, 08:28:43 pm
  • avatar
    • Brazil
So,i'm working on this character named Kung-Fu Man-R...basically a improved version of KFM. When coding his AI,i noticed that he would lose against small characters(Jump Force styled),something that i was not expecting,since he could beat Dragon Claw easily. Why that? Because the standard MUGEN AI almost didn't crouch. So,i coded a AI for him to crouch immediately when he gets 20 pixels close to his opponent. But,when i saw how he was in the game,he loopingly crouched.Here's the code (note:it's on statedef -2).
[State -2, Crouching AI]
type=ChangeState
value=10
triggerall=var(7)
triggerall=ctrl
trigger1=statetype=S
trigger1=p2bodydist x<=20
I think it has something to do with him repeating over an over again,so the solution would be stopping him from looping
Re: KFM's AI crouching infinetly
#2  June 04, 2024, 03:21:49 pm
  • **
    • Ukraine
I'd add a random chance of this action happening, something simple, like 'random < 100'. And maybe some more conditions.

I think the reason is while crouching, a character is still in control, meaning, he chooses to do another action, but since crouching has 100% chance happening at tick 1 he keeps going in that state?

The solution may be coding crouching state for AI's usage specifically. Where he wouldn't be in control, so then you can 'cancel' this AI crouching state into a crouching attack etc.
Re: KFM's AI crouching infinetly
#3  June 04, 2024, 08:02:33 pm
  • ******
  • 90's Kawaii
  • :thinking:
    • Guatemala
-2 is processed before -1, so this block of code fundamentally overrides all ai commands when the conditions are met.

You're pretty much looking at this the wrong way. You shouldn't tell the ai to crouch whenever it can, you should tell it to use crouching attacks, and if your main concern is jus characters, to do so when the opponent's size constant is below a certain threshold.
Re: KFM's AI crouching infinetly
#4  June 06, 2024, 09:10:25 pm
  • *****
  • Shame on you!
    • USA
What Foobs said.

 
[State 1350, Chest Finder]
type = VarSet
trigger1 = (Time%1) = 0
v = 12    ;fv = 10
value = floor( (enemy,const(size.head.pos.y) - enemy,const(size.mid.pos.y) )/2 )

[State 1350, Chest Tracker]
type = VarSet
trigger1 = (Time%1) = 0
v = 13    ;fv = 10
;value = floor( const(size.mid.pos.y) +  var(12))
value = ifelse(enemynear(0), statetype = L , 10, ifelse(enemynear(0), statetype = C ,floor( enemy,const(size.mid.pos.y)/2), floor( enemy,const(size.mid.pos.y) +  var(12))))

[State 1350, WTFisIT]
type = VarSet
trigger1 = (Time%1) = 0
v = 10
value = ceil(P2BodyDist Y + var(13)  )/20;10
This will give your character the spot for P2's chest. You can change the trigger to happen once at the start of the round or w/e. But if P2's creator set him up correctly you'll know about how tall it is. Then you can have a method to stop standing attacks in StateDef -1 from working unless P2 is in the air next to you.
vVv N00bSaibot & Muramasa RoofTop vVv