10-11-2012, 06:01 PM
With the help of the users on the forums, I have managed to put together my own AI code for my lf2 mod.
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.
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.
![:) :)](https://lf-empire.de/forum/images/smilies/smile.gif)