Welcome to MaxCheaters.com

Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads

[Share]Custom item that adds pvp and pk kills.


Recommended Posts

Hi guys. I(and i mean I) created a custom item(configurable id), that when you click it, it will give you pvp pk points of your choice(configurable) and it will delete the item(i didn't have to write this :P). It cannot be used during olympiad(configurable), during you are dead(non-configurable), if you are not nobless(configurable), if you are not hero(configurable), if you are not with a subclass(configurable) or if you are not at the required level(configurable). It was a bit tricky to make it, because i had to create(actually c/p and change sth) new methods in L2PcInstance. Anyway here:

Index: gameserver/java/net/sf/l2j/Config.java
===================================================================
--- gameserver/java/net/sf/l2j/Config.java	(revision 29)
+++ gameserver/java/net/sf/l2j/Config.java	(working copy)
@@ -42,6 +42,16 @@
{
     protected static final Logger _log = Logger.getLogger(Config.class.getName());
     
+    public static boolean ALLOW_PVP_PK_ITEM;
+    public static int PVP_PK_ITEM_ID;
+    public static int PVP_PK_ITEM_LVL_NEEDED;
+    public static boolean PVP_PK_ITEM_IN_OLYMPIAD;
+    public static boolean PVP_PK_ITEM_SUBCLASS_NEEDED;
+    public static boolean PVP_PK_ITEM_HERO_NEEDED;
+    public static boolean PVP_PK_ITEM_NOBLE_NEEDED;
+    public static int PVP_PK_ITEM_PVPS_REWARD;
+    public static int PVP_PK_ITEM_PKS_REWARD;
+
	/**--------------------------------------------------
	// Property File Definitions
	//-------------------------------------------------*/
@@ -1058,6 +1068,15 @@
                 
     	        BUFFS_MAX_AMOUNT 		= Byte.parseByte(playersSettings.getProperty("maxbuffamount","24"));
     	        STORE_SKILL_COOLTIME 	= Boolean.parseBoolean(playersSettings.getProperty("StoreSkillCooltime", "true"));
+    	        ALLOW_PVP_PK_ITEM  	= Boolean.parseBoolean(playersSettings.getProperty("AllowPvpPkItem", "false"));
+    	        PVP_PK_ITEM_ID = Integer.parseInt(playersSettings.getProperty("PvpPkItemId", "6673"));
+    	        PVP_PK_ITEM_LVL_NEEDED = Integer.parseInt(playersSettings.getProperty("PvpPkItemLvlNeeded", "76"));
+    	        PVP_PK_ITEM_IN_OLYMPIAD 	= Boolean.parseBoolean(playersSettings.getProperty("PvpPkItemInOlympiad", "false"));
+    	        PVP_PK_ITEM_SUBCLASS_NEEDED 	= Boolean.parseBoolean(playersSettings.getProperty("PvpPkItemSubclassNedded", "true"));
+    	        PVP_PK_ITEM_HERO_NEEDED 	= Boolean.parseBoolean(playersSettings.getProperty("PvpPkItemHeroNeeded", "false"));
+    	        PVP_PK_ITEM_NOBLE_NEEDED 	= Boolean.parseBoolean(playersSettings.getProperty("PvpPkItemNobleNeeded", "true"));
+    	        PVP_PK_ITEM_PVPS_REWARD = Integer.parseInt(playersSettings.getProperty("PvpPkItemPvpsReward", "1000"));
+    	        PVP_PK_ITEM_PKS_REWARD = Integer.parseInt(playersSettings.getProperty("PvpPkItemPksReward", "1000"));
             }
             catch (Exception e)
             {
Index: gameserver/java/net/sf/l2j/gameserver/handler/itemhandlers/PvpPkItem.java
===================================================================
--- gameserver/java/net/sf/l2j/gameserver/handler/itemhandlers/PvpPkItem.java	(revision 0)
+++ gameserver/java/net/sf/l2j/gameserver/handler/itemhandlers/PvpPkItem.java	(revision 0)
@@ -0,0 +1,95 @@
+/*
+ * 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 2, 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package net.sf.l2j.gameserver.handler.itemhandlers;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.handler.IItemHandler;
+import net.sf.l2j.gameserver.model.L2Character;
+import net.sf.l2j.gameserver.model.L2ItemInstance;
+import net.sf.l2j.gameserver.model.L2World;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance;
+import net.sf.l2j.gameserver.model.actor.stat.PcStat;
+import net.sf.l2j.gameserver.model.zone.type.L2BossZone;
+import net.sf.l2j.gameserver.network.L2GameClient;
+import net.sf.l2j.gameserver.network.serverpackets.CharInfo;
+import net.sf.l2j.gameserver.network.serverpackets.ItemList;
+import net.sf.l2j.gameserver.network.serverpackets.L2GameServerPacket;
+import net.sf.l2j.gameserver.network.serverpackets.UserInfo;
+import net.sf.l2j.gameserver.util.Broadcast;
+
+/**
+ * Beast SoulShot Handler
+ *
+ * @author Tempy
+ */
+public class PvpPkItem implements IItemHandler
+{
+    // All the item IDs that this handler knows.
+    private static final int[] ITEM_IDS = { Config.PVP_PK_ITEM_ID };
+    
+    public void useItem(L2PlayableInstance playable, L2ItemInstance item)
+    {
+        if(!(playable instanceof L2PcInstance))
+            return;
+        L2PcInstance activeChar = (L2PcInstance)playable;
+        if (activeChar.getLevel() < Config.PVP_PK_ITEM_LVL_NEEDED)
+        {
+        	activeChar.sendMessage("You need to be over level " +Config.PVP_PK_ITEM_LVL_NEEDED+ " to use this item.");
+        	return;
+        }
+        if (activeChar.isInOlympiadMode() && Config.PVP_PK_ITEM_IN_OLYMPIAD)
+        {
+        	activeChar.sendMessage("You cannot use this item in Olympiad Mode!");
+        	return;
+        }
+        if (activeChar.isAlikeDead())
+        {
+        	activeChar.sendMessage("You cannot use this item while you are dead!");
+        	return;
+        }
+        if (!activeChar.isSubClassActive() && Config.PVP_PK_ITEM_SUBCLASS_NEEDED)
+        {
+        	activeChar.sendMessage("You cannot use this item in your main class!");
+        	return;
+        }
+        if (!activeChar.isHero() && Config.PVP_PK_ITEM_HERO_NEEDED)
+        {
+        	activeChar.sendMessage("You cannot use this item if you are not hero!");
+        	return;
+        }
+        if (!activeChar.isNoble() && Config.PVP_PK_ITEM_NOBLE_NEEDED)
+        {
+        	activeChar.sendMessage("You cannot use this item if you are not noble!");
+        	return;
+        }
+        else
+        {
+        	activeChar.addPvpKills(Config.PVP_PK_ITEM_PVPS_REWARD);
+        	activeChar.addPkKills(Config.PVP_PK_ITEM_PKS_REWARD);
+            activeChar.sendMessage("Gratz! You have been rewarded with " +Config.PVP_PK_ITEM_PVPS_REWARD+ " pvps and " +Config.PVP_PK_ITEM_PKS_REWARD+ " pks!");
+            playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
+        }
+    }
+
+    public int[] getItemIds()
+    {
+        return ITEM_IDS;
+    }
+}
Index: gameserver/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- gameserver/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(revision 29)
+++ gameserver/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -344,8 +344,8 @@

	private long _expBeforeDeath;
	private int _karma;
-	private int _pvpKills;
-	private int _pkKills;
+	public int _pvpKills;
+	public int _pkKills;
	private byte _pvpFlag;
	private byte _siegeState = 0;
	private int _curWeightPenalty = 0;
@@ -4338,7 +4338,23 @@
         // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
         sendPacket(new UserInfo(this));
     }
+    public void addPvpKills(int pvpKills)
+    {
+        // Add karma to attacker and increase its PK counter
+        setPvpKills(getPvpKills() + Config.PVP_PK_ITEM_PVPS_REWARD);

+        // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
+        sendPacket(new UserInfo(this));
+    }
+    public void addPkKills(int pkKills)
+    {
+        // Add karma to attacker and increase its PK counter
+        setPkKills(getPkKills() + Config.PVP_PK_ITEM_PKS_REWARD);
+
+        // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
+        sendPacket(new UserInfo(this));
+    }
+
     /**
      * Increase pk count, karma and send the info to the player
      *
Index: gameserver/java/net/sf/l2j/gameserver/handler/ItemHandler.java
===================================================================
--- gameserver/java/net/sf/l2j/gameserver/handler/ItemHandler.java	(revision 29)
+++ gameserver/java/net/sf/l2j/gameserver/handler/ItemHandler.java	(working copy)
@@ -18,6 +18,7 @@
  */
package net.sf.l2j.gameserver.handler;

+import net.sf.l2j.Config;
import java.util.Map;
import java.util.TreeMap;
import net.sf.l2j.gameserver.handler.itemhandlers.*;
@@ -60,6 +61,10 @@
         registerItemHandler(new PaganKeys());
		registerItemHandler(new Maps());
		registerItemHandler(new Potions());
+		if (Config.ALLOW_PVP_PK_ITEM)
+		{
+			registerItemHandler(new PvpPkItem());
+		}
		registerItemHandler(new Recipes());
         registerItemHandler(new RollingDice());
         registerItemHandler(new MysteryPotion());
Index: gameserver/java/config/players.properties
===================================================================
--- gameserver/java/config/players.properties	(revision 29)
+++ gameserver/java/config/players.properties	(working copy)
@@ -320,4 +320,30 @@
maxbuffamount = 24

# Store buffs/debuffs on user logout?
-StoreSkillCooltime = True
\ No newline at end of file
+StoreSkillCooltime = True
+
+#=============================================================
+#                        PVP - PK ITEM CONFIGS
+#=============================================================
+
+# Explanation: When a character is in the right conditions to use this item,
+# when he use it he will be rewarded with the pvps and pks amount you will choose.
+
+# Allow pvp pk item? Default: False
+AllowPvpPkItem = False
+# Item id for pvp pk item? Default: 6673
+PvpPkItemId = 6673
+# PvP Pk item level needed to use? Default: 76
+PvpPkItemLvlNeeded = 76
+# Allow to use pvp pk item in olympiad? Default: False
+PvpPkItemInOlympiad = False
+# Player must be in subclass to use pvp pk item? Default: True
+PvpPkItemSubclassNeeded = True
+# Player must be a server hero to use pvp pk item? Default: False
+PvpPkItemHeroNeeded = False
+# Player must be nobless to use pvp pk item? Default: True
+PvpPkItemNobleNeeded = True
+# How many pvps will the player be rewarded with if he use the item? Default: 1000
+PvpPkItemPvpsReward = 1000
+# How many pks will the player be rewarded with if he use the item? Default: 1000
+PvpPkItemPksReward = 1000
\ No newline at end of file

 

I don't need feedback, it is tested. Credits are 100% mine. Have Fun!

 

NOTE: It is coded on latest revision(29) of L2JaCis.

Share this post


Link to post
Share on other sites

Well,

The code aint bad,ofc it can be done in a better way than this now.

Thanks for share.


Also i think it will ruin the gameplay >.>

hmm why will it ruin the gameplay?

Share this post


Link to post
Share on other sites

Bad idea.

An item to give pvps and pk....bahh...

No fun like that.

 

And btw what's the prob if he use it with main class?

or in olympiad?

Share this post


Link to post
Share on other sites

Bad idea.

An item to give pvps and pk....bahh...

No fun like that.

 

And btw what's the prob if he use it with main class?

or in olympiad?

some ppl might not want :D i liked the idea, because i thought the pvp pk color.... it could be nice in some servers....

Share this post


Link to post
Share on other sites

Well,

The code aint bad,ofc it can be done in a better way than this now.

Thanks for share.


Also i think it will ruin the gameplay >.>

whats way is better?

Share this post


Link to post
Share on other sites

whats way is better?

Since he can use the methods which is exist,there's no reason to create new >.>

Also Olympus you use too many useless booleans >.>

Share this post


Link to post
Share on other sites

Since he can use the methods which is exist,there's no reason to create new >.>

Also Olympus you use too many useless booleans >.>

i want ppl to FULLY configure it. also when i used existing methods i had so many errors.... nm i made 2 new methods, 4 lines each, will they cause lags? :D

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.