So here you are:
http://en.wikibooks.org/wiki/C_Programming nice introduction to programming, I think you should especially read (and understand) part about program flow
http://www.angelcode.com/angelscript/sdk...cript.html a bit more advanced, reference documentation of AngelScript
You should also read YinYin's tutorial because it consists every variable and function accessible from your scripts, they are characteristic only for LF2-AI AngelScript implementation.
If you have any problems, just ask
Sorry for confusion.
Edit:
I will also try to explain it myself. Let's assume you want only to add to your characters some new moves, so they wouldn't be so dumb. The easiest way to do so, is NOT to use void id() function, because in this way we would overwrite whole the basic AI. Instead we will write our code in a body of ego() function. It means that this code:
will do only basic AI's actions, no combos at all.
Combos need to be performed only when a suitable situation occurs, i.e. we will use combo only when we are in the same line (the same z axis coordinate) as an opponent. It would be also nice to do it when we are at a good distance and when we are faced towards him. I wrote some functions to help me in this task:
Using them we can script AI in a very simple way. For example I would like to do a close combat combo, only when I am close enough to an opponent and have enough MP:
&& means literally "and".
The condition in the IF statement means:
IF ( distance between us and an opponent is from 10 to 60 (while being faced towards him) AND
our target (opponent) is staying, walking or running (states 0, 1 and 2) - check THIS out AND
we are in the same line (nearly the same z axis coordinate) AND
our mana is above 50 ) DO Defense+Down+Attack combo.
Check my AI scripts to learn some tricks from them.
http://en.wikibooks.org/wiki/C_Programming nice introduction to programming, I think you should especially read (and understand) part about program flow
http://www.angelcode.com/angelscript/sdk...cript.html a bit more advanced, reference documentation of AngelScript
You should also read YinYin's tutorial because it consists every variable and function accessible from your scripts, they are characteristic only for LF2-AI AngelScript implementation.
If you have any problems, just ask
Sorry for confusion.Edit:
I will also try to explain it myself. Let's assume you want only to add to your characters some new moves, so they wouldn't be so dumb. The easiest way to do so, is NOT to use void id() function, because in this way we would overwrite whole the basic AI. Instead we will write our code in a body of ego() function. It means that this code:
Code:
int ego()
{
return 0;
}Combos need to be performed only when a suitable situation occurs, i.e. we will use combo only when we are in the same line (the same z axis coordinate) as an opponent. It would be also nice to do it when we are at a good distance and when we are faced towards him. I wrote some functions to help me in this task:
Code:
int face_distance()
// distance to target, positive when faced towards it (vis-a-vis), negative when we are faced in the opposite direction
// 80 pixels may be considered as a maximum distance allowing close combat
{
return ( self.x - target.x ) * ( 2 * ( self.facing ? 1 : 0 ) - 1 );
}
bool dist_between( int min, int max )
// checks whether distance to target is within bounds
{
return ( ( face_distance() < max ) && ( face_distance() > min ) );
}
bool z_axis_dist( int dist )
// a more general version of same_z_axis()
{
return ( abs( self.z - target.z ) <= dist ) ? true : false;
}
bool same_z_axis()
// checks whether our character is on the same z axis as the opponent
{
return ( abs( self.z - target.z ) <= 8 ) ? true : false;
}Using them we can script AI in a very simple way. For example I would like to do a close combat combo, only when I am close enough to an opponent and have enough MP:
Code:
//... functions from above should be here ...
int ego()
{
if( dist_between(10,60) && ( target.state < 3 ) && same_z_axis() && ( self.mp > 50 ) )
{
DdA();
}
return 0;
}&& means literally "and".
The condition in the IF statement means:
IF ( distance between us and an opponent is from 10 to 60 (while being faced towards him) AND
our target (opponent) is staying, walking or running (states 0, 1 and 2) - check THIS out AND
we are in the same line (nearly the same z axis coordinate) AND
our mana is above 50 ) DO Defense+Down+Attack combo.
Check my AI scripts to learn some tricks from them.

Chat






