I decided to publish some AI scripts independently from LF2 Plus mod. So here they are:
Silva's AI:
Aeron's AI:
Frozen's AI:
(YinYin and Siegvar's Frozen version)
Enjoy.
Silva's AI:
Code:
int face_distance()
// distance to target, positive when faced towards it
// 80 pixels may be considered as a maximum distance allowing close combat
{
return ( self.x - target.x ) * ( 2 * ( self.facing ? 1 : 0 ) - 1 );
}
bool dist_between( int min, int max )
// checks whether distance to target is within bounds
{
return ( ( face_distance() < max ) && ( face_distance() > min ) );
}
bool z_axis_dist( int dist )
{
return ( abs( self.z - target.z ) <= dist ) ? true : false;
}
bool same_z_axis()
// checks whether our character is on the same z axis as the opponent
{
return ( abs( self.z - target.z ) <= 8 ) ? true : false;
}
int ego()
{
// mid and long range
if( self.frame == 235 )
{
if( dist_between(400,700) && ( self.mp > 350 ) )
D();
if( dist_between(150,400) && (self.mp > 200) )
J();
}
if( dist_between(400,700) && ( self.mp > 350 ) )
{
if( self.facing )
{
DlA();
}
else
{
DrA();
}
return 0;
}
if( dist_between(150,400) && same_z_axis() && ( self.mp > 70 ) && ( target.state < 3 ) )
{
if( self.facing )
{
DlA();
}
else
{
DrA();
}
return 0;
}
// close range combos
if( self.frame == 257 )
{
if( target.state == 12 )
J();
if( target.y == 0 )
A();
return 0;
}
if( self.frame == 75 )
{
J();
return 0;
}
if( dist_between(10,60) && ( target.state < 3 ) && same_z_axis() && ( self.mp > 50 ) )
{
DdA();
return 0;
}
return 0;
}
Aeron's AI:
Code:
int face_distance()
// distance to target, positive when faced towards it
// 80 pixels may be considered as a maximum distance allowing close combat
{
return ( self.x - target.x ) * ( 2 * ( self.facing ? 1 : 0 ) - 1 );
}
bool dist_between( int min, int max )
// checks whether distance to target is within bounds
{
return ( ( face_distance() < max ) && ( face_distance() > min ) );
}
bool z_axis_dist( int dist )
{
return ( abs( self.z - target.z ) <= dist ) ? true : false;
}
bool same_z_axis()
// checks whether our character is on the same z axis as the opponent
{
return ( abs( self.z - target.z ) <= 8 ) ? true : false;
}
void select_nearest_opponent()
{
int temp;
int k = -1;
int min_dist = 0;
for( int i = 0; i < 400; ++i )
{
temp = loadTarget(i);
if( ( temp == 0 ) && ( target.team != self.team ) && ( ( abs( self.x - target.x ) < min_dist ) || ( k == -1 ) ) )
{
k = i;
min_dist = abs( self.x - target.x );
}
}
loadTarget(k);
}
void follow_target()
{
if( ( self.x > 100 ) && ( self.x < stage_bound - 100 ) )
{
if( self.x > target.x )
{
left();
if( face_distance() > 400 )
J();
}
if( self.x < target.x )
{
right();
if( face_distance() > 400 )
J();
}
if( self.z + 3 < target.z )
down();
if( self.z > target.z + 3 )
up();
if( dist_between(-25,25) )
J(); // we do not want to be too close..
}
else
{
if( self.x <= 100 )
right();
if( self.x >= stage_bound - 100 )
left();
}
}
void attack_opponent()
{
if( target.team != self.team )
{
if( dist_between(100,200) && same_z_axis() && ( self.mp > 300 ) && ( target.state != 14 ) )
{
if( self.facing )
{
DlJ();
}
else
{
DrJ();
}
return;
}
if( dist_between(200,500) && same_z_axis() && ( self.mp > 200 ) && ( target.state != 14 ) )
{
if( self.facing )
{
DlA();
}
else
{
DrA();
}
return;
}
if( dist_between(100,200) && same_z_axis() && ( target.state < 3 ) && ( target.state != 14 ) )
{
J();
return;
}
if( dist_between(50,100) && same_z_axis() && ( target.state != 14 ) )
{
A();
return;
}
}
}
void reset_input()
{
left(0,0);
right(0,0);
up(0,0);
down(0,0);
A(0,0);
D(0,0);
J(0,0);
}
void id()
{
reset_input();
if( !stage_clear )
{
select_nearest_opponent();
attack_opponent();
follow_target();
}
else
{
right();
if( !self.facing )
J();
}
}
Frozen's AI:
(YinYin and Siegvar's Frozen version)
Code:
int face_distance()
// distance to target, positive when faced towards it
// 80 pixels may be considered as a maximum distance allowing close combat
{
return ( self.x - target.x ) * ( 2 * ( self.facing ? 1 : 0 ) - 1 );
}
bool dist_between( int min, int max )
// checks whether distance to target is within bounds
{
return ( ( face_distance() < max ) && ( face_distance() > min ) );
}
bool z_axis_dist( int dist )
{
return ( abs( self.z - target.z ) <= dist ) ? true : false;
}
bool same_z_axis()
// checks whether our character is on the same z axis as the opponent
{
return ( abs( self.z - target.z ) <= 8 ) ? true : false;
}
int ego()
{
if( ( self.frame >= 261 ) && ( self.frame <= 269 ) )
{
if( ( target.state == 13 ) || ( target.state == 14 ) )
{
D();
return 0;
}
if( ( self.frame == 269 ) && ( target.y == 0 ) )
{
D();
return 0;
}
return 1;
}
else
{
// grab the opponent if he is prone to :)
if( dist_between(40,80) && ( target.state == 16 ) && same_z_axis() )
{
if( self.facing )
left();
else
right();
return 0;
}
// while grabbing
if( ( self.state == 9 ) && ( target.state == 10 ) && same_z_axis() && ( self.ctimer < 75 ) && ( self.mp > 30 ) )
{
DJA();
return 0;
}
if( dist_between(10,50) && ( target.state == 3 ) && same_z_axis() && ( self.mp > 30 ) )
{
DJA();
J();
return 0;
}
if( dist_between(25,80) && ( target.state < 3 ) && same_z_axis() && ( self.mp > 60 ) )
{
DdA();
return 0;
}
if( dist_between(150,500) && same_z_axis() && ( self.mp > 200 ) )
{
if( self.facing )
{
DlA();
A();
}
else
{
DrA();
A();
}
return 0;
}
if( dist_between(-200,200) && z_axis_dist(70) && ( self.mp > 400 ) && ( target.state != 13 ) && ( target.state != 14 ) )
{
DuJ();
return 1;
}
}
return 0;
}
Enjoy.