Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ego() help
#1
With the help of the users on the forums, I have managed to put together my own AI code for my lf2 mod.

Code:
// distance to target, positive when faced towards it (vis-a-vis), negative when we are faced in the opposite direction

int face_distance()
{
    return ( self.x - target.x ) * ( 2 * ( self.facing ? 1 : 0 ) - 1 );
}


// checks whether distance to target is within bounds

bool dist_between( int min, int max )
{
    return ( ( face_distance() < max ) && ( face_distance() > min ) );
}


// checks whether our character is on the same z axis as the opponent

bool same_z_axis()
{
    return ( abs( self.z - target.z ) <= 6 ) ? true : false;
}


// checks whether our target is on the right of us

bool onright()
{
    return (target.x > self.x);
}

int a = 0;
int b = 0;
int c = 0;
int d = 0;
int e = 0;
int f = 0;


//CHARACTER AI

int ego()
{


    if( dist_between(300,600) && same_z_axis() && ( self.mp > 200 ) && ( a < 2) && not (( self.mp > 400 ) && (self.hp < 100)))
    {
    if( onright())
    {
    print("Fireball Right \n");
    a = a + 1;
    b = 0;
    c = 0;
    d = 0;
    e = 0;
    f = 0;
    DrA();
    }
    else
    {
    print("Fireball Left \n");
    a = a + 1;
    b = 0;
    c = 0;
    d = 0;
    e = 0;
    f = 0;
    DlA();
    }}

    if( dist_between(150,300) && same_z_axis() && ( self.mp > 200 ) && ( b < 2) && not (( self.mp > 400 ) && (self.hp < 100)))
    {
    if( onright())
    {
    print("Blaze Right \n");
    a = 0;
    b = b + 1;
    c = 0;
    d = 0;
    e = 0;
    f = 0;
    DrJ();
    }
    else
    {
    print("Blaze Left \n");
    a = 0;
    b = b + 1;
    c = 0;
    d = 0;
    e = 0;
    f = 0;
    DlJ();
    }}

    if( dist_between(0,150) && same_z_axis() && ( self.mp > 200 ) && ( c < 2) && not (( self.mp > 400 ) && (self.hp < 100)))
    {
    if( onright())
    {
    print("Clearing Inferno Right \n");
    a = 0;
    b = 0;
    c = c + 1;
    d = 0;
    e = 0;
    f = 0;
    DuA();
    }
    else
    {
    print("Clearing Inferno Left \n");
    a = 0;
    b = 0;
    c = c + 1;
    d = 0;
    e = 0;
    f = 0;
    DuA();
    }}

    if( dist_between(200,600) && not same_z_axis() && ( self.mp > 200 ) && ( d < 2) && not (( self.mp > 400 ) && (self.hp < 100)))
    {
    if( onright())
    {
    print("Fire Tooth Right \n");
    a = 0;
    b = 0;
    c = 0;
    d = d + 1;
    e = 0;
    f = 0;
    DuJ();
    }
    else
    {
    print("Fire Tooth Left \n");
    a = 0;
    b = 0;
    c = 0;
    d = d + 1;
    e = 0;
    f = 0;
    DuJ();
    }}

    if( dist_between(0,200) && not same_z_axis() && ( self.mp > 200 ) && ( e < 2) && not (( self.mp > 400 ) && (self.hp < 100)))
    {
    if( onright())
    {
    print("Fire Wall Right \n");
    a = 0;
    b = 0;
    c = 0;
    d = 0;
    e = e + 1;
    f = 0;
    DdJ();
    }
    else
    {
    print("Fire Wall Left \n");
    a = 0;
    b = 0;
    c = 0;
    d = 0;
    e = e + 1;
    f = 0;
    DdJ();
    }}

    if( ( self.hp < 100) && ( self.mp > 400 ) && ( f < 2))
    {
    if( onright())
    {
    print("Flame Volley Right \n");
    a = 0;
    b = 0;
    c = 0;
    d = 0;
    e = 0;
    f = 0;
    DJA();
    }
    else
    {
    print("Flame Volley Left \n");
    a = 0;
    b = 0;
    c = 0;
    d = 0;
    e = 0;
    f = 0;
    DJA();
    }}
    return 0;
}

As you can see I have some helper functions (provided by Shymeck, thank you) and then the coding for the special moves.

For characters with no advanced base AI attached to their id (id values that are not some of the standard 10 fighters in the game), this AI works perfectly. The problem I have is when this AI is used over top of an id which already had an AI to it which uses special moves.

This is the code for id: 8. Because i am using the ego() function, this code is applied on top of the old AI for id: 8 meaning that the character can still use the special moves when its old AI says it can.

What I want is the ability to set the base AI for id: 8 to something that will not use any special attacks (something like the AI for the Template character) so that it will ONLY draw on my AI code in order to use special moves.

If there is any way to do this (or accomplish what I want through a different method) please let me know. If anyone needs more clarification as to what my problem is, I can try to explain further.

Thanks.:)
Reply
Thanks given by:
#2
Try with an empty file and see what moves it does. I'm pretty sure the only move it could do is D>A, thats because that code isn't inside the function that ego detours rather the id() function. The work around is use ID's that don't have D>A associated with it, or use id() which replaces the entire AI.
[Image: doty7Xn.gif]

