Position - JohnDoeAntler/LF2-AI-Abstraction GitHub Wiki

A class that assists the calculation of position prediction and direction determination.

Constructor

Initializing via coordinates

Position(int x, int y, int z);

// examples
Position@ p1 = Position(1, 1, 1);

Initializing via Info object

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);

Initializing via object number

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);

Properties

x

// examples
class DerivedPosition : Position {
  void example () {
    this.x = ...;
  }
}

y

// examples
class DerivedPosition : Position {
  void example () {
    this.y = ...;
  }
}

z

// examples
class DerivedPosition : Position {
  void example () {
    this.z = ...;
  }
}

vx

// examples
class DerivedPosition : Position {
  void example () {
    this.vx = ...;
  }
}

vy

// examples
class DerivedPosition : Position {
  void example () {
    this.vy = ...;
  }
}

vz

// examples
class DerivedPosition : Position {
  void example () {
    this.vz = ...;
  }
}

Methods

getX

it will return the x coordinate of current wrapped object.

position.getX();

getY

it will return the y coordinate of current wrapped object.

position.getY();

getZ

it will return the z coordinate of current wrapped object.

position.getZ();

getVx

it will return the x velocity of current wrapped object.

position.getVx();

getVy

it will return the y velocity of current wrapped object.

position.getVy();

getVz

it will return the z velocity of current wrapped object.

position.getVz();

isLeftOf

return a boolean value of checking whether current object is to the left of specified object.

isLeftOf(Position@ pos);

// examples
p1.isLeftOf(p2);

isRightOf

return a boolean value of checking whether current object is to the right of specified object.

isRightOf(Position@ pos);

// examples
p1.isRightOf(p2);

isTopOf

return a boolean value of checking whether current object is to the top of specified object.

isTopOf(Position@ pos);

// examples
p1.isTopOf(p2);

isBottomOf

return a boolean value of checking whether current object is to the bottom of specified object.

isBottomOf(Position@ pos);

// examples
p1.isBottomOf(p2);

isApproaching

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.

isLeaving

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

distanceTo

return the distance between current wrapped object and specified object.

further reading: Distance

distanceTo(Position@ pos);

// examples
p1.distanceTo(p2);

distanceToSelf

return the distance between current wrapped object and AI itself.

further reading: Distance

distanceToSelf();

// examples
p1.distanceToSelf();

distanceToBoundary

return the distance between current wrapped object and boundary.

distanceToBoundary();

// examples
p1.distanceToBoundary();

inRangeX (Not Recommended)

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();
}

inRangeY (Not Recommended)

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();
}

inRangeZ (Not Recommended)

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();
}

inProjectileRange (Not Recommended)

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();
}

toString

return a nicely-formatted string.

toString();

// examples
p1.toString();

Operator Overloading

Position@ multiplication = p1 * p2;

Snippets

No Snippets available.

⚠️ **GitHub.com Fallback** ⚠️