Jump to content

Hit splats API?


darkxor

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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