Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: dist/game/config/magic-lamp.ini
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/dist/game/config/magic-lamp.ini b/dist/game/config/magic-lamp.ini
- new file mode 100644
- --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- +++ b/dist/game/config/magic-lamp.ini (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -0,0 +1,6 @@
- +enable = true
- +game_max_count = 300
- +count_per_game = 1
- +greater_count_per_game = 10
- +max_level_exp = 2000000
- +charge = 0.1
- \ No newline at end of file
- Index: dist/game/data/magic-lamps.xml
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/dist/game/data/magic-lamps.xml b/dist/game/data/magic-lamps.xml
- new file mode 100644
- --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- +++ b/dist/game/data/magic-lamps.xml (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -0,0 +1,12 @@
- +<?xml version="1.0" encoding="UTF-8"?>
- +<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://l2j.org" xsi:schemaLocation="http://l2j.org xsd/magic-lamps.xsd" >
- + <greater_lamp_mode item="91641" count="5" />
- + <lamp mode="NORMAL" type="RED" exp="100000000" sp="2700000" chance="20" />
- + <lamp mode="NORMAL" type="PURPLE" exp="30000000" sp="810000" chance="35" />
- + <lamp mode="NORMAL" type="BLUE" exp="10000000" sp="270000" chance="60" />
- + <lamp mode="NORMAL" type="GREEN" exp="5000000" sp="135000" chance="100" />
- + <lamp mode="GREATER" type="RED" exp="1200000000" sp="32400000" chance="20" />
- + <lamp mode="GREATER" type="PURPLE" exp="360000000" sp="9720000" chance="35" />
- + <lamp mode="GREATER" type="BLUE" exp="120000000" sp="3240000" chance="60" />
- + <lamp mode="GREATER" type="GREEN" exp="60000000" sp="1620000" chance="100" />
- +</list>
- \ No newline at end of file
- Index: dist/game/data/xsd/magic-lamps.xsd
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/dist/game/data/xsd/magic-lamps.xsd b/dist/game/data/xsd/magic-lamps.xsd
- new file mode 100644
- --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- +++ b/dist/game/data/xsd/magic-lamps.xsd (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -0,0 +1,26 @@
- +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- + targetNamespace="http://l2j.org"
- + xmlns="http://l2j.org"
- + elementFormDefault="qualified">
- + <xs:element name="list">
- + <xs:complexType>
- + <xs:sequence>
- + <xs:element maxOccurs="unbounded" name="greater_lamp_mode">
- + <xs:complexType>
- + <xs:attribute name="item" type="xs:unsignedInt" use="required" />
- + <xs:attribute name="count" type="xs:unsignedInt" use="required" />
- + </xs:complexType>
- + </xs:element>
- + <xs:element maxOccurs="unbounded" name="lamp">
- + <xs:complexType>
- + <xs:attribute name="mode" type="xs:string" use="required" />
- + <xs:attribute name="type" type="xs:string" use="required" />
- + <xs:attribute name="exp" type="xs:unsignedInt" use="required" />
- + <xs:attribute name="sp" type="xs:unsignedInt" use="required" />
- + <xs:attribute name="chance" type="xs:decimal" use="required" />
- + </xs:complexType>
- + </xs:element>
- + </xs:sequence>
- + </xs:complexType>
- + </xs:element>
- +</xs:schema>
- \ No newline at end of file
- Index: java/org/l2jmobius/Config.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/Config.java b/java/org/l2jmobius/Config.java
- --- a/java/org/l2jmobius/Config.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
- +++ b/java/org/l2jmobius/Config.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -106,7 +106,8 @@
- private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt";
- private static final String HEXID_FILE = "./config/hexid.txt";
- private static final String IPCONFIG_FILE = "./config/ipconfig.xml";
- -
- + private static final String MAGIC_LAMP_FILE = "./config/magic-lamp.ini";
- +
- // --------------------------------------------------
- // Custom Config File Definitions
- // --------------------------------------------------
- @@ -845,7 +846,15 @@
- public static int MAX_CONNECTION_PER_IP;
- public static boolean ENABLE_CMD_LINE_LOGIN;
- public static boolean ONLY_CMD_LINE_LOGIN;
- -
- +
- + // Magic Lamp
- + public static boolean MAGIC_LAMP_ENABLE;
- + public static int MAGIC_LAMP_GAME_MAX_COUNT;
- + public static int MAGIC_LAMP_COUNT_PER_GAME;
- + public static int MAGIC_LAMP_GREATER_COUNT_PER_GAME;
- + public static int MAGIC_LAMP_MAX_LEVEL_EXP;
- + public static double MAGIC_LAMP_CHARGE;
- +
- // GrandBoss Settings
- // Antharas
- @@ -1859,6 +1868,15 @@
- TIME_LIMITED_ZONE_RESET_DELAY = timeLimitedZoneSettings.getLong("ResetDelay", 36000000);
- TIME_LIMITED_ZONE_TELEPORT_FEE = timeLimitedZoneSettings.getLong("TeleportFee", 10000);
- + // Load Training Camp config file (if exists)
- + final PropertiesParser magicLampSettings = new PropertiesParser(MAGIC_LAMP_FILE);
- + MAGIC_LAMP_ENABLE = magicLampSettings.getBoolean("enable", true);
- + MAGIC_LAMP_GAME_MAX_COUNT = magicLampSettings.getInt("game_max_count", 300);
- + MAGIC_LAMP_COUNT_PER_GAME = magicLampSettings.getInt("count_per_game", 1);
- + MAGIC_LAMP_GREATER_COUNT_PER_GAME = magicLampSettings.getInt("greater_count_per_game", 10);
- + MAGIC_LAMP_MAX_LEVEL_EXP = magicLampSettings.getInt("max_level_exp", 2000000);
- + MAGIC_LAMP_CHARGE = magicLampSettings.getDouble("charge", 0.1);
- +
- // Load Training Camp config file (if exists)
- final PropertiesParser trainingCampSettings = new PropertiesParser(TRAINING_CAMP_CONFIG_FILE);
- TRAINING_CAMP_ENABLE = trainingCampSettings.getBoolean("TrainingCampEnable", false);
- Index: java/org/l2jmobius/commons/util/Rnd.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/commons/util/Rnd.java b/java/org/l2jmobius/commons/util/Rnd.java
- --- a/java/org/l2jmobius/commons/util/Rnd.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
- +++ b/java/org/l2jmobius/commons/util/Rnd.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -16,6 +16,7 @@
- */
- package org.l2jmobius.commons.util;
- +import java.util.List;
- import java.util.Random;
- /**
- @@ -137,6 +138,18 @@
- }
- return origin + (((bound - origin) + 1) * RANDOM.get().nextDouble());
- }
- +
- + public static boolean chance(double chance) {
- + return chance > 0 && (chance >= 100 || RANDOM.get().nextDouble() * 100 <= chance);
- + }
- +
- + public static <E> E get(List<E> list) {
- + if(list.isEmpty())
- + return null;
- + if(list.size() == 1)
- + return list.get(0);
- + return list.get(get(list.size()));
- + }
- /**
- * @return a random double value between zero (inclusive) and one (exclusive).
- Index: java/org/l2jmobius/gameserver/GameServer.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/gameserver/GameServer.java b/java/org/l2jmobius/gameserver/GameServer.java
- --- a/java/org/l2jmobius/gameserver/GameServer.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
- +++ b/java/org/l2jmobius/gameserver/GameServer.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -44,66 +44,7 @@
- import org.l2jmobius.gameserver.data.sql.ClanTable;
- import org.l2jmobius.gameserver.data.sql.CrestTable;
- import org.l2jmobius.gameserver.data.sql.OfflineTraderTable;
- -import org.l2jmobius.gameserver.data.xml.ActionData;
- -import org.l2jmobius.gameserver.data.xml.AdminData;
- -import org.l2jmobius.gameserver.data.xml.AppearanceItemData;
- -import org.l2jmobius.gameserver.data.xml.ArmorSetData;
- -import org.l2jmobius.gameserver.data.xml.AttendanceRewardData;
- -import org.l2jmobius.gameserver.data.xml.BeautyShopData;
- -import org.l2jmobius.gameserver.data.xml.BuyListData;
- -import org.l2jmobius.gameserver.data.xml.CategoryData;
- -import org.l2jmobius.gameserver.data.xml.ClanHallData;
- -import org.l2jmobius.gameserver.data.xml.ClanRewardData;
- -import org.l2jmobius.gameserver.data.xml.ClassListData;
- -import org.l2jmobius.gameserver.data.xml.CombinationItemsData;
- -import org.l2jmobius.gameserver.data.xml.CubicData;
- -import org.l2jmobius.gameserver.data.xml.DailyMissionData;
- -import org.l2jmobius.gameserver.data.xml.DoorData;
- -import org.l2jmobius.gameserver.data.xml.ElementalSpiritData;
- -import org.l2jmobius.gameserver.data.xml.EnchantItemData;
- -import org.l2jmobius.gameserver.data.xml.EnchantItemGroupsData;
- -import org.l2jmobius.gameserver.data.xml.EnchantItemHPBonusData;
- -import org.l2jmobius.gameserver.data.xml.EnchantItemOptionsData;
- -import org.l2jmobius.gameserver.data.xml.EnchantSkillGroupsData;
- -import org.l2jmobius.gameserver.data.xml.EnsoulData;
- -import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeData;
- -import org.l2jmobius.gameserver.data.xml.EventEngineData;
- -import org.l2jmobius.gameserver.data.xml.ExperienceData;
- -import org.l2jmobius.gameserver.data.xml.FakePlayerData;
- -import org.l2jmobius.gameserver.data.xml.FenceData;
- -import org.l2jmobius.gameserver.data.xml.FishingData;
- -import org.l2jmobius.gameserver.data.xml.HennaData;
- -import org.l2jmobius.gameserver.data.xml.HitConditionBonusData;
- -import org.l2jmobius.gameserver.data.xml.InitialEquipmentData;
- -import org.l2jmobius.gameserver.data.xml.InitialShortcutData;
- -import org.l2jmobius.gameserver.data.xml.ItemCrystallizationData;
- -import org.l2jmobius.gameserver.data.xml.KarmaData;
- -import org.l2jmobius.gameserver.data.xml.LCoinShopData;
- -import org.l2jmobius.gameserver.data.xml.LuckyGameData;
- -import org.l2jmobius.gameserver.data.xml.MultisellData;
- -import org.l2jmobius.gameserver.data.xml.NpcData;
- -import org.l2jmobius.gameserver.data.xml.NpcNameLocalisationData;
- -import org.l2jmobius.gameserver.data.xml.OptionData;
- -import org.l2jmobius.gameserver.data.xml.PetDataTable;
- -import org.l2jmobius.gameserver.data.xml.PetSkillData;
- -import org.l2jmobius.gameserver.data.xml.PlayerTemplateData;
- -import org.l2jmobius.gameserver.data.xml.PlayerXpPercentLostData;
- -import org.l2jmobius.gameserver.data.xml.PrimeShopData;
- -import org.l2jmobius.gameserver.data.xml.RecipeData;
- -import org.l2jmobius.gameserver.data.xml.ResidenceFunctionsData;
- -import org.l2jmobius.gameserver.data.xml.SayuneData;
- -import org.l2jmobius.gameserver.data.xml.SecondaryAuthData;
- -import org.l2jmobius.gameserver.data.xml.SendMessageLocalisationData;
- -import org.l2jmobius.gameserver.data.xml.ShuttleData;
- -import org.l2jmobius.gameserver.data.xml.SiegeScheduleData;
- -import org.l2jmobius.gameserver.data.xml.SkillData;
- -import org.l2jmobius.gameserver.data.xml.SkillTreeData;
- -import org.l2jmobius.gameserver.data.xml.SpawnData;
- -import org.l2jmobius.gameserver.data.xml.StaticObjectData;
- -import org.l2jmobius.gameserver.data.xml.TeleportListData;
- -import org.l2jmobius.gameserver.data.xml.TeleporterData;
- -import org.l2jmobius.gameserver.data.xml.TransformData;
- -import org.l2jmobius.gameserver.data.xml.VariationData;
- +import org.l2jmobius.gameserver.data.xml.*;
- import org.l2jmobius.gameserver.geoengine.GeoEngine;
- import org.l2jmobius.gameserver.handler.ConditionHandler;
- import org.l2jmobius.gameserver.handler.DailyMissionHandler;
- @@ -280,6 +221,7 @@
- CommissionManager.getInstance();
- LuckyGameData.getInstance();
- AttendanceRewardData.getInstance();
- + MagicLampData.init();
- printSection("Characters");
- ClassListData.getInstance();
- Index: java/org/l2jmobius/gameserver/data/xml/MagicLampData.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/gameserver/data/xml/MagicLampData.java b/java/org/l2jmobius/gameserver/data/xml/MagicLampData.java
- new file mode 100644
- --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- +++ b/java/org/l2jmobius/gameserver/data/xml/MagicLampData.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -0,0 +1,96 @@
- +/*
- + * Copyright © 2019-2020 L2JOrg
- + *
- + * This file is part of the L2JOrg project.
- + *
- + * L2JOrg is free software: you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation, either version 3 of the License, or
- + * (at your option) any later version.
- + *
- + * L2JOrg is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package org.l2jmobius.gameserver.data.xml;
- +
- +import org.l2jmobius.Config;
- +import org.l2jmobius.commons.util.IXmlReader;
- +import org.l2jmobius.gameserver.model.GreaterMagicLampHolder;
- +import org.l2jmobius.gameserver.model.MagicLampHolder;
- +import org.l2jmobius.gameserver.model.StatSet;
- +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
- +import org.l2jmobius.gameserver.network.serverpackets.magiclamp.ExMagicLampExpInfoUI;
- +import org.w3c.dom.Document;
- +
- +import java.io.File;
- +import java.util.ArrayList;
- +import java.util.List;
- +
- +/**
- + * @author L2CCCP
- + */
- +public class MagicLampData implements IXmlReader {
- + private final List<GreaterMagicLampHolder> greater_lamps = new ArrayList<>();
- + private final List<MagicLampHolder> lamps = new ArrayList<>();
- +
- + @Override
- + public void load() {
- + lamps.clear();
- + parseDatapackFile("data/magic-lamps.xml");
- + LOGGER.info("Loaded " + lamps.size() + " magic lamp(s) data.");
- + }
- +
- + @Override
- + public void parseDocument(Document doc, File f) {
- + forEach(doc, "list", listNode ->
- + forEach(listNode, node -> {
- + if (node.getNodeName().equalsIgnoreCase("greater_lamp_mode")) {
- + final GreaterMagicLampHolder lamp = new GreaterMagicLampHolder(new StatSet(parseAttributes(node)));
- + greater_lamps.add(lamp);
- + } else {
- + final MagicLampHolder lamp = new MagicLampHolder(new StatSet(parseAttributes(node)));
- + lamps.add(lamp);
- + }
- + })
- + );
- + }
- +
- + public void addLampExp(final PlayerInstance player, final double exp) {
- + if (Config.MAGIC_LAMP_ENABLE) {
- + var lamp_exp = (int) (exp * Config.MAGIC_LAMP_CHARGE);
- + var calc = lamp_exp + player.getLampExp();
- + if (calc > Config.MAGIC_LAMP_MAX_LEVEL_EXP) {
- + calc %= Config.MAGIC_LAMP_MAX_LEVEL_EXP;
- + var have_lamps = player.getLampCount();
- + player.setLampCount(have_lamps + 1);
- + }
- + player.setLampExp(calc);
- + player.sendPacket(new ExMagicLampExpInfoUI(player));
- + }
- + }
- +
- + public List<MagicLampHolder> getLamps() {
- + return lamps;
- + }
- +
- + public List<GreaterMagicLampHolder> getGreaterLamps() {
- + return greater_lamps;
- + }
- +
- + public static void init() {
- + getInstance().load();
- + }
- +
- + public static MagicLampData getInstance() {
- + return Singleton.INSTANCE;
- + }
- +
- + private static class Singleton {
- + protected static final MagicLampData INSTANCE = new MagicLampData();
- + }
- +}
- \ No newline at end of file
- Index: java/org/l2jmobius/gameserver/enums/LampMode.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/gameserver/enums/LampMode.java b/java/org/l2jmobius/gameserver/enums/LampMode.java
- new file mode 100644
- --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- +++ b/java/org/l2jmobius/gameserver/enums/LampMode.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -0,0 +1,33 @@
- +/*
- + * Copyright © 2019-2020 L2JOrg
- + *
- + * This file is part of the L2JOrg project.
- + *
- + * L2JOrg is free software: you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation, either version 3 of the License, or
- + * (at your option) any later version.
- + *
- + * L2JOrg is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package org.l2jmobius.gameserver.enums;
- +
- +import java.util.Arrays;
- +
- +/**
- + * @author L2CCCP
- + */
- +public enum LampMode {
- + NORMAL,
- + GREATER;
- +
- + public static LampMode getByMode(final byte mode) {
- + return Arrays.stream(values()).filter(type -> type.ordinal() == mode).findAny().orElse(NORMAL);
- + }
- +}
- \ No newline at end of file
- Index: java/org/l2jmobius/gameserver/enums/LampType.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/gameserver/enums/LampType.java b/java/org/l2jmobius/gameserver/enums/LampType.java
- new file mode 100644
- --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- +++ b/java/org/l2jmobius/gameserver/enums/LampType.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -0,0 +1,38 @@
- +/*
- + * Copyright © 2019-2020 L2JOrg
- + *
- + * This file is part of the L2JOrg project.
- + *
- + * L2JOrg is free software: you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation, either version 3 of the License, or
- + * (at your option) any later version.
- + *
- + * L2JOrg is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package org.l2jmobius.gameserver.enums;
- +
- +/**
- + * @author L2CCCP
- + */
- +public enum LampType {
- + RED(1),
- + PURPLE(2),
- + BLUE(3),
- + GREEN(4);
- + private int grade;
- +
- + LampType(int grade) {
- + this.grade = grade;
- + }
- +
- + public int getGrade() {
- + return grade;
- + }
- +}
- \ No newline at end of file
- Index: java/org/l2jmobius/gameserver/model/GreaterMagicLampHolder.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/gameserver/model/GreaterMagicLampHolder.java b/java/org/l2jmobius/gameserver/model/GreaterMagicLampHolder.java
- new file mode 100644
- --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- +++ b/java/org/l2jmobius/gameserver/model/GreaterMagicLampHolder.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -0,0 +1,40 @@
- +/*
- + * Copyright © 2019-2020 L2JOrg
- + *
- + * This file is part of the L2JOrg project.
- + *
- + * L2JOrg is free software: you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation, either version 3 of the License, or
- + * (at your option) any later version.
- + *
- + * L2JOrg is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package org.l2jmobius.gameserver.model;
- +
- +/**
- + * @author L2CCCP
- + */
- +public class GreaterMagicLampHolder {
- + private final int item;
- + private final long count;
- +
- + public GreaterMagicLampHolder(StatSet params) {
- + this.item = params.getInt("item");
- + this.count = params.getLong("count");
- + }
- +
- + public int getItem() {
- + return item;
- + }
- +
- + public long getCount() {
- + return count;
- + }
- +}
- \ No newline at end of file
- Index: java/org/l2jmobius/gameserver/model/MagicLamp.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/gameserver/model/MagicLamp.java b/java/org/l2jmobius/gameserver/model/MagicLamp.java
- new file mode 100644
- --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- +++ b/java/org/l2jmobius/gameserver/model/MagicLamp.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -0,0 +1,58 @@
- +/*
- + * Copyright © 2019-2020 L2JOrg
- + *
- + * This file is part of the L2JOrg project.
- + *
- + * L2JOrg is free software: you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation, either version 3 of the License, or
- + * (at your option) any later version.
- + *
- + * L2JOrg is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package org.l2jmobius.gameserver.model;
- +
- +import org.l2jmobius.gameserver.data.xml.MagicLampHolder;
- +import org.l2jmobius.gameserver.enums.LampType;
- +
- +/**
- + * @author L2CCCP
- + */
- +public class MagicLamp {
- + private final MagicLampHolder lamp;
- + private int count;
- + private long exp;
- + private long sp;
- +
- + public MagicLamp(MagicLampHolder lamp) {
- + this.lamp = lamp;
- + }
- +
- + public void inc() {
- + count++;
- + exp += lamp.getExp();
- + sp += lamp.getSp();
- + }
- +
- + public LampType getType() {
- + return lamp.getType();
- + }
- +
- + public int getCount() {
- + return count;
- + }
- +
- + public long getExp() {
- + return exp;
- + }
- +
- + public long getSp() {
- + return sp;
- + }
- +}
- \ No newline at end of file
- Index: java/org/l2jmobius/gameserver/model/MagicLampHolder.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/gameserver/model/MagicLampHolder.java b/java/org/l2jmobius/gameserver/model/MagicLampHolder.java
- new file mode 100644
- --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- +++ b/java/org/l2jmobius/gameserver/model/MagicLampHolder.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -0,0 +1,61 @@
- +/*
- + * Copyright © 2019-2020 L2JOrg
- + *
- + * This file is part of the L2JOrg project.
- + *
- + * L2JOrg is free software: you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation, either version 3 of the License, or
- + * (at your option) any later version.
- + *
- + * L2JOrg is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package org.l2jmobius.gameserver.model;
- +
- +import org.l2jmobius.gameserver.enums.LampMode;
- +import org.l2jmobius.gameserver.enums.LampType;
- +
- +/**
- + * @author L2CCCP
- + */
- +public class MagicLampHolder {
- + private final LampMode mode;
- + private final LampType type;
- + private final long exp;
- + private final long sp;
- + private final double chance;
- +
- + public MagicLampHolder(StatSet params) {
- + this.mode = params.getEnum("mode", LampMode.class);
- + this.type = params.getEnum("type", LampType.class);
- + this.exp = params.getLong("exp");
- + this.sp = params.getLong("sp");
- + this.chance = params.getDouble("chance");
- + }
- +
- + public LampMode getMode() {
- + return mode;
- + }
- +
- + public LampType getType() {
- + return type;
- + }
- +
- + public long getExp() {
- + return exp;
- + }
- +
- + public long getSp() {
- + return sp;
- + }
- +
- + public double getChance() {
- + return chance;
- + }
- +}
- \ No newline at end of file
- Index: java/org/l2jmobius/gameserver/model/Party.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/gameserver/model/Party.java b/java/org/l2jmobius/gameserver/model/Party.java
- --- a/java/org/l2jmobius/gameserver/model/Party.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
- +++ b/java/org/l2jmobius/gameserver/model/Party.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -34,6 +34,7 @@
- import org.l2jmobius.commons.util.Rnd;
- import org.l2jmobius.gameserver.GameTimeController;
- import org.l2jmobius.gameserver.data.ItemTable;
- +import org.l2jmobius.gameserver.data.xml.MagicLampData;
- import org.l2jmobius.gameserver.enums.PartyDistributionType;
- import org.l2jmobius.gameserver.enums.StatusUpdateType;
- import org.l2jmobius.gameserver.instancemanager.DuelManager;
- @@ -896,6 +897,7 @@
- }
- member.updateSayhaGracePoints(target.getSayhaGracePoints(member.getLevel(), exp, target.isRaid()), true, false);
- PcCafePointsManager.getInstance().givePcCafePoint(member, exp);
- + MagicLampData.getInstance().addLampExp(member, exp);
- }
- }
- else
- Index: java/org/l2jmobius/gameserver/model/actor/Attackable.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/java/org/l2jmobius/gameserver/model/actor/Attackable.java
- --- a/java/org/l2jmobius/gameserver/model/actor/Attackable.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
- +++ b/java/org/l2jmobius/gameserver/model/actor/Attackable.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -35,6 +35,7 @@
- import org.l2jmobius.gameserver.ai.CtrlIntention;
- import org.l2jmobius.gameserver.data.EventDroplist;
- import org.l2jmobius.gameserver.data.ItemTable;
- +import org.l2jmobius.gameserver.data.xml.MagicLampData;
- import org.l2jmobius.gameserver.enums.ChatType;
- import org.l2jmobius.gameserver.enums.DropType;
- import org.l2jmobius.gameserver.enums.ElementalType;
- @@ -525,6 +526,7 @@
- }
- attacker.updateSayhaGracePoints(getSayhaGracePoints(attacker.getLevel(), exp, _isRaid), true, false);
- PcCafePointsManager.getInstance().givePcCafePoint(attacker, exp);
- + MagicLampData.getInstance().addLampExp(attacker, exp);
- }
- rewardAttributeExp(attacker, damage, totalDamage);
- Index: java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java
- --- a/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
- +++ b/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -1207,7 +1207,23 @@
- {
- getVariables().set(PlayerVariables.HAIR_ACCESSORY_VARIABLE_NAME, enabled);
- }
- -
- +
- + public int getLampExp() {
- + return getVariables().getInt(PlayerVariables.MAGIC_LAMP_EXP);
- + }
- +
- + public int getLampCount() {
- + return getVariables().getInt(PlayerVariables.MAGIC_LAMP_COUNT);
- + }
- +
- + public void setLampExp(int exp) {
- + getVariables().set(PlayerVariables.MAGIC_LAMP_EXP, exp);
- + }
- +
- + public void setLampCount(int count) {
- + getVariables().set(PlayerVariables.MAGIC_LAMP_COUNT, count);
- + }
- +
- /**
- * @return the base PlayerTemplate link to the PlayerInstance.
- */
- Index: java/org/l2jmobius/gameserver/model/events/AbstractScript.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/gameserver/model/events/AbstractScript.java b/java/org/l2jmobius/gameserver/model/events/AbstractScript.java
- --- a/java/org/l2jmobius/gameserver/model/events/AbstractScript.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
- +++ b/java/org/l2jmobius/gameserver/model/events/AbstractScript.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -39,6 +39,7 @@
- import org.l2jmobius.gameserver.ai.CtrlIntention;
- import org.l2jmobius.gameserver.data.ItemTable;
- import org.l2jmobius.gameserver.data.xml.DoorData;
- +import org.l2jmobius.gameserver.data.xml.MagicLampData;
- import org.l2jmobius.gameserver.data.xml.NpcData;
- import org.l2jmobius.gameserver.enums.AttributeType;
- import org.l2jmobius.gameserver.enums.Movie;
- @@ -3069,6 +3070,7 @@
- }
- 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)));
- PcCafePointsManager.getInstance().givePcCafePoint(player, (long) (exp * Config.RATE_QUEST_REWARD_XP));
- + MagicLampData.getInstance().addLampExp(player, exp);
- }
- /**
- Index: java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java b/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
- --- a/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
- +++ b/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -71,6 +71,8 @@
- public static final String STAT_WIT = "STAT_WIT";
- public static final String STAT_MEN = "STAT_MEN";
- public static final String FAVORITE_TELEPORTS = "FAVORITE_TELEPORTS";
- + public static final String MAGIC_LAMP_EXP = "MAGIC_LAMP_EXP";
- + public static final String MAGIC_LAMP_COUNT = "MAGIC_LAMP_COUNT";
- private final int _objectId;
- Index: java/org/l2jmobius/gameserver/network/ExIncomingPackets.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java
- --- a/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
- +++ b/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -81,6 +81,8 @@
- import org.l2jmobius.gameserver.network.clientpackets.limitshop.RequestPurchaseLimitShopItemList;
- import org.l2jmobius.gameserver.network.clientpackets.luckygame.RequestLuckyGamePlay;
- import org.l2jmobius.gameserver.network.clientpackets.luckygame.RequestLuckyGameStartInfo;
- +import org.l2jmobius.gameserver.network.clientpackets.magiclamp.ExMagicLampGameInfo;
- +import org.l2jmobius.gameserver.network.clientpackets.magiclamp.ExMagicLampGameStart;
- import org.l2jmobius.gameserver.network.clientpackets.mentoring.ConfirmMenteeAdd;
- import org.l2jmobius.gameserver.network.clientpackets.mentoring.RequestMenteeAdd;
- import org.l2jmobius.gameserver.network.clientpackets.mentoring.RequestMenteeWaitingList;
- @@ -491,8 +493,8 @@
- EX_COSTUME_EXTRACT(0x16C, null, ConnectionState.IN_GAME),
- EX_COSTUME_LOCK(0x16D, null, ConnectionState.IN_GAME),
- EX_COSTUME_CHANGE_SHORTCUT(0x16E, null, ConnectionState.IN_GAME),
- - EX_MAGICLAMP_GAME_INFO(0x16F, null, ConnectionState.IN_GAME),
- - EX_MAGICLAMP_GAME_START(0x170, null, ConnectionState.IN_GAME),
- + EX_MAGICLAMP_GAME_INFO(0x16F, ExMagicLampGameInfo::new, ConnectionState.IN_GAME),
- + EX_MAGICLAMP_GAME_START(0x170, ExMagicLampGameStart::new, ConnectionState.IN_GAME),
- EX_ACTIVATE_AUTO_SHORTCUT(0x171, ExRequestActivateAutoShortcut::new, ConnectionState.IN_GAME),
- EX_PREMIUM_MANAGER_LINK_HTML(0x172, null, ConnectionState.IN_GAME),
- EX_PREMIUM_MANAGER_PASS_CMD_TO_SERVER(0x173, null, ConnectionState.IN_GAME),
- Index: java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java
- --- a/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
- +++ b/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -107,6 +107,7 @@
- import org.l2jmobius.gameserver.network.serverpackets.dailymission.ExOneDayReceiveRewardList;
- import org.l2jmobius.gameserver.network.serverpackets.friend.L2FriendList;
- import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExBloodyCoinCount;
- +import org.l2jmobius.gameserver.network.serverpackets.magiclamp.ExMagicLampExpInfoUI;
- import org.l2jmobius.gameserver.util.BuilderUtil;
- @@ -635,6 +636,8 @@
- player.sendPacket(new ExWorldChatCnt(player));
- }
- player.sendPacket(new ExConnectedTimeAndGettableReward(player));
- + if (Config.MAGIC_LAMP_ENABLE)
- + player.sendPacket(new ExMagicLampExpInfoUI(player));
- player.sendPacket(new ExOneDayReceiveRewardList(player, true));
- // Handle soulshots, disable all on EnterWorld
- Index: java/org/l2jmobius/gameserver/network/clientpackets/magiclamp/ExMagicLampGameInfo.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/gameserver/network/clientpackets/magiclamp/ExMagicLampGameInfo.java b/java/org/l2jmobius/gameserver/network/clientpackets/magiclamp/ExMagicLampGameInfo.java
- new file mode 100644
- --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- +++ b/java/org/l2jmobius/gameserver/network/clientpackets/magiclamp/ExMagicLampGameInfo.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -0,0 +1,47 @@
- +/*
- + * Copyright © 2019-2020 L2JOrg
- + *
- + * This file is part of the L2JOrg project.
- + *
- + * L2JOrg is free software: you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation, either version 3 of the License, or
- + * (at your option) any later version.
- + *
- + * L2JOrg is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package org.l2jmobius.gameserver.network.clientpackets.magiclamp;
- +
- +import org.l2jmobius.commons.network.PacketReader;
- +import org.l2jmobius.gameserver.network.GameClient;
- +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
- +import org.l2jmobius.gameserver.network.serverpackets.magiclamp.ExMagicLampGameInfoUI;
- +
- +/**
- + * @author L2CCCP
- + */
- +public class ExMagicLampGameInfo implements IClientIncomingPacket {
- + private byte mode;
- +
- + @Override
- + public boolean read(GameClient client, PacketReader packet) {
- + mode = (byte) packet.readC(); // cGameMode
- + return true;
- + }
- +
- + @Override
- + public void run(GameClient client) {
- + var player = client.getPlayer();
- + if (player == null) {
- + return;
- + }
- +
- + player.sendPacket(new ExMagicLampGameInfoUI(player, mode, 1));
- + }
- +}
- \ No newline at end of file
- Index: java/org/l2jmobius/gameserver/network/clientpackets/magiclamp/ExMagicLampGameStart.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/gameserver/network/clientpackets/magiclamp/ExMagicLampGameStart.java b/java/org/l2jmobius/gameserver/network/clientpackets/magiclamp/ExMagicLampGameStart.java
- new file mode 100644
- --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- +++ b/java/org/l2jmobius/gameserver/network/clientpackets/magiclamp/ExMagicLampGameStart.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -0,0 +1,49 @@
- +/*
- + * Copyright © 2019-2020 L2JOrg
- + *
- + * This file is part of the L2JOrg project.
- + *
- + * L2JOrg is free software: you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation, either version 3 of the License, or
- + * (at your option) any later version.
- + *
- + * L2JOrg is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package org.l2jmobius.gameserver.network.clientpackets.magiclamp;
- +
- +import org.l2jmobius.commons.network.PacketReader;
- +import org.l2jmobius.gameserver.network.GameClient;
- +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
- +import org.l2jmobius.gameserver.network.serverpackets.magiclamp.ExMagicLampGameResult;
- +
- +/**
- + * @author L2CCCP
- + */
- +public class ExMagicLampGameStart implements IClientIncomingPacket {
- + private int count;
- + private byte mode;
- +
- + @Override
- + public boolean read(GameClient client, PacketReader packet) {
- + count = packet.readD(); // nMagicLampGameCCount
- + mode = (byte) packet.readC(); // cGameMode
- + return true;
- + }
- +
- + @Override
- + public void run(GameClient client) {
- + var player = client.getPlayer();
- + if (player == null) {
- + return;
- + }
- +
- + client.sendPacket(new ExMagicLampGameResult(player, count, mode));
- + }
- +}
- Index: java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagiclampExpInfo.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagiclampExpInfo.java b/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampExpInfoUI.java
- rename from java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagiclampExpInfo.java
- rename to java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampExpInfoUI.java
- --- a/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagiclampExpInfo.java (revision b311f23d060572cdc5a680d172ea24eaa9cf9230)
- +++ b/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampExpInfoUI.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -16,33 +16,29 @@
- */
- package org.l2jmobius.gameserver.network.serverpackets.magiclamp;
- +import org.l2jmobius.Config;
- import org.l2jmobius.commons.network.PacketWriter;
- import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
- import org.l2jmobius.gameserver.network.OutgoingPackets;
- import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
- /**
- - * @author Mobius
- + * @author L2CCCP
- */
- -public class ExMagiclampExpInfo implements IClientOutgoingPacket
- -{
- - private final PlayerInstance _player;
- -
- - public ExMagiclampExpInfo(PlayerInstance player)
- - {
- - _player = player;
- - }
- -
- - @Override
- - public boolean write(PacketWriter packet)
- - {
- - OutgoingPackets.EX_MAGICLAMP_EXP_INFO.writeId(packet);
- -
- - packet.writeD(1); // IsOpen
- - packet.writeD(10000); // MaxMagicLampExp
- - packet.writeD(1); // MagicLampExp
- - packet.writeD(1); // MagicLampCount
- -
- - return true;
- - }
- +public class ExMagicLampExpInfoUI implements IClientOutgoingPacket {
- + private final PlayerInstance player;
- +
- + public ExMagicLampExpInfoUI(PlayerInstance player) {
- + this.player = player;
- + }
- +
- + @Override
- + public boolean write(PacketWriter packet) {
- + OutgoingPackets.EX_MAGICLAMP_EXP_INFO.writeId(packet);
- + packet.writeD(Config.MAGIC_LAMP_ENABLE ? 0x01 : 0x00); // IsOpen
- + packet.writeD(Config.MAGIC_LAMP_MAX_LEVEL_EXP); // MaxMagicLampExp
- + packet.writeD(player.getLampExp()); // MagicLampExp
- + packet.writeD(player.getLampCount()); // MagicLampCount
- + return true;
- + }
- }
- \ No newline at end of file
- Index: java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampGameInfoUI.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampGameInfoUI.java b/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampGameInfoUI.java
- new file mode 100644
- --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- +++ b/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampGameInfoUI.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -0,0 +1,68 @@
- +/*
- + * Copyright © 2019-2020 L2JOrg
- + *
- + * This file is part of the L2JOrg project.
- + *
- + * L2JOrg is free software: you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation, either version 3 of the License, or
- + * (at your option) any later version.
- + *
- + * L2JOrg is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package org.l2jmobius.gameserver.network.serverpackets.magiclamp;
- +
- +import org.l2jmobius.Config;
- +import org.l2jmobius.commons.network.PacketWriter;
- +import org.l2jmobius.gameserver.data.xml.MagicLampData;
- +import org.l2jmobius.gameserver.enums.LampMode;
- +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
- +import org.l2jmobius.gameserver.network.OutgoingPackets;
- +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
- +
- +/**
- + * @author L2CCCP
- + */
- +public class ExMagicLampGameInfoUI implements IClientOutgoingPacket {
- + private final PlayerInstance player;
- + private final byte mode;
- + private final int count;
- +
- + public ExMagicLampGameInfoUI(PlayerInstance player, final byte mode, final int count) {
- + this.player = player;
- + this.mode = mode;
- + this.count = count;
- + }
- +
- + @Override
- + public boolean write(PacketWriter packet) {
- + OutgoingPackets.EX_MAGICLAMP_GAME_INFO.writeId(packet);
- + packet.writeD(Config.MAGIC_LAMP_GAME_MAX_COUNT); // nMagicLampGameMaxCCount
- + packet.writeD(count); // cMagicLampGameCCount
- + var type = LampMode.getByMode(mode);
- + switch (type) {
- + case NORMAL:
- + packet.writeD(Config.MAGIC_LAMP_COUNT_PER_GAME);// cMagicLampCountPerGame
- + break;
- + case GREATER:
- + packet.writeD(Config.MAGIC_LAMP_GREATER_COUNT_PER_GAME); // cMagicLampCountPerGame
- + break;
- + }
- + packet.writeD(player.getLampCount()); // cMagicLampCount
- + packet.writeC(mode); // cGameMode
- + var greater = MagicLampData.getInstance().getGreaterLamps();
- + packet.writeD(greater.size()); // costItemList
- + greater.forEach(lamp -> {
- + packet.writeD(lamp.getItem()); // nItemClassID
- + packet.writeQ(lamp.getCount()); // nItemAmountPerGame
- + packet.writeQ(player.getInventory().getInventoryItemCount(lamp.getItem(), -1)); // nItemAmount
- + });
- + return true;
- + }
- +}
- \ No newline at end of file
- Index: java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampGameResult.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- diff --git a/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampGameResult.java b/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampGameResult.java
- new file mode 100644
- --- /dev/null (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- +++ b/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampGameResult.java (revision 6cca41cf6944f722a3aa46539d810e747fbc6f3f)
- @@ -0,0 +1,92 @@
- +/*
- + * Copyright © 2019-2020 L2JOrg
- + *
- + * This file is part of the L2JOrg project.
- + *
- + * L2JOrg is free software: you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation, either version 3 of the License, or
- + * (at your option) any later version.
- + *
- + * L2JOrg is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package org.l2jmobius.gameserver.network.serverpackets.magiclamp;
- +
- +import org.l2jmobius.Config;
- +import org.l2jmobius.commons.network.PacketWriter;
- +import org.l2jmobius.commons.util.Rnd;
- +import org.l2jmobius.gameserver.data.xml.MagicLampData;
- +import org.l2jmobius.gameserver.enums.LampMode;
- +import org.l2jmobius.gameserver.enums.LampType;
- +import org.l2jmobius.gameserver.model.MagicLamp;
- +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
- +import org.l2jmobius.gameserver.network.OutgoingPackets;
- +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
- +
- +import java.util.HashMap;
- +import java.util.Map;
- +import java.util.stream.Collectors;
- +
- +import static java.util.Objects.nonNull;
- +
- +/**
- + * @author L2CCCP
- + */
- +public class ExMagicLampGameResult implements IClientOutgoingPacket {
- + private final Map<LampType, MagicLamp> reward = new HashMap<>();
- +
- + public ExMagicLampGameResult(PlayerInstance player, final int count, final byte mode) {
- + var type = LampMode.getByMode(mode);
- + var consume = calcConsume(type, count);
- + var have = player.getLampCount();
- + if (have >= consume) {
- + init(type, count);
- + player.setLampCount(have - consume);
- + reward.values().forEach(lamp -> player.addExpAndSp(lamp.getExp(), lamp.getSp()));
- + // update UI
- + var left = player.getLampCount();
- + player.sendPacket(new ExMagicLampGameInfoUI(player, mode, left > consume ? count : left)); // check left count for update UI
- + player.sendPacket(new ExMagicLampExpInfoUI(player));
- + }
- + }
- +
- + private void init(final LampMode mode, final int count) {
- + for (int x = count; x > 0; x--) {
- + var available = MagicLampData.getInstance().getLamps().stream().filter(lamp -> lamp.getMode() == mode && Rnd.chance(lamp.getChance())).collect(Collectors.toList());
- + var random = Rnd.get(available);
- + if (nonNull(random)) {
- + reward.computeIfAbsent(random.getType(), list -> new MagicLamp(random)).inc();
- + }
- + }
- + }
- +
- + private int calcConsume(final LampMode mode, final int count) {
- + switch (mode) {
- + case NORMAL:
- + return Config.MAGIC_LAMP_COUNT_PER_GAME * count;
- + case GREATER:
- + return Config.MAGIC_LAMP_GREATER_COUNT_PER_GAME * count;
- + default:
- + return 0;
- + }
- + }
- +
- + @Override
- + public boolean write(PacketWriter packet) {
- + OutgoingPackets.EX_MAGICLAMP_GAME_RESULT.writeId(packet);
- + packet.writeD(reward.size()); // magicLampGameResult
- + reward.values().forEach(lamp -> {
- + packet.writeC(lamp.getType().getGrade()); // cGradeNum
- + packet.writeD(lamp.getCount()); // nRewardCount
- + packet.writeQ(lamp.getExp()); // nEXP
- + packet.writeQ(lamp.getSp()); // nSP
- + });
- + return true;
- + }
- +}
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement