Jump to content

Recommended Posts

Posted

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

Posted

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

 

 

Guest Elfocrash
Posted

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

Better use tasks.

Nice code tho +1

Posted

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

  • 11 months later...
Posted

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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • what pack you use  send me on discord for it
    • package custom.events.RandomZoneEvent; import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.concurrent.ScheduledFuture; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.commons.time.SchedulingPattern; import org.l2jmobius.commons.time.TimeUtil; import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.gameserver.managers.ZoneManager; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.quest.Event; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.RandomZone; import org.l2jmobius.gameserver.util.Broadcast; /** * Random Zone Event - Activates one random PvP zone temporarily. No modifica la clase de la zona: usa flags PvP en runtime. * @author Juan */ public class RandomZoneEvent extends Event { private static final String CONFIG_FILE = "data/scripts/custom/events/RandomZoneEvent/config.xml"; private static int EVENT_DURATION_MINUTES = 15; private static boolean _isActive = false; private ScheduledFuture<?> _eventTask = null; private final List<ZoneType> _availableZones = new ArrayList<>(); private ZoneType _activeZone = null; public RandomZoneEvent() { loadConfig(); loadZones(); registerZoneListeners(); } /** * Registra listeners a TODAS LAS ZONAS random */ private void registerZoneListeners() { for (ZoneType zone : _availableZones) { addEnterZoneId(zone.getId()); addExitZoneId(zone.getId()); LOGGER.info("[RandomZoneEvent] Registered listener for zone: " + zone.getName()); } } private void loadConfig() { new IXmlReader() { @Override public void load() { parseDatapackFile(CONFIG_FILE); } @Override public void parseDocument(Document doc, File file) { forEach(doc, "event", eventNode -> { final StatSet att = new StatSet(parseAttributes(eventNode)); final String name = att.getString("name"); for (Node node = eventNode.getFirstChild(); node != null; node = node.getNextSibling()) { if ("schedule".equals(node.getNodeName())) { final StatSet attributes = new StatSet(parseAttributes(node)); final String pattern = attributes.getString("pattern"); final SchedulingPattern schedulingPattern = new SchedulingPattern(pattern); final StatSet params = new StatSet(); params.set("Name", name); params.set("SchedulingPattern", pattern); final long delay = schedulingPattern.getDelayToNextFromNow(); getTimers().addTimer("Schedule_" + name, params, delay + 5000, null, null); LOGGER.info("[RandomZoneEvent] Event " + name + " scheduled at " + TimeUtil.getDateTimeString(System.currentTimeMillis() + delay)); } } }); } }.load(); } private void loadZones() { for (ZoneType zone : ZoneManager.getInstance().getAllZones(RandomZone.class)) { if ((zone.getName() != null) && zone.getName().toLowerCase().startsWith("random_zone")) { _availableZones.add(zone); LOGGER.info("[RandomZoneEvent] Loaded zone: " + zone.getName() + " (id=" + zone.getId() + ")"); } } LOGGER.info("[RandomZoneEvent] Total random zones loaded: " + _availableZones.size()); } @Override public void onTimerEvent(String event, StatSet params, Npc npc, Player player) { if (event.startsWith("Schedule_")) { eventStart(null); final SchedulingPattern schedulingPattern = new SchedulingPattern(params.getString("SchedulingPattern")); final long delay = schedulingPattern.getDelayToNextFromNow(); getTimers().addTimer(event, params, delay + 5000, null, null); LOGGER.info("[RandomZoneEvent] Rescheduled for " + TimeUtil.getDateTimeString(System.currentTimeMillis() + delay)); } } @Override public boolean eventStart(Player eventMaker) { if (_isActive) { if (eventMaker != null) { eventMaker.sendMessage("RandomZoneEvent already active."); } return false; } if (_availableZones.isEmpty()) { Broadcast.toAllOnlinePlayers("[RandomZoneEvent] No zones configured."); return false; } _isActive = true; Broadcast.toAllOnlinePlayers("⚔️ Random Zone Event has started!"); _eventTask = ThreadPool.schedule(this::activateRandomZone, 5_000); return true; } private void activateRandomZone() { _activeZone = _availableZones.get(new Random().nextInt(_availableZones.size())); _activeZone.setEnabled(true); Broadcast.toAllOnlinePlayers("🔥 Random Zone Event: " + _activeZone.getName() + " is now PvP for " + EVENT_DURATION_MINUTES + " minutes!"); _eventTask = ThreadPool.schedule(this::eventStop, EVENT_DURATION_MINUTES * 60 * 1000L); } @Override public boolean eventStop() { if (!_isActive) { return false; } _isActive = false; if (_eventTask != null) { _eventTask.cancel(true); _eventTask = null; } if (_activeZone != null) { _activeZone.setEnabled(false); Broadcast.toAllOnlinePlayers("🏁 Random Zone Event ended. " + _activeZone.getName() + " is back to normal."); _activeZone = null; } else { Broadcast.toAllOnlinePlayers("🏁 Random Zone Event ended."); } return true; } @Override public void onEnterZone(Creature creature, ZoneType zone) { if (!_isActive || (_activeZone == null)) { return; } if ((zone == _activeZone) && creature.isPlayable()) { creature.setInsideZone(ZoneId.PVP, true); if (creature.isPlayer()) { creature.sendMessage("Esta zona está en modo PvP temporalmente."); } } } @Override public void onExitZone(Creature creature, ZoneType zone) { if (!_isActive || (_activeZone == null)) { return; } if ((zone == _activeZone) && creature.isPlayable()) { creature.setInsideZone(ZoneId.PVP, false); if (creature.isPlayer()) { creature.sendMessage("Abandonaste la zona PvP temporal."); } } } @Override public boolean eventBypass(Player player, String bypass) { return true; } @Override public String onEvent(String event, Npc npc, Player player) { return super.onEvent(event, npc, player); } @Override public String onFirstTalk(Npc npc, Player player) { return null; } public static void main(String[] args) { new RandomZoneEvent(); } } i have this but its not working
    • ZonePvPSpawnBossRadio=0 ZonePvPSpawnBossBarakiel=0 at the Customs.ini in L2Server folder. Im prety sure this is it because i had the same problem with you in cruma 1 floor for example and i couldn't fix it but i fixed it finally by changing these 2 lines
    • Siege Reward Start PM Msg Rework Config root BossDieAnnounce and BossDieSound in the L24Team.properties and Config.java files for global raid boss death notifications and sounds. Adds a new reward_list table to the DB.sql file to track castle rewards. Improves character creation logic for thread safety and validation. Adds extensive state checks to the RequestEnchantItem method to prevent enchantments during inappropriate player states. Fixed auto-attack animation bug (there was no attack animation, only damage animation) Clean Code Other fixes I forgot to list! Java 14 Fixed issue where deleting a character would prevent it from leaving the screen or being removed, or even after a delete CD (it would only exit when re-logging in or creating a new character). Added Premium System from the other C2 project (Needs testing and improvement). Added the "Improved" Community Board (incomplete).
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock