02-20-2016, 12:40 PM
(This post was last modified: 02-20-2016, 12:41 PM by T.O.R.N.A.D.O.)

So I tried making a simple and basic AI for a character called Naruto from my mod. Here is the code:

Now the problem I am getting is - the computer spams J+J+A for no reason. I haven't put anything like that in the ego function and the basic character AI cannot be THAT retarded. So why is he behaving like that? Any thoughts?

PS: The id used here is 1.

Code:

`int ego(){`

int rxdist=(target.x-self.x);

int lxdist=(self.x-target.x);

int random=rand(100);

//Run in correct direction

if (abs(self.x-target.x) > 100)

{

if (self.x-target.x > 0)

{

left(1,0);

left(1,0);

}

else if (self.x-target.x < 0)

{

right(1,0);

right(1,0);

}

}

//Rasenshuriken

if ((abs(self.z-target.z) < 5) && ((self.x-target.x) < 100) && ((self.x-target.x) > 50) && self.mp > 200 && self.hp<480 && random<=5)

{

if (self.x-target.x > 0)

{

left(1,0);

if (self.facing==true)

DuJ();

}

else if (self.x-target.x < 0)

{

right(1,0);

if (self.facing==false)

DuJ();

}

}

//Shuriken

if(lxdist<=50 && self.mp>50 && random<=30)

{

DlA();

}

else if(rxdist<=50 && self.mp>50 && random<=30)

{

DrA();

}

//Rasengan

if(lxdist<=30 && self.mp>100 && random<=30)

{

DlJ();

}

else if(rxdist<=30 && self.mp>100 && random<=30)

{

DrJ();

}

//Surprise Clone

if(lxdist<10 || rxdist<10 && self.mp>100 && random<=30)

{

A(1,1);

J();

}

//Mass Clone

if(lxdist>200 || rxdist>200 && self.mp>480 && random<=5)

{

DdJ();

}

//Frog

if((lxdist<500 && lxdist>20) || (rxdist<500 && rxdist>20) && self.mp>100 && random<=10 && abs(self.z-target.z)<=10)

{

DdA();

}

return 0;

}

Now the problem I am getting is - the computer spams J+J+A for no reason. I haven't put anything like that in the ego function and the basic character AI cannot be THAT retarded. So why is he behaving like that? Any thoughts?

PS: The id used here is 1.