Advertisement
Guest User

Untitled

a guest
May 9th, 2021
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.90 KB | None | 0 0
  1. diff --git a/aCis_datapack/data/xml/monstersDrops.xml b/aCis_datapack/data/xml/monstersDrops.xml
  2. new file mode 100644
  3. index 0000000..184d745
  4. --- /dev/null
  5. +++ b/aCis_datapack/data/xml/monstersDrops.xml
  6. @@ -0,0 +1,6 @@
  7. +<?xml version="1.0" encoding="UTF-8"?>
  8. +<list>
  9. + <drops npcId="21337">
  10. + <settings itemId="9215" minDrop="1" maxDrop="1" chance="1000000" enchant="5-10" enchantChance="100"/>
  11. + </drops>
  12. +</list>
  13. \ No newline at end of file
  14. diff --git a/aCis_gameserver/config/players.properties b/aCis_gameserver/config/players.properties
  15. index 809b980..6c6515e 100644
  16. --- a/aCis_gameserver/config/players.properties
  17. +++ b/aCis_gameserver/config/players.properties
  18. @@ -73,6 +72,9 @@
  19. # Configure messages that players will receive. Variables: $player for player name; $days for days; $npc for npc name.
  20. HeroMsg = Congratulations $player you received $days days of HERO for murdering the boss $npc.
  21.  
  22. +# Enable Custom Drops, configure in data/xml/monstersDrops.xml
  23. +MonsterDrops = True
  24. +
  25. #=============================================================
  26. # Aio System
  27. #=============================================================
  28. diff --git a/aCis_gameserver/java/net/sf/l2j/Config.java b/aCis_gameserver/java/net/sf/l2j/Config.java
  29. index 782e7c3..ec42ff4 100644
  30. --- a/aCis_gameserver/java/net/sf/l2j/Config.java
  31. +++ b/aCis_gameserver/java/net/sf/l2j/Config.java
  32. @@ -473,12 +473,13 @@
  33. public static List<Integer> RAIDBOSS_NOBLES = new ArrayList<>();
  34. public static int BANKING_SYSTEM_ADENA;
  35. public static IntIntHolder[] BANKING_SYSTEM_GOLDCOIN;
  36. public static IntIntHolder[] PVP_COLORS;
  37. public static IntIntHolder[] KILL_RAID_HERO;
  38. public static String KILL_HERO_MSG;
  39. public static IntIntHolder[] KILL_RAID_VIP;
  40. public static String KILL_VIP_MSG;
  41. + public static boolean MONSTERS_DROPS;
  42.  
  43. /** Aio */
  44. public static int AIO_COLOR;
  45. @@ -1308,10 +1309,14 @@
  46.  
  47. for (String skill_id : players.getProperty("RaidBossId", "").split(";"))
  48. RAIDBOSS_NOBLES.add(Integer.parseInt(skill_id));
  49. +
  50. + MONSTERS_DROPS = players.getProperty("MonsterDrops", false);
  51. +
  52. BANKING_SYSTEM_GOLDCOIN = players.parseIntIntList("BankingGoldCoin", "9209-1");
  53. BANKING_SYSTEM_ADENA = players.getProperty("BankingAdenaCount", 500000000);
  54.  
  55. PVP_COLORS = players.parseIntIntList("PvpColors", "10-99050");
  56.  
  57. diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/GameServer.java b/aCis_gameserver/java/net/sf/l2j/gameserver/GameServer.java
  58. index 150e4c5..520b05c 100644
  59. --- a/aCis_gameserver/java/net/sf/l2j/gameserver/GameServer.java
  60. +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/GameServer.java
  61. @@ -58,7 +58,7 @@
  62. import net.sf.l2j.gameserver.data.xml.ArmorSetData;
  63. import net.sf.l2j.gameserver.data.xml.AugmentationData;
  64. import net.sf.l2j.gameserver.data.xml.DoorData;
  65. -import net.sf.l2j.gameserver.data.xml.DropsData;
  66. +import net.sf.l2j.gameserver.data.xml.DropMonstersData;
  67. import net.sf.l2j.gameserver.data.xml.EnchantData;
  68. import net.sf.l2j.gameserver.data.xml.FishData;
  69. import net.sf.l2j.gameserver.data.xml.HennaData;
  70. @@ -243,15 +243,12 @@
  71. StringUtil.printSection("Manor Manager");
  72. CastleManorManager.getInstance();
  73.  
  74. + StringUtil.printSection("Drop Monsters");
  75. + DropMonstersData.getInstance();
  76. +
  77. StringUtil.printSection("NPCs");
  78. BufferManager.getInstance();
  79. HerbDropData.getInstance();
  80. -
  81. NpcData.getInstance();
  82. WalkerRouteData.getInstance();
  83. DoorData.getInstance().spawn();
  84. diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/data/xml/DropMonstersData.java b/aCis_gameserver/java/net/sf/l2j/gameserver/data/xml/DropMonstersData.java
  85. new file mode 100644
  86. index 0000000..66b5292
  87. --- /dev/null
  88. +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/data/xml/DropMonstersData.java
  89. @@ -0,0 +1,65 @@
  90. +package net.sf.l2j.gameserver.data.xml;
  91. +
  92. +import java.nio.file.Path;
  93. +import java.util.HashMap;
  94. +import java.util.Map;
  95. +
  96. +import net.sf.l2j.commons.data.xml.IXmlReader;
  97. +import net.sf.l2j.commons.util.StatsSet;
  98. +
  99. +import net.sf.l2j.gameserver.model.DropMonsters;
  100. +
  101. +import org.w3c.dom.Document;
  102. +
  103. +/**
  104. + * @author Williams
  105. + *
  106. + */
  107. +public class DropMonstersData implements IXmlReader
  108. +{
  109. + private final Map<Integer, DropMonsters> _data = new HashMap<>();
  110. +
  111. + public DropMonstersData()
  112. + {
  113. + load();
  114. + }
  115. +
  116. + public void reload()
  117. + {
  118. + _data.clear();
  119. + load();
  120. + }
  121. +
  122. + @Override
  123. + public void load()
  124. + {
  125. + parseFile("./data/xml/monstersDrops.xml");
  126. + LOGGER.info("Loaded {} drop data.", _data.size());
  127. + }
  128. +
  129. + @Override
  130. + public void parseDocument(Document doc, Path path)
  131. + {
  132. + forEach(doc, "list", listNode -> forEach(listNode, "drops", monstersNode ->
  133. + {
  134. + final StatsSet set = parseAttributes(monstersNode);
  135. + forEach(monstersNode, "settings", setNode -> set.putAll(parseAttributes(setNode)));
  136. + _data.put(set.getInteger("npcId"), new DropMonsters(set));
  137. + }));
  138. + }
  139. +
  140. + public DropMonsters getNpcs(int npcId)
  141. + {
  142. + return _data.get(npcId);
  143. + }
  144. +
  145. + public static DropMonstersData getInstance()
  146. + {
  147. + return SingletonHolder.INSTANCE;
  148. + }
  149. +
  150. + private static class SingletonHolder
  151. + {
  152. + protected static final DropMonstersData INSTANCE = new DropMonstersData();
  153. + }
  154. +}
  155. \ No newline at end of file
  156. diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/model/DropMonsters.java b/aCis_gameserver/java/net/sf/l2j/gameserver/model/DropMonsters.java
  157. new file mode 100644
  158. index 0000000..c00d11d
  159. --- /dev/null
  160. +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/DropMonsters.java
  161. @@ -0,0 +1,67 @@
  162. +package net.sf.l2j.gameserver.model;
  163. +
  164. +import net.sf.l2j.commons.random.Rnd;
  165. +import net.sf.l2j.commons.util.StatsSet;
  166. +
  167. +import net.sf.l2j.gameserver.model.holder.IntIntHolder;
  168. +
  169. +/**
  170. + * @author Williams
  171. + *
  172. + */
  173. +public class DropMonsters
  174. +{
  175. + private int _itemId;
  176. + private int _minDrop;
  177. + private int _maxDrop;
  178. + private int _chance;
  179. +
  180. + private final IntIntHolder _enchant;
  181. + private final int _enchantChance;
  182. +
  183. + public DropMonsters(StatsSet set)
  184. + {
  185. + _itemId = set.getInteger("itemId");
  186. + _minDrop = set.getInteger("minDrop");
  187. + _maxDrop = set.getInteger("maxDrop");
  188. + _chance = set.getInteger("chance");
  189. +
  190. + _enchant = set.getString("enchant", "").isEmpty() ? null : set.getIntIntHolder("enchant");
  191. + _enchantChance = set.getInteger("enchantChance", 0);
  192. + }
  193. +
  194. + public int getMinDrop()
  195. + {
  196. + return _minDrop;
  197. + }
  198. +
  199. + public int getMaxDrop()
  200. + {
  201. + return _maxDrop;
  202. + }
  203. +
  204. + public int getChance()
  205. + {
  206. + return _chance;
  207. + }
  208. +
  209. + public int getItemId()
  210. + {
  211. + return _itemId;
  212. + }
  213. +
  214. + public int getEnchant()
  215. + {
  216. + return Rnd.get(Math.min(_enchant.getId(), _enchant.getValue()), Math.max(_enchant.getId(), _enchant.getValue()));
  217. + }
  218. +
  219. + public int getEnchantChance()
  220. + {
  221. + return _enchantChance;
  222. + }
  223. +
  224. + public boolean hasEnchant()
  225. + {
  226. + return _enchant != null;
  227. + }
  228. +}
  229. \ No newline at end of file
  230. diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/Monster.java b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/Monster.java
  231. index fa7ed64..fce5b0d 100644
  232. --- a/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/Monster.java
  233. +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/Monster.java
  234. @@ -12,8 +12,9 @@
  235.  
  236. import net.sf.l2j.Config;
  237. import net.sf.l2j.gameserver.data.manager.CursedWeaponManager;
  238. +import net.sf.l2j.gameserver.data.xml.DropMonstersData;
  239. import net.sf.l2j.gameserver.data.xml.HerbDropData;
  240. +import net.sf.l2j.gameserver.model.DropMonsters;
  241. import net.sf.l2j.gameserver.model.L2Skill;
  242. import net.sf.l2j.gameserver.model.actor.Attackable;
  243. import net.sf.l2j.gameserver.model.actor.Creature;
  244. @@ -1153,6 +1155,37 @@
  245. }
  246. }
  247.  
  248. + if (Config.MONSTERS_DROPS)
  249. + {
  250. + final DropMonsters monsters = DropMonstersData.getInstance().getNpcs(npcTemplate.getNpcId());
  251. + if (monsters == null)
  252. + return;
  253. +
  254. + int dropChance = monsters.getChance();
  255. +
  256. + // Apply level modifier, if any/wanted.
  257. + if (Config.DEEPBLUE_DROP_RULES)
  258. + {
  259. + int deepBlueDrop = (levelModifier > 0) ? 3 : 1;
  260. +
  261. + // Check if we should apply our maths so deep blue mobs will not drop that easy.
  262. + dropChance = ((monsters.getChance() - ((monsters.getChance() * levelModifier) / 100)) / deepBlueDrop);
  263. + }
  264. +
  265. + if (Config.AUTO_LOOT)
  266. + {
  267. + if (Rnd.get(1, 100) < dropChance)
  268. + {
  269. + final ItemInstance item = player.addItem("", monsters.getItemId(), Rnd.get(monsters.getMinDrop(), monsters.getMaxDrop()), player, true);
  270. + if (item.getItem().getType1() == Item.TYPE1_WEAPON_RING_EARRING_NECKLACE || item.getItem().getType1() == Item.TYPE1_SHIELD_ARMOR)
  271. + {
  272. + if (monsters.hasEnchant() && Rnd.get(1, 100) < monsters.getEnchantChance())
  273. + item.setEnchantLevel(monsters.getEnchant());
  274. + }
  275. + }
  276. + }
  277. + }
  278. +
  279. // Apply special item drop for champions.
  280. if (isChampion() && Config.CHAMPION_REWARD > 0)
  281. {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement