Problem w/ ai code

Non-platform specific questions.

Problem w/ ai code

Postby Freddy » Sat Jan 05, 2008 4:06 pm

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
Hola
User avatar
Freddy
 
Posts: 548
Joined: Sat Jun 02, 2007 3:42 pm
Location: Why do you want to know?
Score: 14 Give a positive score

Re: Problem w/ ai code

Postby makslane » Sun Jan 06, 2008 12:37 am

More than zero? The code will works for any value < 1, including the values between 0 and 1!
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: Problem w/ ai code

Postby Bee-Ant » Sun Jan 06, 2008 7:10 am

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
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Problem w/ ai code

Postby DarkParadox » Mon Jan 07, 2008 10:47 pm

try:
Code: Select all
if(knockout =! 0)

it checks if knockout does not equal 0.
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: Problem w/ ai code

Postby Bee-Ant » Tue Jan 08, 2008 5:13 am

So... =! same as != ??? :roll:
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Problem w/ ai code

Postby Fuzzy » Tue Jan 08, 2008 7:08 am

perhaps. By you should always use !=
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: Problem w/ ai code

Postby Bee-Ant » Tue Jan 08, 2008 8:52 am

Yeah...usualy I use != :oops:
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Problem w/ ai code

Postby DarkParadox » Tue Jan 08, 2008 10:31 pm

they are the same
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: Problem w/ ai code

Postby Game A Gogo » Wed Jan 09, 2008 12:57 am

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
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Problem w/ ai code

Postby DarkParadox » Fri Jan 11, 2008 3:00 am

like your new avatar game a gogo its cool.
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron