Explorar el Código

BETA: `Util#map` methods should constrain '''input''' value to '''inputMin''' and '''inputMax'''.
* Added configs for level gaps in '''NPC.properties'''.
* Removed unused '''!PreciseDropCalculation''' config.

Reviewed by: St3eT, !UnAfraid

Nos hace 11 años
padre
commit
34da21fedb

+ 30 - 0
L2J_Server_BETA/dist/game/config/NPC.properties

@@ -178,6 +178,36 @@ RaidChaosTime = 10
 GrandChaosTime = 10
 MinionChaosTime = 10
 
+# ---------------------------------------------------------------------------
+# Drops
+# ---------------------------------------------------------------------------
+
+# The min and max level difference used for level gap calculation
+# this is only for how many levels higher the player is than the monster
+# Default: 8
+DropAdenaMinLevelDifference=8
+# Default: 15
+DropAdenaMaxLevelDifference=15
+
+# This is the minimum level gap chance meaning for 10 that the monster will have 10% chance
+# to allow dropping the item if level difference is bigger than DropAdenaMaxLevelDifference
+# Note: This value is scalling from 100 to the specified value for DropAdenaMinLevelDifference to DropAdenaMaxLevelDifference limits
+# Default: 10
+DropAdenaMinLevelGapChance=10
+
+# The min and max level difference used for level gap calculation
+# this is only for how many levels higher the player is than the monster
+# Default: 5
+DropItemMinLevelDifference=5
+# Default: 10
+DropItemMaxLevelDifference=10
+
+# This is the minimum level gap chance meaning for 10 that the monster will have 10% chance
+# to allow dropping the item if level difference is bigger than DropAdenaMaxLevelDifference
+# Note: This value is scalling from 100 to the specified value for DropAdenaMinLevelDifference to DropAdenaMaxLevelDifference limits
+# Default: 10
+DropItemMinLevelGapChance=10
+
 # A comma separated list of all NPCs who have no dialog, i.e. double-clicking on them doesn't open a chat window
 # Default: 18684,18685,18686,18687,18688,18689,18690,19691,18692,31202,31203,31204,31205,31206,31207,31208,31209,31266,31557,31593,31606,31671,31672,31673,31674,31758,31955,32026,32030,32031,32032,32306,32619,32620,32621
 NonTalkingNpcs = 18684,18685,18686,18687,18688,18689,18690,19691,18692,18848,18849,18926,18927,18933,31202,31203,31204,31205,31206,31207,31208,31209,31266,31557,31593,31606,31671,31672,31673,31674,31758,31955,32026,32030,32031,32032,32306,32619,32620,32621,32715,32716,32717,32718,32719,32720,32721,18839

+ 15 - 4
L2J_Server_BETA/java/com/l2jserver/Config.java

@@ -825,6 +825,12 @@ public final class Config
 	public static int INVENTORY_MAXIMUM_PET;
 	public static double PET_HP_REGEN_MULTIPLIER;
 	public static double PET_MP_REGEN_MULTIPLIER;
+	public static int DROP_ADENA_MIN_LEVEL_DIFFERENCE;
+	public static int DROP_ADENA_MAX_LEVEL_DIFFERENCE;
+	public static double DROP_ADENA_MIN_LEVEL_GAP_CHANCE;
+	public static int DROP_ITEM_MIN_LEVEL_DIFFERENCE;
+	public static int DROP_ITEM_MAX_LEVEL_DIFFERENCE;
+	public static double DROP_ITEM_MIN_LEVEL_GAP_CHANCE;
 	public static List<Integer> NON_TALKING_NPCS;
 	
 	// --------------------------------------------------
@@ -1831,7 +1837,6 @@ public final class Config
 			SAVE_DROPPED_ITEM_INTERVAL = General.getInt("SaveDroppedItemInterval", 60) * 60000;
 			CLEAR_DROPPED_ITEM_TABLE = General.getBoolean("ClearDroppedItemTable", false);
 			AUTODELETE_INVALID_QUEST_DATA = General.getBoolean("AutoDeleteInvalidQuestData", false);
-			PRECISE_DROP_CALCULATION = General.getBoolean("PreciseDropCalculation", true);
 			MULTIPLE_ITEM_DROP = General.getBoolean("MultipleItemDrop", true);
 			FORCE_INVENTORY_UPDATE = General.getBoolean("ForceInventoryUpdate", false);
 			LAZY_CACHE = General.getBoolean("LazyCache", true);
@@ -2082,6 +2087,15 @@ public final class Config
 			INVENTORY_MAXIMUM_PET = NPC.getInt("MaximumSlotsForPet", 12);
 			PET_HP_REGEN_MULTIPLIER = NPC.getDouble("PetHpRegenMultiplier", 100) / 100;
 			PET_MP_REGEN_MULTIPLIER = NPC.getDouble("PetMpRegenMultiplier", 100) / 100;
