From 8fdb533aa5a234d85bd326161d37478e92b593ce Mon Sep 17 00:00:00 2001
From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com>
Date: Sat, 16 Jan 2021 01:43:14 +0000
Subject: [PATCH] Addition of random craft system. Thanks to Mode.
---
.../sql/game/character_random_craft.sql | 28 +
.../dist/game/config/General.ini | 8 -
.../dist/game/config/RandomCraft.ini | 12 +
.../dist/game/data/RandomCraftExtractData.xml | 4220 +++++++++++++++++
.../dist/game/data/RandomCraftRewardData.xml | 236 +
.../admincommandhandlers/AdminReload.java | 7 +
.../game/data/xsd/RandomCraftExtractData.xsd | 25 +
.../game/data/xsd/RandomCraftRewardData.xsd | 26 +
.../java/org/l2jmobius/Config.java | 18 +-
.../org/l2jmobius/gameserver/GameServer.java | 2 +
.../gameserver/data/xml/MagicLampData.java | 2 +-
.../gameserver/data/xml/RandomCraftData.java | 173 +
.../model/actor/instance/PlayerInstance.java | 31 +-
.../actor/request/RandomCraftRequest.java | 36 +
.../holders/RandomCraftExtractDataHolder.java | 42 +
.../holders/RandomCraftRewardDataHolder.java | 56 +
.../holders/RandomCraftRewardItemHolder.java | 70 +
.../model/itemcontainer/Inventory.java | 2 +-
.../model/itemcontainer/PlayerInventory.java | 2 +-
.../itemcontainer/PlayerRandomCraft.java | 355 ++
.../gameserver/network/ExIncomingPackets.java | 15 +-
.../network/clientpackets/EnterWorld.java | 16 +-
.../clientpackets/RequestDestroyItem.java | 3 +-
.../clientpackets/RequestEnchantItem.java | 2 +-
.../ExRequestRandomCraftExtract.java | 109 +
.../randomcraft/ExRequestRandomCraftInfo.java | 53 +
.../ExRequestRandomCraftLockSlot.java | 83 +
.../randomcraft/ExRequestRandomCraftMake.java | 54 +
.../ExRequestRandomCraftRefresh.java | 54 +
.../network/serverpackets/ExItemAnnounce.java | 13 +-
.../limitshop/ExBloodyCoinCount.java | 5 +-
.../magiclamp/ExMagicLampExpInfoUI.java | 2 +-
.../randomcraft/ExCraftExtract.java | 39 +
.../randomcraft/ExCraftInfo.java | 49 +
.../randomcraft/ExCraftRandomInfo.java | 78 +
.../randomcraft/ExCraftRandomLockSlot.java | 39 +
.../randomcraft/ExCraftRandomMake.java | 48 +
.../randomcraft/ExCraftRandomRefresh.java | 39 +
.../readme.txt | 6 +
39 files changed, 6017 insertions(+), 41 deletions(-)
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/db_installer/sql/game/character_random_craft.sql
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/config/RandomCraft.ini
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/RandomCraftExtractData.xml
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/RandomCraftRewardData.xml
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/xsd/RandomCraftExtractData.xsd
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/xsd/RandomCraftRewardData.xsd
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/RandomCraftData.java
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/request/RandomCraftRequest.java
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/RandomCraftExtractDataHolder.java
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/RandomCraftRewardDataHolder.java
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/RandomCraftRewardItemHolder.java
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/itemcontainer/PlayerRandomCraft.java
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftExtract.java
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftInfo.java
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftLockSlot.java
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftMake.java
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftRefresh.java
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftExtract.java
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftInfo.java
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftRandomInfo.java
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftRandomLockSlot.java
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftRandomMake.java
create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftRandomRefresh.java
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/db_installer/sql/game/character_random_craft.sql b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/db_installer/sql/game/character_random_craft.sql
new file mode 100644
index 0000000000..977113bbe3
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/db_installer/sql/game/character_random_craft.sql
@@ -0,0 +1,28 @@
+DROP TABLE IF EXISTS `character_random_craft`;
+CREATE TABLE IF NOT EXISTS `character_random_craft` (
+ `charId` INT UNSIGNED NOT NULL DEFAULT 0,
+ `random_craft_full_points` INT NOT NULL DEFAULT 0,
+ `random_craft_points` INT NOT NULL DEFAULT 0,
+ `sayha_roll` TINYINT NOT NULL DEFAULT 0,
+ `item_1_id` INT NOT NULL DEFAULT 0,
+ `item_1_count` BIGINT UNSIGNED NOT NULL DEFAULT 0,
+ `item_1_locked` TINYINT NOT NULL DEFAULT 0,
+ `item_1_lock_left` INT NOT NULL DEFAULT 0,
+ `item_2_id` INT NOT NULL DEFAULT 0,
+ `item_2_count` BIGINT UNSIGNED NOT NULL DEFAULT 0,
+ `item_2_locked` TINYINT NOT NULL DEFAULT 0,
+ `item_2_lock_left` INT NOT NULL DEFAULT 0,
+ `item_3_id` INT NOT NULL DEFAULT 0,
+ `item_3_count` BIGINT UNSIGNED NOT NULL DEFAULT 0,
+ `item_3_locked` TINYINT NOT NULL DEFAULT 0,
+ `item_3_lock_left` INT NOT NULL DEFAULT 0,
+ `item_4_id` INT NOT NULL DEFAULT 0,
+ `item_4_count` BIGINT UNSIGNED NOT NULL DEFAULT 0,
+ `item_4_locked` TINYINT NOT NULL DEFAULT 0,
+ `item_4_lock_left` INT NOT NULL DEFAULT 0,
+ `item_5_id` INT NOT NULL DEFAULT 0,
+ `item_5_count` BIGINT UNSIGNED NOT NULL DEFAULT 0,
+ `item_5_locked` TINYINT NOT NULL DEFAULT 0,
+ `item_5_lock_left` INT NOT NULL DEFAULT 0,
+ PRIMARY KEY (`charId`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
\ No newline at end of file
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/config/General.ini b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/config/General.ini
index 6d934b70d2..12c35512a7 100644
--- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/config/General.ini
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/config/General.ini
@@ -654,14 +654,6 @@ EnableAutoBuff = True
EnableAutoItem = True
-# ---------------------------------------------------------------------------
-# Random Craft Settings
-# ---------------------------------------------------------------------------
-
-# Drop materials for random craft.
-DropRandomCraftMaterials = False
-
-
# ---------------------------------------------------------------------------
# Developer Settings
# ---------------------------------------------------------------------------
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/config/RandomCraft.ini b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/config/RandomCraft.ini
new file mode 100644
index 0000000000..2c8022720f
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/config/RandomCraft.ini
@@ -0,0 +1,12 @@
+# ---------------------------------------------------------------------------
+# Random Craft Settings
+# ---------------------------------------------------------------------------
+
+# Enable random craft system.
+RandomCraftEnabled = False
+
+# Drop materials for random craft.
+# Cannot be reloaded. It needs server restart.
+# Works independently from above config.
+# Recommend to use same value as RandomCraftEnabled.
+DropRandomCraftMaterials = False
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/RandomCraftExtractData.xml b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/RandomCraftExtractData.xml
new file mode 100644
index 0000000000..01e83b5b26
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/RandomCraftExtractData.xml
@@ -0,0 +1,4220 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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its/dist/game/data/RandomCraftRewardData.xml b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/RandomCraftRewardData.xml
new file mode 100644
index 0000000000..0f0929fa08
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/RandomCraftRewardData.xml
@@ -0,0 +1,236 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/scripts/handlers/admincommandhandlers/AdminReload.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/scripts/handlers/admincommandhandlers/AdminReload.java
index 6f4a58e302..0c8cb3180d 100644
--- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/scripts/handlers/admincommandhandlers/AdminReload.java
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/scripts/handlers/admincommandhandlers/AdminReload.java
@@ -46,6 +46,7 @@ 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.PrimeShopData;
+import org.l2jmobius.gameserver.data.xml.RandomCraftData;
import org.l2jmobius.gameserver.data.xml.SayuneData;
import org.l2jmobius.gameserver.data.xml.SendMessageLocalisationData;
import org.l2jmobius.gameserver.data.xml.SkillData;
@@ -369,6 +370,12 @@ public class AdminReload implements IAdminCommandHandler
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Equipment Upgrade data.");
break;
}
+ case "randomcraft":
+ {
+ RandomCraftData.getInstance().load();
+ AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Random Craft data.");
+ break;
+ }
default:
{
activeChar.sendMessage(RELOAD_USAGE);
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/xsd/RandomCraftExtractData.xsd b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/xsd/RandomCraftExtractData.xsd
new file mode 100644
index 0000000000..d9235e6102
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/xsd/RandomCraftExtractData.xsd
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/xsd/RandomCraftRewardData.xsd b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/xsd/RandomCraftRewardData.xsd
new file mode 100644
index 0000000000..6d296a1115
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/xsd/RandomCraftRewardData.xsd
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/Config.java
index f71bade6e8..df8edf25f2 100644
--- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/Config.java
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/Config.java
@@ -107,6 +107,7 @@ public class Config
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/MagicLamp.ini";
+ private static final String RANDOM_CRAFT_FILE = "./config/RandomCraft.ini";
// --------------------------------------------------
// Custom Config File Definitions
@@ -591,7 +592,6 @@ public class Config
public static boolean ENABLE_AUTO_POTION;
public static boolean ENABLE_AUTO_BUFF;
public static boolean ENABLE_AUTO_ITEM;
- public static boolean DROP_RANDOM_CRAFT_MATERIALS;
// --------------------------------------------------
// FloodProtector Settings
@@ -857,13 +857,17 @@ public class Config
public static boolean ONLY_CMD_LINE_LOGIN;
// Magic Lamp
- public static boolean MAGIC_LAMP_ENABLE;
+ public static boolean ENABLE_MAGIC_LAMP;
public static int MAGIC_LAMP_MAX_GAME_COUNT;
public static int MAGIC_LAMP_REWARD_COUNT;
public static int MAGIC_LAMP_GREATER_REWARD_COUNT;
public static int MAGIC_LAMP_MAX_LEVEL_EXP;
public static double MAGIC_LAMP_CHARGE_RATE;
+ // Random Craft
+ public static boolean ENABLE_RANDOM_CRAFT;
+ public static boolean DROP_RANDOM_CRAFT_MATERIALS;
+
// GrandBoss Settings
// Antharas
@@ -1879,15 +1883,20 @@ public class Config
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)
+ // Load Magic Lamp config file (if exists)
final PropertiesParser magicLampSettings = new PropertiesParser(MAGIC_LAMP_FILE);
- MAGIC_LAMP_ENABLE = magicLampSettings.getBoolean("MagicLampEnabled", false);
+ ENABLE_MAGIC_LAMP = magicLampSettings.getBoolean("MagicLampEnabled", false);
MAGIC_LAMP_MAX_GAME_COUNT = magicLampSettings.getInt("MagicLampMaxGames", 300);
MAGIC_LAMP_REWARD_COUNT = magicLampSettings.getInt("MagicLampRewardCount", 1);
MAGIC_LAMP_GREATER_REWARD_COUNT = magicLampSettings.getInt("MagicLampGreaterRewardCount", 10);
MAGIC_LAMP_MAX_LEVEL_EXP = magicLampSettings.getInt("MagicLampMaxLevelExp", 10000000);
MAGIC_LAMP_CHARGE_RATE = magicLampSettings.getDouble("MagicLampChargeRate", 0.1);
+ // Load Random Craft config file (if exists)
+ final PropertiesParser randomCraftSettings = new PropertiesParser(RANDOM_CRAFT_FILE);
+ ENABLE_RANDOM_CRAFT = randomCraftSettings.getBoolean("RandomCraftEnabled", false);
+ DROP_RANDOM_CRAFT_MATERIALS = randomCraftSettings.getBoolean("DropRandomCraftMaterials", false);
+
// Load Training Camp config file (if exists)
final PropertiesParser trainingCampSettings = new PropertiesParser(TRAINING_CAMP_CONFIG_FILE);
TRAINING_CAMP_ENABLE = trainingCampSettings.getBoolean("TrainingCampEnable", false);
@@ -2060,7 +2069,6 @@ public class Config
ENABLE_AUTO_POTION = General.getBoolean("EnableAutoPotion", true);
ENABLE_AUTO_BUFF = General.getBoolean("EnableAutoBuff", true);
ENABLE_AUTO_ITEM = General.getBoolean("EnableAutoItem", true);
- DROP_RANDOM_CRAFT_MATERIALS = General.getBoolean("DropRandomCraftMaterials", true);
// Load FloodProtector config file
final PropertiesParser FloodProtectors = new PropertiesParser(FLOOD_PROTECTOR_CONFIG_FILE);
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/GameServer.java
index fca5561c97..532e979b5b 100644
--- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/GameServer.java
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/GameServer.java
@@ -91,6 +91,7 @@ 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.RandomCraftData;
import org.l2jmobius.gameserver.data.xml.RecipeData;
import org.l2jmobius.gameserver.data.xml.ResidenceFunctionsData;
import org.l2jmobius.gameserver.data.xml.SayuneData;
@@ -285,6 +286,7 @@ public class GameServer
LuckyGameData.getInstance();
AttendanceRewardData.getInstance();
MagicLampData.getInstance();
+ RandomCraftData.getInstance();
printSection("Characters");
ClassListData.getInstance();
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/MagicLampData.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/MagicLampData.java
index 90493281c0..5155fccd06 100644
--- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/MagicLampData.java
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/MagicLampData.java
@@ -71,7 +71,7 @@ public class MagicLampData implements IXmlReader
public void addLampExp(PlayerInstance player, double exp, boolean rateModifiers)
{
- if (Config.MAGIC_LAMP_ENABLE)
+ if (Config.ENABLE_MAGIC_LAMP)
{
final int lampExp = (int) (exp * (rateModifiers ? Config.MAGIC_LAMP_CHARGE_RATE * player.getStat().getMul(Stat.MAGIC_LAMP_EXP_RATE, 1) : 1));
int calc = lampExp + player.getLampExp();
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/RandomCraftData.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/RandomCraftData.java
new file mode 100644
index 0000000000..44ece37dcf
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/RandomCraftData.java
@@ -0,0 +1,173 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * This program 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.
+ *
+ * This program 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 .
+ */
+package org.l2jmobius.gameserver.data.xml;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.w3c.dom.Document;
+
+import org.l2jmobius.commons.util.IXmlReader;
+import org.l2jmobius.commons.util.Rnd;
+import org.l2jmobius.gameserver.data.ItemTable;
+import org.l2jmobius.gameserver.model.StatSet;
+import org.l2jmobius.gameserver.model.holders.RandomCraftExtractDataHolder;
+import org.l2jmobius.gameserver.model.holders.RandomCraftRewardDataHolder;
+import org.l2jmobius.gameserver.model.holders.RandomCraftRewardItemHolder;
+import org.l2jmobius.gameserver.model.items.Item;
+
+/**
+ * @author Mode, Mobius
+ */
+public class RandomCraftData implements IXmlReader
+{
+ private static final Map EXTRACT_DATA = new HashMap<>();
+ private static final Map REWARD_DATA = new HashMap<>();
+
+ protected RandomCraftData()
+ {
+ load();
+ }
+
+ @Override
+ public void load()
+ {
+ EXTRACT_DATA.clear();
+ parseDatapackFile("data/RandomCraftExtractData.xml");
+ final int extractCount = EXTRACT_DATA.size();
+ if (extractCount > 0)
+ {
+ LOGGER.info(getClass().getSimpleName() + ": Loaded " + extractCount + " extraction data.");
+ }
+
+ REWARD_DATA.clear();
+ parseDatapackFile("data/RandomCraftRewardData.xml");
+ final int rewardCount = REWARD_DATA.size();
+ if (rewardCount > 4)
+ {
+ LOGGER.info(getClass().getSimpleName() + ": Loaded " + rewardCount + " rewards.");
+ }
+ else if (rewardCount > 0)
+ {
+ LOGGER.info(getClass().getSimpleName() + ": Random craft rewards should be more than " + rewardCount + ".");
+ REWARD_DATA.clear();
+ }
+ }
+
+ @Override
+ public void parseDocument(Document doc, File f)
+ {
+ forEach(doc, "list", listNode -> forEach(listNode, "extract", extractNode ->
+ {
+ forEach(extractNode, "item", itemNode ->
+ {
+ final StatSet stats = new StatSet(parseAttributes(itemNode));
+ final int itemId = stats.getInt("id");
+ final long points = stats.getLong("points");
+ final long fee = stats.getLong("fee");
+ EXTRACT_DATA.put(itemId, new RandomCraftExtractDataHolder(points, fee));
+ });
+ }));
+
+ forEach(doc, "list", listNode -> forEach(listNode, "rewards", rewardNode ->
+ {
+ forEach(rewardNode, "item", itemNode ->
+ {
+ final StatSet stats = new StatSet(parseAttributes(itemNode));
+ final int itemId = stats.getInt("id");
+ final Item item = ItemTable.getInstance().getTemplate(itemId);
+ if (item == null)
+ {
+ LOGGER.warning(getClass().getSimpleName() + " unexisting item reward: " + itemId);
+ }
+ else
+ {
+ REWARD_DATA.put(itemId, new RandomCraftRewardDataHolder(stats.getInt("id"), stats.getLong("count", 1), Math.min(100, Math.max(0.00000000000001, stats.getDouble("chance", 100))), stats.getBoolean("announce", false)));
+ }
+ });
+ }));
+ }
+
+ public boolean isEmpty()
+ {
+ return REWARD_DATA.isEmpty();
+ }
+
+ public RandomCraftRewardItemHolder getNewReward()
+ {
+ final List rewards = new ArrayList<>(REWARD_DATA.values());
+ Collections.shuffle(rewards);
+
+ RandomCraftRewardItemHolder result = null;
+ while (result == null)
+ {
+ SEARCH: for (RandomCraftRewardDataHolder reward : rewards)
+ {
+ if (Rnd.get(100d) < reward.getChance())
+ {
+ result = new RandomCraftRewardItemHolder(reward.getItemId(), reward.getCount(), false, 20);
+ break SEARCH;
+ }
+ }
+ }
+ return result;
+ }
+
+ public boolean isAnnounce(int id)
+ {
+ final RandomCraftRewardDataHolder holder = REWARD_DATA.get(id);
+ if (holder == null)
+ {
+ return false;
+ }
+ return holder.isAnnounce();
+ }
+
+ public long getPoints(int id)
+ {
+ final RandomCraftExtractDataHolder holder = EXTRACT_DATA.get(id);
+ if (holder == null)
+ {
+ return 0;
+ }
+ return holder.getPoints();
+ }
+
+ public long getFee(int id)
+ {
+ final RandomCraftExtractDataHolder holder = EXTRACT_DATA.get(id);
+ if (holder == null)
+ {
+ return 0;
+ }
+ return holder.getFee();
+ }
+
+ public static RandomCraftData getInstance()
+ {
+ return SingletonHolder.INSTANCE;
+ }
+
+ private static class SingletonHolder
+ {
+ protected static final RandomCraftData INSTANCE = new RandomCraftData();
+ }
+}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java
index ac7430069f..e1d5d004be 100644
--- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java
@@ -235,6 +235,7 @@ import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.model.itemcontainer.ItemContainer;
import org.l2jmobius.gameserver.model.itemcontainer.PlayerFreight;
import org.l2jmobius.gameserver.model.itemcontainer.PlayerInventory;
+import org.l2jmobius.gameserver.model.itemcontainer.PlayerRandomCraft;
import org.l2jmobius.gameserver.model.itemcontainer.PlayerRefund;
import org.l2jmobius.gameserver.model.itemcontainer.PlayerWarehouse;
import org.l2jmobius.gameserver.model.items.Armor;
@@ -883,6 +884,8 @@ public class PlayerInstance extends Playable
private ScheduledFuture> _timedHuntingZoneFinishTask = null;
+ private PlayerRandomCraft _randomCraft = null;
+
private final List _questTimers = new ArrayList<>();
private final List> _timerHolders = new ArrayList<>();
@@ -3394,7 +3397,7 @@ public class PlayerInstance extends Playable
}
// LCoin UI update.
- if (destoyedItem.getId() == ExBloodyCoinCount.LCOIN_ID)
+ if (destoyedItem.getId() == Inventory.LCOIN_ID)
{
sendPacket(new ExBloodyCoinCount(this));
}
@@ -3509,7 +3512,7 @@ public class PlayerInstance extends Playable
}
// LCoin UI update.
- if (item.getId() == ExBloodyCoinCount.LCOIN_ID)
+ if (item.getId() == Inventory.LCOIN_ID)
{
sendPacket(new ExBloodyCoinCount(this));
}
@@ -3584,7 +3587,7 @@ public class PlayerInstance extends Playable
}
// LCoin UI update.
- if (newItem.getId() == ExBloodyCoinCount.LCOIN_ID)
+ if (newItem.getId() == Inventory.LCOIN_ID)
{
sendPacket(new ExBloodyCoinCount(this));
}
@@ -3697,7 +3700,7 @@ public class PlayerInstance extends Playable
}
// LCoin UI update.
- if (item.getId() == ExBloodyCoinCount.LCOIN_ID)
+ if (item.getId() == Inventory.LCOIN_ID)
{
sendPacket(new ExBloodyCoinCount(this));
}
@@ -3777,7 +3780,7 @@ public class PlayerInstance extends Playable
}
// LCoin UI update.
- if (item.getId() == ExBloodyCoinCount.LCOIN_ID)
+ if (item.getId() == Inventory.LCOIN_ID)
{
sendPacket(new ExBloodyCoinCount(this));
}
@@ -6731,6 +6734,8 @@ public class PlayerInstance extends Playable
player.restoreFriendList();
+ player.restoreRandomCraft();
+
player.loadRecommendations();
player.startRecoGiveTask();
player.startOnlineTimeUpdateTask();
@@ -7029,6 +7034,11 @@ public class PlayerInstance extends Playable
}
}
}
+
+ if (_randomCraft != null)
+ {
+ _randomCraft.store();
+ }
}
@Override
@@ -14422,4 +14432,15 @@ public class PlayerInstance extends Playable
}
return 0;
}
+
+ private void restoreRandomCraft()
+ {
+ _randomCraft = new PlayerRandomCraft(this);
+ _randomCraft.restore();
+ }
+
+ public PlayerRandomCraft getRandomCraft()
+ {
+ return _randomCraft;
+ }
}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/request/RandomCraftRequest.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/request/RandomCraftRequest.java
new file mode 100644
index 0000000000..066afd135b
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/request/RandomCraftRequest.java
@@ -0,0 +1,36 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * This program 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.
+ *
+ * This program 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 .
+ */
+package org.l2jmobius.gameserver.model.actor.request;
+
+import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+
+/**
+ * @author Mobius
+ */
+public class RandomCraftRequest extends AbstractRequest
+{
+ public RandomCraftRequest(PlayerInstance player)
+ {
+ super(player);
+ }
+
+ @Override
+ public boolean isUsing(int objectId)
+ {
+ return false;
+ }
+}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/RandomCraftExtractDataHolder.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/RandomCraftExtractDataHolder.java
new file mode 100644
index 0000000000..48fe019222
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/RandomCraftExtractDataHolder.java
@@ -0,0 +1,42 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * This program 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.
+ *
+ * This program 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 .
+ */
+package org.l2jmobius.gameserver.model.holders;
+
+/**
+ * @author Mobius
+ */
+public class RandomCraftExtractDataHolder
+{
+ private final long _points;
+ private final long _fee;
+
+ public RandomCraftExtractDataHolder(long points, long fee)
+ {
+ _points = points;
+ _fee = fee;
+ }
+
+ public long getPoints()
+ {
+ return _points;
+ }
+
+ public long getFee()
+ {
+ return _fee;
+ }
+}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/RandomCraftRewardDataHolder.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/RandomCraftRewardDataHolder.java
new file mode 100644
index 0000000000..55a09bde1e
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/RandomCraftRewardDataHolder.java
@@ -0,0 +1,56 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * This program 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.
+ *
+ * This program 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 .
+ */
+package org.l2jmobius.gameserver.model.holders;
+
+/**
+ * @author Mode
+ */
+public class RandomCraftRewardDataHolder
+{
+ private final int _itemId;
+ private final long _count;
+ private final double _chance;
+ private final boolean _announce;
+
+ public RandomCraftRewardDataHolder(int itemId, long count, double chance, boolean announce)
+ {
+ _itemId = itemId;
+ _count = count;
+ _chance = chance;
+ _announce = announce;
+ }
+
+ public int getItemId()
+ {
+ return _itemId;
+ }
+
+ public long getCount()
+ {
+ return _count;
+ }
+
+ public double getChance()
+ {
+ return _chance;
+ }
+
+ public boolean isAnnounce()
+ {
+ return _announce;
+ }
+}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/RandomCraftRewardItemHolder.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/RandomCraftRewardItemHolder.java
new file mode 100644
index 0000000000..b98055ba8c
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/RandomCraftRewardItemHolder.java
@@ -0,0 +1,70 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * This program 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.
+ *
+ * This program 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 .
+ */
+package org.l2jmobius.gameserver.model.holders;
+
+/**
+ * @author Mode
+ */
+public class RandomCraftRewardItemHolder
+{
+ private final int _id;
+ private final long _count;
+ private boolean _locked;
+ private int _lockLeft;
+
+ public RandomCraftRewardItemHolder(int id, long count, boolean locked, int lockLeft)
+ {
+ _id = id;
+ _count = count;
+ _locked = locked;
+ _lockLeft = lockLeft;
+ }
+
+ public int getItemId()
+ {
+ return _id;
+ }
+
+ public long getItemCount()
+ {
+ return _count;
+ }
+
+ public boolean isLocked()
+ {
+ return _locked;
+ }
+
+ public int getLockLeft()
+ {
+ return _lockLeft;
+ }
+
+ public void lock()
+ {
+ _locked = true;
+ }
+
+ public void decLock()
+ {
+ _lockLeft--;
+ if (_lockLeft <= 0)
+ {
+ _locked = false;
+ }
+ }
+}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java
index 941dfd8b3a..cc36465e75 100644
--- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java
@@ -88,7 +88,7 @@ public abstract class Inventory extends ItemContainer
public static final int AIR_STONE_ID = 39461;
public static final int TEMPEST_STONE_ID = 39592;
public static final int ELCYUM_CRYSTAL_ID = 36514;
-
+ public static final int LCOIN_ID = 91663;
public static final long MAX_ADENA = Config.MAX_ADENA;
public static final int PAPERDOLL_UNDER = 0;
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/itemcontainer/PlayerInventory.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/itemcontainer/PlayerInventory.java
index e5239288ac..3079d1ec2a 100644
--- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/itemcontainer/PlayerInventory.java
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/itemcontainer/PlayerInventory.java
@@ -478,7 +478,7 @@ public class PlayerInventory extends Inventory
}
// LCoin UI update.
- if (item.getId() == ExBloodyCoinCount.LCOIN_ID)
+ if (item.getId() == Inventory.LCOIN_ID)
{
actor.sendPacket(new ExBloodyCoinCount(actor));
}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/itemcontainer/PlayerRandomCraft.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/itemcontainer/PlayerRandomCraft.java
new file mode 100644
index 0000000000..d090504076
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/itemcontainer/PlayerRandomCraft.java
@@ -0,0 +1,355 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * This program 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.
+ *
+ * This program 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 .
+ */
+package org.l2jmobius.gameserver.model.itemcontainer;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.l2jmobius.commons.database.DatabaseFactory;
+import org.l2jmobius.commons.util.Rnd;
+import org.l2jmobius.gameserver.data.xml.RandomCraftData;
+import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.model.actor.request.RandomCraftRequest;
+import org.l2jmobius.gameserver.model.holders.RandomCraftRewardItemHolder;
+import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
+import org.l2jmobius.gameserver.network.SystemMessageId;
+import org.l2jmobius.gameserver.network.serverpackets.ExItemAnnounce;
+import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
+import org.l2jmobius.gameserver.network.serverpackets.randomcraft.ExCraftInfo;
+import org.l2jmobius.gameserver.network.serverpackets.randomcraft.ExCraftRandomInfo;
+import org.l2jmobius.gameserver.network.serverpackets.randomcraft.ExCraftRandomMake;
+import org.l2jmobius.gameserver.network.serverpackets.randomcraft.ExCraftRandomRefresh;
+import org.l2jmobius.gameserver.util.Broadcast;
+
+/**
+ * @author Mode
+ */
+public class PlayerRandomCraft
+{
+ private static final Logger LOGGER = Logger.getLogger(PlayerRandomCraft.class.getName());
+
+ public static final int MAX_FULL_CRAFT_POINTS = 99;
+ public static final int MAX_CRAFT_POINTS = 1000000;
+
+ private final PlayerInstance _player;
+ private final List _rewardList = new ArrayList<>(5);
+
+ private int _fullCraftPoints = 0;
+ private int _craftPoints = 0;
+ private boolean _isSayhaRoll = false;
+
+ public PlayerRandomCraft(PlayerInstance player)
+ {
+ _player = player;
+ }
+
+ public void restore()
+ {
+ try (Connection con = DatabaseFactory.getConnection();
+ PreparedStatement ps = con.prepareStatement("SELECT * FROM character_random_craft WHERE charId=?"))
+ {
+ ps.setInt(1, _player.getObjectId());
+ try (ResultSet rs = ps.executeQuery())
+ {
+ if (rs.next())
+ {
+ try
+ {
+ _fullCraftPoints = rs.getInt("random_craft_full_points");
+ _craftPoints = rs.getInt("random_craft_points");
+ _isSayhaRoll = rs.getBoolean("sayha_roll");
+ for (int i = 1; i <= 5; i++)
+ {
+ final int itemId = rs.getInt("item_" + i + "_id");
+ final long itemCount = rs.getLong("item_" + i + "_count");
+ final boolean itemLocked = rs.getBoolean("item_" + i + "_locked");
+ final int itemLockLeft = rs.getInt("item_" + i + "_lock_left");
+ final RandomCraftRewardItemHolder holder = new RandomCraftRewardItemHolder(itemId, itemCount, itemLocked, itemLockLeft);
+ _rewardList.add(i - 1, holder);
+ }
+ }
+ catch (Exception e)
+ {
+ LOGGER.warning("Could not restore random craft for " + _player);
+ }
+ }
+ else
+ {
+ storeNew();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, "Could not restore random craft for " + _player, e);
+ }
+ }
+
+ public void store()
+ {
+ try (Connection con = DatabaseFactory.getConnection();
+ PreparedStatement ps = con.prepareStatement("UPDATE character_random_craft SET random_craft_full_points=?,random_craft_points=?,sayha_roll=?,item_1_id=?,item_1_count=?,item_1_locked=?,item_1_lock_left=?,item_2_id=?,item_2_count=?,item_2_locked=?,item_2_lock_left=?,item_3_id=?,item_3_count=?,item_3_locked=?,item_3_lock_left=?,item_4_id=?,item_4_count=?,item_4_locked=?,item_4_lock_left=?,item_5_id=?,item_5_count=?,item_5_locked=?,item_5_lock_left=?"))
+ {
+ ps.setInt(1, _fullCraftPoints);
+ ps.setInt(2, _craftPoints);
+ ps.setBoolean(3, _isSayhaRoll);
+ for (int i = 0; i < 5; i++)
+ {
+ if (_rewardList.size() >= (i + 1))
+ {
+ final RandomCraftRewardItemHolder holder = _rewardList.get(i);
+ ps.setInt(4 + (i * 4), holder == null ? 0 : holder.getItemId());
+ ps.setLong(5 + (i * 4), holder == null ? 0 : holder.getItemCount());
+ ps.setBoolean(6 + (i * 4), holder == null ? false : holder.isLocked());
+ ps.setInt(7 + (i * 4), holder == null ? 20 : holder.getLockLeft());
+ }
+ else
+ {
+ ps.setInt(4 + (i * 4), 0);
+ ps.setLong(5 + (i * 4), 0);
+ ps.setBoolean(6 + (i * 4), false);
+ ps.setInt(7 + (i * 4), 20);
+ }
+ }
+ ps.execute();
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.SEVERE, "Could not store RandomCraft for: " + _player, e);
+ }
+ }
+
+ public void storeNew()
+ {
+ try (Connection con = DatabaseFactory.getConnection();
+ PreparedStatement ps = con.prepareStatement("INSERT INTO character_random_craft VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"))
+ {
+ ps.setInt(1, _player.getObjectId());
+ ps.setInt(2, _fullCraftPoints);
+ ps.setInt(3, _craftPoints);
+ ps.setBoolean(4, _isSayhaRoll);
+ for (int i = 0; i < 5; i++)
+ {
+ ps.setInt(5 + (i * 4), 0);
+ ps.setLong(6 + (i * 4), 0);
+ ps.setBoolean(7 + (i * 4), false);
+ ps.setInt(8 + (i * 4), 0);
+ }
+ ps.executeUpdate();
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.SEVERE, "Could not store new RandomCraft for: " + _player, e.getMessage());
+ }
+ }
+
+ public void refresh()
+ {
+ if (_player.hasItemRequest() || _player.hasRequest(RandomCraftRequest.class))
+ {
+ return;
+ }
+ _player.addRequest(new RandomCraftRequest(_player));
+
+ if ((_fullCraftPoints > 0) && _player.reduceAdena("RandomCraft Refresh", 10000, _player, true))
+ {
+ _player.sendPacket(new ExCraftInfo(_player));
+ _player.sendPacket(new ExCraftRandomRefresh());
+ _fullCraftPoints--;
+ if (_isSayhaRoll)
+ {
+ _player.addItem("RandomCraft Roll", 91641, 2, _player, true);
+ _isSayhaRoll = false;
+ }
+ _player.sendPacket(new ExCraftInfo(_player));
+
+ for (int i = 0; i < 5; i++)
+ {
+ final RandomCraftRewardItemHolder holder;
+ if (i > (_rewardList.size() - 1))
+ {
+ holder = null;
+ }
+ else
+ {
+ holder = _rewardList.get(i);
+ }
+
+ if (holder == null)
+ {
+ _rewardList.add(i, getNewReward());
+ }
+ else if (!holder.isLocked())
+ {
+ _rewardList.set(i, getNewReward());
+ }
+ else
+ {
+ holder.decLock();
+ }
+ }
+ _player.sendPacket(new ExCraftRandomInfo(_player));
+ }
+
+ _player.removeRequest(RandomCraftRequest.class);
+ }
+
+ private RandomCraftRewardItemHolder getNewReward()
+ {
+ if (RandomCraftData.getInstance().isEmpty())
+ {
+ return null;
+ }
+
+ RandomCraftRewardItemHolder result = null;
+ while (result == null)
+ {
+ result = RandomCraftData.getInstance().getNewReward();
+ SEARCH: for (RandomCraftRewardItemHolder reward : _rewardList)
+ {
+ if (reward.getItemId() == result.getItemId())
+ {
+ result = null;
+ break SEARCH;
+ }
+ }
+ }
+ return result;
+ }
+
+ public void make()
+ {
+ if (_player.hasItemRequest() || _player.hasRequest(RandomCraftRequest.class))
+ {
+ return;
+ }
+ _player.addRequest(new RandomCraftRequest(_player));
+
+ if (_player.reduceAdena("RandomCraft Make", 500000, _player, true))
+ {
+ final int madeId = Rnd.get(0, 4);
+ final RandomCraftRewardItemHolder holder = _rewardList.get(madeId);
+ final int itemId = holder.getItemId();
+ final long itemCount = holder.getItemCount();
+ _rewardList.clear();
+ final ItemInstance item = _player.addItem("RandomCraft Make", itemId, itemCount, _player, true);
+ if (RandomCraftData.getInstance().isAnnounce(itemId))
+ {
+ Broadcast.toAllOnlinePlayers(new ExItemAnnounce(_player, item, ExItemAnnounce.RANDOM_CRAFT));
+ LOGGER.log(Level.INFO, _player + " randomly crafted " + item.getItem() + " [" + item.getObjectId() + "]");
+ }
+ _player.sendPacket(new ExCraftRandomMake(itemId, itemCount));
+ _player.sendPacket(new ExCraftRandomInfo(_player));
+
+ }
+ _player.removeRequest(RandomCraftRequest.class);
+ }
+
+ public List getRewards()
+ {
+ return _rewardList;
+ }
+
+ public int getFullCraftPoints()
+ {
+ return _fullCraftPoints;
+ }
+
+ public void addFullCraftPoints(int value)
+ {
+ addFullCraftPoints(value, false);
+ }
+
+ public void addFullCraftPoints(int value, boolean broadcast)
+ {
+ _fullCraftPoints = Math.min(_fullCraftPoints + value, MAX_FULL_CRAFT_POINTS);
+ if (_craftPoints >= MAX_CRAFT_POINTS)
+ {
+ _craftPoints = 0;
+ }
+ if (value > 0)
+ {
+ _isSayhaRoll = true;
+ }
+ if (broadcast)
+ {
+ _player.sendPacket(new ExCraftInfo(_player));
+ }
+ }
+
+ public void removeFullCraftPoints(int value)
+ {
+ _fullCraftPoints -= value;
+ _player.sendPacket(new ExCraftInfo(_player));
+ }
+
+ public void addCraftPoints(int value)
+ {
+ if ((_craftPoints - 1) < MAX_CRAFT_POINTS)
+ {
+ _craftPoints += value;
+ }
+
+ final int fullPointsToAdd = _craftPoints / MAX_CRAFT_POINTS;
+ final int pointsToRemove = MAX_CRAFT_POINTS * fullPointsToAdd;
+
+ _craftPoints -= pointsToRemove;
+ addFullCraftPoints(fullPointsToAdd);
+ if (_fullCraftPoints == MAX_FULL_CRAFT_POINTS)
+ {
+ _craftPoints = MAX_CRAFT_POINTS;
+ }
+
+ final SystemMessage sm = new SystemMessage(SystemMessageId.YOU_HAVE_ACQUIRED_S1_CRAFT_SCALE_POINTS);
+ sm.addLong(value);
+ _player.sendPacket(sm);
+ _player.sendPacket(new ExCraftInfo(_player));
+ }
+
+ public int getCraftPoints()
+ {
+ return _craftPoints;
+ }
+
+ public void setIsSayhaRoll(boolean value)
+ {
+ _isSayhaRoll = value;
+ }
+
+ public boolean isSayhaRoll()
+ {
+ return _isSayhaRoll;
+ }
+
+ public int getLockedSlotCount()
+ {
+ int count = 0;
+ for (RandomCraftRewardItemHolder holder : _rewardList)
+ {
+ if (holder.isLocked())
+ {
+ count++;
+ }
+ }
+ return count;
+ }
+}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java
index f065c45ae9..fbf4839cd6 100644
--- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java
@@ -99,6 +99,11 @@ import org.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRProduct
import org.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRRecentProductList;
import org.l2jmobius.gameserver.network.clientpackets.raidbossinfo.RequestRaidBossSpawnInfo;
import org.l2jmobius.gameserver.network.clientpackets.raidbossinfo.RequestRaidServerInfo;
+import org.l2jmobius.gameserver.network.clientpackets.randomcraft.ExRequestRandomCraftExtract;
+import org.l2jmobius.gameserver.network.clientpackets.randomcraft.ExRequestRandomCraftInfo;
+import org.l2jmobius.gameserver.network.clientpackets.randomcraft.ExRequestRandomCraftLockSlot;
+import org.l2jmobius.gameserver.network.clientpackets.randomcraft.ExRequestRandomCraftMake;
+import org.l2jmobius.gameserver.network.clientpackets.randomcraft.ExRequestRandomCraftRefresh;
import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestOlympiadHeroAndLegendInfo;
import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestOlympiadMyRankingInfo;
import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestOlympiadRankingInfo;
@@ -535,11 +540,11 @@ public enum ExIncomingPackets implements IIncomingPackets
EX_CASTLEWAR_OBSERVER_START(0x196, null, ConnectionState.IN_GAME),
EX_RAID_TELEPORT_INFO(0x197, null, ConnectionState.IN_GAME),
EX_TELEPORT_TO_RAID_POSITION(0x198, null, ConnectionState.IN_GAME),
- EX_CRAFT_EXTRACT(0x199, null, ConnectionState.IN_GAME),
- EX_CRAFT_RANDOM_INFO(0x19A, null, ConnectionState.IN_GAME),
- EX_CRAFT_RANDOM_LOCK_SLOTEX_CRAFT_RANDOM_INFO(0x19B, null, ConnectionState.IN_GAME),
- EX_CRAFT_RANDOM_REFRESH(0x19C, null, ConnectionState.IN_GAME),
- EX_CRAFT_RANDOM_MAKE(0x19D, null, ConnectionState.IN_GAME),
+ EX_CRAFT_EXTRACT(0x199, ExRequestRandomCraftExtract::new, ConnectionState.IN_GAME),
+ EX_CRAFT_RANDOM_INFO(0x19A, ExRequestRandomCraftInfo::new, ConnectionState.IN_GAME),
+ EX_CRAFT_RANDOM_LOCK_SLOTEX_CRAFT_RANDOM_INFO(0x19B, ExRequestRandomCraftLockSlot::new, ConnectionState.IN_GAME),
+ EX_CRAFT_RANDOM_REFRESH(0x19C, ExRequestRandomCraftRefresh::new, ConnectionState.IN_GAME),
+ EX_CRAFT_RANDOM_MAKE(0x19D, ExRequestRandomCraftMake::new, ConnectionState.IN_GAME),
EX_MULTI_SELL_LIST(0x19E, null, ConnectionState.IN_GAME),
EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19F, null, ConnectionState.IN_GAME),
EX_OLYMPIAD_UI(0x1A0, null, ConnectionState.IN_GAME),
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java
index 5811776dff..eb5092a429 100644
--- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java
@@ -109,6 +109,7 @@ import org.l2jmobius.gameserver.network.serverpackets.dailymission.ExOneDayRecei
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.network.serverpackets.randomcraft.ExCraftInfo;
import org.l2jmobius.gameserver.util.BuilderUtil;
/**
@@ -633,11 +634,6 @@ public class EnterWorld implements IClientIncomingPacket
player.sendPacket(new ExConnectedTimeAndGettableReward(player));
player.sendPacket(new ExOneDayReceiveRewardList(player, true));
- if (Config.MAGIC_LAMP_ENABLE)
- {
- player.sendPacket(new ExMagicLampExpInfoUI(player));
- }
-
// Handle soulshots, disable all on EnterWorld
player.sendPacket(new ExAutoSoulShot(0, true, 0));
player.sendPacket(new ExAutoSoulShot(0, true, 1));
@@ -664,6 +660,16 @@ public class EnterWorld implements IClientIncomingPacket
player.sendPacket(new ExVitalityEffectInfo(player));
}
+ if (Config.ENABLE_MAGIC_LAMP)
+ {
+ player.sendPacket(new ExMagicLampExpInfoUI(player));
+ }
+
+ if (Config.ENABLE_RANDOM_CRAFT)
+ {
+ player.sendPacket(new ExCraftInfo(player));
+ }
+
// Activate first agathion when available.
final ItemInstance agathion = player.getInventory().unEquipItemInBodySlot(Item.SLOT_AGATHION);
if (agathion != null)
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestDestroyItem.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestDestroyItem.java
index 3d73ccd56f..c06ad57bec 100644
--- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestDestroyItem.java
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestDestroyItem.java
@@ -31,6 +31,7 @@ import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
@@ -228,7 +229,7 @@ public class RequestDestroyItem implements IClientIncomingPacket
}
// LCoin UI update.
- if (removedItem.getId() == ExBloodyCoinCount.LCOIN_ID)
+ if (removedItem.getId() == Inventory.LCOIN_ID)
{
player.sendPacket(new ExBloodyCoinCount(player));
}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java
index 8d22a8bcb0..34c8379fa3 100644
--- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java
@@ -234,7 +234,7 @@ public class RequestEnchantItem implements IClientIncomingPacket
sm.addInt(item.getEnchantLevel());
sm.addItemName(item);
player.broadcastPacket(sm);
- Broadcast.toAllOnlinePlayers(new ExItemAnnounce(item, player));
+ Broadcast.toAllOnlinePlayers(new ExItemAnnounce(player, item, ExItemAnnounce.ENCHANT));
final Skill skill = CommonSkill.FIREWORK.getSkill();
if (skill != null)
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftExtract.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftExtract.java
new file mode 100644
index 0000000000..3aeb3f07a8
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftExtract.java
@@ -0,0 +1,109 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * This program 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.
+ *
+ * This program 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 .
+ */
+package org.l2jmobius.gameserver.network.clientpackets.randomcraft;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.l2jmobius.Config;
+import org.l2jmobius.commons.network.PacketReader;
+import org.l2jmobius.gameserver.data.xml.RandomCraftData;
+import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.model.actor.request.RandomCraftRequest;
+import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
+import org.l2jmobius.gameserver.network.GameClient;
+import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
+import org.l2jmobius.gameserver.network.serverpackets.randomcraft.ExCraftExtract;
+import org.l2jmobius.gameserver.network.serverpackets.randomcraft.ExCraftInfo;
+
+/**
+ * @author Mode
+ */
+public class ExRequestRandomCraftExtract implements IClientIncomingPacket
+{
+ private final Map _items = new HashMap<>();
+
+ @Override
+ public boolean read(GameClient client, PacketReader packet)
+ {
+ final int size = packet.readD();
+ for (int i = 0; i < size; i++)
+ {
+ final int objId = packet.readD();
+ final long count = packet.readQ();
+ _items.put(objId, count);
+ }
+ return true;
+ }
+
+ @Override
+ public void run(GameClient client)
+ {
+ if (!Config.ENABLE_RANDOM_CRAFT)
+ {
+ return;
+ }
+
+ final PlayerInstance player = client.getPlayer();
+ if (player == null)
+ {
+ return;
+ }
+
+ if (player.hasItemRequest() || player.hasRequest(RandomCraftRequest.class))
+ {
+ return;
+ }
+ player.addRequest(new RandomCraftRequest(player));
+
+ int points = 0;
+ int fee = 0;
+ Map toDestroy = new HashMap<>();
+ for (Entry e : _items.entrySet())
+ {
+ final int objId = e.getKey();
+ long count = e.getValue();
+ if (count < 1)
+ {
+ player.removeRequest(RandomCraftRequest.class);
+ return;
+ }
+ final ItemInstance item = player.getInventory().getItemByObjectId(objId);
+ if (item != null)
+ {
+ count = Math.min(item.getCount(), count);
+ toDestroy.put(objId, count);
+ points += RandomCraftData.getInstance().getPoints(item.getId()) * count;
+ fee += RandomCraftData.getInstance().getFee(item.getId()) * count;
+ }
+ }
+
+ if (player.reduceAdena("RandomCraft Extract", fee, player, true))
+ {
+ for (Entry e : toDestroy.entrySet())
+ {
+ player.destroyItem("RandomCraft Extract", e.getKey(), e.getValue(), player, true);
+ }
+ player.getRandomCraft().addCraftPoints(points);
+ }
+
+ player.sendPacket(new ExCraftInfo(player));
+ player.sendPacket(new ExCraftExtract());
+ player.removeRequest(RandomCraftRequest.class);
+ }
+}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftInfo.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftInfo.java
new file mode 100644
index 0000000000..5f5d87ad09
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftInfo.java
@@ -0,0 +1,53 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * This program 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.
+ *
+ * This program 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 .
+ */
+package org.l2jmobius.gameserver.network.clientpackets.randomcraft;
+
+import org.l2jmobius.Config;
+import org.l2jmobius.commons.network.PacketReader;
+import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.network.GameClient;
+import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
+import org.l2jmobius.gameserver.network.serverpackets.randomcraft.ExCraftRandomInfo;
+
+/**
+ * @author Mode
+ */
+public class ExRequestRandomCraftInfo implements IClientIncomingPacket
+{
+ @Override
+ public boolean read(GameClient client, PacketReader packet)
+ {
+ return true;
+ }
+
+ @Override
+ public void run(GameClient client)
+ {
+ if (!Config.ENABLE_RANDOM_CRAFT)
+ {
+ return;
+ }
+
+ final PlayerInstance player = client.getPlayer();
+ if (player == null)
+ {
+ return;
+ }
+
+ player.sendPacket(new ExCraftRandomInfo(player));
+ }
+}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftLockSlot.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftLockSlot.java
new file mode 100644
index 0000000000..f9421ddeb1
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftLockSlot.java
@@ -0,0 +1,83 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * This program 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.
+ *
+ * This program 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 .
+ */
+package org.l2jmobius.gameserver.network.clientpackets.randomcraft;
+
+import org.l2jmobius.Config;
+import org.l2jmobius.commons.network.PacketReader;
+import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
+import org.l2jmobius.gameserver.model.itemcontainer.PlayerRandomCraft;
+import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
+import org.l2jmobius.gameserver.network.GameClient;
+import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
+import org.l2jmobius.gameserver.network.serverpackets.randomcraft.ExCraftRandomInfo;
+import org.l2jmobius.gameserver.network.serverpackets.randomcraft.ExCraftRandomLockSlot;
+
+/**
+ * @author Mode
+ */
+public class ExRequestRandomCraftLockSlot implements IClientIncomingPacket
+{
+ private static final int[] LOCK_PRICE =
+ {
+ 100,
+ 500,
+ 1000
+ };
+
+ private int _id;
+
+ @Override
+ public boolean read(GameClient client, PacketReader packet)
+ {
+ _id = packet.readD();
+ return true;
+ }
+
+ @Override
+ public void run(GameClient client)
+ {
+ if (!Config.ENABLE_RANDOM_CRAFT)
+ {
+ return;
+ }
+
+ final PlayerInstance player = client.getPlayer();
+ if (player == null)
+ {
+ return;
+ }
+
+ if ((_id >= 0) && (_id < 5))
+ {
+ final PlayerRandomCraft rc = player.getRandomCraft();
+ int lockedItemCount = rc.getLockedSlotCount();
+ if (((rc.getRewards().size() - 1) >= _id) && (lockedItemCount < 3))
+ {
+ int price = LOCK_PRICE[Math.min(lockedItemCount, 2)];
+ ItemInstance lcoin = player.getInventory().getItemByItemId(Inventory.LCOIN_ID);
+ if ((lcoin != null) && (lcoin.getCount() >= price))
+ {
+ player.destroyItem("RandomCraft Lock Slot", lcoin, price, player, true);
+ rc.getRewards().get(_id).lock();
+ player.sendPacket(new ExCraftRandomLockSlot());
+ player.sendPacket(new ExCraftRandomInfo(player));
+ }
+ }
+ }
+ }
+}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftMake.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftMake.java
new file mode 100644
index 0000000000..1e41aac07f
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftMake.java
@@ -0,0 +1,54 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * This program 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.
+ *
+ * This program 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 .
+ */
+package org.l2jmobius.gameserver.network.clientpackets.randomcraft;
+
+import org.l2jmobius.Config;
+import org.l2jmobius.commons.network.PacketReader;
+import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.model.itemcontainer.PlayerRandomCraft;
+import org.l2jmobius.gameserver.network.GameClient;
+import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
+
+/**
+ * @author Mode
+ */
+public class ExRequestRandomCraftMake implements IClientIncomingPacket
+{
+ @Override
+ public boolean read(GameClient client, PacketReader packet)
+ {
+ return true;
+ }
+
+ @Override
+ public void run(GameClient client)
+ {
+ if (!Config.ENABLE_RANDOM_CRAFT)
+ {
+ return;
+ }
+
+ final PlayerInstance player = client.getPlayer();
+ if (player == null)
+ {
+ return;
+ }
+
+ final PlayerRandomCraft rc = player.getRandomCraft();
+ rc.make();
+ }
+}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftRefresh.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftRefresh.java
new file mode 100644
index 0000000000..602ba3def7
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/randomcraft/ExRequestRandomCraftRefresh.java
@@ -0,0 +1,54 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * This program 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.
+ *
+ * This program 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 .
+ */
+package org.l2jmobius.gameserver.network.clientpackets.randomcraft;
+
+import org.l2jmobius.Config;
+import org.l2jmobius.commons.network.PacketReader;
+import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.model.itemcontainer.PlayerRandomCraft;
+import org.l2jmobius.gameserver.network.GameClient;
+import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
+
+/**
+ * @author Mode
+ */
+public class ExRequestRandomCraftRefresh implements IClientIncomingPacket
+{
+ @Override
+ public boolean read(GameClient client, PacketReader packet)
+ {
+ return true;
+ }
+
+ @Override
+ public void run(GameClient client)
+ {
+ if (!Config.ENABLE_RANDOM_CRAFT)
+ {
+ return;
+ }
+
+ final PlayerInstance player = client.getPlayer();
+ if (player == null)
+ {
+ return;
+ }
+
+ final PlayerRandomCraft rc = player.getRandomCraft();
+ rc.refresh();
+ }
+}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java
index dfca262784..8a8bb6c3bc 100644
--- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java
@@ -22,24 +22,29 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.network.OutgoingPackets;
/**
- * @author NviX
+ * @author NviX, Mobius
*/
public class ExItemAnnounce implements IClientOutgoingPacket
{
+ public static final int ENCHANT = 0x00;
+ public static final int RANDOM_CRAFT = 0x02;
+
private final ItemInstance _item;
private final PlayerInstance _player;
+ private final int _type;
- public ExItemAnnounce(ItemInstance item, PlayerInstance player)
+ public ExItemAnnounce(PlayerInstance player, ItemInstance item, int type)
{
- _item = item;
_player = player;
+ _item = item;
+ _type = type;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_ITEM_ANNOUNCE.writeId(packet);
- packet.writeC(0x00); // item icon
+ packet.writeC(_type); // announce type
packet.writeString(_player.getName()); // name of player
packet.writeD(_item.getId()); // item id
packet.writeD(_item.getEnchantLevel()); // enchant level
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/limitshop/ExBloodyCoinCount.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/limitshop/ExBloodyCoinCount.java
index 25240923b2..b6ccf0a8ae 100644
--- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/limitshop/ExBloodyCoinCount.java
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/limitshop/ExBloodyCoinCount.java
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets.limitshop;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
@@ -26,13 +27,11 @@ import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
*/
public class ExBloodyCoinCount implements IClientOutgoingPacket
{
- public final static int LCOIN_ID = 91663;
-
private final long _count;
public ExBloodyCoinCount(PlayerInstance player)
{
- _count = player.getInventory().getInventoryItemCount(LCOIN_ID, -1);
+ _count = player.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1);
}
@Override
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampExpInfoUI.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampExpInfoUI.java
index 8b0d75ff4b..46441a29d9 100644
--- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampExpInfoUI.java
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/magiclamp/ExMagicLampExpInfoUI.java
@@ -38,7 +38,7 @@ public class ExMagicLampExpInfoUI implements IClientOutgoingPacket
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_MAGICLAMP_EXP_INFO.writeId(packet);
- packet.writeD(Config.MAGIC_LAMP_ENABLE ? 0x01 : 0x00); // IsOpen
+ packet.writeD(Config.ENABLE_MAGIC_LAMP ? 0x01 : 0x00); // IsOpen
packet.writeD(Config.MAGIC_LAMP_MAX_LEVEL_EXP); // MaxMagicLampExp
packet.writeD(_player.getLampExp()); // MagicLampExp
packet.writeD(_player.getLampCount()); // MagicLampCount
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftExtract.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftExtract.java
new file mode 100644
index 0000000000..5d082bad06
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftExtract.java
@@ -0,0 +1,39 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * This program 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.
+ *
+ * This program 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 .
+ */
+package org.l2jmobius.gameserver.network.serverpackets.randomcraft;
+
+import org.l2jmobius.commons.network.PacketWriter;
+import org.l2jmobius.gameserver.network.OutgoingPackets;
+import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
+
+/**
+ * @author Mode
+ */
+public class ExCraftExtract implements IClientOutgoingPacket
+{
+ public ExCraftExtract()
+ {
+ }
+
+ @Override
+ public boolean write(PacketWriter packet)
+ {
+ OutgoingPackets.EX_CRAFT_EXTRACT.writeId(packet);
+ packet.writeC(0x00);
+ return true;
+ }
+}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftInfo.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftInfo.java
new file mode 100644
index 0000000000..4e4aa71893
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftInfo.java
@@ -0,0 +1,49 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * This program 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.
+ *
+ * This program 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 .
+ */
+package org.l2jmobius.gameserver.network.serverpackets.randomcraft;
+
+import org.l2jmobius.commons.network.PacketWriter;
+import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.model.itemcontainer.PlayerRandomCraft;
+import org.l2jmobius.gameserver.network.OutgoingPackets;
+import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
+
+/**
+ * @author Mode
+ */
+public class ExCraftInfo implements IClientOutgoingPacket
+{
+ private final PlayerInstance _player;
+
+ public ExCraftInfo(PlayerInstance player)
+ {
+ _player = player;
+ }
+
+ @Override
+ public boolean write(PacketWriter packet)
+ {
+ OutgoingPackets.EX_CRAFT_INFO.writeId(packet);
+
+ final PlayerRandomCraft rc = _player.getRandomCraft();
+ packet.writeD(rc.getFullCraftPoints()); // Full points owned
+ packet.writeD(rc.getCraftPoints()); // Craft Points (10k = 1%)
+ packet.writeC(rc.isSayhaRoll() ? 0x01 : 0x00); // Will get sayha?
+
+ return true;
+ }
+}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftRandomInfo.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftRandomInfo.java
new file mode 100644
index 0000000000..5030e92343
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftRandomInfo.java
@@ -0,0 +1,78 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * This program 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.
+ *
+ * This program 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 .
+ */
+package org.l2jmobius.gameserver.network.serverpackets.randomcraft;
+
+import java.util.List;
+
+import org.l2jmobius.commons.network.PacketWriter;
+import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.model.holders.RandomCraftRewardItemHolder;
+import org.l2jmobius.gameserver.network.OutgoingPackets;
+import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
+
+/**
+ * @author Mode
+ */
+public class ExCraftRandomInfo implements IClientOutgoingPacket
+{
+ private final PlayerInstance _player;
+
+ public ExCraftRandomInfo(PlayerInstance player)
+ {
+ _player = player;
+ }
+
+ @Override
+ public boolean write(PacketWriter packet)
+ {
+ OutgoingPackets.EX_CRAFT_RANDOM_INFO.writeId(packet);
+
+ final List rewards = _player.getRandomCraft().getRewards();
+ int size = 5;
+ packet.writeD(size); // size
+ for (int i = 0; i < rewards.size(); i++)
+ {
+ final RandomCraftRewardItemHolder holder = rewards.get(i);
+ if ((holder != null) && (holder.getItemId() != 0))
+ {
+ packet.writeC(holder.isLocked() ? 0x01 : 0x00); // Locked
+ packet.writeD(holder.getLockLeft()); // Rolls it will stay locked
+ packet.writeD(holder.getItemId()); // Item id
+ packet.writeQ(holder.getItemCount()); // Item count
+ }
+ else
+ {
+ packet.writeC(0x00);
+ packet.writeD(0x00);
+ packet.writeD(0x00);
+ packet.writeQ(0x00);
+ }
+ size--;
+ }
+
+ // Write missing
+ for (int i = size; i > 0; i--)
+ {
+ packet.writeC(0x00);
+ packet.writeD(0x00);
+ packet.writeD(0x00);
+ packet.writeQ(0x00);
+ }
+
+ return true;
+ }
+}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftRandomLockSlot.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftRandomLockSlot.java
new file mode 100644
index 0000000000..d4f6f05a0c
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftRandomLockSlot.java
@@ -0,0 +1,39 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * This program 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.
+ *
+ * This program 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 .
+ */
+package org.l2jmobius.gameserver.network.serverpackets.randomcraft;
+
+import org.l2jmobius.commons.network.PacketWriter;
+import org.l2jmobius.gameserver.network.OutgoingPackets;
+import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
+
+/**
+ * @author Mode
+ */
+public class ExCraftRandomLockSlot implements IClientOutgoingPacket
+{
+ public ExCraftRandomLockSlot()
+ {
+ }
+
+ @Override
+ public boolean write(PacketWriter packet)
+ {
+ OutgoingPackets.EX_CRAFT_RANDOM_LOCK_SLOT.writeId(packet);
+ packet.writeC(0x00);
+ return true;
+ }
+}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftRandomMake.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftRandomMake.java
new file mode 100644
index 0000000000..9b82b3d21e
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftRandomMake.java
@@ -0,0 +1,48 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * This program 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.
+ *
+ * This program 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 .
+ */
+package org.l2jmobius.gameserver.network.serverpackets.randomcraft;
+
+import org.l2jmobius.commons.network.PacketWriter;
+import org.l2jmobius.gameserver.network.OutgoingPackets;
+import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
+
+/**
+ * @author Mode
+ */
+public class ExCraftRandomMake implements IClientOutgoingPacket
+{
+ private final int _itemId;
+ private final long _itemCount;
+
+ public ExCraftRandomMake(int itemId, long itemCount)
+ {
+ _itemId = itemId;
+ _itemCount = itemCount;
+ }
+
+ @Override
+ public boolean write(PacketWriter packet)
+ {
+ OutgoingPackets.EX_CRAFT_RANDOM_MAKE.writeId(packet);
+ packet.writeC(0x00); // Close window
+ packet.writeH(0x0F); // Unknown
+ packet.writeD(_itemId);
+ packet.writeQ(_itemCount);
+ packet.writeC(0x00); // Enchantment level
+ return true;
+ }
+}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftRandomRefresh.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftRandomRefresh.java
new file mode 100644
index 0000000000..8ffe0f4ede
--- /dev/null
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/randomcraft/ExCraftRandomRefresh.java
@@ -0,0 +1,39 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * This program 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.
+ *
+ * This program 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 .
+ */
+package org.l2jmobius.gameserver.network.serverpackets.randomcraft;
+
+import org.l2jmobius.commons.network.PacketWriter;
+import org.l2jmobius.gameserver.network.OutgoingPackets;
+import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
+
+/**
+ * @author Mode
+ */
+public class ExCraftRandomRefresh implements IClientOutgoingPacket
+{
+ public ExCraftRandomRefresh()
+ {
+ }
+
+ @Override
+ public boolean write(PacketWriter packet)
+ {
+ OutgoingPackets.EX_CRAFT_RANDOM_REFRESH.writeId(packet);
+ packet.writeC(0x00);
+ return true;
+ }
+}
diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/readme.txt b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/readme.txt
index dea891d886..9fa123162e 100644
--- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/readme.txt
+++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/readme.txt
@@ -107,7 +107,13 @@ The Kamael: https://eu.4game.com/patchnotes/lineage2classic/154/
Death Knight: https://eu.4game.com/patchnotes/lineage2essence/196/
-Death Knight creation support
+-Death knight starting area
+-Death knight quests
-Player bonus stats system
+-LCoin shop system
+-Sayha's Grace system
+-Random Craft system
+-Magic Lamp system
Fluffy Reinforcement: https://eu.4game.com/patchnotes/lineage2essence/204/
-Teleport favorites system