From 6b069bb28abcda46c98d80b5e566ec98579871b8 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Wed, 27 Oct 2021 21:26:39 +0000 Subject: [PATCH] Addition of getMainDamageDealer method. --- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 4 +++- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 4 +++- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 4 +++- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 4 +++- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 4 +++- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 4 +++- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 4 +++- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 4 +++- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 4 +++- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 4 +++- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 24 +++++-------------- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 24 +++++-------------- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 7 ++++-- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 7 ++++-- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 4 +++- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 4 +++- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 4 +++- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 4 +++- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 4 +++- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 4 +++- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 4 +++- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 4 +++- .../gameserver/model/actor/Attackable.java | 21 ++++++++++++++++ .../gameserver/model/actor/Creature.java | 4 +++- 46 files changed, 562 insertions(+), 59 deletions(-) diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Attackable.java index 5d860858a4..e4b851a00d 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -726,6 +726,27 @@ public class Attackable extends Npc getAttackByList().add(new WeakReference<>(creature)); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Creature.java index b9705afe58..1c96c824c0 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1692,7 +1692,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe abortAttack(); abortCast(); - calculateRewards(killer); + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); // Set target to null and cancel Attack or Cast setTarget(null); diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Attackable.java index e3db18c4c9..80da91d9d5 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -722,6 +722,27 @@ public class Attackable extends Npc getAttackByList().add(new WeakReference<>(creature)); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Creature.java index b9705afe58..1c96c824c0 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1692,7 +1692,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe abortAttack(); abortCast(); - calculateRewards(killer); + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); // Set target to null and cancel Attack or Cast setTarget(null); diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Attackable.java index e3db18c4c9..80da91d9d5 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -722,6 +722,27 @@ public class Attackable extends Npc getAttackByList().add(new WeakReference<>(creature)); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Creature.java index 80c6c72be0..3cc1d29bc5 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1692,7 +1692,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe abortAttack(); abortCast(); - calculateRewards(killer); + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); // Set target to null and cancel Attack or Cast setTarget(null); diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Attackable.java index e3db18c4c9..80da91d9d5 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -722,6 +722,27 @@ public class Attackable extends Npc getAttackByList().add(new WeakReference<>(creature)); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Creature.java index 80c6c72be0..3cc1d29bc5 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1692,7 +1692,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe abortAttack(); abortCast(); - calculateRewards(killer); + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); // Set target to null and cancel Attack or Cast setTarget(null); diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Attackable.java index 8da6fad568..290678348a 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -708,6 +708,27 @@ public class Attackable extends Npc getAttackByList().add(new WeakReference<>(creature)); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Creature.java index b286fa417d..6d05859f20 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1692,7 +1692,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe abortAttack(); abortCast(); - calculateRewards(killer); + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); // Set target to null and cancel Attack or Cast setTarget(null); diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Attackable.java index 8da6fad568..290678348a 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -708,6 +708,27 @@ public class Attackable extends Npc getAttackByList().add(new WeakReference<>(creature)); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Creature.java index b286fa417d..6d05859f20 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1692,7 +1692,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe abortAttack(); abortCast(); - calculateRewards(killer); + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); // Set target to null and cancel Attack or Cast setTarget(null); diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Attackable.java index 8da6fad568..290678348a 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -708,6 +708,27 @@ public class Attackable extends Npc getAttackByList().add(new WeakReference<>(creature)); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Creature.java index b286fa417d..6d05859f20 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1692,7 +1692,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe abortAttack(); abortCast(); - calculateRewards(killer); + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); // Set target to null and cancel Attack or Cast setTarget(null); diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Attackable.java index f5d70e58f1..5574726fe5 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -719,6 +719,27 @@ public class Attackable extends Npc getAttackByList().add(new WeakReference<>(creature)); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Creature.java index 5a2d32a928..a5053fce48 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1692,7 +1692,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe abortAttack(); abortCast(); - calculateRewards(killer); + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); // Set target to null and cancel Attack or Cast setTarget(null); diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Attackable.java index f5d70e58f1..5574726fe5 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -719,6 +719,27 @@ public class Attackable extends Npc getAttackByList().add(new WeakReference<>(creature)); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Creature.java index a6d0e6b7af..eaf80b8f2b 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1692,7 +1692,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe abortAttack(); abortCast(); - calculateRewards(killer); + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); // Set target to null and cancel Attack or Cast setTarget(null); diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Attackable.java index f5d70e58f1..5574726fe5 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -719,6 +719,27 @@ public class Attackable extends Npc getAttackByList().add(new WeakReference<>(creature)); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Creature.java index a6d0e6b7af..eaf80b8f2b 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1692,7 +1692,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe abortAttack(); abortCast(); - calculateRewards(killer); + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); // Set target to null and cancel Attack or Cast setTarget(null); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Attackable.java index c0e1be7d7f..003e53b9ed 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -920,6 +920,27 @@ public class Attackable extends NpcInstance } } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info._damage > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info._attacker, true)) + { + damage = info._damage; + damageDealer = info._attacker; + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Creature.java index 965489752d..307f549fd7 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1774,6 +1774,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder setKilledAlready(true); } + + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); + // Set target to null and cancel Attack or Cast setTarget(null); @@ -1842,28 +1847,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder stopAllEffects(); } } - else - // this means all other characters, including Summons + else // this means all other characters, including Summons { stopAllEffects(); } - // if killer is the same then the most damager/hated - Creature mostHated = null; - if (this instanceof Attackable) - { - mostHated = ((Attackable) this)._mostHated; - } - - if ((mostHated != null) && isInsideRadius2D(mostHated, 200)) - { - calculateRewards(mostHated); - } - else - { - calculateRewards(killer); - } - // Send the Server->Client packet StatusUpdate with current HP and MP to all other PlayerInstance to inform broadcastStatusUpdate(); diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Attackable.java index b35540564e..4fd1a32166 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -921,6 +921,27 @@ public class Attackable extends NpcInstance } } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info._damage > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info._attacker, true)) + { + damage = info._damage; + damageDealer = info._attacker; + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java index 458487945b..3b0859e31b 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1817,6 +1817,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder setKilledAlready(true); } + + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); + // Set target to null and cancel Attack or Cast setTarget(null); @@ -1885,28 +1890,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder stopAllEffects(); } } - else - // this means all other characters, including Summons + else // this means all other characters, including Summons { stopAllEffects(); } - // if killer is the same then the most damager/hated - Creature mostHated = null; - if (this instanceof Attackable) - { - mostHated = ((Attackable) this)._mostHated; - } - - if ((mostHated != null) && isInsideRadius2D(mostHated, 200)) - { - calculateRewards(mostHated); - } - else - { - calculateRewards(killer); - } - // Send the Server->Client packet StatusUpdate with current HP and MP to all other PlayerInstance to inform broadcastStatusUpdate(); diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Attackable.java index f8cb3256a7..3894517ade 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -679,6 +679,27 @@ public class Attackable extends Npc getAttackByList().add(creature); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Creature.java index 6a78a2e711..1f8ebe572a 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -73,6 +73,7 @@ import org.l2jmobius.gameserver.model.TimeStamp; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.WorldRegion; +import org.l2jmobius.gameserver.model.actor.instance.MonsterInstance; import org.l2jmobius.gameserver.model.actor.instance.PetInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.QuestGuardInstance; @@ -2432,6 +2433,10 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe setDead(true); } + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); + // Set target to null and cancel Attack or Cast setTarget(null); @@ -2458,8 +2463,6 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe stopAllEffectsExceptThoseThatLastThroughDeath(); } - calculateRewards(killer); - // Send the Server->Client packet StatusUpdate with current HP and MP to all other PlayerInstance to inform broadcastStatusUpdate(); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Attackable.java index f8cb3256a7..3894517ade 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -679,6 +679,27 @@ public class Attackable extends Npc getAttackByList().add(creature); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Creature.java index 793d6842d1..a2ae303d9f 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -73,6 +73,7 @@ import org.l2jmobius.gameserver.model.TimeStamp; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.WorldRegion; +import org.l2jmobius.gameserver.model.actor.instance.MonsterInstance; import org.l2jmobius.gameserver.model.actor.instance.PetInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.QuestGuardInstance; @@ -2434,6 +2435,10 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe setDead(true); } + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); + // Set target to null and cancel Attack or Cast setTarget(null); @@ -2460,8 +2465,6 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe stopAllEffectsExceptThoseThatLastThroughDeath(); } - calculateRewards(killer); - // Send the Server->Client packet StatusUpdate with current HP and MP to all other PlayerInstance to inform broadcastStatusUpdate(); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Attackable.java index 7ca5fa2103..4c70df7456 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -722,6 +722,27 @@ public class Attackable extends Npc getAttackByList().add(new WeakReference<>(creature)); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Creature.java index 3b42741754..4eada88274 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1692,7 +1692,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe abortAttack(); abortCast(); - calculateRewards(killer); + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); // Set target to null and cancel Attack or Cast setTarget(null); diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Attackable.java index 7ca5fa2103..4c70df7456 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -722,6 +722,27 @@ public class Attackable extends Npc getAttackByList().add(new WeakReference<>(creature)); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Creature.java index 3b42741754..4eada88274 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1692,7 +1692,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe abortAttack(); abortCast(); - calculateRewards(killer); + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); // Set target to null and cancel Attack or Cast setTarget(null); diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Attackable.java index 9f5a30e156..861638e6e4 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -722,6 +722,27 @@ public class Attackable extends Npc getAttackByList().add(new WeakReference<>(creature)); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Creature.java index 15775c65bc..4c40f0eb84 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1692,7 +1692,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe abortAttack(); abortCast(); - calculateRewards(killer); + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); // Set target to null and cancel Attack or Cast setTarget(null); diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Attackable.java index a2c875f8fa..9f52982dcf 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -743,6 +743,27 @@ public class Attackable extends Npc getAttackByList().add(new WeakReference<>(creature)); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Creature.java index fe092f9475..6e632a9712 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1693,7 +1693,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe abortAttack(); abortCast(); - calculateRewards(killer); + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); // Set target to null and cancel Attack or Cast setTarget(null); diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Attackable.java index a2c875f8fa..9f52982dcf 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -743,6 +743,27 @@ public class Attackable extends Npc getAttackByList().add(new WeakReference<>(creature)); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Creature.java index fe092f9475..6e632a9712 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1693,7 +1693,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe abortAttack(); abortCast(); - calculateRewards(killer); + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); // Set target to null and cancel Attack or Cast setTarget(null); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Attackable.java index a2c875f8fa..9f52982dcf 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -743,6 +743,27 @@ public class Attackable extends Npc getAttackByList().add(new WeakReference<>(creature)); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Creature.java index fae8843017..db424ba772 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1693,7 +1693,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe abortAttack(); abortCast(); - calculateRewards(killer); + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); // Set target to null and cancel Attack or Cast setTarget(null); diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Attackable.java index 4e6bf68ed4..3c1b2c7611 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -726,6 +726,27 @@ public class Attackable extends Npc getAttackByList().add(new WeakReference<>(creature)); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java index 3b42741754..4eada88274 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1692,7 +1692,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe abortAttack(); abortCast(); - calculateRewards(killer); + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); // Set target to null and cancel Attack or Cast setTarget(null); diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Attackable.java index 54abb77b60..1425d1a04f 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -748,6 +748,27 @@ public class Attackable extends Npc getAttackByList().add(new WeakReference<>(creature)); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Creature.java index 1a0302162f..99a3af0e55 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1696,7 +1696,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe abortAttack(); abortCast(); - calculateRewards(killer); + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); // Set target to null and cancel Attack or Cast setTarget(null); diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Attackable.java index 70cfc77dbf..69efb08aca 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -753,6 +753,27 @@ public class Attackable extends Npc getAttackByList().add(new WeakReference<>(creature)); } + public Creature getMainDamageDealer() + { + if (_aggroList.isEmpty()) + { + return null; + } + + int damage = 0; + Creature damageDealer = null; + for (AggroInfo info : _aggroList.values()) + { + if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true)) + { + damage = info.getDamage(); + damageDealer = info.getAttacker(); + } + } + + return damageDealer; + } + /** * Add damage and hate to the attacker AggroInfo of the Attackable _aggroList. * @param attacker The Creature that gave damages to this Attackable diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Creature.java index bc62af494b..b25efad7bd 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -1703,7 +1703,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe abortAttack(); abortCast(); - calculateRewards(killer); + // Calculate rewards for main damage dealer. + final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null; + calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer); // Set target to null and cancel Attack or Cast setTarget(null);