Little Fighter Empire - Forums
Few questioins about AI script - Printable Version

+- Little Fighter Empire - Forums (https://lf-empire.de/forum)
+-- Forum: Little Fighter 2 Zone (https://lf-empire.de/forum/forumdisplay.php?fid=7)
+--- Forum: AI Scripting (https://lf-empire.de/forum/forumdisplay.php?fid=56)
+--- Thread: Few questioins about AI script (/showthread.php?tid=9201)



Few questioins about AI script - TheRoot - 05-06-2014

How to use my bot randomly blows skills without conditions? Without spam?


RE: Few questioins about AI script - A-Man - 05-06-2014

Just make use of the "rand()" function:
    AI-Code:
int randomval = rand(100); //returns an int b/w 0 & 100
if (randomval<=20)
    MoveOne();
if (randomval>20 && randomval<=40)
    MoveTwo();
if (randomval>40 && randomval<=60)
    MoveThree();
if (randomval>60 && randomval<=80)
    MoveThree();
if (randomval>80)
    MoveThree();

Of course you will end up having conditions if you don't want it to work awkwardly. The conditions are the base of the whole AI stuff.


RE: Few questioins about AI script - TheRoot - 05-06-2014

In this case:


if( dist_between(351,500) && same_z_axis() && ( self.mp > 100 ) && ( target.state != 14 ) )
{
DuJ();
return 0;
}



I need to put int randomval = rand(100) inside or outside this function?

To put other command


RE: Few questioins about AI script - A-Man - 05-06-2014

It doesn't really matter, but best, outside right after the "int ego(){}". This is what it would look like:
[code=AI]
int ego(){
int randomval = rand(100); //returns an int b/w 0 & 100
//....other code here
if( randomval <10 && (dist_between(351,500) && same_z_axis() && ( self.mp > 100 ) && ( target.state != 14 )) )
{
DuJ();
}
return 0;
//....some code here
return 1;
}


RE: Few questioins about AI script - TheRoot - 05-07-2014

Does not work :/