1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Question Check if mob health is zero?

Discussion in 'Developer Support' started by bia10, Nov 7, 2020.

  1. bia10

    Joined:
    Feb 24, 2020
    Messages:
    33
    Likes Received:
    4
    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 (Text):
    1.     public static boolean IsHPZero(Actor actor) {
    2.         if (actor.getHealthGauge() != null ) {
    3.             return actor.getHealthGauge().getPercent() == 0;
    4.         }
    5.         return false;
    6.     }
    it doesn't seem to work, although i checked with devkit and indeed when the gauge is red it says 0 percent
    --- Double Post Merged, Nov 8, 2020, Original Post Date: Nov 7, 2020 ---
    Well i did some debug and its confusing
    Code (Text):
    1. getLogger().info("False mob: " + (myTarget != null ? myTarget.toString() : null) + " gauge: " + (myTarget != null ? myTarget.getHealthGauge() : null));
    when fighting with 0 hp mob return this:

    Code (Text):
    1. 00:00:08 DEBUG    Hovered Lizard(level: 42, position: 3400, 3066, 0) on the first attempt.
    2. 00:00:08 DEBUG    Hovered MenuItem{2 : "Attack" : "Lizard" : Lizard(level: 42, position: 3400, 3066, 0)} on the first attempt.
    3. 00:00:11 INFO    False mob: null gauge: null
    at 00:00:11 Lizard(level: 42, position: 3400, 3066, 0) rechead 0 hp
    --- Double Post Merged, Nov 8, 2020 ---
    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 (Text):
    1. 00:00:42 INFO    CurTarget: Desert Lizard(level: 24, position: 3403, 3061, 0) gauge: StatusGauge(percent=0)
    2. 00:00:42 INFO    MobTargetingMe: Desert Lizard(level: 24, position: 3403, 3061, 0) gauge: StatusGauge(percent=0)
    3. 00:00:42 INFO    Finish!: Desert Lizard(level: 24, position: 3403, 3061, 0)
    4. 00:00:42 DEBUG    Hovered SpriteItem(name:Ice cooler, quantity: 73, index: 10,  origin: INVENTORY) on the first attempt.
    5. 00:00:43 DEBUG    Hovered Desert Lizard(level: 24, position: 3403, 3061, 0) on the first attempt.
     

Share This Page

Loading...