Page 1 of 1

[JAVA - HELP] Checking if player is in combat

Posted: Tue Mar 29, 2011 9:35 am
by zatei
Hi!

I'm currently modifying core of my server and i need to check if player is in combat with mob.
I think the best solution in my case is to check that anybody is aggro on the player, how to code this check right?

P.S. Maybe anyone on this forum solved this problem in other way? Any ideas?

Thank you!

Re: [JAVA - HELP] Checking if player is in combat

Posted: Tue Mar 29, 2011 12:44 pm
by Stake
Hi!

There is a simple boolean function for that: player.isInCombat() - returns true, if the character is in combat stance including when attacking
Or if attacking: player.isAttacking() - returns true, if the character's ai is on attack

For example:

Code: Select all

if(player.isInCombat()) {    // do some stuff...}
Or if you mean a player is on a mob's aggrolist, then you should use getAggroList(), like

Code: Select all

if(mob.getAggroList().contains(player)) {    // do some stuff...}

Re: [JAVA - HELP] Checking if player is in combat

Posted: Sun Apr 03, 2011 7:39 pm
by zatei
Thank you but maybe i'm doing something wrong and isInCombat don't work for me :(