Solved AI attack priority, or: "ok stop taunting and punch me"

Question that is answered or resolved.

Weoooo

Member
I've made an enemy who has a short range attack, a jump attack, and uses an attack to taunt. I thought that was the best way to do it, because I wanted it to be a randomly occurring thing rather than something that happened at specific times, which is how other enemy taunts I've seen got used. Like in Trouble in Southtown, where they're follow animations after successful attacks.

This, however, has caused an issue. Since it's an attack that can be done from anywhere, the AI thinks its just a great idea to use it. I understand why, as far as the AI is concerned it's just an attack they can use and if they're able to, why not?

So I've tried lots of things, from playing with ranges to just setting all attacks to default to making it a freespecial with a cost, and the only thing that's made it behave anywhere near normally is if the taunt and attack have the same range. Which is... not ideal behavior. I can restrict how many times they can USE it with the cost, but it doesn't stop them from wanting to.

Is it scripting time? Or is there something else I'm just not noticing?
 
Solution
You can use range to tell the engine which moves do you want to use.
but some moves prevail over others, even if they have the same range. This is the case of ATTACK1, which is more used than ATTACK2 and so on. Same for FREESPECIAL1, FREEPSECIAL2, etc.

SO if you want the taunt to be executed less than other moves with the same range, put it as a bigger number like ATTACK5 or FREESPECIAL5 (if you have enough attacks to fill the gap)

Or, you can use script for that.
I use this code:

C-like:
void randomAnim(int iLimit, int iChance, int Ani)
{ // Randonly goes to another animation, based on the chance
// Douglas Baldan - 15/06/2018 - Thanks Bloodbane
// http://www.brazilmugenteam.com
    void self = getlocalvar("self");
    int r =...
You can use range to tell the engine which moves do you want to use.
but some moves prevail over others, even if they have the same range. This is the case of ATTACK1, which is more used than ATTACK2 and so on. Same for FREESPECIAL1, FREEPSECIAL2, etc.

SO if you want the taunt to be executed less than other moves with the same range, put it as a bigger number like ATTACK5 or FREESPECIAL5 (if you have enough attacks to fill the gap)

Or, you can use script for that.
I use this code:

C-like:
void randomAnim(int iLimit, int iChance, int Ani)
{ // Randonly goes to another animation, based on the chance
// Douglas Baldan - 15/06/2018 - Thanks Bloodbane
// http://www.brazilmugenteam.com
    void self = getlocalvar("self");
    int r = rand()%iLimit;
    if(r > iChance){
        if (!getentityproperty(self, "dead")){
        performattack(self, openborconstant(Ani));
        }
    }
}

@cmd randomAnim 30 0 "ANI_FOLLOW1"

PS: I know we should be using openborconstant on a different way, I just don't have time to modify this script now.
 
Solution
When you mentioned the ATTACK 5 thing I realized there was a pretty easy solution staring me in my face, just make a bunch of the same attack until I get down far. However, I would like to know how to set a percentage, and while I can sort of get the script there, I don't know if I actually understand it.
I think what you'd do is add that to the character, and put in the animation you want where ani is and specify the percentage. It'll run some sort of RNG, and if it hits the percentage and the character ISN'T dead, it'll play the animation.

But why the cmd randomanim? Am I fixating on something dumb here, or is that key?
 
I think what you'd do is add that to the character, and put in the animation you want where ani is and specify the percentage. It'll run some sort of RNG, and if it hits the percentage and the character ISN'T dead, it'll play the animation.
That is exactly what the script above does :)

In the example above, 30 is the limit and 0 is the chance.
So it will randomly pick a number from the limit (on that case, from -30 to 30, since it counts the negative numbers) and if the number is higher than CHANCE (on that case, 0), it will execute the animation.

Since we are getting 60 numbers (61 to be more exact, -30 to 30) and the chance is 0, this means 50% (as I am getting only the positive numbers).

If I want 25% chance, I would use @cmd randomAnim 30 15 "ANI_FOLLOW1"
 
If I want 25% chance, I would use @cmd randomAnim 30 15 "ANI_FOLLOW1"

okay so not all set. I'm 2 dumb. I did what I thought I was supposed to, which was plug in the values I wanted in the script(ilimit set to 50, chance set to 35, ani to ani_follow1) but then the game crashed. So I went "oh, the command is what you do." So I changed that command. But the game crashed. Then I went, "well, my version is a little out of date," so I updated it and tried again. But the game crashed both ways. The log always said that the script was invalid.

I am... clearly misunderstanding how this works.
 
That is an animation script. you need to have that code in a script and call it on your character header.

let's say you save this on a file animation.c under data/scripts

so you have to add this to your character header:

animationscript data/scripts/animation.c
 
Oh, I actually know how to do that. But I think I managed to ruin the script itself. Game crashes, I get "Message: Error parsing function main of animation script in file '%s'!" in the log. I tried a few different ways, down to just copy pasting that exact thing like this:


Code:
void randomAnim(int iLimit, int iChance, int Ani)
{ // Randonly goes to another animation, based on the chance
// Douglas Baldan - 15/06/2018 - Thanks Bloodbane
// http:// www brazilmugenteam com
    void self = getlocalvar("self");
    int r = rand()%iLimit;
    if(r > iChance){
        if (!getentityproperty(self, "dead")){
        performattack(self, openborconstant(Ani));
        }
    }
}

@cmd randomAnim 30 0 "ANI_FOLLOW1"

except the url is intact
and I get that. I don't know why. I'm clearly missing something vital about how this whole thing functions.


Hey so that "something vital" was what @cmd even was. Everything is good now. In case someone is looking at this and ALSO didn't know anything about anything, the @cmd is something that goes in your character text file that you put before an entry.
 
Last edited:
Back
Top Bottom