Ver código fonte

BETA: Support for decimal values for drop list, by UnAfraid, thanks.

Zoey76 13 anos atrás
pai
commit
c29c7ae20f

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/NpcTable.java

@@ -223,7 +223,7 @@ public class NpcTable
 					dropDat.setItemId(dropData.getInt("itemId"));
 					dropDat.setMinDrop(dropData.getInt("min"));
 					dropDat.setMaxDrop(dropData.getInt("max"));
-					dropDat.setChance(dropData.getInt("chance"));
+					dropDat.setChance(dropData.getDouble("chance"));
 					
 					int category = dropData.getInt("category");
 					

+ 3 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/model/L2DropData.java

@@ -31,7 +31,7 @@ public class L2DropData
 	private int _itemId;
 	private int _minDrop;
 	private int _maxDrop;
-	private int _chance;
+	private double _chance;
 	private String _questID = null;
 	private String[] _stateID = null;
 	
@@ -75,7 +75,7 @@ public class L2DropData
 	 * Returns the chance of having a drop
 	 * @return int
 	 */
-	public int getChance()
+	public double getChance()
 	{
 		return _chance;
 	}
@@ -102,7 +102,7 @@ public class L2DropData
 	 * Sets the chance of having the item for a drop
 	 * @param chance : int designating the chance
 	 */
-	public void setChance(int chance)
+	public void setChance(double chance)
 	{
 		_chance = chance;
 	}

+ 5 - 16
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Attackable.java

@@ -1188,7 +1188,7 @@ public class L2Attackable extends L2Npc
 	private RewardItem calculateRewardItem(L2PcInstance lastAttacker, L2DropData drop, int levelModifier, boolean isSweep)
 	{
 		// Get default drop chance
-		float dropChance = drop.getChance();
+		double dropChance = drop.getChance();
 		
 		int deepBlueDrop = 1;
 		
@@ -1223,9 +1223,6 @@ public class L2Attackable extends L2Npc
 		if (Config.L2JMOD_CHAMPION_ENABLE && isChampion())
 			dropChance *= Config.L2JMOD_CHAMPION_REWARDS;
 		
-		// Round drop chance
-		dropChance = Math.round(dropChance);
-		
 		// Set our limits for chance of drop
 		if (dropChance < 1)
 			dropChance = 1;
@@ -1321,9 +1318,6 @@ public class L2Attackable extends L2Npc
 		if (Config.L2JMOD_CHAMPION_ENABLE && isChampion())
 			categoryDropChance *= Config.L2JMOD_CHAMPION_REWARDS;
 		
-		// Round drop chance
-		categoryDropChance = Math.round(categoryDropChance);
-		
 		// Set our limits for chance of drop
 		if (categoryDropChance < 1)
 			categoryDropChance = 1;
@@ -1348,7 +1342,7 @@ public class L2Attackable extends L2Npc
 			// At least 1 item will be dropped for sure.	So the chance will be adjusted to 100%
 			// if smaller.
 			
-			int dropChance = drop.getChance();
+			double dropChance = drop.getChance();
 			
 			if (Config.RATE_DROP_ITEMS_ID.get(drop.getItemId()) != 0)
 				dropChance *= Config.RATE_DROP_ITEMS_ID.get(drop.getItemId());
@@ -1373,7 +1367,7 @@ public class L2Attackable extends L2Npc
 			// Count and chance adjustment for high rate servers
 			if (dropChance > L2DropData.MAX_CHANCE && !Config.PRECISE_DROP_CALCULATION)
 			{
-				int multiplier = dropChance / L2DropData.MAX_CHANCE;
+				long multiplier = Math.round(dropChance / L2DropData.MAX_CHANCE);
 				
 				if (min < max)
 					itemCount += Rnd.get(min * multiplier, max * multiplier);
@@ -1475,9 +1469,6 @@ public class L2Attackable extends L2Npc
 				categoryDropChance *= Config.RATE_DROP_COMMON_HERBS;
 		}
 		
-		// Round drop chance
-		categoryDropChance = Math.round(categoryDropChance);
-		
 		// Set our limits for chance of drop
 		if (categoryDropChance < 1)
 			categoryDropChance = 1;
@@ -1502,7 +1493,7 @@ public class L2Attackable extends L2Npc
 			// At least 1 item will be dropped for sure.	So the chance will be adjusted to 100%
 			// if smaller.
 			
-			int dropChance = drop.getChance();
+			double dropChance = drop.getChance();
 			
 			switch (categoryDrops.getCategoryType())
 			{
@@ -1522,8 +1513,6 @@ public class L2Attackable extends L2Npc
 					dropChance *= Config.RATE_DROP_COMMON_HERBS;
 			}
 			
-			dropChance = Math.round(dropChance);
-			
 			if (dropChance < L2DropData.MAX_CHANCE)
 				dropChance = L2DropData.MAX_CHANCE;
 			
@@ -1537,7 +1526,7 @@ public class L2Attackable extends L2Npc
 			// Count and chance adjustment for high rate servers
 			if (dropChance > L2DropData.MAX_CHANCE && !Config.PRECISE_DROP_CALCULATION)
 			{
-				int multiplier = dropChance / L2DropData.MAX_CHANCE;
+				long multiplier = Math.round(dropChance / L2DropData.MAX_CHANCE);
 				
 				if (min < max)
 					itemCount += Rnd.get(min * multiplier, max * multiplier);