Addition of Holiday out of Schedule event.
Contributed by Index.
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<event name="DefeatTheQueen" active="22 09 2021-13 10 2029" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../xsd/eventConfig.xsd">
 | 
			
		||||
<event name="DefeatTheQueen" active="22 09 2021-13 10 2021" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../xsd/eventConfig.xsd">
 | 
			
		||||
	<spawnlist>
 | 
			
		||||
		<add npc="34184" x="83332" y="149161" z="-3384" heading="49151" /> <!-- Antri Giran -->
 | 
			
		||||
		<add npc="34184" x="147783" y="25627" z="-1996" heading="28180" /> <!-- Antri Aden Acord -->
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,8 @@
 | 
			
		||||
<html><body>Humanized Rudolph:<br>
 | 
			
		||||
Greetings! It's amazing we can meet like this. I'm Rudolph. Yes, the exact Rudolph who pulls Santa's sled.<br>
 | 
			
		||||
Curious why do I look like this? It's complicated. I was about to go give everyone presents, but suddenly turned into human.<br>
 | 
			
		||||
I cannot help with the sled looking like this, so I left gifts delivery to Santa Claus and decided to guide the adventurers to the city he is it.<br>
 | 
			
		||||
By the way! Santa Claus is on his way.<br>
 | 
			
		||||
He delivers gifts at 11:00 a.m. and 09:00 p.m. for an hour. Come to me during this time. Go to Santa Claus.<br>
 | 
			
		||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest HolidayOutOfSchedule 34338-01.htm">"Ask about Santa Claus"</Button>
 | 
			
		||||
</body></html>
 | 
			
		||||
@@ -0,0 +1,8 @@
 | 
			
		||||
<html><body>Humanized Rudolph:<br>
 | 
			
		||||
Greetings! It's amazing we can meet like this. I'm Rudolph. Yes, the exact Rudolph who pulls Santa's sled.<br>
 | 
			
		||||
Curious why do I look like this? It's complicated. I was about to go give everyone presents, but suddenly turned into human.<br>
 | 
			
		||||
I cannot help with the sled looking like this, so I left gifts delivery to Santa Claus and decided to guide the adventurers to the city he is it.<br>
 | 
			
		||||
I'm worrying a bit about Santa Claus, he doesn't know the area very well. He's going to give presents from 11:00 to 21:00, so go to see him and ask your gift.<br>
 | 
			
		||||
<Button ALIGN=LEFT ICON="TELEPORT" action="bypass -h Quest HolidayOutOfSchedule GOTO_SANTA">"Go to Santa Claus"</Button>
 | 
			
		||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest HolidayOutOfSchedule 34338-01.htm">"Ask about Santa Claus"</Button>
 | 
			
		||||
</body></html>
 | 
			
		||||
@@ -0,0 +1,5 @@
 | 
			
		||||
<html><body>Humanized Rudolph:<br>
 | 
			
		||||
Surely you've heard what they say about Santa Claus. Most of it is true. He comes on New Year's Eve to give gifts to all well-behaved children.<br>
 | 
			
		||||
In fact, not only children get gifts, but also adults, if they've worked hard all year. It's clear to me as day that you've fought a lot of monsters. I have no doubt that you too will get a gift.<br>
 | 
			
		||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest HolidayOutOfSchedule BACK">Back</Button>
 | 
			
		||||
</body></html>
 | 
			
		||||
@@ -0,0 +1,6 @@
 | 
			
		||||
<html><body>Humanized Rudolph:<br>
 | 
			
		||||
I'll teleport you to Santa Claus.<br>
 | 
			
		||||
By the way! Santa Claus might have lost his way since his eyesight is not that well.<br>
 | 
			
		||||
Look around if you cannot see him tight away.<br>
 | 
			
		||||
I hope you like the gift from Santa Claus. Good luck!
 | 
			
		||||
</body></html>
 | 
			
		||||
@@ -0,0 +1,4 @@
 | 
			
		||||
<html><body>Humanized Rudolph:<br>
 | 
			
		||||
