Selaa lähdekoodia

Re-introducing the chance overflow of old L2J drops. This has been discussed with Nos, and this approach seems OK.

Sdw- 10 vuotta sitten
vanhempi
sitoutus
62055b3dfd

+ 8 - 1
L2J_Server/dist/game/config/L2JMods.properties

@@ -498,4 +498,11 @@ DualboxCheckWhitelist = 127.0.0.1,0
 
 # Enables .changepassword voiced command which allows the players to change their account's password ingame.
 # Default: False
-AllowChangePassword = False
+AllowChangePassword = False
+
+# Enables L2J old drop behavior
+# The old L2J system used to add amount of items drop per 100% range of chance.
+# For example, if chance is 230% when rate are applied, it will do :
+# amount dropped = (2 * getRandomAmount(min,max)) + 30% chance to get ad additional getRandomAmount(min,max)
+# Default : False
+OldDropBehavior = False

+ 3 - 0
L2J_Server/java/com/l2jserver/Config.java

@@ -779,6 +779,7 @@ public final class Config
 	public static int L2JMOD_DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP;
 	public static Map<Integer, Integer> L2JMOD_DUALBOX_CHECK_WHITELIST;
 	public static boolean L2JMOD_ALLOW_CHANGE_PASSWORD;
+	public static boolean L2JMOD_OLD_DROP_BEHAVIOR;
 	// --------------------------------------------------
 	// NPC Settings
 	// --------------------------------------------------
@@ -2242,6 +2243,8 @@ public final class Config
 			L2JMOD_ENABLE_WAREHOUSESORTING_CLAN = L2JModSettings.getBoolean("EnableWarehouseSortingClan", false);
 			L2JMOD_ENABLE_WAREHOUSESORTING_PRIVATE = L2JModSettings.getBoolean("EnableWarehouseSortingPrivate", false);
 			
+			L2JMOD_OLD_DROP_BEHAVIOR = L2JModSettings.getBoolean("OldDropBehavior", false);
+			
 			if (TVT_EVENT_PARTICIPATION_NPC_ID == 0)
 			{
 				TVT_EVENT_ENABLED = false;

+ 38 - 6
L2J_Server/java/com/l2jserver/gameserver/model/drops/GeneralDropItem.java

@@ -222,16 +222,48 @@ public class GeneralDropItem implements IDropItem
 			return null;
 		}
 		
-		if (getChance(victim, killer) > (Rnd.nextDouble() * 100))
+		final List<ItemHolder> items = new ArrayList<>(1);
+		
+		if (Config.L2JMOD_OLD_DROP_BEHAVIOR)
 		{
-			final long amount = Rnd.get(getMin(victim, killer), getMax(victim, killer));
-			final List<ItemHolder> items = new ArrayList<>(1);
+			double chance = getChance(victim, killer);
+			if (Config.L2JMOD_CHAMPION_ENABLE && victim.isChampion() && (getItemId() != Inventory.ADENA_ID))
+			{
+				chance *= Config.L2JMOD_CHAMPION_REWARDS;
+			}
+			
+			long amount = 0;
 			
-			items.add(new ItemHolder(getItemId(), amount));
+			if (chance > 100)
+			{
+				int chanceOveflow = (int) (chance / 100);
+				chance = chance % 100;
+				while (chanceOveflow > 0)
+				{
+					amount += Rnd.get(getMin(victim, killer), getMax(victim, killer));
+					chanceOveflow--;
+				}
+			}
+			
+			if (chance > (Rnd.nextDouble() * 100))
+			{
+				amount += Rnd.get(getMin(victim, killer), getMax(victim, killer));
+			}
 			
-			return items;
+			if (amount > 0)
+			{
+				items.add(new ItemHolder(getItemId(), amount));
+			}
+		}
+		else
+		{
+			if (getChance(victim, killer) > (Rnd.nextDouble() * 100))
+			{
+				final long amount = Rnd.get(getMin(victim, killer), getMax(victim, killer));
+				items.add(new ItemHolder(getItemId(), amount));
+			}
 		}
 		
-		return null;
+		return items;
 	}
 }

+ 49 - 9
L2J_Server/java/com/l2jserver/gameserver/model/drops/GroupedGeneralDropItem.java

@@ -126,22 +126,62 @@ public class GroupedGeneralDropItem implements IDropItem
 		
 		if ((getChance(victim, killer) * chanceModifier) > (Rnd.nextDouble() * 100))
 		{
-			double random = (Rnd.nextDouble() * 100);
+			final List<ItemHolder> items = new ArrayList<>(1);
+			long amount = 0;
 			double totalChance = 0;
-			for (GeneralDropItem item : getItems())
+			double random = (Rnd.nextDouble() * 100);
+			double chance = 0;
+			
+			if (Config.L2JMOD_OLD_DROP_BEHAVIOR)
 			{
-				// Grouped item chance rates should not be modified.
-				totalChance += item.getChance();
-				if (totalChance > random)
+				for (GeneralDropItem item : getItems())
 				{
-					long amount = Rnd.get(item.getMin(victim, killer), item.getMax(victim, killer));
+					// Grouped item chance rates should not be modified.
+					totalChance += item.getChance();
+					
+					if (totalChance > 100)
+					{
+						int chanceOverflow = (int) (totalChance / 100);
+						chance = totalChance % 100;
+						while (chanceOverflow > 0)
+						{
+							amount += Rnd.get(item.getMin(victim, killer), item.getMax(victim, killer));
+							chanceOverflow--;
+						}
+					}
+					else
+					{
+						chance = totalChance;
+					}
+					
+					if (chance > random)
+					{
+						amount += Rnd.get(item.getMin(victim, killer), item.getMax(victim, killer));
+					}
 					
-					List<ItemHolder> items = new ArrayList<>(1);
-					items.add(new ItemHolder(item.getItemId(), amount));
-					return items;
+					if (amount > 0)
+					{
+						items.add(new ItemHolder(item.getItemId(), amount));
+						return items;
+					}
+				}
+			}
+			else
+			{
+				for (GeneralDropItem item : getItems())
+				{
+					// Grouped item chance rates should not be modified.
+					totalChance += item.getChance();
+					if (totalChance > random)
+					{
+						amount = Rnd.get(item.getMin(victim, killer), item.getMax(victim, killer));
+						items.add(new ItemHolder(item.getItemId(), amount));
+						return items;
+					}
 				}
 			}
 		}
+		
 		return null;
 	}
 }