Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question Check if mob health is zero?

Joined
Feb 24, 2020
Messages
33
Hello,

i need to perform action when mob health is at 0 however i am not able to accomplish such a task with the API i tried:

Code:
    public static boolean IsHPZero(Actor actor) {
        if (actor.getHealthGauge() != null ) {
            return actor.getHealthGauge().getPercent() == 0;
        }
        return false;
    }

it doesn't seem to work, although i checked with devkit and indeed when the gauge is red it says 0 percent
 
Well i did some debug and its confusing
Code:
getLogger().info("False mob: " + (myTarget != null ? myTarget.toString() : null) + " gauge: " + (myTarget != null ? myTarget.getHealthGauge() : null));

when fighting with 0 hp mob return this:

Code:
00:00:08 DEBUG    Hovered Lizard(level: 42, position: 3400, 3066, 0) on the first attempt.
00:00:08 DEBUG    Hovered MenuItem{2 : "Attack" : "Lizard" : Lizard(level: 42, position: 3400, 3066, 0)} on the first attempt.
00:00:11 INFO    False mob: null gauge: null

at 00:00:11 Lizard(level: 42, position: 3400, 3066, 0) rechead 0 hp
 
can be closed, found my mistake, before killing slayer monsters i had implemented combat check which assumed mob is dead at hp 0.

works fine now :
Code:
00:00:42 INFO    CurTarget: Desert Lizard(level: 24, position: 3403, 3061, 0) gauge: StatusGauge(percent=0)
00:00:42 INFO    MobTargetingMe: Desert Lizard(level: 24, position: 3403, 3061, 0) gauge: StatusGauge(percent=0)
00:00:42 INFO    Finish!: Desert Lizard(level: 24, position: 3403, 3061, 0)
00:00:42 DEBUG    Hovered SpriteItem(name:Ice cooler, quantity: 73, index: 10,  origin: INVENTORY) on the first attempt.
00:00:43 DEBUG    Hovered Desert Lizard(level: 24, position: 3403, 3061, 0) on the first attempt.
 
Top