From 2c61857b122562fa2018ef0a960446c6253839c6 Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Wed, 4 Oct 2017 01:09:16 +0000 Subject: [PATCH] Fixed drop chance multiplier by item id. --- .../handlers/bypasshandlers/NpcViewMod.java | 2 +- .../model/drops/GroupedGeneralDropItem.java | 36 +++++++++++++++++- .../handlers/bypasshandlers/NpcViewMod.java | 2 +- .../model/drops/GroupedGeneralDropItem.java | 36 +++++++++++++++++- .../handlers/bypasshandlers/NpcViewMod.java | 2 +- .../model/drops/GroupedGeneralDropItem.java | 36 +++++++++++++++++- .../handlers/bypasshandlers/NpcViewMod.java | 2 +- .../model/drops/GroupedGeneralDropItem.java | 38 +++++++++++++++++-- .../handlers/bypasshandlers/NpcViewMod.java | 2 +- .../model/drops/GroupedGeneralDropItem.java | 36 +++++++++++++++++- 10 files changed, 176 insertions(+), 16 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java index 8178160913..5616cacd5e 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java +++ b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java @@ -517,7 +517,7 @@ public class NpcViewMod implements IBypassHandler sb.append("Chance:"); sb.append(""); - sb.append(chanceFormat.format(Math.min(generalDropItem.getChance(), 100))); + sb.append(chanceFormat.format(Math.min(generalDropItem.getChance(npc, activeChar), 100))); sb.append("% "); height += 64; diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java index 995445985b..2049e0ca1e 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java @@ -71,8 +71,40 @@ public class GroupedGeneralDropItem implements IDropItem for (GeneralDropItem gdi : getItems()) { final L2Item item = ItemTable.getInstance().getTemplate(gdi.getItemId()); - if ((item == null) || !item.hasExImmediateEffect()) + if (item == null) { + return 0; + } + if (!item.hasExImmediateEffect()) + { + // individual chance + Float individualDropChanceMultiplier = null; + if (killer.getActingPlayer().hasPremiumStatus()) + { + final Float normalMultiplier = Config.RATE_DROP_CHANCE_BY_ID.get(item.getId()); + final Float premiumMultiplier = Config.PREMIUM_RATE_DROP_CHANCE_BY_ID.get(item.getId()); + if ((normalMultiplier != null) && (premiumMultiplier != null)) + { + individualDropChanceMultiplier = normalMultiplier * premiumMultiplier; + } + else if (normalMultiplier != null) + { + individualDropChanceMultiplier = normalMultiplier; + } + else if (premiumMultiplier != null) + { + individualDropChanceMultiplier = premiumMultiplier; + } + } + else + { + individualDropChanceMultiplier = Config.RATE_DROP_CHANCE_BY_ID.get(item.getId()); + } + if (individualDropChanceMultiplier != null) + { + return getChance() * individualDropChanceMultiplier; + } + return getChance() * getGlobalChanceMultiplier(); } } @@ -130,7 +162,7 @@ public class GroupedGeneralDropItem implements IDropItem for (GeneralDropItem item : getItems()) { // Grouped item chance rates should not be modified. - totalChance += item.getChance(); + totalChance += item.getChance(victim, killer); if (totalChance > random) { final Collection items = new ArrayList<>(1); diff --git a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java index 8178160913..5616cacd5e 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java +++ b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java @@ -517,7 +517,7 @@ public class NpcViewMod implements IBypassHandler sb.append("Chance:"); sb.append(""); - sb.append(chanceFormat.format(Math.min(generalDropItem.getChance(), 100))); + sb.append(chanceFormat.format(Math.min(generalDropItem.getChance(npc, activeChar), 100))); sb.append("% "); height += 64; diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java index 995445985b..2049e0ca1e 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java @@ -71,8 +71,40 @@ public class GroupedGeneralDropItem implements IDropItem for (GeneralDropItem gdi : getItems()) { final L2Item item = ItemTable.getInstance().getTemplate(gdi.getItemId()); - if ((item == null) || !item.hasExImmediateEffect()) + if (item == null) { + return 0; + } + if (!item.hasExImmediateEffect()) + { + // individual chance + Float individualDropChanceMultiplier = null; + if (killer.getActingPlayer().hasPremiumStatus()) + { + final Float normalMultiplier = Config.RATE_DROP_CHANCE_BY_ID.get(item.getId()); + final Float premiumMultiplier = Config.PREMIUM_RATE_DROP_CHANCE_BY_ID.get(item.getId()); + if ((normalMultiplier != null) && (premiumMultiplier != null)) + { + individualDropChanceMultiplier = normalMultiplier * premiumMultiplier; + } + else if (normalMultiplier != null) + { + individualDropChanceMultiplier = normalMultiplier; + } + else if (premiumMultiplier != null) + { + individualDropChanceMultiplier = premiumMultiplier; + } + } + else + { + individualDropChanceMultiplier = Config.RATE_DROP_CHANCE_BY_ID.get(item.getId()); + } + if (individualDropChanceMultiplier != null) + { + return getChance() * individualDropChanceMultiplier; + } + return getChance() * getGlobalChanceMultiplier(); } } @@ -130,7 +162,7 @@ public class GroupedGeneralDropItem implements IDropItem for (GeneralDropItem item : getItems()) { // Grouped item chance rates should not be modified. - totalChance += item.getChance(); + totalChance += item.getChance(victim, killer); if (totalChance > random) { final Collection items = new ArrayList<>(1); diff --git a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java index 8178160913..5616cacd5e 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java +++ b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java @@ -517,7 +517,7 @@ public class NpcViewMod implements IBypassHandler sb.append("Chance:"); sb.append(""); - sb.append(chanceFormat.format(Math.min(generalDropItem.getChance(), 100))); + sb.append(chanceFormat.format(Math.min(generalDropItem.getChance(npc, activeChar), 100))); sb.append("% "); height += 64; diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java index 995445985b..2049e0ca1e 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java @@ -71,8 +71,40 @@ public class GroupedGeneralDropItem implements IDropItem for (GeneralDropItem gdi : getItems()) { final L2Item item = ItemTable.getInstance().getTemplate(gdi.getItemId()); - if ((item == null) || !item.hasExImmediateEffect()) + if (item == null) { + return 0; + } + if (!item.hasExImmediateEffect()) + { + // individual chance + Float individualDropChanceMultiplier = null; + if (killer.getActingPlayer().hasPremiumStatus()) + { + final Float normalMultiplier = Config.RATE_DROP_CHANCE_BY_ID.get(item.getId()); + final Float premiumMultiplier = Config.PREMIUM_RATE_DROP_CHANCE_BY_ID.get(item.getId()); + if ((normalMultiplier != null) && (premiumMultiplier != null)) + { + individualDropChanceMultiplier = normalMultiplier * premiumMultiplier; + } + else if (normalMultiplier != null) + { + individualDropChanceMultiplier = normalMultiplier; + } + else if (premiumMultiplier != null) + { + individualDropChanceMultiplier = premiumMultiplier; + } + } + else + { + individualDropChanceMultiplier = Config.RATE_DROP_CHANCE_BY_ID.get(item.getId()); + } + if (individualDropChanceMultiplier != null) + { + return getChance() * individualDropChanceMultiplier; + } + return getChance() * getGlobalChanceMultiplier(); } } @@ -130,7 +162,7 @@ public class GroupedGeneralDropItem implements IDropItem for (GeneralDropItem item : getItems()) { // Grouped item chance rates should not be modified. - totalChance += item.getChance(); + totalChance += item.getChance(victim, killer); if (totalChance > random) { final Collection items = new ArrayList<>(1); diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java index 247de6c8b5..96623d70ce 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java @@ -93,7 +93,7 @@ public class NpcViewMod implements IBypassHandler return false; } - NpcViewMod.sendNpcView(activeChar, npc); + sendNpcView(activeChar, npc); break; } case "droplist": diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java index 7e884a4f4f..84f3c8ef2d 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java @@ -71,8 +71,40 @@ public class GroupedGeneralDropItem implements IDropItem for (GeneralDropItem gdi : getItems()) { final L2Item item = ItemTable.getInstance().getTemplate(gdi.getItemId()); - if ((item == null) || !item.hasExImmediateEffect()) + if (item == null) { + return 0; + } + if (!item.hasExImmediateEffect()) + { + // individual chance + Float individualDropChanceMultiplier = null; + if (killer.getActingPlayer().hasPremiumStatus()) + { + final Float normalMultiplier = Config.RATE_DROP_CHANCE_BY_ID.get(item.getId()); + final Float premiumMultiplier = Config.PREMIUM_RATE_DROP_CHANCE_BY_ID.get(item.getId()); + if ((normalMultiplier != null) && (premiumMultiplier != null)) + { + individualDropChanceMultiplier = normalMultiplier * premiumMultiplier; + } + else if (normalMultiplier != null) + { + individualDropChanceMultiplier = normalMultiplier; + } + else if (premiumMultiplier != null) + { + individualDropChanceMultiplier = premiumMultiplier; + } + } + else + { + individualDropChanceMultiplier = Config.RATE_DROP_CHANCE_BY_ID.get(item.getId()); + } + if (individualDropChanceMultiplier != null) + { + return getChance() * individualDropChanceMultiplier; + } + return getChance() * getGlobalChanceMultiplier(); } } @@ -130,12 +162,12 @@ public class GroupedGeneralDropItem implements IDropItem for (GeneralDropItem item : getItems()) { // Grouped item chance rates should not be modified. - totalChance += item.getChance(); + totalChance += item.getChance(victim, killer); if (totalChance > random) { final Collection items = new ArrayList<>(1); final long baseDropCount = Rnd.get(item.getMin(victim, killer), item.getMax(victim, killer)); - final long finaldropCount = (long) (Config.L2JMOD_OLD_DROP_BEHAVIOR ? (baseDropCount * Math.max(1, chance / 100)) + (chance > 100 && (chance % 100) > (Rnd.nextDouble() * 100) ? baseDropCount : 0) : baseDropCount); + final long finaldropCount = (long) (Config.L2JMOD_OLD_DROP_BEHAVIOR ? (baseDropCount * Math.max(1, chance / 100)) + ((chance > 100) && ((chance % 100) > (Rnd.nextDouble() * 100)) ? baseDropCount : 0) : baseDropCount); items.add(new ItemHolder(item.getItemId(), finaldropCount)); return items; } diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java index 8178160913..5616cacd5e 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/bypasshandlers/NpcViewMod.java @@ -517,7 +517,7 @@ public class NpcViewMod implements IBypassHandler sb.append("Chance:"); sb.append(""); - sb.append(chanceFormat.format(Math.min(generalDropItem.getChance(), 100))); + sb.append(chanceFormat.format(Math.min(generalDropItem.getChance(npc, activeChar), 100))); sb.append("% "); height += 64; diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java index 995445985b..2049e0ca1e 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/drops/GroupedGeneralDropItem.java @@ -71,8 +71,40 @@ public class GroupedGeneralDropItem implements IDropItem for (GeneralDropItem gdi : getItems()) { final L2Item item = ItemTable.getInstance().getTemplate(gdi.getItemId()); - if ((item == null) || !item.hasExImmediateEffect()) + if (item == null) { + return 0; + } + if (!item.hasExImmediateEffect()) + { + // individual chance + Float individualDropChanceMultiplier = null; + if (killer.getActingPlayer().hasPremiumStatus()) + { + final Float normalMultiplier = Config.RATE_DROP_CHANCE_BY_ID.get(item.getId()); + final Float premiumMultiplier = Config.PREMIUM_RATE_DROP_CHANCE_BY_ID.get(item.getId()); + if ((normalMultiplier != null) && (premiumMultiplier != null)) + { + individualDropChanceMultiplier = normalMultiplier * premiumMultiplier; + } + else if (normalMultiplier != null) + { + individualDropChanceMultiplier = normalMultiplier; + } + else if (premiumMultiplier != null) + { + individualDropChanceMultiplier = premiumMultiplier; + } + } + else + { + individualDropChanceMultiplier = Config.RATE_DROP_CHANCE_BY_ID.get(item.getId()); + } + if (individualDropChanceMultiplier != null) + { + return getChance() * individualDropChanceMultiplier; + } + return getChance() * getGlobalChanceMultiplier(); } } @@ -130,7 +162,7 @@ public class GroupedGeneralDropItem implements IDropItem for (GeneralDropItem item : getItems()) { // Grouped item chance rates should not be modified. - totalChance += item.getChance(); + totalChance += item.getChance(victim, killer); if (totalChance > random) { final Collection items = new ArrayList<>(1);