Position - JohnDoeAntler/LF2-AI-Abstraction GitHub Wiki
A class that assists the calculation of position prediction and direction determination.
Position(int x, int y, int z);
// examples
Position@ p1 = Position(1, 1, 1);
Usually, you should use TargetLoader to receive Entity class which extends from Position.
Directly instantiating Position class is not recommended.
Position(Info@ info);
// examples
Position@ p1 = Position(self);
Position@ p2 = Position(target);
Usually, you should use TargetLoader to receive Entity class which extends from Position.
Directly instantiating Position class is not recommended.
Position(int num);
// examples
Position@ p1 = Position(self.num);
Position@ p2 = Position(target.num);
// examples
class DerivedPosition : Position {
void example () {
this.x = ...;
}
}
// examples
class DerivedPosition : Position {
void example () {
this.y = ...;
}
}
// examples
class DerivedPosition : Position {
void example () {
this.z = ...;
}
}
// examples
class DerivedPosition : Position {
void example () {
this.vx = ...;
}
}
// examples
class DerivedPosition : Position {
void example () {
this.vy = ...;
}
}
// examples
class DerivedPosition : Position {
void example () {
this.vz = ...;
}
}
it will return the x coordinate of current wrapped object.
position.getX();
it will return the y coordinate of current wrapped object.
position.getY();
it will return the z coordinate of current wrapped object.
position.getZ();
it will return the x velocity of current wrapped object.
position.getVx();
it will return the y velocity of current wrapped object.
position.getVy();
it will return the z velocity of current wrapped object.
position.getVz();
return a boolean value of checking whether current object is to the left of specified object.
isLeftOf(Position@ pos);
// examples
p1.isLeftOf(p2);
return a boolean value of checking whether current object is to the right of specified object.
isRightOf(Position@ pos);
// examples
p1.isRightOf(p2);
return a boolean value of checking whether current object is to the top of specified object.
isTopOf(Position@ pos);
// examples
p1.isTopOf(p2);
return a boolean value of checking whether current object is to the bottom of specified object.
isBottomOf(Position@ pos);
// examples
p1.isBottomOf(p2);
return a boolean value of checking whether current wrapped object is approaching (x-axis) to the specified object.
isApproaching(Position@ pos);
// examples
p2.isApproaching(p1); // check whether p2 is approaching to p1.
return a boolean value of whether current wrapped object is leaving (x-axis) to the specified object.
isLeaving(Position@ pos);
// examples
p2.isLeaving(p1); // check whether p2 is escaping from p1
return the distance between current wrapped object and specified object.
further reading: Distance
distanceTo(Position@ pos);
// examples
p1.distanceTo(p2);
return the distance between current wrapped object and AI itself.
further reading: Distance
distanceToSelf();
// examples
p1.distanceToSelf();
return the distance between current wrapped object and boundary.
distanceToBoundary();
// examples
p1.distanceToBoundary();
return a boolean value of checking whether the specified object is in the given x-axis range of current object.
inRangeX(Position@ pos, int val);
// examples
if (p1.inRangeX(p2, 50)) { // mocking character punching range
A();
}
return a boolean value of checking whether the specified object is in the given y-axis range of current object.
inRangeY(Position@ pos, int val);
// examples
if (p1.inRangeY(p2, 30)) { // mocking character punching range
A();
}
return a boolean value of checking whether the specified object is in the given z-axis range of current object.
inRangeZ(Position@ pos, int val);
// examples
if (p1.inRangeZ(p2, 14)) { // mocking character punching range
A();
}
return a boolean value of checking whether the specified object is in the tangent scope of current object.
inProjectileRange(Position@ pos, int x, int z);
inProjectileRange(Position@ pos, int x, int z, int zwidth, int offset);
// examples
// mocking henry normal arrow range
// p1 = henry/enemy (the order is not important)
// p2 = enemy/henry (the order is not important)
// 428 = max arrow attack range of x-axis
// 45 = max arrow attack range of z-axis
if (p1.inProjectileRange(p2, 428, 45)) {
A();
}
// mocking henry normal arrow range
// p1 = henry/enemy (the order is not important)
// p2 = enemy/henry (the order is not important)
// 373 = max arrow attack range of x-axis
// 45 = max arrow attack range of z-axis
// 14 = zwidth of arrow itr
// 55 = the x-axis offset of the arrow spawning position
if (p1.inProjectileRange(p2, 373, 45, 14, 55)) {
A();
}
return a nicely-formatted string.
toString();
// examples
p1.toString();
Position@ multiplication = p1 * p2;
No Snippets available.