Advertisement
manax182

Magic_Lamp_system

Jan 4th, 2021
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 50.50 KB | None | 0 0
  1. Index: dist/game/config/magic-lamp.ini
  2. IDEA additional info:
  3. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  4. <+>UTF-8
  5. ===================================================================
  6. diff --git a/dist/game/config/magic-lamp.ini b/dist/game/config/magic-lamp.ini
  7. new file mode 100644
  8. --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  9. +++ b/dist/game/config/magic-lamp.ini (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  10. @@ -0,0 +1,6 @@
  11. +enable = true
  12. +game_max_count = 300
  13. +count_per_game = 1
  14. +greater_count_per_game = 10
  15. +max_level_exp = 2000000
  16. +charge = 0.1
  17. \ No newline at end of file
  18. Index: dist/game/data/magic-lamps.xml
  19. IDEA additional info:
  20. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  21. <+>UTF-8
  22. ===================================================================
  23. diff --git a/dist/game/data/magic-lamps.xml b/dist/game/data/magic-lamps.xml
  24. new file mode 100644
  25. --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  26. +++ b/dist/game/data/magic-lamps.xml (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  27. @@ -0,0 +1,12 @@
  28. +<?xml version="1.0" encoding="UTF-8"?>
  29. +<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://l2j.org" xsi:schemaLocation="http://l2j.org xsd/magic-lamps.xsd" >
  30. + <greater_lamp_mode item="91641" count="5" />
  31. + <lamp mode="NORMAL" type="RED" exp="100000000" sp="2700000" chance="20" />
  32. + <lamp mode="NORMAL" type="PURPLE" exp="30000000" sp="810000" chance="35" />
  33. + <lamp mode="NORMAL" type="BLUE" exp="10000000" sp="270000" chance="60" />
  34. + <lamp mode="NORMAL" type="GREEN" exp="5000000" sp="135000" chance="100" />
  35. + <lamp mode="GREATER" type="RED" exp="1200000000" sp="32400000" chance="20" />
  36. + <lamp mode="GREATER" type="PURPLE" exp="360000000" sp="9720000" chance="35" />
  37. + <lamp mode="GREATER" type="BLUE" exp="120000000" sp="3240000" chance="60" />
  38. + <lamp mode="GREATER" type="GREEN" exp="60000000" sp="1620000" chance="100" />
  39. +</list>
  40. \ No newline at end of file
  41. Index: dist/game/data/xsd/magic-lamps.xsd
  42. IDEA additional info:
  43. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  44. <+>UTF-8
  45. ===================================================================
  46. diff --git a/dist/game/data/xsd/magic-lamps.xsd b/dist/game/data/xsd/magic-lamps.xsd
  47. new file mode 100644
  48. --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  49. +++ b/dist/game/data/xsd/magic-lamps.xsd (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  50. @@ -0,0 +1,26 @@
  51. +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  52. + targetNamespace="http://l2j.org"
  53. + xmlns="http://l2j.org"
  54. + elementFormDefault="qualified">
  55. + <xs:element name="list">
  56. + <xs:complexType>
  57. + <xs:sequence>
  58. + <xs:element maxOccurs="unbounded" name="greater_lamp_mode">
  59. + <xs:complexType>
  60. + <xs:attribute name="item" type="xs:unsignedInt" use="required" />
  61. + <xs:attribute name="count" type="xs:unsignedInt" use="required" />
  62. + </xs:complexType>
  63. + </xs:element>
  64. + <xs:element maxOccurs="unbounded" name="lamp">
  65. + <xs:complexType>
  66. + <xs:attribute name="mode" type="xs:string" use="required" />
  67. + <xs:attribute name="type" type="xs:string" use="required" />
  68. + <xs:attribute name="exp" type="xs:unsignedInt" use="required" />
  69. + <xs:attribute name="sp" type="xs:unsignedInt" use="required" />
  70. + <xs:attribute name="chance" type="xs:decimal" use="required" />
  71. + </xs:complexType>
  72. + </xs:element>
  73. + </xs:sequence>
  74. + </xs:complexType>
  75. + </xs:element>
  76. +</xs:schema>
  77. \ No newline at end of file
  78. Index: java/org/l2jmobius/Config.java
  79. IDEA additional info:
  80. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  81. <+>UTF-8
  82. ===================================================================
  83. diff --git a/java/org/l2jmobius/Config.java b/java/org/l2jmobius/Config.java
  84. --- a/java/org/l2jmobius/Config.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
  85. +++ b/java/org/l2jmobius/Config.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  86. @@ -106,7 +106,8 @@
  87. private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt";
  88. private static final String HEXID_FILE = "./config/hexid.txt";
  89. private static final String IPCONFIG_FILE = "./config/ipconfig.xml";
  90. -
  91. + private static final String MAGIC_LAMP_FILE = "./config/magic-lamp.ini";
  92. +
  93. // --------------------------------------------------
  94. // Custom Config File Definitions
  95. // --------------------------------------------------
  96. @@ -845,7 +846,15 @@
  97. public static int MAX_CONNECTION_PER_IP;
  98. public static boolean ENABLE_CMD_LINE_LOGIN;
  99. public static boolean ONLY_CMD_LINE_LOGIN;
  100. -
  101. +
  102. + // Magic Lamp
  103. + public static boolean MAGIC_LAMP_ENABLE;
  104. + public static int MAGIC_LAMP_GAME_MAX_COUNT;
  105. + public static int MAGIC_LAMP_COUNT_PER_GAME;
  106. + public static int MAGIC_LAMP_GREATER_COUNT_PER_GAME;
  107. + public static int MAGIC_LAMP_MAX_LEVEL_EXP;
  108. + public static double MAGIC_LAMP_CHARGE;
  109. +
  110. // GrandBoss Settings
  111.  
  112. // Antharas
  113. @@ -1859,6 +1868,15 @@
  114. TIME_LIMITED_ZONE_RESET_DELAY = timeLimitedZoneSettings.getLong("ResetDelay", 36000000);
  115. TIME_LIMITED_ZONE_TELEPORT_FEE = timeLimitedZoneSettings.getLong("TeleportFee", 10000);
  116.  
  117. + // Load Training Camp config file (if exists)
  118. + final PropertiesParser magicLampSettings = new PropertiesParser(MAGIC_LAMP_FILE);
  119. + MAGIC_LAMP_ENABLE = magicLampSettings.getBoolean("enable", true);
  120. + MAGIC_LAMP_GAME_MAX_COUNT = magicLampSettings.getInt("game_max_count", 300);
  121. + MAGIC_LAMP_COUNT_PER_GAME = magicLampSettings.getInt("count_per_game", 1);
  122. + MAGIC_LAMP_GREATER_COUNT_PER_GAME = magicLampSettings.getInt("greater_count_per_game", 10);
  123. + MAGIC_LAMP_MAX_LEVEL_EXP = magicLampSettings.getInt("max_level_exp", 2000000);
  124. + MAGIC_LAMP_CHARGE = magicLampSettings.getDouble("charge", 0.1);
  125. +
  126. // Load Training Camp config file (if exists)
  127. final PropertiesParser trainingCampSettings = new PropertiesParser(TRAINING_CAMP_CONFIG_FILE);
  128. TRAINING_CAMP_ENABLE = trainingCampSettings.getBoolean("TrainingCampEnable", false);
  129. Index: java/org/l2jmobius/commons/util/Rnd.java
  130. IDEA additional info:
  131. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  132. <+>UTF-8
  133. ===================================================================
  134. diff --git a/java/org/l2jmobius/commons/util/Rnd.java b/java/org/l2jmobius/commons/util/Rnd.java
  135. --- a/java/org/l2jmobius/commons/util/Rnd.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
  136. +++ b/java/org/l2jmobius/commons/util/Rnd.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  137. @@ -16,6 +16,7 @@
  138. */
  139. package org.l2jmobius.commons.util;
  140.  
  141. +import java.util.List;
  142. import java.util.Random;
  143.  
  144. /**
  145. @@ -137,6 +138,18 @@
  146. }
  147. return origin + (((bound - origin) + 1) * RANDOM.get().nextDouble());
  148. }
  149. +
  150. + public static boolean chance(double chance) {
  151. + return chance > 0 && (chance >= 100 || RANDOM.get().nextDouble() * 100 <= chance);
  152. + }
  153. +
  154. + public static <E> E get(List<E> list) {
  155. + if(list.isEmpty())
  156. + return null;
  157. + if(list.size() == 1)
  158. + return list.get(0);
  159. + return list.get(get(list.size()));
  160. + }
  161.  
  162. /**
  163. * @return a random double value between zero (inclusive) and one (exclusive).
  164. Index: java/org/l2jmobius/gameserver/GameServer.java
  165. IDEA additional info:
  166. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  167. <+>UTF-8
  168. ===================================================================
  169. diff --git a/java/org/l2jmobius/gameserver/GameServer.java b/java/org/l2jmobius/gameserver/GameServer.java
  170. --- a/java/org/l2jmobius/gameserver/GameServer.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
  171. +++ b/java/org/l2jmobius/gameserver/GameServer.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  172. @@ -44,66 +44,7 @@
  173. import org.l2jmobius.gameserver.data.sql.ClanTable;
  174. import org.l2jmobius.gameserver.data.sql.CrestTable;
  175. import org.l2jmobius.gameserver.data.sql.OfflineTraderTable;
  176. -import org.l2jmobius.gameserver.data.xml.ActionData;
  177. -import org.l2jmobius.gameserver.data.xml.AdminData;
  178. -import org.l2jmobius.gameserver.data.xml.AppearanceItemData;
  179. -import org.l2jmobius.gameserver.data.xml.ArmorSetData;
  180. -import org.l2jmobius.gameserver.data.xml.AttendanceRewardData;
  181. -import org.l2jmobius.gameserver.data.xml.BeautyShopData;
  182. -import org.l2jmobius.gameserver.data.xml.BuyListData;
  183. -import org.l2jmobius.gameserver.data.xml.CategoryData;
  184. -import org.l2jmobius.gameserver.data.xml.ClanHallData;
  185. -import org.l2jmobius.gameserver.data.xml.ClanRewardData;
  186. -import org.l2jmobius.gameserver.data.xml.ClassListData;
  187. -import org.l2jmobius.gameserver.data.xml.CombinationItemsData;
  188. -import org.l2jmobius.gameserver.data.xml.CubicData;
  189. -import org.l2jmobius.gameserver.data.xml.DailyMissionData;
  190. -import org.l2jmobius.gameserver.data.xml.DoorData;
  191. -import org.l2jmobius.gameserver.data.xml.ElementalSpiritData;
  192. -import org.l2jmobius.gameserver.data.xml.EnchantItemData;
  193. -import org.l2jmobius.gameserver.data.xml.EnchantItemGroupsData;
  194. -import org.l2jmobius.gameserver.data.xml.EnchantItemHPBonusData;
  195. -import org.l2jmobius.gameserver.data.xml.EnchantItemOptionsData;
  196. -import org.l2jmobius.gameserver.data.xml.EnchantSkillGroupsData;
  197. -import org.l2jmobius.gameserver.data.xml.EnsoulData;
  198. -import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeData;
  199. -import org.l2jmobius.gameserver.data.xml.EventEngineData;
  200. -import org.l2jmobius.gameserver.data.xml.ExperienceData;
  201. -import org.l2jmobius.gameserver.data.xml.FakePlayerData;
  202. -import org.l2jmobius.gameserver.data.xml.FenceData;
  203. -import org.l2jmobius.gameserver.data.xml.FishingData;
  204. -import org.l2jmobius.gameserver.data.xml.HennaData;
  205. -import org.l2jmobius.gameserver.data.xml.HitConditionBonusData;
  206. -import org.l2jmobius.gameserver.data.xml.InitialEquipmentData;
  207. -import org.l2jmobius.gameserver.data.xml.InitialShortcutData;
  208. -import org.l2jmobius.gameserver.data.xml.ItemCrystallizationData;
  209. -import org.l2jmobius.gameserver.data.xml.KarmaData;
  210. -import org.l2jmobius.gameserver.data.xml.LCoinShopData;
  211. -import org.l2jmobius.gameserver.data.xml.LuckyGameData;
  212. -import org.l2jmobius.gameserver.data.xml.MultisellData;
  213. -import org.l2jmobius.gameserver.data.xml.NpcData;
  214. -import org.l2jmobius.gameserver.data.xml.NpcNameLocalisationData;
  215. -import org.l2jmobius.gameserver.data.xml.OptionData;
  216. -import org.l2jmobius.gameserver.data.xml.PetDataTable;
  217. -import org.l2jmobius.gameserver.data.xml.PetSkillData;
  218. -import org.l2jmobius.gameserver.data.xml.PlayerTemplateData;
  219. -import org.l2jmobius.gameserver.data.xml.PlayerXpPercentLostData;
  220. -import org.l2jmobius.gameserver.data.xml.PrimeShopData;
  221. -import org.l2jmobius.gameserver.data.xml.RecipeData;
  222. -import org.l2jmobius.gameserver.data.xml.ResidenceFunctionsData;
  223. -import org.l2jmobius.gameserver.data.xml.SayuneData;
  224. -import org.l2jmobius.gameserver.data.xml.SecondaryAuthData;
  225. -import org.l2jmobius.gameserver.data.xml.SendMessageLocalisationData;
  226. -import org.l2jmobius.gameserver.data.xml.ShuttleData;
  227. -import org.l2jmobius.gameserver.data.xml.SiegeScheduleData;
  228. -import org.l2jmobius.gameserver.data.xml.SkillData;
  229. -import org.l2jmobius.gameserver.data.xml.SkillTreeData;
  230. -import org.l2jmobius.gameserver.data.xml.SpawnData;
  231. -import org.l2jmobius.gameserver.data.xml.StaticObjectData;
  232. -import org.l2jmobius.gameserver.data.xml.TeleportListData;
  233. -import org.l2jmobius.gameserver.data.xml.TeleporterData;
  234. -import org.l2jmobius.gameserver.data.xml.TransformData;
  235. -import org.l2jmobius.gameserver.data.xml.VariationData;
  236. +import org.l2jmobius.gameserver.data.xml.*;
  237. import org.l2jmobius.gameserver.geoengine.GeoEngine;
  238. import org.l2jmobius.gameserver.handler.ConditionHandler;
  239. import org.l2jmobius.gameserver.handler.DailyMissionHandler;
  240. @@ -280,6 +221,7 @@
  241. CommissionManager.getInstance();
  242. LuckyGameData.getInstance();
  243. AttendanceRewardData.getInstance();
  244. + MagicLampData.init();
  245.  
  246. printSection("Characters");
  247. ClassListData.getInstance();
  248. Index: java/org/l2jmobius/gameserver/data/xml/MagicLampData.java
  249. IDEA additional info:
  250. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  251. <+>UTF-8
  252. ===================================================================
  253. diff --git a/java/org/l2jmobius/gameserver/data/xml/MagicLampData.java b/java/org/l2jmobius/gameserver/data/xml/MagicLampData.java
  254. new file mode 100644
  255. --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  256. +++ b/java/org/l2jmobius/gameserver/data/xml/MagicLampData.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  257. @@ -0,0 +1,96 @@
  258. +/*
  259. + * Copyright © 2019-2020 L2JOrg
  260. + *
  261. + * This file is part of the L2JOrg project.
  262. + *
  263. + * L2JOrg is free software: you can redistribute it and/or modify
  264. + * it under the terms of the GNU General Public License as published by
  265. + * the Free Software Foundation, either version 3 of the License, or
  266. + * (at your option) any later version.
  267. + *
  268. + * L2JOrg is distributed in the hope that it will be useful,
  269. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  270. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  271. + * General Public License for more details.
  272. + *
  273. + * You should have received a copy of the GNU General Public License
  274. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  275. + */
  276. +package org.l2jmobius.gameserver.data.xml;
  277. +
  278. +import org.l2jmobius.Config;
  279. +import org.l2jmobius.commons.util.IXmlReader;
  280. +import org.l2jmobius.gameserver.model.GreaterMagicLampHolder;
  281. +import org.l2jmobius.gameserver.model.MagicLampHolder;
  282. +import org.l2jmobius.gameserver.model.StatSet;
  283. +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
  284. +import org.l2jmobius.gameserver.network.serverpackets.magiclamp.ExMagicLampExpInfoUI;
  285. +import org.w3c.dom.Document;
  286. +
  287. +import java.io.File;
  288. +import java.util.ArrayList;
  289. +import java.util.List;
  290. +
  291. +/**
  292. + * @author L2CCCP
  293. + */
  294. +public class MagicLampData implements IXmlReader {
  295. + private final List<GreaterMagicLampHolder> greater_lamps = new ArrayList<>();
  296. + private final List<MagicLampHolder> lamps = new ArrayList<>();
  297. +
  298. + @Override
  299. + public void load() {
  300. + lamps.clear();
  301. + parseDatapackFile("data/magic-lamps.xml");
  302. + LOGGER.info("Loaded " + lamps.size() + " magic lamp(s) data.");
  303. + }
  304. +
  305. + @Override
  306. + public void parseDocument(Document doc, File f) {
  307. + forEach(doc, "list", listNode ->
  308. + forEach(listNode, node -> {
  309. + if (node.getNodeName().equalsIgnoreCase("greater_lamp_mode")) {
  310. + final GreaterMagicLampHolder lamp = new GreaterMagicLampHolder(new StatSet(parseAttributes(node)));
  311. + greater_lamps.add(lamp);
  312. + } else {
  313. + final MagicLampHolder lamp = new MagicLampHolder(new StatSet(parseAttributes(node)));
  314. + lamps.add(lamp);
  315. + }
  316. + })
  317. + );
  318. + }
  319. +
  320. + public void addLampExp(final PlayerInstance player, final double exp) {
  321. + if (Config.MAGIC_LAMP_ENABLE) {
  322. + var lamp_exp = (int) (exp * Config.MAGIC_LAMP_CHARGE);
  323. + var calc = lamp_exp + player.getLampExp();
  324. + if (calc > Config.MAGIC_LAMP_MAX_LEVEL_EXP) {
  325. + calc %= Config.MAGIC_LAMP_MAX_LEVEL_EXP;
  326. + var have_lamps = player.getLampCount();
  327. + player.setLampCount(have_lamps + 1);
  328. + }
  329. + player.setLampExp(calc);
  330. + player.sendPacket(new ExMagicLampExpInfoUI(player));
  331. + }
  332. + }
  333. +
  334. + public List<MagicLampHolder> getLamps() {
  335. + return lamps;
  336. + }
  337. +
  338. + public List<GreaterMagicLampHolder> getGreaterLamps() {
  339. + return greater_lamps;
  340. + }
  341. +
  342. + public static void init() {
  343. + getInstance().load();
  344. + }
  345. +
  346. + public static MagicLampData getInstance() {
  347. + return Singleton.INSTANCE;
  348. + }
  349. +
  350. + private static class Singleton {
  351. + protected static final MagicLampData INSTANCE = new MagicLampData();
  352. + }
  353. +}
  354. \ No newline at end of file
  355. Index: java/org/l2jmobius/gameserver/enums/LampMode.java
  356. IDEA additional info:
  357. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  358. <+>UTF-8
  359. ===================================================================
  360. diff --git a/java/org/l2jmobius/gameserver/enums/LampMode.java b/java/org/l2jmobius/gameserver/enums/LampMode.java
  361. new file mode 100644
  362. --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  363. +++ b/java/org/l2jmobius/gameserver/enums/LampMode.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  364. @@ -0,0 +1,33 @@
  365. +/*
  366. + * Copyright © 2019-2020 L2JOrg
  367. + *
  368. + * This file is part of the L2JOrg project.
  369. + *
  370. + * L2JOrg is free software: you can redistribute it and/or modify
  371. + * it under the terms of the GNU General Public License as published by
  372. + * the Free Software Foundation, either version 3 of the License, or
  373. + * (at your option) any later version.
  374. + *
  375. + * L2JOrg is distributed in the hope that it will be useful,
  376. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  377. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  378. + * General Public License for more details.
  379. + *
  380. + * You should have received a copy of the GNU General Public License
  381. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  382. + */
  383. +package org.l2jmobius.gameserver.enums;
  384. +
  385. +import java.util.Arrays;
  386. +
  387. +/**
  388. + * @author L2CCCP
  389. + */
  390. +public enum LampMode {
  391. + NORMAL,
  392. + GREATER;
  393. +
  394. + public static LampMode getByMode(final byte mode) {
  395. + return Arrays.stream(values()).filter(type -> type.ordinal() == mode).findAny().orElse(NORMAL);
  396. + }
  397. +}
  398. \ No newline at end of file
  399. Index: java/org/l2jmobius/gameserver/enums/LampType.java
  400. IDEA additional info:
  401. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  402. <+>UTF-8
  403. ===================================================================
  404. diff --git a/java/org/l2jmobius/gameserver/enums/LampType.java b/java/org/l2jmobius/gameserver/enums/LampType.java
  405. new file mode 100644
  406. --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  407. +++ b/java/org/l2jmobius/gameserver/enums/LampType.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  408. @@ -0,0 +1,38 @@
  409. +/*
  410. + * Copyright © 2019-2020 L2JOrg
  411. + *
  412. + * This file is part of the L2JOrg project.
  413. + *
  414. + * L2JOrg is free software: you can redistribute it and/or modify
  415. + * it under the terms of the GNU General Public License as published by
  416. + * the Free Software Foundation, either version 3 of the License, or
  417. + * (at your option) any later version.
  418. + *
  419. + * L2JOrg is distributed in the hope that it will be useful,
  420. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  421. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  422. + * General Public License for more details.
  423. + *
  424. + * You should have received a copy of the GNU General Public License
  425. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  426. + */
  427. +package org.l2jmobius.gameserver.enums;
  428. +
  429. +/**
  430. + * @author L2CCCP
  431. + */
  432. +public enum LampType {
  433. + RED(1),
  434. + PURPLE(2),
  435. + BLUE(3),
  436. + GREEN(4);
  437. + private int grade;
  438. +
  439. + LampType(int grade) {
  440. + this.grade = grade;
  441. + }
  442. +
  443. + public int getGrade() {
  444. + return grade;
  445. + }
  446. +}
  447. \ No newline at end of file
  448. Index: java/org/l2jmobius/gameserver/model/GreaterMagicLampHolder.java
  449. IDEA additional info:
  450. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  451. <+>UTF-8
  452. ===================================================================
  453. diff --git a/java/org/l2jmobius/gameserver/model/GreaterMagicLampHolder.java b/java/org/l2jmobius/gameserver/model/GreaterMagicLampHolder.java
  454. new file mode 100644
  455. --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  456. +++ b/java/org/l2jmobius/gameserver/model/GreaterMagicLampHolder.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  457. @@ -0,0 +1,40 @@
  458. +/*
  459. + * Copyright © 2019-2020 L2JOrg
  460. + *
  461. + * This file is part of the L2JOrg project.
  462. + *
  463. + * L2JOrg is free software: you can redistribute it and/or modify
  464. + * it under the terms of the GNU General Public License as published by
  465. + * the Free Software Foundation, either version 3 of the License, or
  466. + * (at your option) any later version.
  467. + *
  468. + * L2JOrg is distributed in the hope that it will be useful,
  469. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  470. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  471. + * General Public License for more details.
  472. + *
  473. + * You should have received a copy of the GNU General Public License
  474. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  475. + */
  476. +package org.l2jmobius.gameserver.model;
  477. +
  478. +/**
  479. + * @author L2CCCP
  480. + */
  481. +public class GreaterMagicLampHolder {
  482. + private final int item;
  483. + private final long count;
  484. +
  485. + public GreaterMagicLampHolder(StatSet params) {
  486. + this.item = params.getInt("item");
  487. + this.count = params.getLong("count");
  488. + }
  489. +
  490. + public int getItem() {
  491. + return item;
  492. + }
  493. +
  494. + public long getCount() {
  495. + return count;
  496. + }
  497. +}
  498. \ No newline at end of file
  499. Index: java/org/l2jmobius/gameserver/model/MagicLamp.java
  500. IDEA additional info:
  501. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  502. <+>UTF-8
  503. ===================================================================
  504. diff --git a/java/org/l2jmobius/gameserver/model/MagicLamp.java b/java/org/l2jmobius/gameserver/model/MagicLamp.java
  505. new file mode 100644
  506. --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  507. +++ b/java/org/l2jmobius/gameserver/model/MagicLamp.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  508. @@ -0,0 +1,58 @@
  509. +/*
  510. + * Copyright © 2019-2020 L2JOrg
  511. + *
  512. + * This file is part of the L2JOrg project.
  513. + *
  514. + * L2JOrg is free software: you can redistribute it and/or modify
  515. + * it under the terms of the GNU General Public License as published by
  516. + * the Free Software Foundation, either version 3 of the License, or
  517. + * (at your option) any later version.
  518. + *
  519. + * L2JOrg is distributed in the hope that it will be useful,
  520. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  521. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  522. + * General Public License for more details.
  523. + *
  524. + * You should have received a copy of the GNU General Public License
  525. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  526. + */
  527. +package org.l2jmobius.gameserver.model;
  528. +
  529. +import org.l2jmobius.gameserver.data.xml.MagicLampHolder;
  530. +import org.l2jmobius.gameserver.enums.LampType;
  531. +
  532. +/**
  533. + * @author L2CCCP
  534. + */
  535. +public class MagicLamp {
  536. + private final MagicLampHolder lamp;
  537. + private int count;
  538. + private long exp;
  539. + private long sp;
  540. +
  541. + public MagicLamp(MagicLampHolder lamp) {
  542. + this.lamp = lamp;
  543. + }
  544. +
  545. + public void inc() {
  546. + count++;
  547. + exp += lamp.getExp();
  548. + sp += lamp.getSp();
  549. + }
  550. +
  551. + public LampType getType() {
  552. + return lamp.getType();
  553. + }
  554. +
  555. + public int getCount() {
  556. + return count;
  557. + }
  558. +
  559. + public long getExp() {
  560. + return exp;
  561. + }
  562. +
  563. + public long getSp() {
  564. + return sp;
  565. + }
  566. +}
  567. \ No newline at end of file
  568. Index: java/org/l2jmobius/gameserver/model/MagicLampHolder.java
  569. IDEA additional info:
  570. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  571. <+>UTF-8
  572. ===================================================================
  573. diff --git a/java/org/l2jmobius/gameserver/model/MagicLampHolder.java b/java/org/l2jmobius/gameserver/model/MagicLampHolder.java
  574. new file mode 100644
  575. --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  576. +++ b/java/org/l2jmobius/gameserver/model/MagicLampHolder.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  577. @@ -0,0 +1,61 @@
  578. +/*
  579. + * Copyright © 2019-2020 L2JOrg
  580. + *
  581. + * This file is part of the L2JOrg project.
  582. + *
  583. + * L2JOrg is free software: you can redistribute it and/or modify
  584. + * it under the terms of the GNU General Public License as published by
  585. + * the Free Software Foundation, either version 3 of the License, or
  586. + * (at your option) any later version.
  587. + *
  588. + * L2JOrg is distributed in the hope that it will be useful,
  589. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  590. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  591. + * General Public License for more details.
  592. + *
  593. + * You should have received a copy of the GNU General Public License
  594. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  595. + */
  596. +package org.l2jmobius.gameserver.model;
  597. +
  598. +import org.l2jmobius.gameserver.enums.LampMode;
  599. +import org.l2jmobius.gameserver.enums.LampType;
  600. +
  601. +/**
  602. + * @author L2CCCP
  603. + */
  604. +public class MagicLampHolder {
  605. + private final LampMode mode;
  606. + private final LampType type;
  607. + private final long exp;
  608. + private final long sp;
  609. + private final double chance;
  610. +
  611. + public MagicLampHolder(StatSet params) {
  612. + this.mode = params.getEnum("mode", LampMode.class);
  613. + this.type = params.getEnum("type", LampType.class);
  614. + this.exp = params.getLong("exp");
  615. + this.sp = params.getLong("sp");
  616. + this.chance = params.getDouble("chance");
  617. + }
  618. +
  619. + public LampMode getMode() {
  620. + return mode;
  621. + }
  622. +
  623. + public LampType getType() {
  624. + return type;
  625. + }
  626. +
  627. + public long getExp() {
  628. + return exp;
  629. + }
  630. +
  631. + public long getSp() {
  632. + return sp;
  633. + }
  634. +
  635. + public double getChance() {
  636. + return chance;
  637. + }
  638. +}
  639. \ No newline at end of file
  640. Index: java/org/l2jmobius/gameserver/model/Party.java
  641. IDEA additional info:
  642. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  643. <+>UTF-8
  644. ===================================================================
  645. diff --git a/java/org/l2jmobius/gameserver/model/Party.java b/java/org/l2jmobius/gameserver/model/Party.java
  646. --- a/java/org/l2jmobius/gameserver/model/Party.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
  647. +++ b/java/org/l2jmobius/gameserver/model/Party.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  648. @@ -34,6 +34,7 @@
  649. import org.l2jmobius.commons.util.Rnd;
  650. import org.l2jmobius.gameserver.GameTimeController;
  651. import org.l2jmobius.gameserver.data.ItemTable;
  652. +import org.l2jmobius.gameserver.data.xml.MagicLampData;
  653. import org.l2jmobius.gameserver.enums.PartyDistributionType;
  654. import org.l2jmobius.gameserver.enums.StatusUpdateType;
  655. import org.l2jmobius.gameserver.instancemanager.DuelManager;
  656. @@ -896,6 +897,7 @@
  657. }
  658. member.updateSayhaGracePoints(target.getSayhaGracePoints(member.getLevel(), exp, target.isRaid()), true, false);
  659. PcCafePointsManager.getInstance().givePcCafePoint(member, exp);
  660. + MagicLampData.getInstance().addLampExp(member, exp);
  661. }
  662. }
  663. else
  664. Index: java/org/l2jmobius/gameserver/model/actor/Attackable.java
  665. IDEA additional info:
  666. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  667. <+>UTF-8
  668. ===================================================================
  669. diff --git a/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/java/org/l2jmobius/gameserver/model/actor/Attackable.java
  670. --- a/java/org/l2jmobius/gameserver/model/actor/Attackable.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
  671. +++ b/java/org/l2jmobius/gameserver/model/actor/Attackable.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  672. @@ -35,6 +35,7 @@
  673. import org.l2jmobius.gameserver.ai.CtrlIntention;
  674. import org.l2jmobius.gameserver.data.EventDroplist;
  675. import org.l2jmobius.gameserver.data.ItemTable;
  676. +import org.l2jmobius.gameserver.data.xml.MagicLampData;
  677. import org.l2jmobius.gameserver.enums.ChatType;
  678. import org.l2jmobius.gameserver.enums.DropType;
  679. import org.l2jmobius.gameserver.enums.ElementalType;
  680. @@ -525,6 +526,7 @@
  681. }
  682. attacker.updateSayhaGracePoints(getSayhaGracePoints(attacker.getLevel(), exp, _isRaid), true, false);
  683. PcCafePointsManager.getInstance().givePcCafePoint(attacker, exp);
  684. + MagicLampData.getInstance().addLampExp(attacker, exp);
  685. }
  686.  
  687. rewardAttributeExp(attacker, damage, totalDamage);
  688. Index: java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java
  689. IDEA additional info:
  690. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  691. <+>UTF-8
  692. ===================================================================
  693. diff --git a/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java
  694. --- a/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
  695. +++ b/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  696. @@ -1207,7 +1207,23 @@
  697. {
  698. getVariables().set(PlayerVariables.HAIR_ACCESSORY_VARIABLE_NAME, enabled);
  699. }
  700. -
  701. +
  702. + public int getLampExp() {
  703. + return getVariables().getInt(PlayerVariables.MAGIC_LAMP_EXP);
  704. + }
  705. +
  706. + public int getLampCount() {
  707. + return getVariables().getInt(PlayerVariables.MAGIC_LAMP_COUNT);
  708. + }
  709. +
  710. + public void setLampExp(int exp) {
  711. + getVariables().set(PlayerVariables.MAGIC_LAMP_EXP, exp);
  712. + }
  713. +
  714. + public void setLampCount(int count) {
  715. + getVariables().set(PlayerVariables.MAGIC_LAMP_COUNT, count);
  716. + }
  717. +
  718. /**
  719. * @return the base PlayerTemplate link to the PlayerInstance.
  720. */
  721. Index: java/org/l2jmobius/gameserver/model/events/AbstractScript.java
  722. IDEA additional info:
  723. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  724. <+>UTF-8
  725. ===================================================================
  726. diff --git a/java/org/l2jmobius/gameserver/model/events/AbstractScript.java b/java/org/l2jmobius/gameserver/model/events/AbstractScript.java
  727. --- a/java/org/l2jmobius/gameserver/model/events/AbstractScript.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
  728. +++ b/java/org/l2jmobius/gameserver/model/events/AbstractScript.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  729. @@ -39,6 +39,7 @@
  730. import org.l2jmobius.gameserver.ai.CtrlIntention;
  731. import org.l2jmobius.gameserver.data.ItemTable;
  732. import org.l2jmobius.gameserver.data.xml.DoorData;
  733. +import org.l2jmobius.gameserver.data.xml.MagicLampData;
  734. import org.l2jmobius.gameserver.data.xml.NpcData;
  735. import org.l2jmobius.gameserver.enums.AttributeType;
  736. import org.l2jmobius.gameserver.enums.Movie;
  737. @@ -3069,6 +3070,7 @@
  738. }
  739. player.addExpAndSp((long) player.getStat().getValue(Stat.EXPSP_RATE, (exp * Config.RATE_QUEST_REWARD_XP)), (int) player.getStat().getValue(Stat.EXPSP_RATE, (sp * Config.RATE_QUEST_REWARD_SP)));
  740. PcCafePointsManager.getInstance().givePcCafePoint(player, (long) (exp * Config.RATE_QUEST_REWARD_XP));
  741. + MagicLampData.getInstance().addLampExp(player, exp);
  742. }
  743.  
  744. /**
  745. Index: java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
  746. IDEA additional info:
  747. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  748. <+>UTF-8
  749. ===================================================================
  750. diff --git a/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java b/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
  751. --- a/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
  752. +++ b/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  753. @@ -71,6 +71,8 @@
  754. public static final String STAT_WIT = "STAT_WIT";
  755. public static final String STAT_MEN = "STAT_MEN";
  756. public static final String FAVORITE_TELEPORTS = "FAVORITE_TELEPORTS";
  757. + public static final String MAGIC_LAMP_EXP = "MAGIC_LAMP_EXP";
  758. + public static final String MAGIC_LAMP_COUNT = "MAGIC_LAMP_COUNT";
  759.  
  760. private final int _objectId;
  761.  
  762. Index: java/org/l2jmobius/gameserver/network/ExIncomingPackets.java
  763. IDEA additional info:
  764. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  765. <+>UTF-8
  766. ===================================================================
  767. diff --git a/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java
  768. --- a/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
  769. +++ b/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  770. @@ -81,6 +81,8 @@
  771. import org.l2jmobius.gameserver.network.clientpackets.limitshop.RequestPurchaseLimitShopItemList;
  772. import org.l2jmobius.gameserver.network.clientpackets.luckygame.RequestLuckyGamePlay;
  773. import org.l2jmobius.gameserver.network.clientpackets.luckygame.RequestLuckyGameStartInfo;
  774. +import org.l2jmobius.gameserver.network.clientpackets.magiclamp.ExMagicLampGameInfo;
  775. +import org.l2jmobius.gameserver.network.clientpackets.magiclamp.ExMagicLampGameStart;
  776. import org.l2jmobius.gameserver.network.clientpackets.mentoring.ConfirmMenteeAdd;
  777. import org.l2jmobius.gameserver.network.clientpackets.mentoring.RequestMenteeAdd;
  778. import org.l2jmobius.gameserver.network.clientpackets.mentoring.RequestMenteeWaitingList;
  779. @@ -491,8 +493,8 @@
  780. EX_COSTUME_EXTRACT(0x16C, null, ConnectionState.IN_GAME),
  781. EX_COSTUME_LOCK(0x16D, null, ConnectionState.IN_GAME),
  782. EX_COSTUME_CHANGE_SHORTCUT(0x16E, null, ConnectionState.IN_GAME),
  783. - EX_MAGICLAMP_GAME_INFO(0x16F, null, ConnectionState.IN_GAME),
  784. - EX_MAGICLAMP_GAME_START(0x170, null, ConnectionState.IN_GAME),
  785. + EX_MAGICLAMP_GAME_INFO(0x16F, ExMagicLampGameInfo::new, ConnectionState.IN_GAME),
  786. + EX_MAGICLAMP_GAME_START(0x170, ExMagicLampGameStart::new, ConnectionState.IN_GAME),
  787. EX_ACTIVATE_AUTO_SHORTCUT(0x171, ExRequestActivateAutoShortcut::new, ConnectionState.IN_GAME),
  788. EX_PREMIUM_MANAGER_LINK_HTML(0x172, null, ConnectionState.IN_GAME),
  789. EX_PREMIUM_MANAGER_PASS_CMD_TO_SERVER(0x173, null, ConnectionState.IN_GAME),
  790. Index: java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java
  791. IDEA additional info:
  792. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  793. <+>UTF-8
  794. ===================================================================
  795. diff --git a/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java
  796. --- a/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
  797. +++ b/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  798. @@ -107,6 +107,7 @@
  799. import org.l2jmobius.gameserver.network.serverpackets.dailymission.ExOneDayReceiveRewardList;
  800. import org.l2jmobius.gameserver.network.serverpackets.friend.L2FriendList;
  801. import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExBloodyCoinCount;
  802. +import org.l2jmobius.gameserver.network.serverpackets.magiclamp.ExMagicLampExpInfoUI;
  803. import org.l2jmobius.gameserver.util.BuilderUtil;
  804.  
  805.  
  806. @@ -635,6 +636,8 @@
  807. player.sendPacket(new ExWorldChatCnt(player));
  808. }
  809. player.sendPacket(new ExConnectedTimeAndGettableReward(player));
  810. + if (Config.MAGIC_LAMP_ENABLE)
  811. + player.sendPacket(new ExMagicLampExpInfoUI(player));
  812. player.sendPacket(new ExOneDayReceiveRewardList(player, true));
  813.  
  814. // Handle soulshots, disable all on EnterWorld
  815. Index: java/org/l2jmobius/gameserver/network/clientpackets/magiclamp/ExMagicLampGameInfo.java
  816. IDEA additional info:
  817. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  818. <+>UTF-8
  819. ===================================================================
  820. diff --git a/java/org/l2jmobius/gameserver/network/clientpackets/magiclamp/ExMagicLampGameInfo.java b/java/org/l2jmobius/gameserver/network/clientpackets/magiclamp/ExMagicLampGameInfo.java
  821. new file mode 100644
  822. --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  823. +++ b/java/org/l2jmobius/gameserver/network/clientpackets/magiclamp/ExMagicLampGameInfo.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  824. @@ -0,0 +1,47 @@
  825. +/*
  826. + * Copyright © 2019-2020 L2JOrg
  827. + *
  828. + * This file is part of the L2JOrg project.
  829. + *
  830. + * L2JOrg is free software: you can redistribute it and/or modify
  831. + * it under the terms of the GNU General Public License as published by
  832. + * the Free Software Foundation, either version 3 of the License, or
  833. + * (at your option) any later version.
  834. + *
  835. + * L2JOrg is distributed in the hope that it will be useful,
  836. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  837. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  838. + * General Public License for more details.
  839. + *
  840. + * You should have received a copy of the GNU General Public License
  841. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  842. + */
  843. +package org.l2jmobius.gameserver.network.clientpackets.magiclamp;
  844. +
  845. +import org.l2jmobius.commons.network.PacketReader;
  846. +import org.l2jmobius.gameserver.network.GameClient;
  847. +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
  848. +import org.l2jmobius.gameserver.network.serverpackets.magiclamp.ExMagicLampGameInfoUI;
  849. +
  850. +/**
  851. + * @author L2CCCP
  852. + */
  853. +public class ExMagicLampGameInfo implements IClientIncomingPacket {
  854. + private byte mode;
  855. +
  856. + @Override
  857. + public boolean read(GameClient client, PacketReader packet) {
  858. + mode = (byte) packet.readC(); // cGameMode
  859. + return true;
  860. + }
  861. +
  862. + @Override
  863. + public void run(GameClient client) {
  864. + var player = client.getPlayer();
  865. + if (player == null) {
  866. + return;
  867. + }
  868. +
  869. + player.sendPacket(new ExMagicLampGameInfoUI(player, mode, 1));
  870. + }
  871. +}
  872. \ No newline at end of file
  873. Index: java/org/l2jmobius/gameserver/network/clientpackets/magiclamp/ExMagicLampGameStart.java
  874. IDEA additional info:
  875. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  876. <+>UTF-8
  877. ===================================================================
  878. diff --git a/java/org/l2jmobius/gameserver/network/clientpackets/magiclamp/ExMagicLampGameStart.java b/java/org/l2jmobius/gameserver/network/clientpackets/magiclamp/ExMagicLampGameStart.java
  879. new file mode 100644
  880. --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  881. +++ b/java/org/l2jmobius/gameserver/network/clientpackets/magiclamp/ExMagicLampGameStart.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  882. @@ -0,0 +1,49 @@
  883. +/*
  884. + * Copyright © 2019-2020 L2JOrg
  885. + *
  886. + * This file is part of the L2JOrg project.
  887. + *
  888. + * L2JOrg is free software: you can redistribute it and/or modify
  889. + * it under the terms of the GNU General Public License as published by
  890. + * the Free Software Foundation, either version 3 of the License, or
  891. + * (at your option) any later version.
  892. + *
  893. + * L2JOrg is distributed in the hope that it will be useful,
  894. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  895. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  896. + * General Public License for more details.
  897. + *
  898. + * You should have received a copy of the GNU General Public License
  899. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  900. + */
  901. +package org.l2jmobius.gameserver.network.clientpackets.magiclamp;
  902. +
  903. +import org.l2jmobius.commons.network.PacketReader;
  904. +import org.l2jmobius.gameserver.network.GameClient;
  905. +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
  906. +import org.l2jmobius.gameserver.network.serverpackets.magiclamp.ExMagicLampGameResult;
  907. +
  908. +/**
  909. + * @author L2CCCP
  910. + */
  911. +public class ExMagicLampGameStart implements IClientIncomingPacket {
  912. + private int count;
  913. + private byte mode;
  914. +
  915. + @Override
  916. + public boolean read(GameClient client, PacketReader packet) {
  917. + count = packet.readD(); // nMagicLampGameCCount
  918. + mode = (byte) packet.readC(); // cGameMode
  919. + return true;
  920. + }
  921. +
  922. + @Override
  923. + public void run(GameClient client) {
  924. + var player = client.getPlayer();
  925. + if (player == null) {
  926. + return;
  927. + }
  928. +
  929. + client.sendPacket(new ExMagicLampGameResult(player, count, mode));
  930. + }
  931. +}
  932. Index: java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagiclampExpInfo.java
  933. IDEA additional info:
  934. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  935. <+>UTF-8
  936. ===================================================================
  937. diff --git a/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagiclampExpInfo.java b/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampExpInfoUI.java
  938. rename from java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagiclampExpInfo.java
  939. rename to java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampExpInfoUI.java
  940. --- a/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagiclampExpInfo.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
  941. +++ b/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampExpInfoUI.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  942. @@ -16,33 +16,29 @@
  943. */
  944. package org.l2jmobius.gameserver.network.serverpackets.magiclamp;
  945.  
  946. +import org.l2jmobius.Config;
  947. import org.l2jmobius.commons.network.PacketWriter;
  948. import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
  949. import org.l2jmobius.gameserver.network.OutgoingPackets;
  950. import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
  951.  
  952. /**
  953. - * @author Mobius
  954. + * @author L2CCCP
  955. */
  956. -public class ExMagiclampExpInfo implements IClientOutgoingPacket
  957. -{
  958. - private final PlayerInstance _player;
  959. -
  960. - public ExMagiclampExpInfo(PlayerInstance player)
  961. - {
  962. - _player = player;
  963. - }
  964. -
  965. - @Override
  966. - public boolean write(PacketWriter packet)
  967. - {
  968. - OutgoingPackets.EX_MAGICLAMP_EXP_INFO.writeId(packet);
  969. -
  970. - packet.writeD(1); // IsOpen
  971. - packet.writeD(10000); // MaxMagicLampExp
  972. - packet.writeD(1); // MagicLampExp
  973. - packet.writeD(1); // MagicLampCount
  974. -
  975. - return true;
  976. - }
  977. +public class ExMagicLampExpInfoUI implements IClientOutgoingPacket {
  978. + private final PlayerInstance player;
  979. +
  980. + public ExMagicLampExpInfoUI(PlayerInstance player) {
  981. + this.player = player;
  982. + }
  983. +
  984. + @Override
  985. + public boolean write(PacketWriter packet) {
  986. + OutgoingPackets.EX_MAGICLAMP_EXP_INFO.writeId(packet);
  987. + packet.writeD(Config.MAGIC_LAMP_ENABLE ? 0x01 : 0x00); // IsOpen
  988. + packet.writeD(Config.MAGIC_LAMP_MAX_LEVEL_EXP); // MaxMagicLampExp
  989. + packet.writeD(player.getLampExp()); // MagicLampExp
  990. + packet.writeD(player.getLampCount()); // MagicLampCount
  991. + return true;
  992. + }
  993. }
  994. \ No newline at end of file
  995. Index: java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampGameInfoUI.java
  996. IDEA additional info:
  997. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  998. <+>UTF-8
  999. ===================================================================
  1000. diff --git a/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampGameInfoUI.java b/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampGameInfoUI.java
  1001. new file mode 100644
  1002. --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  1003. +++ b/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampGameInfoUI.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  1004. @@ -0,0 +1,68 @@
  1005. +/*
  1006. + * Copyright © 2019-2020 L2JOrg
  1007. + *
  1008. + * This file is part of the L2JOrg project.
  1009. + *
  1010. + * L2JOrg is free software: you can redistribute it and/or modify
  1011. + * it under the terms of the GNU General Public License as published by
  1012. + * the Free Software Foundation, either version 3 of the License, or
  1013. + * (at your option) any later version.
  1014. + *
  1015. + * L2JOrg is distributed in the hope that it will be useful,
  1016. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1017. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1018. + * General Public License for more details.
  1019. + *
  1020. + * You should have received a copy of the GNU General Public License
  1021. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  1022. + */
  1023. +package org.l2jmobius.gameserver.network.serverpackets.magiclamp;
  1024. +
  1025. +import org.l2jmobius.Config;
  1026. +import org.l2jmobius.commons.network.PacketWriter;
  1027. +import org.l2jmobius.gameserver.data.xml.MagicLampData;
  1028. +import org.l2jmobius.gameserver.enums.LampMode;
  1029. +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
  1030. +import org.l2jmobius.gameserver.network.OutgoingPackets;
  1031. +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
  1032. +
  1033. +/**
  1034. + * @author L2CCCP
  1035. + */
  1036. +public class ExMagicLampGameInfoUI implements IClientOutgoingPacket {
  1037. + private final PlayerInstance player;
  1038. + private final byte mode;
  1039. + private final int count;
  1040. +
  1041. + public ExMagicLampGameInfoUI(PlayerInstance player, final byte mode, final int count) {
  1042. + this.player = player;
  1043. + this.mode = mode;
  1044. + this.count = count;
  1045. + }
  1046. +
  1047. + @Override
  1048. + public boolean write(PacketWriter packet) {
  1049. + OutgoingPackets.EX_MAGICLAMP_GAME_INFO.writeId(packet);
  1050. + packet.writeD(Config.MAGIC_LAMP_GAME_MAX_COUNT); // nMagicLampGameMaxCCount
  1051. + packet.writeD(count); // cMagicLampGameCCount
  1052. + var type = LampMode.getByMode(mode);
  1053. + switch (type) {
  1054. + case NORMAL:
  1055. + packet.writeD(Config.MAGIC_LAMP_COUNT_PER_GAME);// cMagicLampCountPerGame
  1056. + break;
  1057. + case GREATER:
  1058. + packet.writeD(Config.MAGIC_LAMP_GREATER_COUNT_PER_GAME); // cMagicLampCountPerGame
  1059. + break;
  1060. + }
  1061. + packet.writeD(player.getLampCount()); // cMagicLampCount
  1062. + packet.writeC(mode); // cGameMode
  1063. + var greater = MagicLampData.getInstance().getGreaterLamps();
  1064. + packet.writeD(greater.size()); // costItemList
  1065. + greater.forEach(lamp -> {
  1066. + packet.writeD(lamp.getItem()); // nItemClassID
  1067. + packet.writeQ(lamp.getCount()); // nItemAmountPerGame
  1068. + packet.writeQ(player.getInventory().getInventoryItemCount(lamp.getItem(), -1)); // nItemAmount
  1069. + });
  1070. + return true;
  1071. + }
  1072. +}
  1073. \ No newline at end of file
  1074. Index: java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampGameResult.java
  1075. IDEA additional info:
  1076. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  1077. <+>UTF-8
  1078. ===================================================================
  1079. diff --git a/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampGameResult.java b/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampGameResult.java
  1080. new file mode 100644
  1081. --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  1082. +++ b/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampGameResult.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
  1083. @@ -0,0 +1,92 @@
  1084. +/*
  1085. + * Copyright © 2019-2020 L2JOrg
  1086. + *
  1087. + * This file is part of the L2JOrg project.
  1088. + *
  1089. + * L2JOrg is free software: you can redistribute it and/or modify
  1090. + * it under the terms of the GNU General Public License as published by
  1091. + * the Free Software Foundation, either version 3 of the License, or
  1092. + * (at your option) any later version.
  1093. + *
  1094. + * L2JOrg is distributed in the hope that it will be useful,
  1095. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1096. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1097. + * General Public License for more details.
  1098. + *
  1099. + * You should have received a copy of the GNU General Public License
  1100. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  1101. + */
  1102. +package org.l2jmobius.gameserver.network.serverpackets.magiclamp;
  1103. +
  1104. +import org.l2jmobius.Config;
  1105. +import org.l2jmobius.commons.network.PacketWriter;
  1106. +import org.l2jmobius.commons.util.Rnd;
  1107. +import org.l2jmobius.gameserver.data.xml.MagicLampData;
  1108. +import org.l2jmobius.gameserver.enums.LampMode;
  1109. +import org.l2jmobius.gameserver.enums.LampType;
  1110. +import org.l2jmobius.gameserver.model.MagicLamp;
  1111. +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
  1112. +import org.l2jmobius.gameserver.network.OutgoingPackets;
  1113. +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
  1114. +
  1115. +import java.util.HashMap;
  1116. +import java.util.Map;
  1117. +import java.util.stream.Collectors;
  1118. +
  1119. +import static java.util.Objects.nonNull;
  1120. +
  1121. +/**
  1122. + * @author L2CCCP
  1123. + */
  1124. +public class ExMagicLampGameResult implements IClientOutgoingPacket {
  1125. + private final Map<LampType, MagicLamp> reward = new HashMap<>();
  1126. +
  1127. + public ExMagicLampGameResult(PlayerInstance player, final int count, final byte mode) {
  1128. + var type = LampMode.getByMode(mode);
  1129. + var consume = calcConsume(type, count);
  1130. + var have = player.getLampCount();
  1131. + if (have >= consume) {
  1132. + init(type, count);
  1133. + player.setLampCount(have - consume);
  1134. + reward.values().forEach(lamp -> player.addExpAndSp(lamp.getExp(), lamp.getSp()));
  1135. + // update UI
  1136. + var left = player.getLampCount();
  1137. + player.sendPacket(new ExMagicLampGameInfoUI(player, mode, left > consume ? count : left)); // check left count for update UI
  1138. + player.sendPacket(new ExMagicLampExpInfoUI(player));
  1139. + }
  1140. + }
  1141. +
  1142. + private void init(final LampMode mode, final int count) {
  1143. + for (int x = count; x > 0; x--) {
  1144. + var available = MagicLampData.getInstance().getLamps().stream().filter(lamp -> lamp.getMode() == mode && Rnd.chance(lamp.getChance())).collect(Collectors.toList());
  1145. + var random = Rnd.get(available);
  1146. + if (nonNull(random)) {
  1147. + reward.computeIfAbsent(random.getType(), list -> new MagicLamp(random)).inc();
  1148. + }
  1149. + }
  1150. + }
  1151. +
  1152. + private int calcConsume(final LampMode mode, final int count) {
  1153. + switch (mode) {
  1154. + case NORMAL:
  1155. + return Config.MAGIC_LAMP_COUNT_PER_GAME * count;
  1156. + case GREATER:
  1157. + return Config.MAGIC_LAMP_GREATER_COUNT_PER_GAME * count;
  1158. + default:
  1159. + return 0;
  1160. + }
  1161. + }
  1162. +
  1163. + @Override
  1164. + public boolean write(PacketWriter packet) {
  1165. + OutgoingPackets.EX_MAGICLAMP_GAME_RESULT.writeId(packet);
  1166. + packet.writeD(reward.size()); // magicLampGameResult
  1167. + reward.values().forEach(lamp -> {
  1168. + packet.writeC(lamp.getType().getGrade()); // cGradeNum
  1169. + packet.writeD(lamp.getCount()); // nRewardCount
  1170. + packet.writeQ(lamp.getExp()); // nEXP
  1171. + packet.writeQ(lamp.getSp()); // nSP
  1172. + });
  1173. + return true;
  1174. + }
  1175. +}
  1176. \ No newline at end of file
  1177.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement