Page 1 of 1

Problem w/ ai code

PostPosted: Sat Jan 05, 2008 4:06 pm
by Freddy
I made this code for my ai:
Code: Select all
if(knockout <1)
{
 if(x > Player.x + 90)
 {
     x = x - 4;
     if(animindex !=3)
     {
      ChangeAnimation("Event Actor", "WalkLeft", FORWARD);
     }
 }
 else
 {
     if(x < Player.x + 91 && x > Player.x - 51)
     {
      CreateTimer("Event Actor", "AttackLeft", 500);
     }
     if(x < Player.x + 90 && x > Player.x - -75)
     {
      x = x + 4;
      if(animindex !=3)
         {
          ChangeAnimation("Event Actor", "WalkLeft", BACKWARD);
         }
     }
 }
 if(x < Player.x - 90)
 {
     x = x + 4;
     if(animindex !=2)
     {
      ChangeAnimation("Event Actor", "WalkRight", FORWARD);
     }
 }
 else
 {
      if(x > Player.x - 91 && x < Player.x + 51)
      {
       CreateTimer("Event Actor", "AttackRight", 500);
      }
      if(x > Player.x - 89 && x < Player.x + -75)
      {
          x = x - 4;
          if(animindex !=2)
          {
           ChangeAnimation("Event Actor", "WalkRight", BACKWARD);
          }
      }
 }
}


As you might imagine, Im having trouble with the "if knockout < 1" part. The code works fine as it is, but if the knockout is more than zero, it still functions. I want the code to stop when the player is knocked out (when knockout > 1), so that the ai doesnt keep on punching into no where, while the player has a knockout animation. But it doesnt work :( I hope Im being clear, lol. But if you have any suggestions on what I should do, please post them. :D

Re: Problem w/ ai code

PostPosted: Sun Jan 06, 2008 12:37 am
by makslane
More than zero? The code will works for any value < 1, including the values between 0 and 1!

Re: Problem w/ ai code

PostPosted: Sun Jan 06, 2008 7:10 am
by Bee-Ant
In that condition...you should use...
Code: Select all
if(var==...)

not
Code: Select all
if(var<...)

So, the events would work in 1 only condition...and easier to be managed... :D

Re: Problem w/ ai code

PostPosted: Mon Jan 07, 2008 10:47 pm
by DarkParadox
try:
Code: Select all
if(knockout =! 0)

it checks if knockout does not equal 0.

Re: Problem w/ ai code

PostPosted: Tue Jan 08, 2008 5:13 am
by Bee-Ant
So... =! same as != ??? :roll:

Re: Problem w/ ai code

PostPosted: Tue Jan 08, 2008 7:08 am
by Fuzzy
perhaps. By you should always use !=

Re: Problem w/ ai code

PostPosted: Tue Jan 08, 2008 8:52 am
by Bee-Ant
Yeah...usualy I use != :oops:

Re: Problem w/ ai code

PostPosted: Tue Jan 08, 2008 10:31 pm
by DarkParadox
they are the same

Re: Problem w/ ai code

PostPosted: Wed Jan 09, 2008 12:57 am
by Game A Gogo
as Fuzzy said, you should use "!=" cuz it may get confused by with the assign and inverse control "=!" like "Var1=!Var2" Var1 will be equal to 0 if Var2 is higher to 0, will be 1 other wise

Re: Problem w/ ai code

PostPosted: Fri Jan 11, 2008 3:00 am
by DarkParadox
like your new avatar game a gogo its cool.