mirror of
https://github.com/2006-Scape/Parabot-317-API-Minified.git
synced 2026-07-04 16:49:10 +00:00
Changed package
This commit is contained in:
@@ -0,0 +1,177 @@
|
||||
package org.rev317.min.api.wrappers;
|
||||
|
||||
import org.rev317.min.Loader;
|
||||
import org.rev317.min.api.interfaces.Locatable;
|
||||
import org.rev317.min.api.methods.Calculations;
|
||||
import org.rev317.min.api.methods.Game;
|
||||
import org.rev317.min.api.methods.Menu;
|
||||
import org.rev317.min.api.methods.Players;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Character implements Locatable {
|
||||
|
||||
private org.rev317.min.accessors.Character accessor;
|
||||
private int index;
|
||||
|
||||
public Character(org.rev317.min.accessors.Character accessor, int index) {
|
||||
this.accessor = accessor;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets local region x
|
||||
*
|
||||
* @return x
|
||||
*/
|
||||
public int getX() {
|
||||
return accessor.getX() >> 7;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets local region y
|
||||
*
|
||||
* @return y
|
||||
*/
|
||||
public int getY() {
|
||||
return accessor.getY() >> 7;
|
||||
}
|
||||
|
||||
/**
|
||||
* Index of the character array
|
||||
*
|
||||
* @return index
|
||||
*/
|
||||
public int getIndex() {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Animation of this character
|
||||
*
|
||||
* @return animation
|
||||
*/
|
||||
public int getAnimation() {
|
||||
return accessor.getAnimation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Location of this character
|
||||
*
|
||||
* @return location
|
||||
*/
|
||||
public Tile getLocation() {
|
||||
return new Tile(Game.getBaseX() + getX(), Game.getBaseY() + getY());
|
||||
}
|
||||
|
||||
/**
|
||||
* Distance to this character
|
||||
*
|
||||
* @return distance
|
||||
*/
|
||||
public int distanceTo() {
|
||||
return (int) Calculations.distanceTo(getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Interacts with this character
|
||||
*
|
||||
* @param i
|
||||
*/
|
||||
public void interact(int i) {
|
||||
Menu.interact(this, i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets current health
|
||||
*
|
||||
* @return health
|
||||
*/
|
||||
public final int getHealth() {
|
||||
return this.accessor.getCurrentHealth();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets maximum health of this character
|
||||
*
|
||||
* @return max health
|
||||
*/
|
||||
public final int getMaxHealth() {
|
||||
return this.accessor.getMaxHealth();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches loop cycle status
|
||||
*
|
||||
* @return loop cycle status
|
||||
*/
|
||||
public final int getLoopCycleStatus() {
|
||||
return this.accessor.getLoopCycleStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if entity is in combat
|
||||
*
|
||||
* @return <b>true</b> if entity is in combat
|
||||
*/
|
||||
public boolean isInCombat() {
|
||||
return accessor.getLoopCycleStatus() > Loader.getClient()
|
||||
.getLoopCycle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the character this character is interacting with
|
||||
*
|
||||
* @return interacting character
|
||||
*/
|
||||
public final Character getInteractingCharacter() {
|
||||
int index = this.accessor.getInteractingEntity();
|
||||
if (index != -1 && index < 32768) {
|
||||
return new Npc(Loader.getClient().getNpcs()[index], index);
|
||||
} else if (index >= 32768) {
|
||||
index -= 32768;
|
||||
try {
|
||||
if (Loader.getClient().getPlayers()[index] == null) {
|
||||
return Players.getMyPlayer();
|
||||
}
|
||||
return new Player(Loader.getClient().getPlayers()[index], index);
|
||||
} catch (Throwable t) {
|
||||
return Players.getMyPlayer();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result
|
||||
+ ((accessor == null) ? 0 : accessor.hashCode());
|
||||
result = prime * result + index;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Character other = (Character) obj;
|
||||
if (accessor == null) {
|
||||
if (other.accessor != null)
|
||||
return false;
|
||||
} else if (!accessor.equals(other.accessor))
|
||||
return false;
|
||||
if (index != other.index)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user