June 30, 20169 yr I'm scouring the API, yet I can't find how to obtain the current HP remaining of a player. How can this be done?
June 30, 20169 yr getCurrentHealth() This is only updated while in combat and will return 0 if they have never been detected in combat, the associated getCombatTime() will return -1000 if the Player instance has never been detected in combat. Edited June 30, 20169 yr by Token
June 30, 20169 yr Author getCurrentHealth() This is only updated while in combat and will return 0 if they have never been detected in combat, the associated getCombatTime() will return -1000 if the Player instance has never been detected in combat. Thanks so much for the help! Would you please show me an example of how it's used? Do I need to write 'character.getCurrentHealth()'? What object should I attach the method to? Edited June 30, 20169 yr by Imateamcape
June 30, 20169 yr Thanks so much for the help! Would you please show me an example of how it's used? Do I need to write 'character.getCurrentHealth()'? What object should I attach the method to? Player x = players.closest("Johnny"); if (x.getCombatTime() == -1000) { log("Johnny has never been in combat; we can't know his hp"); } else { log("Johnny's hp is: " + x.getCurrentHealth()); }
June 30, 20169 yr getSkills().getDynamic(Skill.HITPOINTS); also gives you the current hitpoints , if you want the percentage use this: double hpPercentage = getSkills().getDynamic(Skill.HITPOINTS) * 100 / getSkills().getStatic(Skill.HITPOINTS);
Create an account or sign in to comment