[JAVA - HELP] Checking if player is in combat

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
User avatar
zatei
Posts: 103
Joined: Sat Apr 10, 2010 11:25 am
Location: Russia

[JAVA - HELP] Checking if player is in combat

Post 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!
Ay kan saey dat dis qest is bollsit cauise itz vaery problames in coaer drunk bear vodka matreshka balalaika...
Sorry for bad English :D
User avatar
Stake
Posts: 383
Joined: Sun Mar 23, 2008 9:33 pm
Location: Hungary
Contact:

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

Post 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...}
Image
Image
User avatar
zatei
Posts: 103
Joined: Sat Apr 10, 2010 11:25 am
Location: Russia

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

Post by zatei »

Thank you but maybe i'm doing something wrong and isInCombat don't work for me :(
Ay kan saey dat dis qest is bollsit cauise itz vaery problames in coaer drunk bear vodka matreshka balalaika...
Sorry for bad English :D
Post Reply