Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Slightly Better Freeze AI
#1
Made a Freeze AI, and I guess I'd post it here.
This AI is designed for 1 vs 1. Although it can find another target if the previous target is defeated, it'll find target only based on which one is the first to be added to the game. It is also not aware of any projectiles, so maybe you'll try to fight it with Bandit.
At distance he will try to perform a dash attack and at melee, punches. Sometimes it can also do some basic combos (Attack 3 times, freeze using Ice Blast, then Dash Attack) and special moves outside combos based on range. Sometimes he accidentally creates an Ice Sword in an attempt to perform Icicle aimed downwards, but he knows how to use it.

The code is below, but you may want to simply download it and put it in the ai folder.
Download link: http://www.mediafire.com/?n8ni5uqc4i8701j

BTW: I don't know why but when I use this AI to fight another custom AI, he only do some punches at a fixed place.

Code:
void id()
{

for (int i = 0; i < 400; ++i)
{
    for (int i = 0; i < 400; i++){ //target
        if (loadTarget(i) == 0 && target.num != self.num && target.hp > 0 && target.id < 100 && target.team != self.team){
            break;
        }
    }
}

  int VARxdst = self.x-target.x;
int VARydst = self.y-target.y;
int VARzdst = self.z-target.z;
int VARzbgu = self.z-bg_zwidth1;
int VARzbgb = bg_zwidth2-self.z;
int VARxbgr = bg_width-self.x;
int VARxabs = abs(VARxdst);
int VARyabs = abs(VARydst);
int VARzabs = abs(VARzdst);
int VARsf; //self facing
int VARtf; //target facing
int VARDirToTargetH; //lawannya di kiri atau kanan
int VARDirToTargetV; //lawannya di atas atau bawah
int VARholdinglgtweapon = 0;

    
if(self.facing == true){VARsf = -1;}
if(self.facing == false){VARsf = 1;}
if(target.facing == true){VARtf = -1;}
if(target.facing == false){VARtf = 1;}
if(VARxdst < 0){VARDirToTargetH = 1;}
if(VARxdst > 0){VARDirToTargetH = -1;}
if(VARzdst < 0){VARDirToTargetV = 1;}
if(VARzdst > 0){VARDirToTargetV = -1;}

    D(0,0);
    A(0,0);
    J(0,0);
    right(0,0);
    down(0,0);
    left(0,0);
    up(0,0);

    if(target.blink == 0 && target.state != 14 && target.id < 100)
    {
        if(target.frame == 200 || target.frame == 201 || target.frame == 202) //if the opponent is frozen, come and use Whirlwind.
        {
            if(self.mp >= 300)
            {
                if(VARxabs > 78 && VARxabs < 82 && VARzabs < 60)
                {
                    D();
                    up();
                    J();
                }
                else
                {
                    if(VARxdst < 0)
                    {
                        if(VARxdst < -80)
                        {
                            right(1,1);
                        }
                        else
                        {
                            left(1,1);
                        }
                    }
                    else
                    {
                        if(VARxdst < 80)
                        {
                            right(1,1);
                        }
                        else
                        {
                            left(1,1);
                        }
                    }
                    if(VARDirToTargetV == 1){down();}else{up();}
                }
            }
            else
            {//Dash Attack if there's not enough MP to perform a Whirlwind.
            if(self.state == 5){A();}
            if(self.state == 2)
            {
                if(VARzdst > 10)
                {up();}
                if(VARzdst < -10)
                {down();}
                J();
            }
            if(VARDirToTargetH == 1){right(1,0);}else{left(1,0);}
            }
        }
        else
            {
            
            if(self.state == 2) //larinya agak atas atau bawah
            {
                if(VARDirToTargetV == 1)
                {
                   if(VARzabs > 35)
                   {
                      down();
                   }
                   else
                   {
                      up();
                   }
                }
                else
                {
                   if(VARzabs > 35)
                   {
                      up();
                   }
                   else
                   {
                      down();
                   }
                }
            }
            
            if(VARxabs < 70 && VARzabs < 60 && self.mp >= 300 && target.state == 1 && self.mp > 300)
            {//Whirlwind
                if(VARDirToTargetH == 1){right();}else{left();}
                D();
                up();
                J();
            }
    
            if(VARxabs < 200 && VARxabs > 30 && VARzabs < 60 && self.mp >= 150)
            {//Icicle
                if(VARzabs > 25)
                {
                    if(VARDirToTargetV == 1){down();}else{up();}
                }
                if(VARDirToTargetH == 1)
                {
                    D(1,0);
                    right(1,0);
                    J(1,0);
                }
                
                if(VARDirToTargetH == -1)
                {
                    D(1,0);
                    left(1,0);
                    J(1,0);
                }
            }
            
            if(self.fall >= 70){VARholdinglgtweapon = 0;}
            if(self.state == 10){VARholdinglgtweapon = 0;}
            if(self.frame == 275){VARholdinglgtweapon = 1;}
            if(self.frame == 219){VARholdinglgtweapon = 1;}
            
            if(VARxdst < 0 && VARsf == -1 && self.state != 2)
             {
                right(1,1);
             }
            
            if(VARxdst > 0 && VARsf == 1 && self.state != 2)
             {
                left(1,1);
             }
            
            if(self.state == 2 && VARxabs > 120 && VARxabs < 150) //Perform a Dash!
            {
                J();
                if(VARzdst > 20)
                {up();}
                if(VARzdst < -20)
                {down();}
            }
            
            if(self.state == 2 && VARxabs > 100 && VARxabs < 200 && VARholdinglgtweapon == 1) //Perform a Dash!
            {
                J();
                if(VARzdst > 20)
                {up();}
                if(VARzdst < -20)
                {down();}
            }
            
            if(self.state == 5) //Perform a Dash Attack!
            {
                if(VARxabs < 160){A(1,1);}
                if(VARxabs < 110 && VARholdinglgtweapon == 1){A(1,1);}
            }
            
            if(VARxabs > 180)
            {
                if(VARDirToTargetH == 1)
                {
                  right(1,0);
                }
                if(VARDirToTargetH == -1)
                {
                  left(1,0);
                }
            }
            
            if(self.fall > 20) //Defend!
            {
                D();
            }
            
            
            if(VARxabs < 105 && VARzabs < 30 && VARholdinglgtweapon == 1) //Use a light weapon!
            {
                if(VARDirToTargetH == 1){right(1,1);}
                if(VARDirToTargetH == -1){left(1,1);}
                if(VARDirToTargetV == 1){down(1,1);}
                if(VARDirToTargetV == -1){up(1,1);}
                A(1,0);
            }
            
            if(VARxabs < 75 && VARzabs < 30 && VARholdinglgtweapon == 0) //Perform a Punch!
            {
                if(target.fall > 38) //Catch?
                {
                if(VARDirToTargetH == 1)
                {
                    right(1,0);
                }
                
                if(VARDirToTargetH == -1)
                {
                    left(1,0);
                }        
                }
                else
                {
                    if(self.state == 9) //Catching?
                    {
                        A();
                        left(0,1);
                        right(0,1);
                    }
                    else
                    {
                        if(VARDirToTargetH == 1){right(1,1);}
                        if(VARDirToTargetH == -1){left(1,1);}
                        if(VARDirToTargetV == 1){down(1,1);}
                        if(VARDirToTargetV == -1){up(1,1);}
                        A(1,0);
                        }
                }
            }
            
        if(target.fall > 39 and self.mp > 100 and VARxabs < 100 and VARxabs > 30 and VARzabs < 30)
        { //Ice Blast
            if(VARDirToTargetH == 1)
            {
                D();
                right();
                A(1,0);
            }
            else
            {
                D();
                left();
                A(1,0);
            }
        }
        
        }
    }
    else
    {
        if(VARDirToTargetH == 1)
        {
            left(1,0);
        }
        else
        {
            right(1,0);
        }        
    }
    
}
aka Verdusk

I don't have a sicknature

LF2 SurGen (survival stage generator!)
Reply
Thanks given by:
#2
Pretty nice. But i can c that everybody's AIs got the same variables. Y'all using YinYin's template or something?
[Image: signature.png]
A-Engine: A new beat em up game engine inspired by LF2. Coming soon

A-Engine Dev Blog - Update #8: Timeout

Reply
Thanks given by:
#3
(07-23-2012, 11:54 AM)A-MAN Wrote:  Pretty nice. But i can c that everybody's AIs got the same variables. Y'all using YinYin's template or something?

Yeah, cuz those variables are really useful. I only take the variables from the template though, nothing else.

EDIT: Made a little update, you might want to empty the 8.as and copy the codes in the code tag to the 8.as if you downloaded it before you can see this sentence.
aka Verdusk

I don't have a sicknature

LF2 SurGen (survival stage generator!)
Reply
Thanks given by: A-Man
#4
Sry for double-post, but I fixed the problem, now it can be used for custom AI vs custom AI.

I've also fixed the problem him not doing the small combos, there was a terrible mistake in the coding when I tried to make him a little smarter when holding ice sword.

Now it's slightly better than the previous slightly better Freeze AI.
aka Verdusk

I don't have a sicknature

LF2 SurGen (survival stage generator!)
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)