Support for drop groups.
This commit is contained in:
		| @@ -37,6 +37,7 @@ import org.l2jmobius.gameserver.model.actor.Attackable; | ||||
| import org.l2jmobius.gameserver.model.actor.Creature; | ||||
| import org.l2jmobius.gameserver.model.actor.Npc; | ||||
| import org.l2jmobius.gameserver.model.actor.Player; | ||||
| import org.l2jmobius.gameserver.model.holders.DropGroupHolder; | ||||
| import org.l2jmobius.gameserver.model.holders.DropHolder; | ||||
| import org.l2jmobius.gameserver.model.item.ItemTemplate; | ||||
| import org.l2jmobius.gameserver.model.itemcontainer.Inventory; | ||||
| @@ -326,12 +327,13 @@ public class NpcViewMod implements IBypassHandler | ||||
| 	private static String getDropListButtons(Npc npc) | ||||
| 	{ | ||||
| 		final StringBuilder sb = new StringBuilder(); | ||||
| 		final List<DropGroupHolder> dropListGroups = npc.getTemplate().getDropGroups(); | ||||
| 		final List<DropHolder> dropListDeath = npc.getTemplate().getDropList(); | ||||
| 		final List<DropHolder> dropListSpoil = npc.getTemplate().getSpoilList(); | ||||
| 		if ((dropListDeath != null) || (dropListSpoil != null)) | ||||
| 		if ((dropListGroups != null) || (dropListDeath != null) || (dropListSpoil != null)) | ||||
| 		{ | ||||
| 			sb.append("<table width=275 cellpadding=0 cellspacing=0><tr>"); | ||||
| 			if (dropListDeath != null) | ||||
| 			if ((dropListGroups != null) || (dropListDeath != null)) | ||||
| 			{ | ||||
| 				sb.append("<td align=center><button value=\"Show Drop\" width=100 height=25 action=\"bypass NpcViewMod dropList DROP " + npc.getObjectId() + "\" back=\"L2UI_CT1.Button_DF_Calculator_Down\" fore=\"L2UI_CT1.Button_DF_Calculator\"></td>"); | ||||
| 			} | ||||
| @@ -348,13 +350,40 @@ public class NpcViewMod implements IBypassHandler | ||||
| 	 | ||||
| 	private void sendNpcDropList(Player player, Npc npc, DropType dropType, int pageValue) | ||||
| 	{ | ||||
| 		final List<DropHolder> templateList = dropType == DropType.SPOIL ? npc.getTemplate().getSpoilList() : npc.getTemplate().getDropList(); | ||||
| 		if (templateList == null) | ||||
| 		List<DropHolder> dropList = null; | ||||
| 		if (dropType == DropType.SPOIL) | ||||
| 		{ | ||||
| 			dropList = new ArrayList<>(npc.getTemplate().getSpoilList()); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			final List<DropHolder> drops = npc.getTemplate().getDropList(); | ||||
| 			if (drops != null) | ||||
| 			{ | ||||
| 				dropList = new ArrayList<>(drops); | ||||
| 			} | ||||
| 			final List<DropGroupHolder> dropGroups = npc.getTemplate().getDropGroups(); | ||||
| 			if (dropGroups != null) | ||||
| 			{ | ||||
| 				if (dropList == null) | ||||
| 				{ | ||||
| 					dropList = new ArrayList<>(); | ||||
| 				} | ||||
| 				for (DropGroupHolder dropGroup : dropGroups) | ||||
| 				{ | ||||
| 					final double chance = dropGroup.getChance() / 100; | ||||
| 					for (DropHolder dropHolder : dropGroup.getDropList()) | ||||
| 					{ | ||||
| 						dropList.add(new DropHolder(dropHolder.getDropType(), dropHolder.getItemId(), dropHolder.getMin(), dropHolder.getMax(), dropHolder.getChance() * chance)); | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		if (dropList == null) | ||||
| 		{ | ||||
| 			return; | ||||
| 		} | ||||
| 		 | ||||
| 		final List<DropHolder> dropList = new ArrayList<>(templateList); | ||||
| 		Collections.sort(dropList, (d1, d2) -> Integer.valueOf(d1.getItemId()).compareTo(Integer.valueOf(d2.getItemId()))); | ||||
| 		 | ||||
| 		int pages = dropList.size() / DROP_LIST_ITEMS_PER_PAGE; | ||||
|   | ||||
| @@ -36,6 +36,7 @@ import org.l2jmobius.gameserver.handler.CommunityBoardHandler; | ||||
| import org.l2jmobius.gameserver.handler.IParseBoardHandler; | ||||
| import org.l2jmobius.gameserver.model.actor.Player; | ||||
| import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate; | ||||
| import org.l2jmobius.gameserver.model.holders.DropGroupHolder; | ||||
| import org.l2jmobius.gameserver.model.holders.DropHolder; | ||||
| import org.l2jmobius.gameserver.model.item.ItemTemplate; | ||||
| import org.l2jmobius.gameserver.model.itemcontainer.Inventory; | ||||
| @@ -104,6 +105,17 @@ public class DropSearchBoard implements IParseBoardHandler | ||||
| 	 | ||||
| 	private void buildDropIndex() | ||||
| 	{ | ||||
| 		NpcData.getInstance().getTemplates(npc -> npc.getDropGroups() != null).forEach(npcTemplate -> | ||||
| 		{ | ||||
| 			for (DropGroupHolder dropGroup : npcTemplate.getDropGroups()) | ||||
| 			{ | ||||
| 				final double chance = dropGroup.getChance() / 100; | ||||
| 				for (DropHolder dropHolder : dropGroup.getDropList()) | ||||
| 				{ | ||||
| 					addToDropList(npcTemplate, new DropHolder(dropHolder.getDropType(), dropHolder.getItemId(), dropHolder.getMin(), dropHolder.getMax(), dropHolder.getChance() * chance)); | ||||
| 				} | ||||
| 			} | ||||
| 		}); | ||||
| 		NpcData.getInstance().getTemplates(npc -> npc.getDropList() != null).forEach(npcTemplate -> | ||||
| 		{ | ||||
| 			for (DropHolder dropHolder : npcTemplate.getDropList()) | ||||
|   | ||||
| @@ -1,16 +1,5 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||||
| 	<xs:complexType name="dropListItem"> | ||||
| 		<xs:attribute name="id" type="xs:positiveInteger" use="required" /> | ||||
| 		<xs:attribute name="min" type="xs:nonNegativeInteger" /> | ||||
| 		<xs:attribute name="max" type="xs:positiveInteger" /> | ||||
| 		<xs:attribute name="chance" type="xs:decimal" /> | ||||
| 	</xs:complexType> | ||||
| 	<xs:complexType name="dropList"> | ||||
| 		<xs:choice minOccurs="1" maxOccurs="unbounded"> | ||||
| 			<xs:element name="item" type="dropListItem" /> | ||||
| 		</xs:choice> | ||||
| 	</xs:complexType> | ||||
| 	<xs:element name="list"> | ||||
| 		<xs:complexType> | ||||
| 			<xs:sequence> | ||||
| @@ -261,11 +250,81 @@ | ||||
| 							</xs:element> | ||||
| 							<xs:element name="dropLists" minOccurs="0" maxOccurs="1"> | ||||
| 								<xs:complexType> | ||||
| 									<xs:all> | ||||
| 										<xs:element name="drop" type="dropList" minOccurs="0" maxOccurs="1" /> | ||||
| 										<xs:element name="spoil" type="dropList" minOccurs="0" maxOccurs="1" /> | ||||
| 										<xs:element name="lucky" type="dropList" minOccurs="0" maxOccurs="1" /> | ||||
| 									</xs:all> | ||||
| 									<xs:sequence> | ||||
| 										<xs:element name="drop" minOccurs="0"> | ||||
| 											<xs:complexType> | ||||
| 												<xs:sequence> | ||||
| 													<xs:element name="item" maxOccurs="unbounded" minOccurs="0"> | ||||
| 														<xs:complexType> | ||||
| 															<xs:simpleContent> | ||||
| 																<xs:extension base="xs:string"> | ||||
| 																	<xs:attribute type="xs:int" name="id" use="required"/> | ||||
| 																	<xs:attribute type="xs:long" name="min" use="required"/> | ||||
| 																	<xs:attribute type="xs:long" name="max" use="required"/> | ||||
| 																	<xs:attribute type="xs:double" name="chance" use="required"/> | ||||
| 																</xs:extension> | ||||
| 															</xs:simpleContent> | ||||
| 														</xs:complexType> | ||||
| 													</xs:element> | ||||
| 													<xs:element name="group" maxOccurs="unbounded" minOccurs="0"> | ||||
| 														<xs:complexType> | ||||
| 															<xs:sequence> | ||||
| 																<xs:element name="item" maxOccurs="unbounded" minOccurs="0"> | ||||
| 																	<xs:complexType> | ||||
| 																		<xs:simpleContent> | ||||
| 																			<xs:extension base="xs:string"> | ||||
| 																				<xs:attribute type="xs:int" name="id" use="required"/> | ||||
| 																				<xs:attribute type="xs:long" name="min" use="required"/> | ||||
| 																				<xs:attribute type="xs:long" name="max" use="required"/> | ||||
| 																				<xs:attribute type="xs:double" name="chance" use="required"/> | ||||
| 																			</xs:extension> | ||||
| 																		</xs:simpleContent> | ||||
| 																	</xs:complexType> | ||||
| 																</xs:element> | ||||
| 															</xs:sequence> | ||||
| 															<xs:attribute type="xs:double" name="chance" use="optional"/> | ||||
| 														</xs:complexType> | ||||
| 													</xs:element> | ||||
| 												</xs:sequence> | ||||
| 											</xs:complexType> | ||||
| 										</xs:element> | ||||
| 										<xs:element name="lucky" minOccurs="0"> | ||||
| 											<xs:complexType> | ||||
| 												<xs:sequence> | ||||
| 													<xs:element name="item" maxOccurs="unbounded" minOccurs="0"> | ||||
| 														<xs:complexType> | ||||
| 															<xs:simpleContent> | ||||
| 																<xs:extension base="xs:string"> | ||||
| 																	<xs:attribute type="xs:int" name="id" use="optional"/> | ||||
| 																	<xs:attribute type="xs:long" name="min" use="optional"/> | ||||
| 																	<xs:attribute type="xs:long" name="max" use="optional"/> | ||||
| 																	<xs:attribute type="xs:double" name="chance" use="optional"/> | ||||
| 																</xs:extension> | ||||
| 															</xs:simpleContent> | ||||
| 														</xs:complexType> | ||||
| 													</xs:element> | ||||
| 												</xs:sequence> | ||||
| 											</xs:complexType> | ||||
| 										</xs:element> | ||||
| 										<xs:element name="spoil" minOccurs="0"> | ||||
| 											<xs:complexType> | ||||
| 												<xs:sequence> | ||||
| 													<xs:element name="item" maxOccurs="unbounded" minOccurs="0"> | ||||
| 														<xs:complexType> | ||||
| 															<xs:simpleContent> | ||||
| 																<xs:extension base="xs:string"> | ||||
| 																	<xs:attribute type="xs:int" name="id" use="optional"/> | ||||
| 																	<xs:attribute type="xs:long" name="min" use="optional"/> | ||||
| 																	<xs:attribute type="xs:long" name="max" use="optional"/> | ||||
| 																	<xs:attribute type="xs:double" name="chance" use="optional"/> | ||||
| 																</xs:extension> | ||||
| 															</xs:simpleContent> | ||||
| 														</xs:complexType> | ||||
| 													</xs:element> | ||||
| 												</xs:sequence> | ||||
| 											</xs:complexType> | ||||
| 										</xs:element> | ||||
| 									</xs:sequence> | ||||
| 								</xs:complexType> | ||||
| 							</xs:element> | ||||
| 							<xs:element name="collision" minOccurs="0" maxOccurs="1"> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 MobiusDevelopment
					MobiusDevelopment