From 720e14c10a1d12db6b26fd8a4a70e8ee37ea7ac2 Mon Sep 17 00:00:00 2001
From: HorridoJoho <HorridoJoho@users.noreply.github.com>
Date: Fri, 1 Jul 2016 23:12:16 +0200
Subject: [PATCH] Feature: Implementation of the Nevits Herald npc. (needs CORE
 part)

This commit implements the Nevits Herald npc. It gives the Nevits
Hourglass buff to players.

Patch By: @Sacrifice
Tested By: @Sacrifice
---
 dist/game/data/scripts.cfg                    |   1 +
 .../scripts/ai/npc/NevitsHerald/4326-1.html   |   5 +
 .../scripts/ai/npc/NevitsHerald/4326.html     |   7 +
 .../ai/npc/NevitsHerald/NevitsHerald.java     | 194 ++++++++++++++++++
 dist/game/data/stats/npcs/04300-04399.xml     |   2 +-
 dist/game/data/stats/skills/23300-23399.xml   |  18 +-
 6 files changed, 224 insertions(+), 3 deletions(-)
 create mode 100644 dist/game/data/scripts/ai/npc/NevitsHerald/4326-1.html
 create mode 100644 dist/game/data/scripts/ai/npc/NevitsHerald/4326.html
 create mode 100644 dist/game/data/scripts/ai/npc/NevitsHerald/NevitsHerald.java

diff --git a/dist/game/data/scripts.cfg b/dist/game/data/scripts.cfg
index bb10624cc8..ca2a6003f4 100644
--- a/dist/game/data/scripts.cfg
+++ b/dist/game/data/scripts.cfg
@@ -43,6 +43,7 @@ ai/npc/ManorManager/ManorManager.java
 ai/npc/MercenaryCaptain/MercenaryCaptain.java
 ai/npc/Minigame/Minigame.java
 ai/npc/MonumentOfHeroes/MonumentOfHeroes.java
+ai/npc/NevitsHerald/NevitsHerald.java
 ai/npc/NpcBuffers/NpcBuffers.java
 ai/npc/NpcBuffers/impl/CabaleBuffer.java
 ai/npc/PriestOfBlessing/PriestOfBlessing.java
