AI attack looping infinitely

Started by Trackiest head, July 23, 2020, 10:25:33 AM

Previous topic - Next topic

Trackiest head

Hi.
I'm currently coding the AI of my WIP and I'm currently facing an issue with his tackle attack which for some reason keeps looping into itself and
as a result most of the time simply stays into place in the first frame of animation of that attack and when that doesn't happen, he simply spams the move when near the opponent.
here's the code but not even the triggerall = stateno !=1300 (1300 is the state of the attack) or the random seem to do a thing.


[state 1300, tackle]
type = ChangeState
value = 1300
triggerall = ailevel
triggerall = stateno != 1300
triggerall = roundstate = 2
triggerall = statetype = S
triggerall = ctrl
trigger1 = p2bodydist x > 70 && random > 998
trigger1 = enemy, numproj = 0
trigger1 = enemy, numhelper = 0
trigger2 = p2stateno != [120,155]


VictorCYBR

Your triggers for the move are a little weird.

For example, you have "random > 998" in one of your trigger1, this is less than 1% chance that it will activate. Meanwhile, you have only one trigger2 which will activate whenever the opponent is not guarding (states 120 ~ 155 are guard states most of the times). So this is what you'll be tweaking. My recommendation is to add more trigger2 conditions.

You know that trigger1 is a condition, and trigger2 is another condition, right? I mean, what you use in trigger1 will not affect trigger2, so, your random > 998 in trigger1 is doing nothing with your trigger2. You need a random at trigger2 too.

Also, change that > 998 because it will almost never activate. Random generates a number from 0 to 999 every tick, > 998 is only 1 tick of activation. Change it to, say, random < 100, which is rounded 10% chance of activation, a much better value.

Trackiest head

That random statement was just a non-working attempt at fixing the spam issue so it's pretty much out of question.
Anyways, not much after posting this thread I've decided to start over with the AI coding since it was getting inconsistent,  buggy and just plain messy (and that because I'm not even remotely thinking to have easy-medium-hard states despite the fact I'm using AIlevel instead of Winane method). And given that this is my first real attempt at AI coding it was foreseeable that I was going to wreck it anytime soon.

For now I'm doing fine although I'm a bit confused whether if start with AI hyper and super moves or the basics but maybe I'll get at least the basic work done in a couple of days although I don't guarantee it will be state-of-the-art (pretty much like the whole WIP in general)

VictorCYBR

Well, a basics for AI coding:


Everything is read from top to bottom, what you put on top will have priority over what you put in the bottom. I usually like to put moves in the following order:
1. System (roll/dodge, run, power charge, jump, guard, etc)
2. Nomals (punches and kicks)
3. Specials (projectiles and motion moves)
4. Supers (moves that needs power bar)

But remember, this is just my preference and there will always be tweakings, sometimes you'll notice the character spamming a move more than you'd like, so lowering it's position in the CMD can help, and, this is exclusive to the AI, DO NOT do this for moves when a human is controlling the character.




Also, you'd need a little knowledge on triggers. It's not hard.

Triggerall: everything you put here must be true for the activation. For example, for supers where you need to always have a certain amount of power, you can add it here as
"triggerall = power >= 1000", it will never activate if you have less than 1000 power.

Individual triggers, such as trigger1, trigger2, and so on, as you probably guessed, are individual. One can be activated without the need of the other. Examples:

trigger1 = p2bodydist x < 70
trigger2 = (p2stateno != [120,155])

This will activate in either cases: the distance between the character and the enemy is less than 70 pixels, OR, the enemy is not guarding. It can happen in both, or either. If these were both trigger1 instead of trigger1 and trigger2, then both must be true, the distance must be less than 70 pixels AND the enemy can't be guarding.

I suggest you look into AI from existing characters as a reference.




After you understand these, you can create specific conditions for your own AI, here is where you need creativity. Using a certain move whenever the enemy jumps, or when punishing, etc.
Hopefully this was helpful. :)

Trackiest head

Thanks for the tips, I'll try my best then eventually share a video in the videos thread or anywhere else showing the progress once done,