Jump to content

Hit splats API?


Recommended Posts

Posted (edited)

Is there any way to retrieve hit splats (damage digits shown at your head)?

I remember there were Player.getHitSplats() but it was removed long time ago.

 

Thanks,

darkxor.

 

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);
}
Edited by Explv
  • Like 1
Posted (edited)

Its not same thing as hit splats. I want be able get not amounts of damage taken by myself but amount of damage dealt to other players/npcs.

getHealth() returns percent for other entities, and also it cant retrieve hits (if two hits received in one tick - it will sum them)

 

You could try:

NPC npc = npcs.closest("Cow"); // Can be a Player instead

int[] splatDamage = npc.accessor.getSplatDamage();
int[] splatTimes = npc.accessor.getSplatTime();
Edited by Explv
  • Like 1
Posted

Ok thanks.

Seems hooks are mismatched and time is in getSplatSecondaryType().

But still can use.

 

There was an issue with the HitSplatListener (I think that was the name). We used to use it in legacy code a while back, then found a more efficient way. After some time the listener broke, nobody used it, and I believe I either deprecated it or deleted it.

  • Like 1
Posted

There was an issue with the HitSplatListener (I think that was the name). We used to use it in legacy code a while back, then found a more efficient way. After some time the listener broke, nobody used it, and I believe I either deprecated it or deleted it.

If you're interested - hit splat times now in XPlayer.getSplatSecondaryType(). I successfully implemented hit splats tracking using it + XPlayer.getSplatDamage(). Was using HitSplat functionality before (not HitSplatListener tho) but needed to comment when you removed support. Now using again.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...