From c578bd43c18d5a697fb40833ef31b5d896659e42 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Mon, 1 Apr 2019 15:21:44 +0000 Subject: [PATCH] Use configurations for attackables calcMagicSuccess method. --- .../dist/game/config/NPC.ini | 4 +- .../handlers/effecthandlers/Plunder.java | 20 +----- .../handlers/effecthandlers/Spoil.java | 20 +----- .../gameserver/model/stats/Formulas.java | 66 +++++++++++-------- .../dist/game/config/NPC.ini | 4 +- .../handlers/effecthandlers/Plunder.java | 20 +----- .../handlers/effecthandlers/Spoil.java | 20 +----- .../gameserver/model/stats/Formulas.java | 66 +++++++++++-------- .../dist/game/config/NPC.ini | 4 +- .../handlers/effecthandlers/Plunder.java | 20 +----- .../handlers/effecthandlers/Spoil.java | 20 +----- .../gameserver/model/stats/Formulas.java | 66 +++++++++++-------- .../dist/game/config/NPC.ini | 4 +- .../handlers/effecthandlers/Plunder.java | 20 +----- .../handlers/effecthandlers/Spoil.java | 20 +----- .../gameserver/model/stats/Formulas.java | 66 +++++++++++-------- .../dist/game/config/NPC.ini | 4 +- .../handlers/effecthandlers/Plunder.java | 20 +----- .../handlers/effecthandlers/Spoil.java | 20 +----- .../gameserver/model/stats/Formulas.java | 66 +++++++++++-------- .../dist/game/config/NPC.ini | 4 +- .../handlers/effecthandlers/Plunder.java | 20 +----- .../handlers/effecthandlers/Spoil.java | 20 +----- .../gameserver/model/stats/Formulas.java | 66 +++++++++++-------- .../dist/game/config/NPC.ini | 4 +- .../handlers/effecthandlers/Plunder.java | 20 +----- .../handlers/effecthandlers/Spoil.java | 20 +----- .../gameserver/model/stats/Formulas.java | 66 +++++++++++-------- .../dist/game/config/NPC.ini | 4 +- .../handlers/effecthandlers/Plunder.java | 20 +----- .../handlers/effecthandlers/Spoil.java | 20 +----- .../gameserver/model/stats/Formulas.java | 66 +++++++++++-------- .../dist/game/config/NPC.ini | 4 +- .../handlers/effecthandlers/Plunder.java | 20 +----- .../handlers/effecthandlers/Spoil.java | 20 +----- .../gameserver/model/stats/Formulas.java | 66 +++++++++++-------- .../dist/game/config/NPC.ini | 4 +- .../handlers/effecthandlers/Plunder.java | 20 +----- .../handlers/effecthandlers/Spoil.java | 20 +----- .../gameserver/model/stats/Formulas.java | 66 +++++++++++-------- .../dist/game/config/NPC.ini | 4 +- .../handlers/effecthandlers/Plunder.java | 20 +----- .../handlers/effecthandlers/Spoil.java | 20 +----- .../gameserver/model/stats/Formulas.java | 66 +++++++++++-------- 44 files changed, 484 insertions(+), 726 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/config/NPC.ini b/L2J_Mobius_1.0_Ertheia/dist/game/config/NPC.ini index 553bbf6ebf..1cd8da1e75 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/config/NPC.ini +++ b/L2J_Mobius_1.0_Ertheia/dist/game/config/NPC.ini @@ -49,7 +49,7 @@ EnableRandomEnchantEffect = False # The minimum NPC level for the Gracia Epilogue rule: # "The amount of damage inflicted on monsters will be lower if your character is 2 or more levels below that of the level 78+ monster." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForDmgPenalty = 78 @@ -62,7 +62,7 @@ SkillDmgPenaltyForLvLDifferences = 0.8, 0.6, 0.5, 0.42, 0.36, 0.32, 0.28, 0.25 # The minimum NPC level for the Gracia Epilogue rule: # "When a character's level is 3 or more levels lower than that of a monsters level the chance that the monster will be able to resist a magic spell will increase." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForMagicPenalty = 78 diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/effecthandlers/Plunder.java b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/effecthandlers/Plunder.java index 58a5190095..76cdf918d8 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/effecthandlers/Plunder.java +++ b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/effecthandlers/Plunder.java @@ -18,8 +18,6 @@ package handlers.effecthandlers; import java.util.Collection; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.Party; import com.l2jmobius.gameserver.model.StatsSet; @@ -30,6 +28,7 @@ import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.holders.ItemHolder; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -44,22 +43,7 @@ public final class Plunder extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/effecthandlers/Spoil.java b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/effecthandlers/Spoil.java index d958317ded..d5657e40b3 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/effecthandlers/Spoil.java +++ b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/effecthandlers/Spoil.java @@ -16,8 +16,6 @@ */ package handlers.effecthandlers; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.actor.Creature; @@ -25,6 +23,7 @@ import com.l2jmobius.gameserver.model.actor.instance.MonsterInstance; import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -40,22 +39,7 @@ public final class Spoil extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/stats/Formulas.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/stats/Formulas.java index 601e08d73f..405e7035cf 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/stats/Formulas.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/stats/Formulas.java @@ -749,41 +749,51 @@ public final class Formulas public static boolean calcMagicSuccess(Creature attacker, Creature target, Skill skill) { - final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); - int mAccModifier = 100; - if (mAccDiff > -20) + double lvlModifier = 1; + float targetModifier = 1; + int mAccModifier = 1; + if (attacker.isAttackable() || target.isAttackable()) { - mAccModifier = 2; + lvlModifier = Math.pow(1.3, target.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : attacker.getLevel())); + + if ((attacker.getActingPlayer() != null) && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) + { + final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; + if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); + } + else + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); + } + } } - else if (mAccDiff > -25) + else { - mAccModifier = 30; - } - else if (mAccDiff > -30) - { - mAccModifier = 60; - } - else if (mAccDiff > -35) - { - mAccModifier = 90; + final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); + mAccModifier = 100; + if (mAccDiff > -20) + { + mAccModifier = 2; + } + else if (mAccDiff > -25) + { + mAccModifier = 30; + } + else if (mAccDiff > -30) + { + mAccModifier = 60; + } + else if (mAccDiff > -35) + { + mAccModifier = 90; + } } - float targetModifier = 1; - if (target.isAttackable() && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (attacker.getActingPlayer() != null) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } // general magic resist final double resModifier = target.getStat().getValue(Stats.MAGIC_SUCCESS_RES, 1); - final int rate = 100 - Math.round((float) (mAccModifier * targetModifier * resModifier)); + final int rate = 100 - Math.round((float) (mAccModifier * lvlModifier * targetModifier * resModifier)); return (Rnd.get(100) < rate); } diff --git a/L2J_Mobius_2.5_Underground/dist/game/config/NPC.ini b/L2J_Mobius_2.5_Underground/dist/game/config/NPC.ini index 553bbf6ebf..1cd8da1e75 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/config/NPC.ini +++ b/L2J_Mobius_2.5_Underground/dist/game/config/NPC.ini @@ -49,7 +49,7 @@ EnableRandomEnchantEffect = False # The minimum NPC level for the Gracia Epilogue rule: # "The amount of damage inflicted on monsters will be lower if your character is 2 or more levels below that of the level 78+ monster." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForDmgPenalty = 78 @@ -62,7 +62,7 @@ SkillDmgPenaltyForLvLDifferences = 0.8, 0.6, 0.5, 0.42, 0.36, 0.32, 0.28, 0.25 # The minimum NPC level for the Gracia Epilogue rule: # "When a character's level is 3 or more levels lower than that of a monsters level the chance that the monster will be able to resist a magic spell will increase." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForMagicPenalty = 78 diff --git a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/effecthandlers/Plunder.java b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/effecthandlers/Plunder.java index 58a5190095..76cdf918d8 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/effecthandlers/Plunder.java +++ b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/effecthandlers/Plunder.java @@ -18,8 +18,6 @@ package handlers.effecthandlers; import java.util.Collection; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.Party; import com.l2jmobius.gameserver.model.StatsSet; @@ -30,6 +28,7 @@ import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.holders.ItemHolder; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -44,22 +43,7 @@ public final class Plunder extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/effecthandlers/Spoil.java b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/effecthandlers/Spoil.java index d958317ded..d5657e40b3 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/effecthandlers/Spoil.java +++ b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/effecthandlers/Spoil.java @@ -16,8 +16,6 @@ */ package handlers.effecthandlers; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.actor.Creature; @@ -25,6 +23,7 @@ import com.l2jmobius.gameserver.model.actor.instance.MonsterInstance; import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -40,22 +39,7 @@ public final class Spoil extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/stats/Formulas.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/stats/Formulas.java index 601e08d73f..405e7035cf 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/stats/Formulas.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/stats/Formulas.java @@ -749,41 +749,51 @@ public final class Formulas public static boolean calcMagicSuccess(Creature attacker, Creature target, Skill skill) { - final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); - int mAccModifier = 100; - if (mAccDiff > -20) + double lvlModifier = 1; + float targetModifier = 1; + int mAccModifier = 1; + if (attacker.isAttackable() || target.isAttackable()) { - mAccModifier = 2; + lvlModifier = Math.pow(1.3, target.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : attacker.getLevel())); + + if ((attacker.getActingPlayer() != null) && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) + { + final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; + if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); + } + else + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); + } + } } - else if (mAccDiff > -25) + else { - mAccModifier = 30; - } - else if (mAccDiff > -30) - { - mAccModifier = 60; - } - else if (mAccDiff > -35) - { - mAccModifier = 90; + final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); + mAccModifier = 100; + if (mAccDiff > -20) + { + mAccModifier = 2; + } + else if (mAccDiff > -25) + { + mAccModifier = 30; + } + else if (mAccDiff > -30) + { + mAccModifier = 60; + } + else if (mAccDiff > -35) + { + mAccModifier = 90; + } } - float targetModifier = 1; - if (target.isAttackable() && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (attacker.getActingPlayer() != null) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } // general magic resist final double resModifier = target.getStat().getValue(Stats.MAGIC_SUCCESS_RES, 1); - final int rate = 100 - Math.round((float) (mAccModifier * targetModifier * resModifier)); + final int rate = 100 - Math.round((float) (mAccModifier * lvlModifier * targetModifier * resModifier)); return (Rnd.get(100) < rate); } diff --git a/L2J_Mobius_3.0_Helios/dist/game/config/NPC.ini b/L2J_Mobius_3.0_Helios/dist/game/config/NPC.ini index 553bbf6ebf..1cd8da1e75 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/config/NPC.ini +++ b/L2J_Mobius_3.0_Helios/dist/game/config/NPC.ini @@ -49,7 +49,7 @@ EnableRandomEnchantEffect = False # The minimum NPC level for the Gracia Epilogue rule: # "The amount of damage inflicted on monsters will be lower if your character is 2 or more levels below that of the level 78+ monster." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForDmgPenalty = 78 @@ -62,7 +62,7 @@ SkillDmgPenaltyForLvLDifferences = 0.8, 0.6, 0.5, 0.42, 0.36, 0.32, 0.28, 0.25 # The minimum NPC level for the Gracia Epilogue rule: # "When a character's level is 3 or more levels lower than that of a monsters level the chance that the monster will be able to resist a magic spell will increase." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForMagicPenalty = 78 diff --git a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/effecthandlers/Plunder.java b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/effecthandlers/Plunder.java index 58a5190095..76cdf918d8 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/effecthandlers/Plunder.java +++ b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/effecthandlers/Plunder.java @@ -18,8 +18,6 @@ package handlers.effecthandlers; import java.util.Collection; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.Party; import com.l2jmobius.gameserver.model.StatsSet; @@ -30,6 +28,7 @@ import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.holders.ItemHolder; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -44,22 +43,7 @@ public final class Plunder extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/effecthandlers/Spoil.java b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/effecthandlers/Spoil.java index d958317ded..d5657e40b3 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/effecthandlers/Spoil.java +++ b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/effecthandlers/Spoil.java @@ -16,8 +16,6 @@ */ package handlers.effecthandlers; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.actor.Creature; @@ -25,6 +23,7 @@ import com.l2jmobius.gameserver.model.actor.instance.MonsterInstance; import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -40,22 +39,7 @@ public final class Spoil extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/stats/Formulas.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/stats/Formulas.java index 601e08d73f..405e7035cf 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/stats/Formulas.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/stats/Formulas.java @@ -749,41 +749,51 @@ public final class Formulas public static boolean calcMagicSuccess(Creature attacker, Creature target, Skill skill) { - final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); - int mAccModifier = 100; - if (mAccDiff > -20) + double lvlModifier = 1; + float targetModifier = 1; + int mAccModifier = 1; + if (attacker.isAttackable() || target.isAttackable()) { - mAccModifier = 2; + lvlModifier = Math.pow(1.3, target.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : attacker.getLevel())); + + if ((attacker.getActingPlayer() != null) && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) + { + final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; + if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); + } + else + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); + } + } } - else if (mAccDiff > -25) + else { - mAccModifier = 30; - } - else if (mAccDiff > -30) - { - mAccModifier = 60; - } - else if (mAccDiff > -35) - { - mAccModifier = 90; + final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); + mAccModifier = 100; + if (mAccDiff > -20) + { + mAccModifier = 2; + } + else if (mAccDiff > -25) + { + mAccModifier = 30; + } + else if (mAccDiff > -30) + { + mAccModifier = 60; + } + else if (mAccDiff > -35) + { + mAccModifier = 90; + } } - float targetModifier = 1; - if (target.isAttackable() && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (attacker.getActingPlayer() != null) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } // general magic resist final double resModifier = target.getStat().getValue(Stats.MAGIC_SUCCESS_RES, 1); - final int rate = 100 - Math.round((float) (mAccModifier * targetModifier * resModifier)); + final int rate = 100 - Math.round((float) (mAccModifier * lvlModifier * targetModifier * resModifier)); return (Rnd.get(100) < rate); } diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/config/NPC.ini b/L2J_Mobius_4.0_GrandCrusade/dist/game/config/NPC.ini index 553bbf6ebf..1cd8da1e75 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/config/NPC.ini +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/config/NPC.ini @@ -49,7 +49,7 @@ EnableRandomEnchantEffect = False # The minimum NPC level for the Gracia Epilogue rule: # "The amount of damage inflicted on monsters will be lower if your character is 2 or more levels below that of the level 78+ monster." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForDmgPenalty = 78 @@ -62,7 +62,7 @@ SkillDmgPenaltyForLvLDifferences = 0.8, 0.6, 0.5, 0.42, 0.36, 0.32, 0.28, 0.25 # The minimum NPC level for the Gracia Epilogue rule: # "When a character's level is 3 or more levels lower than that of a monsters level the chance that the monster will be able to resist a magic spell will increase." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForMagicPenalty = 78 diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/effecthandlers/Plunder.java b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/effecthandlers/Plunder.java index 58a5190095..76cdf918d8 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/effecthandlers/Plunder.java +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/effecthandlers/Plunder.java @@ -18,8 +18,6 @@ package handlers.effecthandlers; import java.util.Collection; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.Party; import com.l2jmobius.gameserver.model.StatsSet; @@ -30,6 +28,7 @@ import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.holders.ItemHolder; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -44,22 +43,7 @@ public final class Plunder extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/effecthandlers/Spoil.java b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/effecthandlers/Spoil.java index d958317ded..d5657e40b3 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/effecthandlers/Spoil.java +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/effecthandlers/Spoil.java @@ -16,8 +16,6 @@ */ package handlers.effecthandlers; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.actor.Creature; @@ -25,6 +23,7 @@ import com.l2jmobius.gameserver.model.actor.instance.MonsterInstance; import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -40,22 +39,7 @@ public final class Spoil extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/stats/Formulas.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/stats/Formulas.java index 83af6bb4ec..2b70379df1 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/stats/Formulas.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/stats/Formulas.java @@ -749,41 +749,51 @@ public final class Formulas public static boolean calcMagicSuccess(Creature attacker, Creature target, Skill skill) { - final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); - int mAccModifier = 100; - if (mAccDiff > -20) + double lvlModifier = 1; + float targetModifier = 1; + int mAccModifier = 1; + if (attacker.isAttackable() || target.isAttackable()) { - mAccModifier = 2; + lvlModifier = Math.pow(1.3, target.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : attacker.getLevel())); + + if ((attacker.getActingPlayer() != null) && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) + { + final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; + if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); + } + else + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); + } + } } - else if (mAccDiff > -25) + else { - mAccModifier = 30; - } - else if (mAccDiff > -30) - { - mAccModifier = 60; - } - else if (mAccDiff > -35) - { - mAccModifier = 90; + final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); + mAccModifier = 100; + if (mAccDiff > -20) + { + mAccModifier = 2; + } + else if (mAccDiff > -25) + { + mAccModifier = 30; + } + else if (mAccDiff > -30) + { + mAccModifier = 60; + } + else if (mAccDiff > -35) + { + mAccModifier = 90; + } } - float targetModifier = 1; - if (target.isAttackable() && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (attacker.getActingPlayer() != null) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } // general magic resist final double resModifier = target.getStat().getValue(Stats.MAGIC_SUCCESS_RES, 1); - final int rate = 100 - Math.round((float) (mAccModifier * targetModifier * resModifier)); + final int rate = 100 - Math.round((float) (mAccModifier * lvlModifier * targetModifier * resModifier)); return (Rnd.get(100) < rate); } diff --git a/L2J_Mobius_5.0_Salvation/dist/game/config/NPC.ini b/L2J_Mobius_5.0_Salvation/dist/game/config/NPC.ini index 553bbf6ebf..1cd8da1e75 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/config/NPC.ini +++ b/L2J_Mobius_5.0_Salvation/dist/game/config/NPC.ini @@ -49,7 +49,7 @@ EnableRandomEnchantEffect = False # The minimum NPC level for the Gracia Epilogue rule: # "The amount of damage inflicted on monsters will be lower if your character is 2 or more levels below that of the level 78+ monster." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForDmgPenalty = 78 @@ -62,7 +62,7 @@ SkillDmgPenaltyForLvLDifferences = 0.8, 0.6, 0.5, 0.42, 0.36, 0.32, 0.28, 0.25 # The minimum NPC level for the Gracia Epilogue rule: # "When a character's level is 3 or more levels lower than that of a monsters level the chance that the monster will be able to resist a magic spell will increase." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForMagicPenalty = 78 diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/effecthandlers/Plunder.java b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/effecthandlers/Plunder.java index 58a5190095..76cdf918d8 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/effecthandlers/Plunder.java +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/effecthandlers/Plunder.java @@ -18,8 +18,6 @@ package handlers.effecthandlers; import java.util.Collection; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.Party; import com.l2jmobius.gameserver.model.StatsSet; @@ -30,6 +28,7 @@ import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.holders.ItemHolder; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -44,22 +43,7 @@ public final class Plunder extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/effecthandlers/Spoil.java b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/effecthandlers/Spoil.java index d958317ded..d5657e40b3 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/effecthandlers/Spoil.java +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/effecthandlers/Spoil.java @@ -16,8 +16,6 @@ */ package handlers.effecthandlers; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.actor.Creature; @@ -25,6 +23,7 @@ import com.l2jmobius.gameserver.model.actor.instance.MonsterInstance; import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -40,22 +39,7 @@ public final class Spoil extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/model/stats/Formulas.java b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/model/stats/Formulas.java index 83af6bb4ec..2b70379df1 100644 --- a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/model/stats/Formulas.java +++ b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/model/stats/Formulas.java @@ -749,41 +749,51 @@ public final class Formulas public static boolean calcMagicSuccess(Creature attacker, Creature target, Skill skill) { - final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); - int mAccModifier = 100; - if (mAccDiff > -20) + double lvlModifier = 1; + float targetModifier = 1; + int mAccModifier = 1; + if (attacker.isAttackable() || target.isAttackable()) { - mAccModifier = 2; + lvlModifier = Math.pow(1.3, target.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : attacker.getLevel())); + + if ((attacker.getActingPlayer() != null) && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) + { + final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; + if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); + } + else + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); + } + } } - else if (mAccDiff > -25) + else { - mAccModifier = 30; - } - else if (mAccDiff > -30) - { - mAccModifier = 60; - } - else if (mAccDiff > -35) - { - mAccModifier = 90; + final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); + mAccModifier = 100; + if (mAccDiff > -20) + { + mAccModifier = 2; + } + else if (mAccDiff > -25) + { + mAccModifier = 30; + } + else if (mAccDiff > -30) + { + mAccModifier = 60; + } + else if (mAccDiff > -35) + { + mAccModifier = 90; + } } - float targetModifier = 1; - if (target.isAttackable() && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (attacker.getActingPlayer() != null) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } // general magic resist final double resModifier = target.getStat().getValue(Stats.MAGIC_SUCCESS_RES, 1); - final int rate = 100 - Math.round((float) (mAccModifier * targetModifier * resModifier)); + final int rate = 100 - Math.round((float) (mAccModifier * lvlModifier * targetModifier * resModifier)); return (Rnd.get(100) < rate); } diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/config/NPC.ini b/L2J_Mobius_5.5_EtinasFate/dist/game/config/NPC.ini index 553bbf6ebf..1cd8da1e75 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/config/NPC.ini +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/config/NPC.ini @@ -49,7 +49,7 @@ EnableRandomEnchantEffect = False # The minimum NPC level for the Gracia Epilogue rule: # "The amount of damage inflicted on monsters will be lower if your character is 2 or more levels below that of the level 78+ monster." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForDmgPenalty = 78 @@ -62,7 +62,7 @@ SkillDmgPenaltyForLvLDifferences = 0.8, 0.6, 0.5, 0.42, 0.36, 0.32, 0.28, 0.25 # The minimum NPC level for the Gracia Epilogue rule: # "When a character's level is 3 or more levels lower than that of a monsters level the chance that the monster will be able to resist a magic spell will increase." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForMagicPenalty = 78 diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/effecthandlers/Plunder.java b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/effecthandlers/Plunder.java index 58a5190095..76cdf918d8 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/effecthandlers/Plunder.java +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/effecthandlers/Plunder.java @@ -18,8 +18,6 @@ package handlers.effecthandlers; import java.util.Collection; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.Party; import com.l2jmobius.gameserver.model.StatsSet; @@ -30,6 +28,7 @@ import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.holders.ItemHolder; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -44,22 +43,7 @@ public final class Plunder extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/effecthandlers/Spoil.java b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/effecthandlers/Spoil.java index d958317ded..d5657e40b3 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/effecthandlers/Spoil.java +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/effecthandlers/Spoil.java @@ -16,8 +16,6 @@ */ package handlers.effecthandlers; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.actor.Creature; @@ -25,6 +23,7 @@ import com.l2jmobius.gameserver.model.actor.instance.MonsterInstance; import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -40,22 +39,7 @@ public final class Spoil extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/model/stats/Formulas.java b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/model/stats/Formulas.java index 83af6bb4ec..2b70379df1 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/model/stats/Formulas.java +++ b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/model/stats/Formulas.java @@ -749,41 +749,51 @@ public final class Formulas public static boolean calcMagicSuccess(Creature attacker, Creature target, Skill skill) { - final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); - int mAccModifier = 100; - if (mAccDiff > -20) + double lvlModifier = 1; + float targetModifier = 1; + int mAccModifier = 1; + if (attacker.isAttackable() || target.isAttackable()) { - mAccModifier = 2; + lvlModifier = Math.pow(1.3, target.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : attacker.getLevel())); + + if ((attacker.getActingPlayer() != null) && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) + { + final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; + if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); + } + else + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); + } + } } - else if (mAccDiff > -25) + else { - mAccModifier = 30; - } - else if (mAccDiff > -30) - { - mAccModifier = 60; - } - else if (mAccDiff > -35) - { - mAccModifier = 90; + final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); + mAccModifier = 100; + if (mAccDiff > -20) + { + mAccModifier = 2; + } + else if (mAccDiff > -25) + { + mAccModifier = 30; + } + else if (mAccDiff > -30) + { + mAccModifier = 60; + } + else if (mAccDiff > -35) + { + mAccModifier = 90; + } } - float targetModifier = 1; - if (target.isAttackable() && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (attacker.getActingPlayer() != null) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } // general magic resist final double resModifier = target.getStat().getValue(Stats.MAGIC_SUCCESS_RES, 1); - final int rate = 100 - Math.round((float) (mAccModifier * targetModifier * resModifier)); + final int rate = 100 - Math.round((float) (mAccModifier * lvlModifier * targetModifier * resModifier)); return (Rnd.get(100) < rate); } diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/config/NPC.ini b/L2J_Mobius_6.0_Fafurion/dist/game/config/NPC.ini index 553bbf6ebf..1cd8da1e75 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/config/NPC.ini +++ b/L2J_Mobius_6.0_Fafurion/dist/game/config/NPC.ini @@ -49,7 +49,7 @@ EnableRandomEnchantEffect = False # The minimum NPC level for the Gracia Epilogue rule: # "The amount of damage inflicted on monsters will be lower if your character is 2 or more levels below that of the level 78+ monster." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForDmgPenalty = 78 @@ -62,7 +62,7 @@ SkillDmgPenaltyForLvLDifferences = 0.8, 0.6, 0.5, 0.42, 0.36, 0.32, 0.28, 0.25 # The minimum NPC level for the Gracia Epilogue rule: # "When a character's level is 3 or more levels lower than that of a monsters level the chance that the monster will be able to resist a magic spell will increase." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForMagicPenalty = 78 diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/effecthandlers/Plunder.java b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/effecthandlers/Plunder.java index 58a5190095..76cdf918d8 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/effecthandlers/Plunder.java +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/effecthandlers/Plunder.java @@ -18,8 +18,6 @@ package handlers.effecthandlers; import java.util.Collection; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.Party; import com.l2jmobius.gameserver.model.StatsSet; @@ -30,6 +28,7 @@ import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.holders.ItemHolder; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -44,22 +43,7 @@ public final class Plunder extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/effecthandlers/Spoil.java b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/effecthandlers/Spoil.java index d958317ded..d5657e40b3 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/effecthandlers/Spoil.java +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/effecthandlers/Spoil.java @@ -16,8 +16,6 @@ */ package handlers.effecthandlers; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.actor.Creature; @@ -25,6 +23,7 @@ import com.l2jmobius.gameserver.model.actor.instance.MonsterInstance; import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -40,22 +39,7 @@ public final class Spoil extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/model/stats/Formulas.java b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/model/stats/Formulas.java index 83af6bb4ec..2b70379df1 100644 --- a/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/model/stats/Formulas.java +++ b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/model/stats/Formulas.java @@ -749,41 +749,51 @@ public final class Formulas public static boolean calcMagicSuccess(Creature attacker, Creature target, Skill skill) { - final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); - int mAccModifier = 100; - if (mAccDiff > -20) + double lvlModifier = 1; + float targetModifier = 1; + int mAccModifier = 1; + if (attacker.isAttackable() || target.isAttackable()) { - mAccModifier = 2; + lvlModifier = Math.pow(1.3, target.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : attacker.getLevel())); + + if ((attacker.getActingPlayer() != null) && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) + { + final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; + if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); + } + else + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); + } + } } - else if (mAccDiff > -25) + else { - mAccModifier = 30; - } - else if (mAccDiff > -30) - { - mAccModifier = 60; - } - else if (mAccDiff > -35) - { - mAccModifier = 90; + final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); + mAccModifier = 100; + if (mAccDiff > -20) + { + mAccModifier = 2; + } + else if (mAccDiff > -25) + { + mAccModifier = 30; + } + else if (mAccDiff > -30) + { + mAccModifier = 60; + } + else if (mAccDiff > -35) + { + mAccModifier = 90; + } } - float targetModifier = 1; - if (target.isAttackable() && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (attacker.getActingPlayer() != null) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } // general magic resist final double resModifier = target.getStat().getValue(Stats.MAGIC_SUCCESS_RES, 1); - final int rate = 100 - Math.round((float) (mAccModifier * targetModifier * resModifier)); + final int rate = 100 - Math.round((float) (mAccModifier * lvlModifier * targetModifier * resModifier)); return (Rnd.get(100) < rate); } diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/NPC.ini b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/NPC.ini index 553bbf6ebf..1cd8da1e75 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/NPC.ini +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/NPC.ini @@ -49,7 +49,7 @@ EnableRandomEnchantEffect = False # The minimum NPC level for the Gracia Epilogue rule: # "The amount of damage inflicted on monsters will be lower if your character is 2 or more levels below that of the level 78+ monster." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForDmgPenalty = 78 @@ -62,7 +62,7 @@ SkillDmgPenaltyForLvLDifferences = 0.8, 0.6, 0.5, 0.42, 0.36, 0.32, 0.28, 0.25 # The minimum NPC level for the Gracia Epilogue rule: # "When a character's level is 3 or more levels lower than that of a monsters level the chance that the monster will be able to resist a magic spell will increase." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForMagicPenalty = 78 diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/effecthandlers/Plunder.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/effecthandlers/Plunder.java index 1c8445237c..405b57d4ee 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/effecthandlers/Plunder.java +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/effecthandlers/Plunder.java @@ -18,8 +18,6 @@ package handlers.effecthandlers; import java.util.Collection; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.Party; import com.l2jmobius.gameserver.model.StatsSet; @@ -30,6 +28,7 @@ import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.holders.ItemHolder; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -44,22 +43,7 @@ public final class Plunder extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/effecthandlers/Spoil.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/effecthandlers/Spoil.java index d958317ded..d5657e40b3 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/effecthandlers/Spoil.java +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/effecthandlers/Spoil.java @@ -16,8 +16,6 @@ */ package handlers.effecthandlers; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.actor.Creature; @@ -25,6 +23,7 @@ import com.l2jmobius.gameserver.model.actor.instance.MonsterInstance; import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -40,22 +39,7 @@ public final class Spoil extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/stats/Formulas.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/stats/Formulas.java index f1a0a8ff7d..4b70d80dcc 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/stats/Formulas.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/stats/Formulas.java @@ -749,41 +749,51 @@ public final class Formulas public static boolean calcMagicSuccess(Creature attacker, Creature target, Skill skill) { - final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); - int mAccModifier = 100; - if (mAccDiff > -20) + double lvlModifier = 1; + float targetModifier = 1; + int mAccModifier = 1; + if (attacker.isAttackable() || target.isAttackable()) { - mAccModifier = 2; + lvlModifier = Math.pow(1.3, target.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : attacker.getLevel())); + + if ((attacker.getActingPlayer() != null) && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) + { + final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; + if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); + } + else + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); + } + } } - else if (mAccDiff > -25) + else { - mAccModifier = 30; - } - else if (mAccDiff > -30) - { - mAccModifier = 60; - } - else if (mAccDiff > -35) - { - mAccModifier = 90; + final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); + mAccModifier = 100; + if (mAccDiff > -20) + { + mAccModifier = 2; + } + else if (mAccDiff > -25) + { + mAccModifier = 30; + } + else if (mAccDiff > -30) + { + mAccModifier = 60; + } + else if (mAccDiff > -35) + { + mAccModifier = 90; + } } - float targetModifier = 1; - if (target.isAttackable() && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (attacker.getActingPlayer() != null) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } // general magic resist final double resModifier = target.getStat().getValue(Stats.MAGIC_SUCCESS_RES, 1); - final int rate = 100 - Math.round((float) (mAccModifier * targetModifier * resModifier)); + final int rate = 100 - Math.round((float) (mAccModifier * lvlModifier * targetModifier * resModifier)); return (Rnd.get(100) < rate); } diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/NPC.ini b/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/NPC.ini index 553bbf6ebf..1cd8da1e75 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/NPC.ini +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/NPC.ini @@ -49,7 +49,7 @@ EnableRandomEnchantEffect = False # The minimum NPC level for the Gracia Epilogue rule: # "The amount of damage inflicted on monsters will be lower if your character is 2 or more levels below that of the level 78+ monster." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForDmgPenalty = 78 @@ -62,7 +62,7 @@ SkillDmgPenaltyForLvLDifferences = 0.8, 0.6, 0.5, 0.42, 0.36, 0.32, 0.28, 0.25 # The minimum NPC level for the Gracia Epilogue rule: # "When a character's level is 3 or more levels lower than that of a monsters level the chance that the monster will be able to resist a magic spell will increase." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForMagicPenalty = 78 diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/effecthandlers/Plunder.java b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/effecthandlers/Plunder.java index 1c8445237c..405b57d4ee 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/effecthandlers/Plunder.java +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/effecthandlers/Plunder.java @@ -18,8 +18,6 @@ package handlers.effecthandlers; import java.util.Collection; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.Party; import com.l2jmobius.gameserver.model.StatsSet; @@ -30,6 +28,7 @@ import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.holders.ItemHolder; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -44,22 +43,7 @@ public final class Plunder extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/effecthandlers/Spoil.java b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/effecthandlers/Spoil.java index d958317ded..d5657e40b3 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/effecthandlers/Spoil.java +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/effecthandlers/Spoil.java @@ -16,8 +16,6 @@ */ package handlers.effecthandlers; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.actor.Creature; @@ -25,6 +23,7 @@ import com.l2jmobius.gameserver.model.actor.instance.MonsterInstance; import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -40,22 +39,7 @@ public final class Spoil extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/stats/Formulas.java b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/stats/Formulas.java index f1a0a8ff7d..4b70d80dcc 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/stats/Formulas.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/stats/Formulas.java @@ -749,41 +749,51 @@ public final class Formulas public static boolean calcMagicSuccess(Creature attacker, Creature target, Skill skill) { - final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); - int mAccModifier = 100; - if (mAccDiff > -20) + double lvlModifier = 1; + float targetModifier = 1; + int mAccModifier = 1; + if (attacker.isAttackable() || target.isAttackable()) { - mAccModifier = 2; + lvlModifier = Math.pow(1.3, target.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : attacker.getLevel())); + + if ((attacker.getActingPlayer() != null) && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) + { + final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; + if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); + } + else + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); + } + } } - else if (mAccDiff > -25) + else { - mAccModifier = 30; - } - else if (mAccDiff > -30) - { - mAccModifier = 60; - } - else if (mAccDiff > -35) - { - mAccModifier = 90; + final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); + mAccModifier = 100; + if (mAccDiff > -20) + { + mAccModifier = 2; + } + else if (mAccDiff > -25) + { + mAccModifier = 30; + } + else if (mAccDiff > -30) + { + mAccModifier = 60; + } + else if (mAccDiff > -35) + { + mAccModifier = 90; + } } - float targetModifier = 1; - if (target.isAttackable() && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (attacker.getActingPlayer() != null) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } // general magic resist final double resModifier = target.getStat().getValue(Stats.MAGIC_SUCCESS_RES, 1); - final int rate = 100 - Math.round((float) (mAccModifier * targetModifier * resModifier)); + final int rate = 100 - Math.round((float) (mAccModifier * lvlModifier * targetModifier * resModifier)); return (Rnd.get(100) < rate); } diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/NPC.ini b/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/NPC.ini index 553bbf6ebf..1cd8da1e75 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/NPC.ini +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/NPC.ini @@ -49,7 +49,7 @@ EnableRandomEnchantEffect = False # The minimum NPC level for the Gracia Epilogue rule: # "The amount of damage inflicted on monsters will be lower if your character is 2 or more levels below that of the level 78+ monster." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForDmgPenalty = 78 @@ -62,7 +62,7 @@ SkillDmgPenaltyForLvLDifferences = 0.8, 0.6, 0.5, 0.42, 0.36, 0.32, 0.28, 0.25 # The minimum NPC level for the Gracia Epilogue rule: # "When a character's level is 3 or more levels lower than that of a monsters level the chance that the monster will be able to resist a magic spell will increase." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForMagicPenalty = 78 diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/effecthandlers/Plunder.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/effecthandlers/Plunder.java index 1c8445237c..405b57d4ee 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/effecthandlers/Plunder.java +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/effecthandlers/Plunder.java @@ -18,8 +18,6 @@ package handlers.effecthandlers; import java.util.Collection; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.Party; import com.l2jmobius.gameserver.model.StatsSet; @@ -30,6 +28,7 @@ import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.holders.ItemHolder; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -44,22 +43,7 @@ public final class Plunder extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/effecthandlers/Spoil.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/effecthandlers/Spoil.java index d958317ded..d5657e40b3 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/effecthandlers/Spoil.java +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/effecthandlers/Spoil.java @@ -16,8 +16,6 @@ */ package handlers.effecthandlers; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.actor.Creature; @@ -25,6 +23,7 @@ import com.l2jmobius.gameserver.model.actor.instance.MonsterInstance; import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -40,22 +39,7 @@ public final class Spoil extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/stats/Formulas.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/stats/Formulas.java index f1a0a8ff7d..4b70d80dcc 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/stats/Formulas.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/stats/Formulas.java @@ -749,41 +749,51 @@ public final class Formulas public static boolean calcMagicSuccess(Creature attacker, Creature target, Skill skill) { - final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); - int mAccModifier = 100; - if (mAccDiff > -20) + double lvlModifier = 1; + float targetModifier = 1; + int mAccModifier = 1; + if (attacker.isAttackable() || target.isAttackable()) { - mAccModifier = 2; + lvlModifier = Math.pow(1.3, target.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : attacker.getLevel())); + + if ((attacker.getActingPlayer() != null) && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) + { + final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; + if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); + } + else + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); + } + } } - else if (mAccDiff > -25) + else { - mAccModifier = 30; - } - else if (mAccDiff > -30) - { - mAccModifier = 60; - } - else if (mAccDiff > -35) - { - mAccModifier = 90; + final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); + mAccModifier = 100; + if (mAccDiff > -20) + { + mAccModifier = 2; + } + else if (mAccDiff > -25) + { + mAccModifier = 30; + } + else if (mAccDiff > -30) + { + mAccModifier = 60; + } + else if (mAccDiff > -35) + { + mAccModifier = 90; + } } - float targetModifier = 1; - if (target.isAttackable() && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (attacker.getActingPlayer() != null) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } // general magic resist final double resModifier = target.getStat().getValue(Stats.MAGIC_SUCCESS_RES, 1); - final int rate = 100 - Math.round((float) (mAccModifier * targetModifier * resModifier)); + final int rate = 100 - Math.round((float) (mAccModifier * lvlModifier * targetModifier * resModifier)); return (Rnd.get(100) < rate); } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/NPC.ini b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/NPC.ini index 553bbf6ebf..1cd8da1e75 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/NPC.ini +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/NPC.ini @@ -49,7 +49,7 @@ EnableRandomEnchantEffect = False # The minimum NPC level for the Gracia Epilogue rule: # "The amount of damage inflicted on monsters will be lower if your character is 2 or more levels below that of the level 78+ monster." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForDmgPenalty = 78 @@ -62,7 +62,7 @@ SkillDmgPenaltyForLvLDifferences = 0.8, 0.6, 0.5, 0.42, 0.36, 0.32, 0.28, 0.25 # The minimum NPC level for the Gracia Epilogue rule: # "When a character's level is 3 or more levels lower than that of a monsters level the chance that the monster will be able to resist a magic spell will increase." # Notes: -# If you want to disable this feature then set it 99 +# If you want to disable this feature then set it to max player level. # Default: 78 MinNPCLevelForMagicPenalty = 78 diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/effecthandlers/Plunder.java b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/effecthandlers/Plunder.java index 1c8445237c..405b57d4ee 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/effecthandlers/Plunder.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/effecthandlers/Plunder.java @@ -18,8 +18,6 @@ package handlers.effecthandlers; import java.util.Collection; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.Party; import com.l2jmobius.gameserver.model.StatsSet; @@ -30,6 +28,7 @@ import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.holders.ItemHolder; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -44,22 +43,7 @@ public final class Plunder extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/effecthandlers/Spoil.java b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/effecthandlers/Spoil.java index d958317ded..d5657e40b3 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/effecthandlers/Spoil.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/effecthandlers/Spoil.java @@ -16,8 +16,6 @@ */ package handlers.effecthandlers; -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.actor.Creature; @@ -25,6 +23,7 @@ import com.l2jmobius.gameserver.model.actor.instance.MonsterInstance; import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; +import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** @@ -40,22 +39,7 @@ public final class Spoil extends AbstractEffect @Override public boolean calcSuccess(Creature effector, Creature effected, Skill skill) { - final int lvlDifference = (effected.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : effector.getLevel())); - final double lvlModifier = Math.pow(1.3, lvlDifference); - float targetModifier = 1; - if (effected.isAttackable() && !effected.isRaid() && !effected.isRaidMinion() && (effected.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (effector.getActingPlayer() != null) && ((effected.getLevel() - effector.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = effected.getLevel() - effector.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } - return Rnd.get(100) < (100 - Math.round((float) (lvlModifier * targetModifier))); + return Formulas.calcMagicSuccess(effector, effected, skill); } @Override diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/model/stats/Formulas.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/model/stats/Formulas.java index f1a0a8ff7d..4b70d80dcc 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/model/stats/Formulas.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/model/stats/Formulas.java @@ -749,41 +749,51 @@ public final class Formulas public static boolean calcMagicSuccess(Creature attacker, Creature target, Skill skill) { - final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); - int mAccModifier = 100; - if (mAccDiff > -20) + double lvlModifier = 1; + float targetModifier = 1; + int mAccModifier = 1; + if (attacker.isAttackable() || target.isAttackable()) { - mAccModifier = 2; + lvlModifier = Math.pow(1.3, target.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : attacker.getLevel())); + + if ((attacker.getActingPlayer() != null) && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) + { + final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; + if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); + } + else + { + targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); + } + } } - else if (mAccDiff > -25) + else { - mAccModifier = 30; - } - else if (mAccDiff > -30) - { - mAccModifier = 60; - } - else if (mAccDiff > -35) - { - mAccModifier = 90; + final int mAccDiff = attacker.getMagicAccuracy() - target.getMagicEvasionRate(); + mAccModifier = 100; + if (mAccDiff > -20) + { + mAccModifier = 2; + } + else if (mAccDiff > -25) + { + mAccModifier = 30; + } + else if (mAccDiff > -30) + { + mAccModifier = 60; + } + else if (mAccDiff > -35) + { + mAccModifier = 90; + } } - float targetModifier = 1; - if (target.isAttackable() && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_MAGIC_PENALTY) && (attacker.getActingPlayer() != null) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 3)) - { - final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 2; - if (lvlDiff >= Config.NPC_SKILL_CHANCE_PENALTY.size()) - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(Config.NPC_SKILL_CHANCE_PENALTY.size() - 1); - } - else - { - targetModifier = Config.NPC_SKILL_CHANCE_PENALTY.get(lvlDiff); - } - } // general magic resist final double resModifier = target.getStat().getValue(Stats.MAGIC_SUCCESS_RES, 1); - final int rate = 100 - Math.round((float) (mAccModifier * targetModifier * resModifier)); + final int rate = 100 - Math.round((float) (mAccModifier * lvlModifier * targetModifier * resModifier)); return (Rnd.get(100) < rate); }