diff --git a/dist/game/data/scripts/ai/npc/NevitsHerald/4326-1.html b/dist/game/data/scripts/ai/npc/NevitsHerald/4326-1.html
new file mode 100644
index 0000000000..6a0e72ce5a
--- /dev/null
+++ b/dist/game/data/scripts/ai/npc/NevitsHerald/4326-1.html
@@ -0,0 +1,5 @@
+<html><body>Nevit's Herald:<br>
+I can already feel the <font color="LEVEL">energy of Nevit's Blessing</font> emanating from you.<br>
+Please come back when Nevit's hand of blessing has been taken from you.<br><br>
+(Come back when the effects of Nevit's Blessing have subsided.)
+</body></html>
\ No newline at end of file
diff --git a/dist/game/data/scripts/ai/npc/NevitsHerald/4326.html b/dist/game/data/scripts/ai/npc/NevitsHerald/4326.html
new file mode 100644
index 0000000000..94ac31bd1b
--- /dev/null
+++ b/dist/game/data/scripts/ai/npc/NevitsHerald/4326.html
@@ -0,0 +1,7 @@
+<html><body>Nevit's Herald:<br>
+The first offspring of the goddess of destruction!<br>
+The evil dragons were defeated by the courageous warriors.<br>
+In order to commemorate the deeds of those warriors, <font color="LEVEL">Nevit</font> blessed all the people of Aden <font color="LEVEL">for 3 hours</font> with the hand of blessing.<br><br>
+Praise the glory of those warriors!!<br>
+<a action="bypass -h Quest NevitsHerald buff">"Glory to the warriors who defeated the evil dragons!!"</a><br>
+</body></html>
\ No newline at end of file
diff --git a/dist/game/data/scripts/ai/npc/NevitsHerald/NevitsHerald.java b/dist/game/data/scripts/ai/npc/NevitsHerald/NevitsHerald.java
new file mode 100644
index 0000000000..5ed22a5001
--- /dev/null
+++ b/dist/game/data/scripts/ai/npc/NevitsHerald/NevitsHerald.java
@@ -0,0 +1,194 @@
+/*
+ * Copyright (C) 2004-2016 L2J Server
+ * 
+ * This file is part of L2J Server.
+ * 
+ * L2J Server 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.
+ * 
+ * L2J Server 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 ai.npc.NevitsHerald;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.l2jserver.gameserver.datatables.SkillData;
+import com.l2jserver.gameserver.model.L2World;
+import com.l2jserver.gameserver.model.actor.L2Npc;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.effects.L2EffectType;
+import com.l2jserver.gameserver.model.quest.QuestState;
+import com.l2jserver.gameserver.network.NpcStringId;
+import com.l2jserver.gameserver.network.clientpackets.Say2;
+import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;
+import com.l2jserver.gameserver.network.serverpackets.NpcSay;
+import com.l2jserver.util.Rnd;
+
+import ai.npc.AbstractNpcAI;
+
+/**
+ * @author Sacrifice
+ */
+public final class NevitsHerald extends AbstractNpcAI
+{
+	private static final int NEVITS_HERALD = 4326;
+	private static final List<L2Npc> SPAWNS = new ArrayList<>();
+	private static final int[][] NEVITS_HERALD_SPAWNS =
+	{
+		// @formatter:off
+		{86979, -142785, -1341, 18259},
+		{44168, -48513, -801, 31924},
+		{148002, -55279, -2735, 44315},
+		{147953, 26656, -2205, 20352},
+		{82313, 53280, -1496, 14791},
+		{81918, 148305, -3471, 49151},
+		{16286, 142805, -2706, 15689},
+		{-13968, 122050, -2990, 19497},
+		{-83207, 150896, -3129, 30709},
+		{116892, 77277, -2695, 45056}
+		// @formatter:on
+	};
+	private static final int[] ANTHARAS =
+	{
+		29019,
+		29066,
+		29067,
+		29068
+	};
+	private static final NpcStringId[] SPAM =
+	{
+		NpcStringId.SHOW_RESPECT_TO_THE_HEROES_WHO_DEFEATED_THE_EVIL_DRAGON_AND_PROTECTED_THIS_ADEN_WORLD,
+		NpcStringId.SHOUT_TO_CELEBRATE_THE_VICTORY_OF_THE_HEROES,
+		NpcStringId.PRAISE_THE_ACHIEVEMENT_OF_THE_HEROES_AND_RECEIVE_NEVITS_BLESSING
+	};
+	private static final int VALAKAS = 29028;
+	private static boolean isActive = false;
+	
+	private NevitsHerald()
+	{
+		super(NevitsHerald.class.getSimpleName(), "ai/npc");
+		
+		addFirstTalkId(NEVITS_HERALD);
+		addStartNpc(NEVITS_HERALD);
+		addTalkId(NEVITS_HERALD);
+		
+		for (int _npc : ANTHARAS)
+		{
+			addKillId(_npc);
+		}
+		addKillId(VALAKAS);
+	}
+	
+	@Override
+	public String onFirstTalk(L2Npc npc, L2PcInstance player)
+	{
+		QuestState st = player.getQuestState(getName());
+		
+		if (st == null)
+		{
+			st = newQuestState(player);
+		}
+		return "4326.htm";
+	}
+	
+	@Override
+	public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
+	{
+		String htmltext = event;
+		
+		if (npc.getId() == NEVITS_HERALD)
+		{
+			if (event.equalsIgnoreCase("buff"))
+			{
+				if (player.getEffectList().getFirstEffect(L2EffectType.NEVIT_HOURGLASS) != null)
+				{
+					return "4326-1.htm";
+				}
+				npc.setTarget(player);
+				npc.doCast(SkillData.getInstance().getSkill(23312, 1));
+				return null;
+			}
+		}
+		else if (event.equalsIgnoreCase("text_spam"))
+		{
+			cancelQuestTimer("text_spam", npc, player);
+			npc.broadcastPacket(new NpcSay(NEVITS_HERALD, Say2.SHOUT, NEVITS_HERALD, SPAM[Rnd.get(0, SPAM.length - 1)]));
+			startQuestTimer("text_spam", 60000, npc, player);
+			return null;
+		}
+		else if (event.equalsIgnoreCase("despawn"))
+		{
+			despawnHeralds();
+		}
+		return htmltext;
+	}
+	
+	@Override
+	public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet)
+	{
+		ExShowScreenMessage message = null;
+		
+		if (npc.getId() == VALAKAS)
+		{
+			message = new ExShowScreenMessage(NpcStringId.THE_EVIL_FIRE_DRAGON_VALAKAS_HAS_BEEN_DEFEATED, 2, 10000);
+		}
+		else
+		{
+			message = new ExShowScreenMessage(NpcStringId.THE_EVIL_LAND_DRAGON_ANTHARAS_HAS_BEEN_DEFEATED, 2, 10000);
+		}
+		
+		for (L2PcInstance onlinePlayer : L2World.getInstance().getPlayers())
+		{
+			if (onlinePlayer == null)
+			{
+				continue;
+			}
+			onlinePlayer.sendPacket(message);
+		}
+		
+		if (!isActive)
+		{
+			isActive = true;
+			
+			SPAWNS.clear();
+			
+			for (int[] _spawn : NEVITS_HERALD_SPAWNS)
+			{
+				L2Npc herald = addSpawn(NEVITS_HERALD, _spawn[0], _spawn[1], _spawn[2], _spawn[3], false, 0);
+				if (herald != null)
+				{
+					SPAWNS.add(herald);
+				}
+			}
+			startQuestTimer("despawn", 14400000, npc, killer);
+			startQuestTimer("text_spam", 3000, npc, killer);
+		}
+		return null;
+	}
+	
+	private void despawnHeralds()
+	{
+		if (!SPAWNS.isEmpty())
+		{
+			for (L2Npc npc : SPAWNS)
+			{
+				npc.deleteMe();
+			}
+		}
+		SPAWNS.clear();
+	}
+	
+	public static void main(String[] args)
+	{
+		new NevitsHerald();
+	}
+}
\ No newline at end of file
diff --git a/dist/game/data/stats/npcs/04300-04399.xml b/dist/game/data/stats/npcs/04300-04399.xml
index 4b9c282e2d..bb0ebf9938 100644
--- a/dist/game/data/stats/npcs/04300-04399.xml
+++ b/dist/game/data/stats/npcs/04300-04399.xml
@@ -740,7 +740,7 @@
 		</skillList>
 		<collision>
 			<radius normal="25" />
