Jump to content

Question

Posted (edited)

I would like to know which method I use for a player not to catch the target of a monster that is being attacked, if I use isInCombat the player does not hit the target when he is in combat

 

use l2jfrozen 1132

Edited by DzStunk

10 answers to this question

Recommended Posts

  • 0
Posted
2 minutes ago, DzStunk said:

I created a debug on the list and had no success

If someone has already attacked the monster, he should be on it's aggrolist. If he's not (well right click -> delete project) but you can also check if there is an attackedBy list.

  • 0
Posted
34 minutes ago, Zake said:

If someone has already attacked the monster, he should be on it's aggrolist. If he's not (well right click -> delete project) but you can also check if there is an attackedBy list.

 

Is there an example of how to do it somewhere?

  • 0
Posted (edited)
24 minutes ago, DzStunk said:

 

Is there an example of how to do it somewhere?

based on Zake's reply, assume that the target is an instance of MonsterInstance so you can simply make a check like
 

if (!target.getAggroList().isEmpty())
   continue;

 

Edited by Amn3sia
  • 0
Posted
6 minutes ago, Amn3sia said:

based on Zake's reply, assume that the target is an instance of MonsterInstance so you can simply make a check like
 

if (!target.getAggroList().isEmpty())
   continue;

 

 

this verification will not work because the player himself will be on the list and will not attack.

  • 0
Posted (edited)

From what I understand you're referring to this 'auto-target' thing that exists in l2, when you don't have a target and a monster attacks you, you automatically target this monster. Unfortunately for you, this is client-side I'm pretty sure and it sends Action packet, which is the same packet the client sends when the player actually requests to target something, so there's no way to work around that server-side.

 

You could try to predict if the player made this target call or it was automatic, but it can't be 100% accurate and it might feel buggy.

 

Maybe I misunderstood what you meant though about the auto-target.

Edited by An4rchy
  • 0
Posted (edited)
On 3/6/2023 at 11:26 PM, DzStunk said:

 

this verification will not work because the player himself will be on the list and will not attack.

if (!target.getAggroList().isEmpty() && !target.getAggroList().containsKey(player))
     continue;

 

Edited by Amn3sia
  • 0
Posted
As said Anarchy, it's client-sided and can't be controlled (from what I know about it and from what I understood of your request).

In a custom use, getAggroList()#containsKey would be your solution if you want the check to be CURRENT, and attackedBy to be both PAST and CURRENT (even with complete loss of aggro).

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...