Noticias:

Debes de estar registrado para poder ver el contenido indicado. Registrate o Conectate

Menú Principal

Item Clean PK

Iniciado por dwight, Abr 09, 2024, 08:58 AM

Tema anterior - Siguiente tema

dwight

Dejo mi aporte de un ItemHandler (Clean PK)

diff --git a/config/CustomItemHandler/ItemHandler.properties
new file mode 100644
index 0000000..0ff21e6
--- /dev/null
+++ b/config/CustomItemHandler/ItemHandler.properties
@@ -0,0 +1,11 @@
+#=============================================================
+#                Item Clean Pk
+#=============================================================
+#Item Clean PK ID
+Clean Pk ItemID = 0
+
+# ID of the anime skill when using the item
+SkillIDCleanPk = 5000
+
+#Clean Pk skill animation time
+SkillEffectsTimeCleanPK = 5000
diff --git a/java/L2jServer/Config.java b/java/L2jServer/Config.java
index f2336bb..77b1b0b 100644
--- a/java/L2jServer/Config.java
+++ b/java/L2jServer/Config.java
@@ -835,6 +835,9 @@
    public static int CLAN_FULL_STATUS;
    public static int CLAN_QUANTIDADE_ITEMFULL;
    public static int ITEM_CLASS_ID;
+    public static int SEGUNDS_SKILL_ANIMATION_PK;
+    public static int SKILL_ID_PK;
+    public static int ITEM_PK_CLEANID;
    // ============================================================
    public static void loadItensCoin()
    {
@@ -846,6 +849,9 @@
            final InputStream is = new FileInputStream(new File(ITEM_HANDLER));
            item.load(is);
            is.close();
+            ITEM_PK_CLEANID = Integer.parseInt(item.getProperty("CleanPkItemID", "0"));
+            SKILL_ID_PK = Integer.parseInt(item.getProperty("SkillIDCleanPk", "0"));
+            SEGUNDS_SKILL_ANIMATION_PK = Integer.parseInt(item.getProperty("SkillEffectsTimeCleanPK", "0"));
            ITEM_CLASS_ID = Integer.parseInt(ItemHandler.getProperty("ItemCard", "0"));
            REWARD_ITEM_D = Integer.parseInt(ItemHandler.getProperty("ItemRewardGradeDCoinID", "0"));
            COIN_ITEM_LEVEL = Integer.parseInt(ItemHandler.getProperty("ItemLevelCoinID", "5557"));
diff --git a/java/L2jServer/gameserver/handler/ItemHandler.java b/java/L2jServer/gameserver/handler/ItemHandler.java
index 63c3b34..3c3027d 100644
--- a/java/L2jServer/gameserver/handler/ItemHandler.java
+++ b/java/L2jServer/gameserver/handler/ItemHandler.java
@@ -42,6 +42,7 @@
import java/L2jServer.gameserver.handler.itemhandlers.ClanLevel;
import java/L2jServer.gameserver.handler.itemhandlers.ClanReputation;
import java/L2jServer.gameserver.handler.itemhandlers.ClassItem;
+import java/L2jServer.gameserver.handler.itemhandlers.CleanPk;
import java/L2jServer.gameserver.handler.itemhandlers.CrystalCarol;
import java/L2jServer.gameserver.handler.itemhandlers.Crystals;
import java/L2jServer.gameserver.handler.itemhandlers.CustomPotions;
@@ -136,6 +137,7 @@
    private ItemHandler()
    {
        _datatable = new TreeMap<>();
+        registerItemHandler(new CleanPk());
        registerItemHandler(new Skin1());
        registerItemHandler(new Skin2());
        registerItemHandler(new Skin3());
diff --git a/java/L2jServer/gameserver/handler/itemhandlers/CleanPk.java b/java/L2jServer/gameserver/handler/itemhandlers/CleanPk.java
new file mode 100644
index 0000000..0c7f435
--- /dev/null
+++ b/java/L2jServer/gameserver/handler/itemhandlers/CleanPk.java
@@ -0,0 +1,67 @@
+package java/L2jServer.gameserver.handler.itemhandlers;
+
+import java/L2jServer.Config;
+import java/L2jServer.gameserver.handler.IItemHandler;
+import java/L2jServer.gameserver.model.L2Object;
+import java/L2jServer.gameserver.model.actor.instance.L2ItemInstance;
+import java/L2jServer.gameserver.model.actor.instance.L2PcInstance;
+import java/L2jServer.gameserver.model.actor.instance.L2PlayableInstance;
+import java/L2jServer.gameserver.network.serverpackets.MagicSkillUser;
+import java/L2jServer.gameserver.network.serverpackets.SetupGauge;
+import java/L2jServer.gameserver.thread.ThreadPoolManager;
+import java/L2jServer.gameserver.util.Broadcast;
+
+/**
+ *
+ * @author Dwight
+ *
+ */
+public class CleanPk implements IItemHandler
+{
+    @Override
+    public void useItem(final L2PlayableInstance playable, final L2ItemInstance item)
+    {       
+       
+        if (!(playable instanceof L2PcInstance))
+            return;
+       
+        L2PcInstance activeChar = (L2PcInstance)playable;
+       
+        if (activeChar.getPkKills() < 5)
+        {
+            activeChar.sendMessage("You do not have enough Pk kills for clean.");
+            return;
+        }
+        if (activeChar.isImmobileUntilAttacked())
+        {
+            activeChar.sendMessage("You do use Item Mod Animation.");
+            return;
+        }
+        ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+        {
+            @Override
+            public void run()
+            {
+                playable.setIsImmobileUntilAttacked(false);
+                activeChar.setPkKills(0);
+                activeChar.sendMessage("You have successfully clean pks!");
+                activeChar.broadcastUserInfo();   
+            }
+        }, Config.SEGUNDS_SKILL_ANIMATION_PK);
+        final L2Object oldTarget = playable.getTarget();
+        playable.setTarget(playable);       
+        Broadcast.toSelfAndKnownPlayers(playable, new MagicSkillUser(playable, Config.SKILL_ID_PK, 1, Config.SEGUNDS_SKILL_ANIMATION_PK, 0));
+        playable.setTarget(oldTarget);
+        playable.sendPacket(new SetupGauge(0, Config.SEGUNDS_SKILL_ANIMATION_PK));   
+        playable.setIsImmobileUntilAttacked(true);
+    }
+    @Override
+    public int[] getItemIds()
+    {
+        return ITEM_IDS;
+    }
+   
+    private static final int ITEM_IDS[] = {
+        Config.ITEM_PK_CLEANID
+    };
+}
\ No newline at end of file