Переглянути джерело

Merge branch 'master' of https://github.com/L2J/L2J_Server

NosBit 10 роки тому
батько
коміт
9116f23e6a

+ 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;
 	}
 }

+ 45 - 16
L2J_Server/java/com/l2jserver/gameserver/util/Util.java

@@ -145,7 +145,7 @@ public final class Util
 	 * @param squared - If set to true, distance returned will be squared.
 	 * @return {@code double} - Distance between object and given x, y , z.
 	 */
-	public static double calculateDistance(int x1, int y1, int z1, int x2, int y2, int z2, boolean includeZAxis, boolean squared)
+	public static double calculateDistance(double x1, double y1, double z1, double x2, double y2, double z2, boolean includeZAxis, boolean squared)
 	{
 		final double distance = Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2) + (includeZAxis ? Math.pow(z1 - z2, 2) : 0);
 		return (squared) ? distance : Math.sqrt(distance);
@@ -596,9 +596,9 @@ public final class Util
 	}
 	
 	/**
-	 * Sends the given html to the player.
-	 * @param activeChar
-	 * @param html
+	 * Helper method to send a NpcHtmlMessage to the specified player.
+	 * @param activeChar the player to send the html content to
+	 * @param html the html content
 	 */
 	public static void sendHtml(L2PcInstance activeChar, String html)
 	{
@@ -607,29 +607,58 @@ public final class Util
 		activeChar.sendPacket(npcHtml);
 	}
 	
+	/**
+	 * Helper method to send a community board html to the specified player.<br>
+	 * HtmlActionCache will be build with npc origin 0 which means the<br>
+	 * links on the html are not bound to a specific npc.
+	 * @param activeChar the player
+	 * @param html the html content
+	 */
 	public static void sendCBHtml(L2PcInstance activeChar, String html)
 	{
-		sendCBHtml(activeChar, html, true);
+		sendCBHtml(activeChar, html, 0);
 	}
 	
-	public static void sendCBHtml(L2PcInstance activeChar, String html, boolean buildActionCache)
+	/**
+	 * Helper method to send a community board html to the specified player.<br>
+	 * When {@code npcObjId} is greater -1 the HtmlActionCache will be build<br>
+	 * with the npcObjId as origin. An origin of 0 means the cached bypasses<br>
+	 * are not bound to a specific npc.
+	 * @param activeChar the player to send the html content to
+	 * @param html the html content
+	 * @param npcObjId bypass origin to use
+	 */
+	public static void sendCBHtml(L2PcInstance activeChar, String html, int npcObjId)
 	{
-		sendCBHtml(activeChar, html, null, buildActionCache);
+		sendCBHtml(activeChar, html, null, npcObjId);
 	}
 	
+	/**
+	 * Helper method to send a community board html to the specified player.<br>
+	 * HtmlActionCache will be build with npc origin 0 which means the<br>
+	 * links on the html are not bound to a specific npc. It also fills a<br>
+	 * multiedit field in the send html if fillMultiEdit is not null.
+	 * @param activeChar the player
+	 * @param html the html content
+	 * @param fillMultiEdit text to fill the multiedit field with(may be null)
+	 */
 	public static void sendCBHtml(L2PcInstance activeChar, String html, String fillMultiEdit)
 	{
-		sendCBHtml(activeChar, html, fillMultiEdit, true);
+		sendCBHtml(activeChar, html, fillMultiEdit, 0);
 	}
 	
 	/**
-	 * Sends the html using the community board window.
-	 * @param activeChar
-	 * @param html
-	 * @param fillMultiEdit fills the multiedit window (if any) inside the community board.
-	 * @param buildActionCache if false, action cache will not be built and players won't be able to click links in the HTML
+	 * Helper method to send a community board html to the specified player.<br>
+	 * It fills a multiedit field in the send html if {@code fillMultiEdit}<br>
+	 * is not null. When {@code npcObjId} is greater -1 the HtmlActionCache will be build<br>
+	 * with the npcObjId as origin. An origin of 0 means the cached bypasses<br>
+	 * are not bound to a specific npc.
+	 * @param activeChar the player
+	 * @param html the html content
+	 * @param fillMultiEdit text to fill the multiedit field with(may be null)
+	 * @param npcObjId bypass origin to use
 	 */
-	public static void sendCBHtml(L2PcInstance activeChar, String html, String fillMultiEdit, boolean buildActionCache)
+	public static void sendCBHtml(L2PcInstance activeChar, String html, String fillMultiEdit, int npcObjId)
 	{
 		if ((activeChar == null) || (html == null))
 		{
@@ -638,9 +667,9 @@ public final class Util
 		
 		activeChar.clearHtmlActions(HtmlActionScope.COMM_BOARD_HTML);
 		
-		if (buildActionCache)
+		if (npcObjId > -1)
 		{
-			buildHtmlActionCache(activeChar, HtmlActionScope.COMM_BOARD_HTML, 0, html);
+			buildHtmlActionCache(activeChar, HtmlActionScope.COMM_BOARD_HTML, npcObjId, html);
 		}
 		
 		if (fillMultiEdit != null)