I'm not sure if there are hitsplats in the API anymore, but to work out the damage to your player you could just do:
private int previousHealth;
@ Override
public final void onStart() {
previousHealth = getHealth();
}
@ Override
public final int onLoop() throws InterruptedException {
final int currentHealth = getHealth();
if (currentHealth < previousHealth) {
final int damage = previousHealth - currentHealth; // Calculate the damage
previousHealth = currentHealth;
}
return random(100, 150);
}
private int getHealth() {
return getSkills().getDynamic(Skill.HITPOINTS);
}
Or if you just want to know the % of hp remaining, for example to know when to eat, you can do:
public final int getHealthPercent() {
return (getSkills().getDynamic(Skill.HITPOINTS) * 100) / getSkills().getStatic(Skill.HITPOINTS);
}