From 786af8325bb8f61a4109e456d37e7e2c6f7d6701 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Mon, 24 Aug 2020 17:14:56 +0000 Subject: [PATCH] Disable Drain skills used on invulnerable NPCs. --- .../gameserver/model/actor/Creature.java | 30 +++++++++---------- .../model/skills/handlers/SkillDrain.java | 7 ++++- .../gameserver/model/actor/Creature.java | 30 +++++++++---------- .../model/skills/handlers/SkillDrain.java | 7 ++++- 4 files changed, 42 insertions(+), 32 deletions(-) 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 2ecf3387f8..7e0d745ec4 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 @@ -9005,56 +9005,56 @@ public abstract class Creature extends WorldObject implements ISkillsHolder /** * Reduce current hp. - * @param i the i + * @param amount the amount * @param attacker the attacker */ - public void reduceCurrentHp(double i, Creature attacker) + public void reduceCurrentHp(double amount, Creature attacker) { - reduceCurrentHp(i, attacker, true); + reduceCurrentHp(amount, attacker, true); } /** * Reduce current hp. - * @param i the i + * @param amount the amount * @param attacker the attacker * @param awake the awake */ - public void reduceCurrentHp(double i, Creature attacker, boolean awake) + public void reduceCurrentHp(double amount, Creature attacker, boolean awake) { - if ((this instanceof NpcInstance) && Config.INVUL_NPC_LIST.contains(((NpcInstance) this).getNpcId())) + if (isNpc() && Config.INVUL_NPC_LIST.contains(((NpcInstance) this).getNpcId())) { return; } if (Config.CHAMPION_ENABLE && _champion && (Config.CHAMPION_HP != 0)) { - getStatus().reduceHp(i / Config.CHAMPION_HP, attacker, awake); + getStatus().reduceHp(amount / Config.CHAMPION_HP, attacker, awake); } else if (_advanceFlag) { - getStatus().reduceHp(i / _advanceMultiplier, attacker, awake); + getStatus().reduceHp(amount / _advanceMultiplier, attacker, awake); } else if (_isUnkillable) { final double hpToReduce = getStatus().getCurrentHp() - 1; - if (i > getStatus().getCurrentHp()) + if (amount > getStatus().getCurrentHp()) { getStatus().reduceHp(hpToReduce, attacker, awake); } else { - getStatus().reduceHp(i, attacker, awake); + getStatus().reduceHp(amount, attacker, awake); } } else { - getStatus().reduceHp(i, attacker, awake); + getStatus().reduceHp(amount, attacker, awake); } } private long _nextReducingHPByOverTime = -1; - public void reduceCurrentHpByDamOverTime(double i, Creature attacker, boolean awake, int period) + public void reduceCurrentHpByDamOverTime(double amount, Creature attacker, boolean awake, int period) { if (_nextReducingHPByOverTime > System.currentTimeMillis()) { @@ -9062,12 +9062,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder } _nextReducingHPByOverTime = System.currentTimeMillis() + (period * 1000); - reduceCurrentHp(i, attacker, awake); + reduceCurrentHp(amount, attacker, awake); } private long _nextReducingMPByOverTime = -1; - public void reduceCurrentMpByDamOverTime(double i, int period) + public void reduceCurrentMpByDamOverTime(double amount, int period) { if (_nextReducingMPByOverTime > System.currentTimeMillis()) { @@ -9075,7 +9075,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder } _nextReducingMPByOverTime = System.currentTimeMillis() + (period * 1000); - reduceCurrentMp(i); + reduceCurrentMp(amount); } /** diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/skills/handlers/SkillDrain.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/skills/handlers/SkillDrain.java index 4521086991..0f010ecbde 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/skills/handlers/SkillDrain.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/skills/handlers/SkillDrain.java @@ -57,13 +57,18 @@ public class SkillDrain extends Skill for (WorldObject target2 : targets) { final Creature target = (Creature) target2; + if (creature.isPlayable() && target.isInvul()) + { + continue; + } + if (target.isAlikeDead() && (getTargetType() != SkillTargetType.TARGET_CORPSE_MOB)) { continue; } // Like L2OFF no effect on invul object except Npcs - if ((creature != target) && (target.isInvul() && !(target instanceof NpcInstance))) + if ((creature != target) && (target.isInvul() && !target.isNpc())) { continue; // No effect on invulnerable chars unless they cast it themselves. } 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 ed990e2170..37d2a50324 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 @@ -9054,56 +9054,56 @@ public abstract class Creature extends WorldObject implements ISkillsHolder /** * Reduce current hp. - * @param i the i + * @param amount the amount * @param attacker the attacker */ - public void reduceCurrentHp(double i, Creature attacker) + public void reduceCurrentHp(double amount, Creature attacker) { - reduceCurrentHp(i, attacker, true); + reduceCurrentHp(amount, attacker, true); } /** * Reduce current hp. - * @param i the i + * @param amount the amount * @param attacker the attacker * @param awake the awake */ - public void reduceCurrentHp(double i, Creature attacker, boolean awake) + public void reduceCurrentHp(double amount, Creature attacker, boolean awake) { - if ((this instanceof NpcInstance) && Config.INVUL_NPC_LIST.contains(((NpcInstance) this).getNpcId())) + if (isNpc() && Config.INVUL_NPC_LIST.contains(((NpcInstance) this).getNpcId())) { return; } if (Config.CHAMPION_ENABLE && _champion && (Config.CHAMPION_HP != 0)) { - getStatus().reduceHp(i / Config.CHAMPION_HP, attacker, awake); + getStatus().reduceHp(amount / Config.CHAMPION_HP, attacker, awake); } else if (_advanceFlag) { - getStatus().reduceHp(i / _advanceMultiplier, attacker, awake); + getStatus().reduceHp(amount / _advanceMultiplier, attacker, awake); } else if (_isUnkillable) { final double hpToReduce = getStatus().getCurrentHp() - 1; - if (i > getStatus().getCurrentHp()) + if (amount > getStatus().getCurrentHp()) { getStatus().reduceHp(hpToReduce, attacker, awake); } else { - getStatus().reduceHp(i, attacker, awake); + getStatus().reduceHp(amount, attacker, awake); } } else { - getStatus().reduceHp(i, attacker, awake); + getStatus().reduceHp(amount, attacker, awake); } } private long _nextReducingHPByOverTime = -1; - public void reduceCurrentHpByDamOverTime(double i, Creature attacker, boolean awake, int period) + public void reduceCurrentHpByDamOverTime(double amount, Creature attacker, boolean awake, int period) { if (_nextReducingHPByOverTime > System.currentTimeMillis()) { @@ -9111,12 +9111,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder } _nextReducingHPByOverTime = System.currentTimeMillis() + (period * 1000); - reduceCurrentHp(i, attacker, awake); + reduceCurrentHp(amount, attacker, awake); } private long _nextReducingMPByOverTime = -1; - public void reduceCurrentMpByDamOverTime(double i, int period) + public void reduceCurrentMpByDamOverTime(double amount, int period) { if (_nextReducingMPByOverTime > System.currentTimeMillis()) { @@ -9124,7 +9124,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder } _nextReducingMPByOverTime = System.currentTimeMillis() + (period * 1000); - reduceCurrentMp(i); + reduceCurrentMp(amount); } /** diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/skills/handlers/SkillDrain.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/skills/handlers/SkillDrain.java index 4521086991..0f010ecbde 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/skills/handlers/SkillDrain.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/skills/handlers/SkillDrain.java @@ -57,13 +57,18 @@ public class SkillDrain extends Skill for (WorldObject target2 : targets) { final Creature target = (Creature) target2; + if (creature.isPlayable() && target.isInvul()) + { + continue; + } + if (target.isAlikeDead() && (getTargetType() != SkillTargetType.TARGET_CORPSE_MOB)) { continue; } // Like L2OFF no effect on invul object except Npcs - if ((creature != target) && (target.isInvul() && !(target instanceof NpcInstance))) + if ((creature != target) && (target.isInvul() && !target.isNpc())) { continue; // No effect on invulnerable chars unless they cast it themselves. }