-			<height normal="35" />
+			<height normal="22" />
 		</collision>
 	</npc>
 	<npc id="4327" level="80" type="L2Npc" name="Worshipper" title="Sinister">
diff --git a/dist/game/data/stats/skills/23300-23399.xml b/dist/game/data/stats/skills/23300-23399.xml
index 533c8bdf4a..ba902f886b 100644
--- a/dist/game/data/stats/skills/23300-23399.xml
+++ b/dist/game/data/stats/skills/23300-23399.xml
@@ -116,8 +116,22 @@
 	</skill>
 	<skill id="23312" levels="1" name="Fall of the Dragon">
 		<!-- Nevit's gift to honor those warriors who caused the evil dragon's fall. Increases Nevit's blessing by 3 hour(s). -->
-		<set name="operateType" val="P" />
-		<set name="targetType" val="NONE" />
+		<set name="abnormalLvl" val="2" />
+		<set name="abnormalTime" val="10800" />
+		<set name="abnormalType" val="VOTE" />
+		<set name="abnormalVisualEffect" val="VP_KEEP" />
+		<set name="icon" val="BranchSys2.icon.the_fall_of_dragon" />
+		<set name="isMagic" val="2" /> <!-- Static Skill -->
+		<set name="magicLvl" val="1" />
+		<set name="operateType" val="A2" />
+		<set name="canBeDispeled" val="false" />
+		<set name="rideState" val="NONE;STRIDER;WYVERN;WOLF" />
+		<set name="targetType" val="ONE" />
+		<for>
+			<effect name="Buff">
+				<mul stat="vitalityConsumeRate" val="0" />
+			</effect>
+		</for>
 	</skill>
 	<skill id="23313" levels="5" name="Action Prohibit Immunity">
 		<!-- Increases resistance to action-inhibiting attacks by 100%. -->
-- 
GitLab