It's time for Santa Claus to go to another place.<br>
 | 
			
		||||
Santa Claus gives gifts at 11:00 a.m. and 09:00 p.m.
 | 
			
		||||
</body></html>
 | 
			
		||||
@@ -0,0 +1,6 @@
 | 
			
		||||
<html><body>Holiday Manager Santa Claus<br>
 | 
			
		||||
Ho-ho-ho! It's been a long time since I've been to Elmoraden. And the kingdom looks so much better this year! Even with my poor eyesight I couldn't help but notice new territories, new bosses and new classes.<br>
 | 
			
		||||
Oh. I'm rambling, and time is wasting... I must give out as many gift as I can. Ironically, event Santa Claus is on schedule. I give out gifts from 11:00 till 12:00 and from 21:00 till 22:00.<br>
 | 
			
		||||
I have quite a lot of gifts. And brave warriors, such as yourself, I'm willing to give one gift per day. Hurry up and get yours!<br>
 | 
			
		||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest HolidayOutOfSchedule GET_SANTA_GIFT">"Get Santa's Gift"</Button>
 | 
			
		||||
</body></html>
 | 
			
		||||
@@ -0,0 +1,4 @@
 | 
			
		||||
<html><body>Holiday Manager Santa Claus<br>
 | 
			
		||||
As agreed, I'm willing to give you <font color="LEVEL">one gift every day</font>. Keep in mind though, that it is <font color="LEVEL">one per account</font>.<br>
 | 
			
		||||
Check the inventory of the other characters on your account, you may have taken the gift by one of them. How do I know about the other characters? Ho-ho-ho. Santa Claus knows a lot.
 | 
			
		||||
</body></html>
 | 
			
		||||
@@ -0,0 +1,324 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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 <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
package events.HolidayOutOfSchedule;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Calendar;
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.time.SchedulingPattern;
 | 
			
		||||
import org.l2jmobius.gameserver.model.Location;
 | 
			
		||||
import org.l2jmobius.gameserver.model.World;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.Npc;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.Player;
 | 
			
		||||
import org.l2jmobius.gameserver.model.holders.ItemHolder;
 | 
			
		||||
import org.l2jmobius.gameserver.model.holders.SkillHolder;
 | 
			
		||||
import org.l2jmobius.gameserver.model.quest.LongTimeEvent;
 | 
			
		||||
import org.l2jmobius.gameserver.model.skill.SkillCaster;
 | 
			
		||||
import org.l2jmobius.gameserver.model.skill.SkillCastingType;
 | 
			
		||||
import org.l2jmobius.gameserver.network.NpcStringId;
 | 
			
		||||
import org.l2jmobius.gameserver.network.SystemMessageId;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillLaunched;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Index
 | 
			
		||||
 */
 | 
			
		||||
