Jump to content

Different AutoEnchant NPC


^Wyatt

Recommended Posts

Well, hi, this is an auto enchanter Npc, but as title says, it's a little different of the others that are already shared.

How it works: you have a field where you specify the number of scrolls that you want to use, then you push the button of the item that you want to enchant (Inventory slot, so you must have this item equipped. Armor, weapon, jewel, belt or shirt.), then the npc will use the number of enchants that you've already specified with the item you set. For every enchant, the npc is taking the % rate of success of your server, so it can brake if it's not inside the minimum safe enchant range.

Also when npc is using the number of enchants that you specified, it shows you the animation. Here it comes a visual bug that I couldn't solve. The image of the item that npc is enchanting is little buggy and shows you the image of the last item that you enchanted manually. But it's only this, a visual bug, the process is fine.

 

I think it's useful in custom servers that have safe enchant +10 or similar, and every time you want to enchant an item you have to use 10 times an scroll, 10 times move the item to the enchant slot, push the button... and it's boring. So the npc helps you with that, or whatever you want to enchant.

 

About the visual bug if someone knows how to solve it I'll appreciate. I spent much time trying to solve it but I couldn't. So I decided to share as it's now and no more.

 

Here's a preview:

 

 

Coded for High Five

### Eclipse Workspace Patch 1.0
#P L2JH_Server
Index: java/com/l2jserver/gameserver/model/actor/instance/L2EnchanterInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2EnchanterInstance.java	(revision 0)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2EnchanterInstance.java	(revision 0)
@@ -0,0 +1,384 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package com.l2jserver.gameserver.model.actor.instance;
+
+import java.util.NoSuchElementException;
+import java.util.StringTokenizer;
+import javolution.text.TextBuilder;
+import com.l2jserver.Config;
+import com.l2jserver.gameserver.datatables.EnchantItemTable;
+import com.l2jserver.gameserver.datatables.SkillTable;
+import com.l2jserver.gameserver.model.EnchantScroll;
+import com.l2jserver.gameserver.model.L2Skill;
+import com.l2jserver.gameserver.model.L2World;
+import com.l2jserver.gameserver.model.actor.L2Npc;
+import com.l2jserver.gameserver.model.item.L2Armor;
+import com.l2jserver.gameserver.model.item.L2Item;
+import com.l2jserver.gameserver.model.item.instance.L2ItemInstance;
+import com.l2jserver.gameserver.network.SystemMessageId;
+import com.l2jserver.gameserver.network.serverpackets.ChooseInventoryItem;
+import com.l2jserver.gameserver.network.serverpackets.EnchantResult;
+//import com.l2jserver.gameserver.network.serverpackets.ExPutEnchantTargetItemResult;
+import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
+import com.l2jserver.gameserver.network.serverpackets.ItemList;
+import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
+import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
+import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
+import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
+import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;
+import com.l2jserver.gameserver.util.Util;
+import com.l2jserver.util.Rnd;
+
+/**
+ * 
+ * @author Wyatt
+ * TODO:FIXME visual bug related with target item
+ *
+ */
+public final class L2EnchanterInstance extends L2Npc
+{
+	boolean w = false;
+	
+	public L2EnchanterInstance(int objectId, L2NpcTemplate template)
+	{
+		super(objectId, template);
+		setInstanceType(InstanceType.L2EnchanterInstance);
+	}
+	
+	@Override
+	public void onBypassFeedback(L2PcInstance activeChar, String actualCommand)
+	{
+		StringTokenizer st = new StringTokenizer(actualCommand, " ");
+		actualCommand = st.nextToken();
+		
+		if (actualCommand.equalsIgnoreCase("enchant") && !activeChar.isImmobilized())
+		{
+			int i = Integer.parseInt(st.nextToken());
+			int q;
+			try
+			{
+				q = Integer.parseInt(st.nextToken());
+			}
+			catch(NumberFormatException enf)
+			{
+				activeChar.sendMessage("Enter a valid number.");
+				return;
+			}
+			catch(NoSuchElementException enf)
+			{
+				activeChar.sendMessage("Enter a valid number.");
+				return;
+			}
+			if(i == 5)
+				w = true;
+			else
+				w = false;
+			L2ItemInstance t = activeChar.getInventory().getPaperdollItem(i);
+			
+			if(t == null)
+			{
+				activeChar.sendMessage("You must have equiped an item in order to enchant it.");
+				return;
+			}		
+			
+			int l = t.getItem().getCrystalType();
+			int d = 0;
+			
+			switch(l)
+			{
+				case 1:
+					if (w)
+						d = 955;
+					else
+						d = 956;
+					break;
+				case 2:
+					if (w)
+						d = 951;
+					else
+						d = 952;
+					break;
+				case 3:
+					if (w)
+						d = 947;
+					else
+						d = 948;
+					break;
+				case 4:
+					if (w)
+						d = 729;
+					else
+						d = 730;
+					break;
+				case 5:
+					if (w)
+						d = 959;
+					else
+						d = 960;
+					break;
+				case 6:
+					if (w)
+						d = 959;
+					else
+						d = 960;
+					break;
+				case 7:
+					if (w)
+						d = 959;
+					else
+						d = 960;
+					break;
+			}
+
+			if(d == 0)
+			{
+				activeChar.sendMessage("The item grade is not enchantable.");
+				return;
+			}
+			
+			if(activeChar.getInventory().getInventoryItemCount(d, -1) < q)
+			{
+				activeChar.sendMessage("You don't have enough scrolls of enchant.");
+				return;
+			}
+			
+			try
+			{
+				activeChar.setIsImmobilized(true);
+				activeChar.setIsEnchanting(true);
+				for(int u=0;u<q;u++)
+				{
+					if(!enchant(activeChar, i, d))
+						continue;
+					Thread.sleep(2000);
+				}
+				activeChar.setIsImmobilized(false);
+				activeChar.setIsEnchanting(false);
+			}
+			catch (InterruptedException e)
+			{
+			}
+		}
+		else
+			super.onBypassFeedback(activeChar, actualCommand);
+	}
+	
+	@Override
+	public void showChatWindow(L2PcInstance player)
+	{
+		NpcHtmlMessage page = new NpcHtmlMessage(5);
+	    TextBuilder replyMSG = new TextBuilder();
+	    replyMSG.append("<html><title>Enchanter Menu</title><body>");
+	    replyMSG.append("<br>Hi "+player.getName()+"! This is a Npc Enchanter that will automatic land the number of enchants that you specify here in your weapon/jewel/armor. It's not a safe enchant npc, so for every enchant it will takes the % chance of success of your server (if its ++ of the safe enchant value).<br>");
+	    replyMSG.append("<center><table width=270><tr><td><font color=LEVEL>Number of enchants:</font></td><td><edit var=\"qbox\" width=80 height=15></td></tr></table><br>");	
+	    replyMSG.append("<center><table width=290 border=0 bgcolor=444444><tr><td><center><button value=\"Weapon\" action=\"bypass -h npc_"+getObjectId()+"_enchant 5 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td><center><button value=\"Shield\" action=\"bypass -h npc_"+getObjectId()+"_enchant 7 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td><center><button value=\"Helmet\" action=\"bypass -h npc_"+getObjectId()+"_enchant 1 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td><center><button value=\"Chest\" action=\"bypass -h npc_"+getObjectId()+"_enchant 6 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td></tr></table><br>");
+	    replyMSG.append("<center><table width=290 border=0 bgcolor=444444><tr><td><center><button value=\"Leggings\" action=\"bypass -h npc_"+getObjectId()+"_enchant 11 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td><center><button value=\"Gloves\" action=\"bypass -h npc_"+getObjectId()+"_enchant 10 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td><center><button value=\"Boots\" action=\"bypass -h npc_"+getObjectId()+"_enchant 12 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td><center><button value=\"Necklace\" action=\"bypass -h npc_"+getObjectId()+"_enchant 4 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td></tr></table><br>");
+	    replyMSG.append("<center><table width=290 border=0 bgcolor=444444><tr><td><center><button value=\"L. Earring\" action=\"bypass -h npc_"+getObjectId()+"_enchant 9 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td><center><button value=\"R. Earring\" action=\"bypass -h npc_"+getObjectId()+"_enchant 8 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td><center><button value=\"L. Ring\" action=\"bypass -h npc_"+getObjectId()+"_enchant 14 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td><center><button value=\"R. Ring\" action=\"bypass -h npc_"+getObjectId()+"_enchant 13 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td></tr></table><br>");
+	    replyMSG.append("<center><table width=290 border=0 bgcolor=444444><tr><td width=72></td><td width=72><center><button value=\"Shirt\" action=\"bypass -h npc_"+getObjectId()+"_enchant 0 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td width=72><center><button value=\"Belt\" action=\"bypass -h npc_"+getObjectId()+"_enchant 24 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td width=72></td></tr></table><br>");	  
+	    replyMSG.append("<br><br><center><img src=\"l2ui.squaregray\" width=290 height=1></center><br><center><table width=270><tr><td width=270><center><font color=444444>By Wyatt</color><br></center></td></tr></table></center>");
+		replyMSG.append("</body></html>");
+	    page.setHtml(replyMSG.toString());
+	    player.sendPacket(page);	
+	}
+	
+	private static boolean enchant(L2PcInstance activeChar, int i, int d) throws InterruptedException
+	{
+		L2ItemInstance t = activeChar.getInventory().getPaperdollItem(i);
+		if(t == null)
+			return false;
+		L2ItemInstance s = activeChar.getInventory().getItemByItemId(d);
+		activeChar.setActiveEnchantItem(s);
+		activeChar.sendPacket(new ChooseInventoryItem(s.getItemId()));
+		//activeChar.sendPacket(new ExPutEnchantTargetItemResult(7575)); TODO:Target item icon not done. It shows you the last item you enchanted through normal method.
+		Thread.sleep(1000);
+		enchantproccess(activeChar, t.getObjectId(), t, d);	
+		return true;
+	}
+	
+	private static void enchantproccess(L2PcInstance activeChar, int _objectId, L2ItemInstance t, int d)
+	{
+		if (activeChar == null || _objectId == 0)
+			return;
+		
+		if (!activeChar.isOnline() || activeChar.getClient().isDetached())
+		{
+			activeChar.setActiveEnchantItem(null);
+			return;
+		}
+		
+		if (activeChar.isProcessingTransaction() || activeChar.isInStoreMode())
+		{
+			activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_ENCHANT_WHILE_STORE));
+			activeChar.setActiveEnchantItem(null);
+			return;
+		}
+		
+		L2ItemInstance item = t;
+		L2ItemInstance scroll = activeChar.getActiveEnchantItem();
+		
+		if (item == null || scroll == null)
+		{
+			activeChar.setActiveEnchantItem(null);
+			return;
+		}
+		
+		EnchantScroll scrollTemplate = EnchantItemTable.getInstance().getEnchantScroll(scroll);
+		if (scrollTemplate == null)
+			return;		
+		
+		synchronized (item)
+		{
+			double chance = scrollTemplate.getChance(item, null);	
+			L2Skill enchant4Skill = null;
+			L2Item it = item.getItem();
+			if (item.getOwnerId() != activeChar.getObjectId() || item.isEnchantable() == 0 || chance < 0)
+			{
+				activeChar.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION);
+				activeChar.setActiveEnchantItem(null);
+				activeChar.sendPacket(new EnchantResult(2, 0, 0));
+				return;
+			}
+			
+			if (Rnd.get(100) < chance)
+			{
+				item.setEnchantLevel(item.getEnchantLevel() + 1);
+				item.updateDatabase();
+				activeChar.sendPacket(new EnchantResult(0, 0, 0));
+				int minEnchantAnnounce = item.isArmor() ? 6 : 7;
+				int maxEnchantAnnounce = item.isArmor() ? 0 : 15;
+				if (item.getEnchantLevel() == minEnchantAnnounce || item.getEnchantLevel() == maxEnchantAnnounce)
+				{
+					SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_SUCCESSFULY_ENCHANTED_A_S2_S3);
+					sm.addCharName(activeChar);
+					sm.addNumber(item.getEnchantLevel());
+					sm.addItemName(item);
+					activeChar.broadcastPacket(sm);
+					
+					L2Skill skill = SkillTable.FrequentSkill.FIREWORK.getSkill();
+					if (skill != null)
+						activeChar.broadcastPacket(new MagicSkillUse(activeChar, activeChar, skill.getId(), skill.getLevel(), skill.getHitTime(), skill.getReuseDelay()));
+				}
+				
+				if (it instanceof L2Armor && item.getEnchantLevel() == 4 && activeChar.getInventory().getItemByObjectId(item.getObjectId()).isEquipped())
+				{
+					enchant4Skill = ((L2Armor)it).getEnchant4Skill();
+					if (enchant4Skill != null)
+					{
+						activeChar.addSkill(enchant4Skill, false);
+						activeChar.sendSkillList();
+					}
+				}
+			}
+			else
+			{
+				if (scrollTemplate.isSafe())
+				{
+					activeChar.sendPacket(new EnchantResult(5, 0, 0));
+				}
+				else
+				{
+					if (item.isEquipped())
+					{
+						if (item.getEnchantLevel() > 0)
+						{
+							SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.EQUIPMENT_S1_S2_REMOVED);
+							sm.addNumber(item.getEnchantLevel());
+							sm.addItemName(item);
+							activeChar.sendPacket(sm);
+						}
+						else
+						{
+							SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISARMED);
+							sm.addItemName(item);
+							activeChar.sendPacket(sm);
+						}
+						
+						L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot());
+						InventoryUpdate iu = new InventoryUpdate();
+						for (L2ItemInstance itm : unequiped)
+							iu.addModifiedItem(itm);
+						
+						activeChar.sendPacket(iu);
+						activeChar.broadcastUserInfo();
+					}
+					
+					if (scrollTemplate.isBlessed())
+					{
+						activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.BLESSED_ENCHANT_FAILED));
+						item.setEnchantLevel(0);
+						item.updateDatabase();
+						activeChar.sendPacket(new EnchantResult(3, 0, 0));
+					}
+					else
+					{
+						int crystalId = item.getItem().getCrystalItemId();
+						int count = item.getCrystalCount() - (item.getItem().getCrystalCount() + 1) / 2;
+						if (count < 1)
+							count = 1;
+						
+						L2ItemInstance destroyItem = activeChar.getInventory().destroyItem("Enchant", item, activeChar, null);
+						if (destroyItem == null)
+						{
+							Util.handleIllegalPlayerAction(activeChar, "Unable to delete item on enchant failure from player " + activeChar.getName() + ", possible cheater !", Config.DEFAULT_PUNISH);
+							activeChar.setActiveEnchantItem(null);
+							activeChar.sendPacket(new EnchantResult(2, 0, 0));
+							return;
+						}
+						
+						L2ItemInstance crystals = null;
+						if (crystalId != 0)
+						{
+							crystals = activeChar.getInventory().addItem("Enchant", crystalId, count, activeChar, destroyItem);
+							
+							SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
+							sm.addItemName(crystals);
+							sm.addItemNumber(count);
+							activeChar.sendPacket(sm);
+						}
+						
+						if (!Config.FORCE_INVENTORY_UPDATE)
+						{
+							InventoryUpdate iu = new InventoryUpdate();
+							if (destroyItem.getCount() == 0)
+								iu.addRemovedItem(destroyItem);
+							else
+								iu.addModifiedItem(destroyItem);
+							
+							if (crystals != null)
+								iu.addItem(crystals);
+							
+							activeChar.sendPacket(iu);
+						}
+						else
+							activeChar.sendPacket(new ItemList(activeChar, true));
+						L2World world = L2World.getInstance();
+						world.removeObject(destroyItem);
+						if (crystalId == 0)
+							activeChar.sendPacket(new EnchantResult(4, 0, 0));
+						else
+							activeChar.sendPacket(new EnchantResult(1, crystalId, count));
+					}
+				}
+			}
+			activeChar.destroyItemByItemId("Echanter Npc", d, 1, activeChar, true);
+			StatusUpdate su = new StatusUpdate(activeChar);
+			su.addAttribute(StatusUpdate.CUR_LOAD, activeChar.getCurrentLoad());
+			activeChar.sendPacket(su);
+			activeChar.sendPacket(new ItemList(activeChar, false));
+			activeChar.broadcastUserInfo();
+			activeChar.setActiveEnchantItem(null);
+		}
+	}
+}
\ No newline at end of file
Index: java/com/l2jserver/gameserver/model/L2Object.java
===================================================================
--- java/com/l2jserver/gameserver/model/L2Object.java	(revision 167)
+++ java/com/l2jserver/gameserver/model/L2Object.java	(working copy)
@@ -183,8 +183,8 @@
		L2EventNpcInstance(L2Npc),
		L2WeddingManagerInstance(L2Npc),
		L2EventMobInstance(L2Npc),
-		L2BirthdayCakeInstance(L2Npc);
-		
+		L2BirthdayCakeInstance(L2Npc), 
+		L2EnchanterInstance(L2Npc);
		private final InstanceType _parent;
		private final long _typeL;
		private final long _typeH;

Credits: Wyatt

Link to comment
Share on other sites

Nice and i have an idea if you want

 

Before that you will chek for an item

if the player has 100 gb ( for example ) he can enchance with 90% rate

second button with

if player has 50gb will enchance with 80%rate

 

or

 

Choose enchance rate

 

option 1: 90 % 500 gb

option 2: 80 % 300 gb

bla bla until 50%

 

Just an Idea :)

 

Gj again

 

 

Link to comment
Share on other sites

using Thread.sleep(2000); is not that much of a good idea.

Better use tasks.

Nice code tho +1

I know but I wanted to block the player and also immobilize while the npc was acting, in order to prevent exploits.

Also I got tired with the visual bug and I didn't want to spend more time on it T_T.

btw ty x'D

Link to comment
Share on other sites

  • 11 months later...

Fix the hidden content please, to avoid spam replies. Thank you. Also, i will trying it out... Thanks for share..

Dammit all old posts the same shit -.- Q_Q

Done.

Link to comment
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.



  • Posts

    • Good afternoon I am selling a list of forums, which contains more than 100 lines of active and current RU forums.   - topics: dark, crypto, SMM, programming, services, cheats, etc.; - sorting from more popular to less popular (by traffic, by the number of new posts per day);   Are you looking for where to advertise your services? This base will definitely suit you! In addition, on the forums you can find a bunch of useful information, software, as well as advertisements about sales and services from other users.   Payment: 12 USTD   After payment you receive a text document with a list of forums (PS. all information is provided for informational purposes only); TELEGRAM - https://t.me/milozare
    • I strongly concur with some opinions shared. As I've previously mentioned on different posts, it's shocking to see how seasonal servers gather this much population. However, being back in the game some months I did start understanding how the current community of L2 plays and thinks.   It's a huge problem, but in my opinion the guilt is shared between server owners and community. To keep a long term project running (more than a year on) you need to have the equivalent community that will support the project, which unfortunately is not that big. The current player community of L2 hops on new servers with such a haste to get full and "dominate" which does indeed give a lot of activity for some weeks but after that it's just downfall, population gets reduced drastically day by day. The reason is, while the community is busy "grinding" to win on their current server, a "new" server is being advertised which most likely is from the same owner. As I've mentioned, the guilt is shared since the server-owners focus on bringing up "new" servers for the cash grab but also since the community doesn't have the patience to support a long-term project. Besides, let's not forget about clans/CPs being invited directly to the server with some benefits. I'll give an example. An admin opens a server, invites 3 groups (either CPs or clans) by promising them some small benefits. Those three groups will invite more players and so on. It's like an investment, they spent 5$ to earn 20$. Therefore, most admins willing to play "fair" do not succeed, except for a few. Most of us "old-timers" play for nostalgia trips and are fine with low populated servers but lets take a step back and think about the owners that really want to provide a good server, no income will slowly dry out the server and eventually die.   Don't get me wrong, there are some great servers out there, but not everything is for everyone. I'll finish by quoting someone I saw few days ago on YouTube, he said something along the lines that we shouldn't expect fair play while we play an "illegal" version of the game.
    • You have to create the "voiced" handler in the core too, or at the very least make sure that the delimiter is underscore and not an empty space. Alternatively, you can try changing all references of the strings below to start with "voiced_", or remove the "voiced_" portion from the button bypass.   private static final String[] VOICED_COMMANDS = { "siege", "siege_gludio", "siege_dion", "siege_giran", "siege_oren", "siege_aden", "siege_innadril", "siege_goddard", "siege_rune", "siege_schuttgart" };
    • Hi maxcheaters, I recently added some code to my l2jacis revision and everything works fine with the .siege commands but when I click on the html options to open the registry I don't succeed!   registerHandler(new Castles());   package net.sf.l2j.gameserver.handler.voicedcommandhandlers;   import net.sf.l2j.Config; import net.sf.l2j.gameserver.handler.IVoicedCommandHandler; import net.sf.l2j.gameserver.data.manager.CastleManager; import net.sf.l2j.gameserver.model.actor.Player; import net.sf.l2j.gameserver.model.entity.Castle; import net.sf.l2j.gameserver.network.SystemMessageId; import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage; import net.sf.l2j.gameserver.network.serverpackets.SiegeInfo;   public class Castles implements IVoicedCommandHandler { private static final String[] VOICED_COMMANDS = { "siege", "siege_gludio", "siege_dion", "siege_giran", "siege_oren", "siege_aden", "siege_innadril", "siege_goddard", "siege_rune", "siege_schuttgart" };   @Override public boolean useVoicedCommand(String command, Player player, String target) { if (command.equals("siege") && Config.ENABLE_MENU) showHtm(player); else if (command.startsWith("siege_")) { if (player.getClan() != null && !player.isClanLeader()) { player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT); return false; }   int castleId = 0; if (command.startsWith("siege_gludio") && Config.SIEGE_GLUDIO) castleId = 1; else if (command.startsWith("siege_dion") && Config.SIEGE_DION) castleId = 2; else if (command.startsWith("siege_giran") && Config.SIEGE_GIRAN) castleId = 3; else if (command.startsWith("siege_oren") && Config.SIEGE_OREN) castleId = 4; else if (command.startsWith("siege_aden") && Config.SIEGE_ADEN) castleId = 5; else if (command.startsWith("siege_innadril") && Config.SIEGE_INNADRIL) castleId = 6; else if (command.startsWith("siege_goddard") && Config.SIEGE_GODDARD) castleId = 7; else if (command.startsWith("siege_rune") && Config.SIEGE_RUNE) castleId = 8; else if (command.startsWith("siege_schuttgart") && Config.SIEGE_SCHUT) castleId = 9; else player.sendMessage("This Castle has been disabled");   Castle castle = CastleManager.getInstance().getCastleById(castleId); if ((castle != null) && (castleId != 0)) player.sendPacket(new SiegeInfo(castle)); } return true; }   private static void showHtm(Player player) { NpcHtmlMessage htm = new NpcHtmlMessage(0); htm.setFile(player.isLang() + "mods/menu/CastleManager.htm"); player.sendPacket(htm); }   @Override public String[] getVoicedCommandList() { return VOICED_COMMANDS; } }     <button value="Giran" action="bypass voiced_siege_giran" width=75 height=22 back="L2UI_ch3.Btn1_normalOn" fore="L2UI_ch3.Btn1_normal">
  • Topics

×
×
  • Create New...