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!
[JAVA - HELP] Checking if player is in combat
Forum rules
READ NOW: L2j Forums Rules of Conduct
READ NOW: L2j Forums Rules of Conduct
- zatei
- Posts: 103
- Joined: Sat Apr 10, 2010 11:25 am
- Location: Russia
[JAVA - HELP] Checking if player is in combat
Ay kan saey dat dis qest is bollsit cauise itz vaery problames in coaer drunk bear vodka matreshka balalaika...
Sorry for bad English
Sorry for bad English

- Stake
- Posts: 383
- Joined: Sun Mar 23, 2008 9:33 pm
- Location: Hungary
- Contact:
Re: [JAVA - HELP] Checking if player is in combat
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:
Or if you mean a player is on a mob's aggrolist, then you should use getAggroList(), like
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...}
Code: Select all
if(mob.getAggroList().contains(player)) { // do some stuff...}


- zatei
- Posts: 103
- Joined: Sat Apr 10, 2010 11:25 am
- Location: Russia
Re: [JAVA - HELP] Checking if player is in combat
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
Sorry for bad English