public class HolidayOutOfSchedule extends LongTimeEvent
 | 
			
		||||
{
 | 
			
		||||
	// NPCs
 | 
			
		||||
	private static final int RUDOLPH_HUMANIZED_NPC_ID = 34338;
 | 
			
		||||
	private static final int LARGE_CHRISTMAS_TREE_NPC_ID = 34278;
 | 
			
		||||
	private static final int SANTA_CLAUS_NPC_ID = 34339;
 | 
			
		||||
	// Skill
 | 
			
		||||
	private static final SkillHolder TREE_SKILL = new SkillHolder(48596, 1);
 | 
			
		||||
	// Items
 | 
			
		||||
	private static final Set<ItemHolder> SANTA_GIFT = new HashSet<>();
 | 
			
		||||
	static
 | 
			
		||||
	{
 | 
			
		||||
		SANTA_GIFT.add(new ItemHolder(97147, 1)); // Dye Powder - Sealed
 | 
			
		||||
		SANTA_GIFT.add(new ItemHolder(71856, 1)); // L-Coin Pouch
 | 
			
		||||
		SANTA_GIFT.add(new ItemHolder(96731, 1)); // Giant's Shining Relic Pouch (Time-limited)
 | 
			
		||||
		SANTA_GIFT.add(new ItemHolder(72359, 1)); // New Year Gift Box (Time-limited)
 | 
			
		||||
		SANTA_GIFT.add(new ItemHolder(94269, 10)); // Scroll: Boost Attack - Sealed
 | 
			
		||||
		SANTA_GIFT.add(new ItemHolder(94271, 10)); // Scroll: Boost Defense - Sealed
 | 
			
		||||
	}
 | 
			
		||||
	// Locations
 | 
			
		||||
	private static final Map<String, Location[]> SANTA_LOCATION = new HashMap<>();
 | 
			
		||||
	static
 | 
			
		||||
	{
 | 
			
		||||
		SANTA_LOCATION.put("CRUMA", new Location[]
 | 
			
		||||
		{
 | 
			
		||||
			new Location(17294, 114772, -3440, 27293), // Santa Claus - Gift Manager
 | 
			
		||||
			new Location(17144, 114731, -3440, 0), // 2015 Christmas Tree, Large
 | 
			
		||||
			new Location(17146, 114176, -3440, 0), // Player Teleport
 | 
			
		||||
		});
 | 
			
		||||
		SANTA_LOCATION.put("SILENT_VALLEY", new Location[]
 | 
			
		||||
		{
 | 
			
		||||
			new Location(183910, 46823, -5952, 9784), // Santa Claus - Gift Manager
 | 
			
		||||
			new Location(184009, 46713, -5952, 0), // 2015 Christmas Tree, Large
 | 
			
		||||
			new Location(184222, 46666, -5936, 0), // Player Teleport
 | 
			
		||||
		});
 | 
			
		||||
		SANTA_LOCATION.put("LIZARDMAN_PLAINS", new Location[]
 | 
			
		||||
		{
 | 
			
		||||
			new Location(79446, 74089, -3192, 3355), // Santa Claus - Gift Manager
 | 
			
		||||
			new Location(79276, 74018, -3192, 0), // 2015 Christmas Tree, Large
 | 
			
		||||
			new Location(81160, 75068, -3592, 0), // Player Teleport
 | 
			
		||||
		});
 | 
			
		||||
		SANTA_LOCATION.put("DRAGON_VALLEY_WEST", new Location[]
 | 
			
		||||
		{
 | 
			
		||||
			new Location(118854, 116910, -3720, 45575), // Santa Claus - Gift Manager
 | 
			
		||||
			new Location(118924, 117063, -3720, 0), // 2015 Christmas Tree, Large
 | 
			
		||||
			new Location(119029, 116799, -3728, 0), // Player Teleport
 | 
			
		||||
		});
 | 
			
		||||
		SANTA_LOCATION.put("DRAGON_VALLEY_EAST", new Location[]
 | 
			
		||||
		{
 | 
			
		||||
			new Location(84847, 109373, -3200, 45344), // Santa Claus - Gift Manager
 | 
			
		||||
			new Location(84938, 109535, -3200, 0), // 2015 Christmas Tree, Large
 | 
			
		||||
			new Location(85021, 109046, -3200, 0), // Player Teleport
 | 
			
		||||
		});
 | 
			
		||||
		SANTA_LOCATION.put("TOI", new Location[]
 | 
			
		||||
		{
 | 
			
		||||
			new Location(112980, 10122, -5144, 9574), // Santa Claus - Gift Manager
 | 
			
		||||
			new Location(112830, 10009, -5128, 0), // 2015 Christmas Tree, Large
 | 
			
		||||
			new Location(114649, 11115, -5120, 0), // Player Teleport
 | 
			
		||||
		});
 | 
			
		||||
		SANTA_LOCATION.put("ORC_BARRAKS", new Location[]
 | 
			
		||||
		{
 | 
			
		||||
			new Location(-91975, 106440, -3680, 8528), // Santa Claus - Gift Manager
 | 
			
		||||
			new Location(-92132, 106468, -3672, 0), // 2015 Christmas Tree, Large
 | 
			
		||||
			new Location(-91509, 107149, -3688, 0), // Player Teleport
 | 
			
		||||
		});
 | 
			
		||||
		SANTA_LOCATION.put("RAKSHAS", new Location[]
 | 
			
		||||
		{
 | 
			
		||||
			new Location(-48112, 139994, -2920, 34492), // Santa Claus - Gift Manager
 | 
			
		||||
			new Location(-48073, 139840, -2904, 0), // 2015 Christmas Tree, Large
 | 
			
		||||
			new Location(-48363, 140230, -2944, 0), // Player Teleport
 | 
			
		||||
		});
 | 
			
		||||
		SANTA_LOCATION.put("GIANT_CAVE", new Location[]
 | 
			
		||||
		{
 | 
			
		||||
			new Location(177391, 50459, -3984, 17216), // Santa Claus - Gift Manager
 | 
			
		||||
			new Location(177391, 50337, -3984, 0), // 2015 Christmas Tree, Large
 | 
			
		||||
			new Location(178024, 52164, -3984, 0), // Player Teleport
 | 
			
		||||
		});
 | 
			
		||||
		SANTA_LOCATION.put("HOT_SPIRITS", new Location[]
 | 
			
		||||
		{
 | 
			
		||||
			new Location(149537, -112910, -2064, 18106), // Santa Claus - Gift Manager
 | 
			
		||||
			new Location(149466, -113060, -2064, 0), // 2015 Christmas Tree, Large
 | 
			
		||||
			new Location(149370, -112869, -2064, 0), // Player Teleport
 | 
			
		||||
		});
 | 
			
		||||
		SANTA_LOCATION.put("GORDE_CANYON", new Location[]
 | 
			
		||||
		{
 | 
			
		||||
			new Location(164359, -49245, -3536, 22516), // Santa Claus - Gift Manager
 | 
			
		||||
			new Location(164443, -49394, -3536, 0), // 2015 Christmas Tree, Large
 | 
			
		||||
			new Location(164389, -47956, -3528, 0), // Player Teleport
 | 
			
		||||
		});
 | 
			
		||||
		SANTA_LOCATION.put("XILENOS_FORTRESS", new Location[]
 | 
			
		||||
		{
 | 
			
		||||
			new Location(128157, -40225, -3504, 60759), // Santa Claus - Gift Manager
 | 
			
		||||
			new Location(128026, -40054, -3520, 0), // 2015 Christmas Tree, Large
 | 
			
		||||
			new Location(127226, -40970, -3584, 0), // Player Teleport
 | 
			
		||||
		});
 | 
			
		||||
		SANTA_LOCATION.put("MORGOD_MILITARY_BASE", new Location[]
 | 
			
		||||
		{
 | 
			
		||||
			new Location(145493, -68714, -3656, 2058), // Santa Claus - Gift Manager
 | 
			
		||||
			new Location(145356, -68603, -3656, 0), // 2015 Christmas Tree, Large
 | 
			
		||||
			new Location(146782, -68944, -3656, 0), // Player Teleport
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
	// Misc
 | 
			
		||||
	private static final Set<Npc> TREE_NPCs = new HashSet<>();
 | 
			
		||||
	private static final Npc[] SCHEDULE_NPCS = new Npc[2];
 | 
			
		||||
	private static boolean _santaActive = false;
 | 
			
		||||
	private static String _santaLocation = null;
 | 
			
		||||
	
 | 
			
		||||
	private HolidayOutOfSchedule()
 | 
			
		||||
	{
 | 
			
		||||
		if (!isEventPeriod())
 | 
			
		||||
		{
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		addFirstTalkId(RUDOLPH_HUMANIZED_NPC_ID, SANTA_CLAUS_NPC_ID);
 | 
			
		||||
		addTalkId(RUDOLPH_HUMANIZED_NPC_ID, SANTA_CLAUS_NPC_ID);
 | 
			
		||||
		addSpawnId(RUDOLPH_HUMANIZED_NPC_ID, LARGE_CHRISTMAS_TREE_NPC_ID, SANTA_CLAUS_NPC_ID);
 | 
			
		||||
		startQuestTimer("BUFF_AROUND_PLAYERS", 7_000, null, null, true);
 | 
			
		||||
		despawnSanta();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String onAdvEvent(String event, Npc npc, Player player)
 | 
			
		||||
	{
 | 
			
		||||
		if (npc != null)
 | 
			
		||||
		{
 | 
			
		||||
			switch (npc.getId())
 | 
			
		||||
			{
 | 
			
		||||
				case RUDOLPH_HUMANIZED_NPC_ID:
 | 
			
		||||
				{
 | 
			
		||||
					switch (event)
 | 
			
		||||
					{
 | 
			
		||||
						case "34338-01.htm":
 | 
			
		||||
						{
 | 
			
		||||
							return event;
 | 
			
		||||
						}
 | 
			
		||||
						case "BACK":
 | 
			
		||||
						{
 | 
			
		||||
							return getRudolphDialogue();
 | 
			
		||||
						}
 | 
			
		||||
						case "GOTO_SANTA":
 | 
			
		||||
						{
 | 
			
		||||
							if (_santaActive)
 | 
			
		||||
							{
 | 
			
		||||
								player.teleToLocation(SANTA_LOCATION.get(_santaLocation)[2], false);
 | 
			
		||||
							}
 | 
			
		||||
							return RUDOLPH_HUMANIZED_NPC_ID + "-0" + (_santaActive ? "2" : "3") + ".htm";
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
				case SANTA_CLAUS_NPC_ID:
 | 
			
		||||
				{
 | 
			
		||||
					if (event.equalsIgnoreCase("GET_SANTA_GIFT"))
 | 
			
		||||
					{
 | 
			
		||||
						final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
 | 
			
		||||
						if (player.getAccountVariables().getInt(getClass().getSimpleName() + "_SANTA_GIFT", 0) != currentDay)
 | 
			
		||||
						{
 | 
			
		||||
							SANTA_GIFT.forEach(g -> player.addItem("Santa Gift", g, npc, true));
 | 
			
		||||
							player.getAccountVariables().set(getClass().getSimpleName() + "_SANTA_GIFT", currentDay);
 | 
			
		||||
						}
 | 
			
		||||
						else
 | 
			
		||||
						{
 | 
			
		||||
							player.sendPacket(new SystemMessage(SystemMessageId.THIS_ACCOUNT_HAS_ALREADY_RECEIVED_A_GIFT_THE_GIFT_CAN_ONLY_BE_GIVEN_ONCE_PER_ACCOUNT));
 | 
			
		||||
						}
 | 
			
		||||
						return SANTA_CLAUS_NPC_ID + "-01.htm";
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			if (event.equalsIgnoreCase("BUFF_AROUND_PLAYERS"))
 | 
			
		||||
			{
 | 
			
		||||
				for (Npc tree : TREE_NPCs)
 | 
			
		||||
				{
 | 
			
		||||
					final List<Player> aroundPlayers = World.getInstance().getVisibleObjectsInRange(tree, Player.class, 300);
 | 
			
		||||
					if (aroundPlayers.isEmpty())
 | 
			
		||||
					{
 | 
			
		||||
						continue;
 | 
			
		||||
					}
 | 
			
		||||
					aroundPlayers.forEach(p ->
 | 
			
		||||
					{
 | 
			
		||||
						SkillCaster.triggerCast(tree, p, TREE_SKILL.getSkill());
 | 
			
		||||
						p.sendPacket(new MagicSkillLaunched(tree, TREE_SKILL.getSkillId(), TREE_SKILL.getSkillLevel(), SkillCastingType.NORMAL, new HashSet<>(aroundPlayers)));
 | 
			
		||||
					});
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			else if (event.equalsIgnoreCase("SANTA_SPAWN"))
 | 
			
		||||
			{
 | 
			
		||||
				activateSanta();
 | 
			
		||||
			}
 | 
			
		||||
			else if (event.equalsIgnoreCase("SANTA_DESPAWN"))
 | 
			
		||||
			{
 | 
			
		||||
				despawnSanta();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return super.onAdvEvent(event, npc, player);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String onFirstTalk(Npc npc, Player player)
 | 
			
		||||
	{
 | 
			
		||||
		return npc.getId() == RUDOLPH_HUMANIZED_NPC_ID ? getRudolphDialogue() : npc.getId() + "-00.htm";
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private String getRudolphDialogue()
 | 
			
		||||
	{
 | 
			
		||||
		return RUDOLPH_HUMANIZED_NPC_ID + "-00_" + (_santaActive ? "b" : "a") + ".htm";
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String onSpawn(Npc npc)
 | 
			
		||||
	{
 | 
			
		||||
		if (npc.getId() == LARGE_CHRISTMAS_TREE_NPC_ID)
 | 
			
		||||
		{
 | 
			
		||||
			TREE_NPCs.add(npc);
 | 
			
		||||
		}
 | 
			
		||||
		return super.onSpawn(npc);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private void activateSanta()
 | 
			
		||||
	{
 | 
			
		||||
		final long currentTime = System.currentTimeMillis();
 | 
			
		||||
		final SchedulingPattern endTimer = new SchedulingPattern("0 12,22 * * *");
 | 
			
		||||
		if (_santaActive)
 | 
			
		||||
		{
 | 
			
		||||
			final SchedulingPattern respawnTimer = new SchedulingPattern("0 11,21 * * *");
 | 
			
		||||
			if (endTimer.next(currentTime) > respawnTimer.next(currentTime))
 | 
			
		||||
			{
 | 
			
		||||
				despawnSanta();
 | 
			
		||||
			}
 | 
			
		||||
			startQuestTimer("SANTA_DESPAWN", endTimer.next(currentTime) - currentTime, null, null);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		_santaActive = true;
 | 
			
		||||
		
 | 
			
		||||
		final List<String> locations = new ArrayList<>(SANTA_LOCATION.keySet());
 | 
			
		||||
		Collections.shuffle(locations);
 | 
			
		||||
		_santaLocation = locations.stream().findAny().orElse("ORC_BARRAKS");
 | 
			
		||||
		
 | 
			
		||||
		SCHEDULE_NPCS[0] = addSpawn(SANTA_CLAUS_NPC_ID, SANTA_LOCATION.get(_santaLocation)[0]); // Remove Santa.
 | 
			
		||||
		SCHEDULE_NPCS[1] = addSpawn(LARGE_CHRISTMAS_TREE_NPC_ID, SANTA_LOCATION.get(_santaLocation)[1]); // Remove tree.
 | 
			
		||||
		TREE_NPCs.add(SCHEDULE_NPCS[1]);
 | 
			
		||||
		
 | 
			
		||||
		World.getInstance().getPlayers().forEach(p -> p.sendPacket(new ExShowScreenMessage(NpcStringId.SANTA_CLAUS_HAS_ARRIVED_ON_THE_ADEN_TERRITORY_FIND_RUDOLPH_IN_THE_CITY_HE_WILL_SEND_YOU_TO_SANTA, ExShowScreenMessage.TOP_CENTER, 10000, true)));
 | 
			
		||||
		startQuestTimer("SANTA_DESPAWN", endTimer.next(currentTime) - currentTime, null, null);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private void despawnSanta()
 | 
			
		||||
	{
 | 
			
		||||
		final long currentTime = System.currentTimeMillis();
 | 
			
		||||
		final SchedulingPattern respawnTimer = new SchedulingPattern("0 11,21 * * *");
 | 
			
		||||
		if (SCHEDULE_NPCS[0] != null)
 | 
			
		||||
		{
 | 
			
		||||
			if (SCHEDULE_NPCS[1] != null)
 | 
			
		||||
			{
 | 
			
		||||
				// Remove tree.
 | 
			
		||||
				TREE_NPCs.remove(SCHEDULE_NPCS[1]);
 | 
			
		||||
				SCHEDULE_NPCS[1].deleteMe();
 | 
			
		||||
				SCHEDULE_NPCS[1] = null;
 | 
			
		||||
			}
 | 
			
		||||
			// Remove Santa.
 | 
			
		||||
			_santaActive = false;
 | 
			
		||||
			SCHEDULE_NPCS[0].deleteMe();
 | 
			
		||||
			SCHEDULE_NPCS[0] = null;
 | 
			
		||||
		}
 | 
			
		||||
		_santaLocation = null;
 | 
			
		||||
		startQuestTimer("SANTA_SPAWN", respawnTimer.next(currentTime) - currentTime, null, null, false);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public static void main(String[] args)
 | 
			
		||||
	{
 | 
			
		||||
		new HolidayOutOfSchedule();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										26
									
								
								L2J_Mobius_Essence_6.3_Crusader/dist/game/data/scripts/events/HolidayOutOfSchedule/config.xml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								L2J_Mobius_Essence_6.3_Crusader/dist/game/data/scripts/events/HolidayOutOfSchedule/config.xml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<event name="Holiday out of Schedule" active="12 12 2022-05 01 2023" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../xsd/eventConfig.xsd">
 | 
			
		||||
	<spawnlist>
 | 
			
		||||
		<!-- Rudolph - Humanized -->
 | 
			
		||||
		<add npc="34338" x="-84488" y="243146" z="-3728" heading="28693" />	<!-- Talking Island -->
 | 
			
		||||
		<add npc="34338" x="44845" y="50692" z="-3056" heading="50119" /> <!-- Elven Village -->
 | 
			
		||||
		<add npc="34338" x="-44363" y="-113500" z="-240" heading="608" /> <!-- Orc Village -->
 | 
			
		||||
		<add npc="34338" x="11881" y="17532" z="-4568" heading="40593" /> <!-- Dark Elven Village -->
 | 
			
		||||
		<add npc="34338" x="115725" y="-178255" z="-936" heading="35281" /> <!-- Dwarf Village -->
 | 
			
		||||
		<add npc="34338" x="-81038" y="149990" z="-3040" heading="61823" /> <!-- Gluddin -->
 | 
			
		||||
		<add npc="34338" x="-14133" y="123877" z="-3112" heading="41864" /> <!-- Gludio -->
 | 
			
		||||
		<add npc="34338" x="16148" y="142849" z="-2696" heading="13978" /> <!-- Dion -->
 | 
			
		||||
		<add npc="34338" x="83332" y="149160" z="-3384" heading="49152" /> <!-- Giran -->
 | 
			
		||||
		<add npc="34338" x="82638" y="54149" z="-1488" heading="49153" /> <!-- Oren -->
 | 
			
		||||
		<add npc="34338" x="147784" y="25627" z="-1992" heading="17329" /> <!-- Aden -->
 | 
			
		||||
		<add npc="34338" x="117375" y="76707" z="-2688" heading="45519" /> <!-- Hunters Village -->
 | 
			
		||||
		<add npc="34338" x="147418" y="-55440" z="-2728" heading="58825" /> <!-- Goddard -->
 | 
			
		||||
		<!-- 2015 Christmas Tree, Large -->
 | 
			
		||||
		<add npc="34278" x="147450" y="28304" z="-2264" heading="15850" /> <!-- Aden -->
 | 
			
		||||
		<add npc="34278" x="82734" y="148768" z="-3464" heading="33453" /> <!-- Giran -->
 | 
			
		||||
	</spawnlist>
 | 
			
		||||
	<messages>
 | 
			
		||||
		<add type="onEnter" text="Holiday out of schedule: Event start!" />
 | 
			
		||||
		<add type="onEnd" text="Holiday out of schedule: Event end!" />
 | 
			
		||||
	</messages>
 | 
			
		||||
</event>
 | 
			
		||||
		Reference in New Issue
	
	Block a user