10 ʏᴇᴀʀs sɪɴᴄᴇ ɪʀᴄ ɢᴏᴏᴅ.ɪ ᴡᴀʟᴋ ᴛʜʀᴏᴜɢʜ ᴛʜᴇ ᴇᴍᴘᴛʏ sᴛʀᴇᴇᴛs ᴛʀʏɪɴɢ ᴛᴏ ᴛʜɪɴᴋ ᴏғ sᴏᴍᴇᴛʜɪɴɢ ᴇʟsᴇ ʙᴜᴛ ᴍʏ ᴘᴀᴛʜ ᴀʟᴡᴀʏs ʟᴇᴀᴅs ᴛᴏ ᴛʜᴇ ɪʀᴄ. ɪ sᴛᴀʀᴇ ᴀᴛ ᴛʜᴇ sᴄʀᴇᴇɴ ғᴏʀ ʜᴏᴜʀs ᴀɴᴅ ᴛʀʏ ᴛᴏ sᴜᴍᴍᴏɴ ᴛʜᴇ ɢᴏᴏᴅ ɪʀᴄ. ɪ ᴡᴀᴛᴄʜ ᴏᴛʜᴇʀ ɪʀᴄ ᴄʜᴀɴɴᴇʟs ʙᴜᴛ ɪᴛ ɪs ɴᴏ ɢᴏᴏᴅ. ɪ ᴘᴇsᴛᴇʀ ᴢᴏʀᴛ ᴀɴᴅ ᴛʀʏ ᴛᴏ ʀᴇsɪsᴛ ʜɪs sᴇxɪɴᴇss ʙᴜᴛ ɪᴛ ɪs ᴀʟʟ ᴍᴇᴀɴɪɴɢʟᴇss. ᴛʜᴇ ᴇɴᴅ ɪs ɴᴇᴀʀ.ɪ ᴛʜᴇɴ ᴜsᴜᴀʟʟʏ ʀᴇᴀᴅ sᴏᴍᴇ ᴏʟᴅ ɪʀᴄ ʟᴏɢs ᴀɴᴅ ᴄʀʏ ᴍʏsᴇʟғ ᴛᴏ sʟᴇᴇᴘ.


Reply
Thanks given by:
#3
You're right. With a blank AI file D>A is the only special attack being used.

If I use the id() function to completely replace the AI it would mean that i need to write all the basic stuff such as walking, running, jumping, drinking, come, stay, move, ect......

Is there an AI template out there with the basics all written so that I can just add my own code for special moves?
Reply
Thanks given by:
#4
Not really. YinYin started writing one here: http://www.lf-empire.de/forum/thread-8187.html

Basically, the easiest work around is to use different IDs.

It's just the way lf2 was written, nothing I can do it about it easily without rewriting a lot of sh*t and breaking stuff etc.
[Image: doty7Xn.gif]

10 ʏᴇᴀʀs sɪɴᴄᴇ ɪʀᴄ ɢᴏᴏᴅ.ɪ ᴡᴀʟᴋ ᴛʜʀᴏᴜɢʜ ᴛʜᴇ ᴇᴍᴘᴛʏ sᴛʀᴇᴇᴛs ᴛʀʏɪɴɢ ᴛᴏ ᴛʜɪɴᴋ ᴏғ sᴏᴍᴇᴛʜɪɴɢ ᴇʟsᴇ ʙᴜᴛ ᴍʏ ᴘᴀᴛʜ ᴀʟᴡᴀʏs ʟᴇᴀᴅs ᴛᴏ ᴛʜᴇ ɪʀᴄ. ɪ sᴛᴀʀᴇ ᴀᴛ ᴛʜᴇ sᴄʀᴇᴇɴ ғᴏʀ ʜᴏᴜʀs ᴀɴᴅ ᴛʀʏ ᴛᴏ sᴜᴍᴍᴏɴ ᴛʜᴇ ɢᴏᴏᴅ ɪʀᴄ. ɪ ᴡᴀᴛᴄʜ ᴏᴛʜᴇʀ ɪʀᴄ ᴄʜᴀɴɴᴇʟs ʙᴜᴛ ɪᴛ ɪs ɴᴏ ɢᴏᴏᴅ. ɪ ᴘᴇsᴛᴇʀ ᴢᴏʀᴛ ᴀɴᴅ ᴛʀʏ ᴛᴏ ʀᴇsɪsᴛ ʜɪs sᴇxɪɴᴇss ʙᴜᴛ ɪᴛ ɪs ᴀʟʟ ᴍᴇᴀɴɪɴɢʟᴇss. ᴛʜᴇ ᴇɴᴅ ɪs ɴᴇᴀʀ.ɪ ᴛʜᴇɴ ᴜsᴜᴀʟʟʏ ʀᴇᴀᴅ sᴏᴍᴇ ᴏʟᴅ ɪʀᴄ ʟᴏɢs ᴀɴᴅ ᴄʀʏ ᴍʏsᴇʟғ ᴛᴏ sʟᴇᴇᴘ.


Reply
Thanks given by: vonfrank
#5
That's OK. Thanks for the help anyway.
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)