+			
+			DROP_ADENA_MIN_LEVEL_DIFFERENCE = NPC.getInt("DropAdenaMinLevelDifference", 8);
+			DROP_ADENA_MAX_LEVEL_DIFFERENCE = NPC.getInt("DropAdenaMaxLevelDifference", 15);
+			DROP_ADENA_MIN_LEVEL_GAP_CHANCE = NPC.getDouble("DropAdenaMinLevelGapChance", 10);
+			
+			DROP_ITEM_MIN_LEVEL_DIFFERENCE = NPC.getInt("DropItemMinLevelDifference", 5);
+			DROP_ITEM_MAX_LEVEL_DIFFERENCE = NPC.getInt("DropItemMaxLevelDifference", 10);
+			DROP_ITEM_MIN_LEVEL_GAP_CHANCE = NPC.getDouble("DropItemMinLevelGapChance", 10);
+			
 			split = NPC.getString("NonTalkingNpcs", "18684,18685,18686,18687,18688,18689,18690,19691,18692,31202,31203,31204,31205,31206,31207,31208,31209,31266,31557,31593,31606,31671,31672,31673,31674,31758,31955,32026,32030,32031,32032,32306,32619,32620,32621").split(",");
 			NON_TALKING_NPCS = new ArrayList<>(split.length);
 			for (String npcId : split)
@@ -3032,9 +3046,6 @@ public final class Config
 			case "cleardroppeditemtable":
 				CLEAR_DROPPED_ITEM_TABLE = Boolean.parseBoolean(pValue);
 				break;
-			case "precisedropcalculation":
-				PRECISE_DROP_CALCULATION = Boolean.parseBoolean(pValue);
-				break;
 			case "multipleitemdrop":
 				MULTIPLE_ITEM_DROP = Boolean.parseBoolean(pValue);
 				break;

+ 7 - 33
L2J_Server_BETA/java/com/l2jserver/gameserver/model/drops/GeneralDropItem.java

@@ -25,6 +25,7 @@ import com.l2jserver.Config;
 import com.l2jserver.gameserver.model.actor.L2Character;
 import com.l2jserver.gameserver.model.holders.ItemHolder;
 import com.l2jserver.gameserver.model.itemcontainer.Inventory;
+import com.l2jserver.gameserver.util.Util;
 import com.l2jserver.util.Rnd;
 
 /**
@@ -153,42 +154,15 @@ public class GeneralDropItem implements IDropItem
 	@Override
 	public List<ItemHolder> calculateDrops(L2Character victim, L2Character killer)
 	{
-		int levelDifference = victim.getLevel() - killer.getLevel();
-		double levelGapChanceToDrop;
+		final int levelDifference = victim.getLevel() - killer.getLevel();
+		final double levelGapChanceToDrop;
 		if (getItemId() == Inventory.ADENA_ID)
 		{
-			
-			if (levelDifference >= -8)
-			{
-				levelGapChanceToDrop = 100;
-			}
-			else if (levelDifference >= -15)
-			{
-				levelGapChanceToDrop = levelDifference;
-				levelGapChanceToDrop *= 12.857;
-				levelGapChanceToDrop += 202.857;
-			}
-			else
-			{
-				levelGapChanceToDrop = 10;
-			}
+			levelGapChanceToDrop = Util.map(levelDifference, -Config.DROP_ADENA_MAX_LEVEL_DIFFERENCE, -Config.DROP_ADENA_MIN_LEVEL_DIFFERENCE, Config.DROP_ADENA_MIN_LEVEL_GAP_CHANCE, 100.0);
 		}
 		else
 		{
-			if (levelDifference >= -5)
-			{
-				levelGapChanceToDrop = 100;
-			}
-			else if (levelDifference >= -10)
-			{
-				levelGapChanceToDrop = levelDifference;
-				levelGapChanceToDrop *= 18;
-				levelGapChanceToDrop += 190;
-			}
-			else
-			{
-				levelGapChanceToDrop = 10;
-			}
+			levelGapChanceToDrop = Util.map(levelDifference, -Config.DROP_ITEM_MAX_LEVEL_DIFFERENCE, -Config.DROP_ITEM_MIN_LEVEL_DIFFERENCE, Config.DROP_ITEM_MIN_LEVEL_GAP_CHANCE, 100.0);
 		}
 		
 		// There is a chance of level gap that it wont drop this item
@@ -199,9 +173,9 @@ public class GeneralDropItem implements IDropItem
 		
 		if (getChance(victim, killer) > (Rnd.nextDouble() * 100))
 		{
-			long amount = Rnd.get(getMin(victim, killer), getMax(victim, killer));
+			final long amount = Rnd.get(getMin(victim, killer), getMax(victim, killer));
 			
-			List<ItemHolder> items = new ArrayList<>(1);
+			final List<ItemHolder> items = new ArrayList<>(1);
 			items.add(new ItemHolder(getItemId(), amount));
 			return items;
 		}

+ 3 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/util/Util.java

@@ -899,6 +899,7 @@ public final class Util
 	 */
 	public static int map(int input, int inputMin, int inputMax, int outputMin, int outputMax)
 	{
+		input = constrain(input, inputMin, inputMax);
 		return (((input - inputMin) * (outputMax - outputMin)) / (inputMax - inputMin)) + outputMin;
 	}
 	
@@ -913,6 +914,7 @@ public final class Util
 	 */
 	public static long map(long input, long inputMin, long inputMax, long outputMin, long outputMax)
 	{
+		input = constrain(input, inputMin, inputMax);
 		return (((input - inputMin) * (outputMax - outputMin)) / (inputMax - inputMin)) + outputMin;
 	}
 	
@@ -927,6 +929,7 @@ public final class Util
 	 */
 	public static double map(double input, double inputMin, double inputMax, double outputMin, double outputMax)
 	{
+		input = constrain(input, inputMin, inputMax);
 		return (((input - inputMin) * (outputMax - outputMin)) / (inputMax - inputMin)) + outputMin;
 	}