From b26f6e7b9ac663b193391a193af6d343f635697b Mon Sep 17 00:00:00 2001
From: Zoey76 <zoey_76@msn.com>
Date: Sat, 7 Dec 2013 22:26:50 +0000
Subject: [PATCH] BETA: AIs updates. 	* Update for Giant's Cave AI. 	
 * Reviewed by: jurchiks, Zoey76 		* Tested by: St3eT 	*
 Update for Pavel Archaic AI. 		* Reviewed by: Zoey76 		*
 Tested by: St3eT, FinalDestination

---
 L2J_DataPack_BETA/dist/game/data/scripts.cfg  |   2 +-
 .../ai/group_template/GiantScouts.java        |  94 --------------
 .../scripts/ai/group_template/GiantsCave.java | 117 ++++++++++++++++++
 .../ai/group_template/PavelArchaic.java       |  38 +++---
 4 files changed, 133 insertions(+), 118 deletions(-)
 delete mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/group_template/GiantScouts.java
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/group_template/GiantsCave.java

diff --git a/L2J_DataPack_BETA/dist/game/data/scripts.cfg b/L2J_DataPack_BETA/dist/game/data/scripts.cfg
index 550c67aa36..2c1becbed1 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts.cfg
+++ b/L2J_DataPack_BETA/dist/game/data/scripts.cfg
@@ -94,7 +94,7 @@ ai/group_template/EvasGiftBoxes.java
 ai/group_template/FairyTrees.java
 ai/group_template/FeedableBeasts.java
 ai/group_template/FrozenLabyrinth.java
-ai/group_template/GiantScouts.java
+ai/group_template/GiantsCave.java
 ai/group_template/IsleOfPrayer.java
 ai/group_template/LairOfAntharas.java
 ai/group_template/MithrilMines.java
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/group_template/GiantScouts.java b/L2J_DataPack_BETA/dist/game/data/scripts/ai/group_template/GiantScouts.java
deleted file mode 100644
index 8ca3a4c56f..0000000000
--- a/L2J_DataPack_BETA/dist/game/data/scripts/ai/group_template/GiantScouts.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2004-2013 L2J DataPack
- * 
- * This file is part of L2J DataPack.
- * 
- * L2J DataPack 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 DataPack 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.group_template;
-
-import java.util.Collection;
-
-import ai.npc.AbstractNpcAI;
-
-import com.l2jserver.gameserver.GeoData;
-import com.l2jserver.gameserver.ai.CtrlIntention;
-import com.l2jserver.gameserver.model.L2Object;
-import com.l2jserver.gameserver.model.actor.L2Attackable;
-import com.l2jserver.gameserver.model.actor.L2Character;
-import com.l2jserver.gameserver.model.actor.L2Npc;
-import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
-import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
-import com.l2jserver.gameserver.network.NpcStringId;
-import com.l2jserver.gameserver.network.clientpackets.Say2;
-import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
-
-/**
- * Giant Scouts AI.
- * @author Gnacik
- */
-public class GiantScouts extends AbstractNpcAI
-{
-	private GiantScouts()
-	{
-		super(GiantScouts.class.getSimpleName(), "ai/group_template");
-		addAggroRangeEnterId(22668, 22669); // scouts
-	}
-	
-	@Override
-	public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isSummon)
-	{
-		L2Character target = isSummon ? player.getSummon() : player;
-		
-		if (GeoData.getInstance().canSeeTarget(npc, target))
-		{
-			if (!npc.isInCombat() && (npc.getTarget() == null))
-			{
-				npc.broadcastPacket(new CreatureSay(npc.getObjectId(), Say2.NPC_SHOUT, npc.getName(), NpcStringId.OH_GIANTS_AN_INTRUDER_HAS_BEEN_DISCOVERED));
-			}
-			
-			npc.setTarget(target);
-			npc.setRunning();
-			((L2Attackable) npc).addDamageHate(target, 0, 999);
-			npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
-			
-			// Notify clan
-			Collection<L2Object> objs = npc.getKnownList().getKnownObjects().values();
-			for (L2Object obj : objs)
-			{
-				if (obj != null)
-				{
-					if (obj instanceof L2MonsterInstance)
-					{
-						L2MonsterInstance monster = (L2MonsterInstance) obj;
-						if (((npc.getClan() != null) && (monster.getClan() != null)) && monster.getClan().equals(npc.getClan()) && GeoData.getInstance().canSeeTarget(npc, monster))
-						{
-							monster.setTarget(target);
-							monster.setRunning();
-							monster.addDamageHate(target, 0, 999);
-							monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
-						}
-					}
-					
-				}
-			}
-		}
-		return super.onAggroRangeEnter(npc, player, isSummon);
-	}
-	
-	public static void main(String[] args)
-	{
-		new GiantScouts();
-	}
-}
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/group_template/GiantsCave.java b/L2J_DataPack_BETA/dist/game/data/scripts/ai/group_template/GiantsCave.java
new file mode 100644
index 0000000000..a839d27712
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/group_template/GiantsCave.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2004-2013 L2J DataPack
+ * 
+ * This file is part of L2J DataPack.
+ * 
+ * L2J DataPack 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 DataPack 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.group_template;
+
+import ai.npc.AbstractNpcAI;
+
+import com.l2jserver.gameserver.model.actor.L2Attackable;
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.actor.L2Npc;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.network.NpcStringId;
+import com.l2jserver.gameserver.network.clientpackets.Say2;
+import com.l2jserver.gameserver.network.serverpackets.NpcSay;
+
+/**
+ * Giant's Cave AI.
+ * @author Gnacik, St3eT
+ */
+public final class GiantsCave extends AbstractNpcAI
+{
+	// NPC
+	private static final int[] SCOUTS =
+	{
+		22668, // Gamlin (Scout)
+		22669, // Leogul (Scout)
+	};
+	
+	private GiantsCave()
+	{
+		super(GiantsCave.class.getSimpleName(), "ai/group_template");
+		addAttackId(SCOUTS);
+		addAggroRangeEnterId(SCOUTS);
+	}
+	
+	@Override
+	public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
+	{
+		if (event.equals("ATTACK") && (player != null) && (npc != null) && !npc.isDead())
+		{
+			if (npc.getId() == SCOUTS[0]) // Gamlin
+			{
+				broadcastNpcSay(npc, Say2.NPC_SHOUT, NpcStringId._INTRUDER_DETECTED);
+			}
+			else
+			{
+				broadcastNpcSay(npc, Say2.NPC_SHOUT, NpcStringId.OH_GIANTS_AN_INTRUDER_HAS_BEEN_DISCOVERED);
+			}
+			
+			for (L2Character characters : npc.getKnownList().getKnownCharactersInRadius(450))
+			{
+				if ((characters != null) && (characters.isL2Attackable()) && (getRandomBoolean()))
+				{
+					L2Attackable monster = (L2Attackable) characters;
+					attackPlayer(monster, player);
+				}
+			}
+		}
+		else if (event.equals("CLEAR") && (npc != null) && !npc.isDead())
+		{
+			npc.setScriptValue(0);
+		}
+		return super.onAdvEvent(event, npc, player);
+	}
+	
+	@Override
+	public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
+	{
+		if (npc.isScriptValue(0))
+		{
+			npc.setScriptValue(1);
+			startQuestTimer("ATTACK", 6000, npc, attacker);
+			startQuestTimer("CLEAR", 120000, npc, null);
+		}
+		return super.onAttack(npc, attacker, damage, isSummon);
+	}
+	
+	@Override
+	public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isSummon)
+	{
+		if (npc.isScriptValue(0))
+		{
+			npc.setScriptValue(1);
+			if (getRandomBoolean())
+			{
+				npc.broadcastPacket(new NpcSay(npc.getObjectId(), Say2.NPC_ALL, npc.getId(), NpcStringId.YOU_GUYS_ARE_DETECTED));
+			}
+			else
+			{
+				npc.broadcastPacket(new NpcSay(npc.getObjectId(), Say2.NPC_ALL, npc.getId(), NpcStringId.WHAT_KIND_OF_CREATURES_ARE_YOU));
+			}
+			startQuestTimer("ATTACK", 6000, npc, player);
+			startQuestTimer("CLEAR", 120000, npc, null);
+		}
+		return super.onAggroRangeEnter(npc, player, isSummon);
+	}
+	
+	public static void main(String[] args)
+	{
+		new GiantsCave();
+	}
+}
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/group_template/PavelArchaic.java b/L2J_DataPack_BETA/dist/game/data/scripts/ai/group_template/PavelArchaic.java
index dd53c422de..d3e130fa92 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/ai/group_template/PavelArchaic.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/group_template/PavelArchaic.java
@@ -26,41 +26,33 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 
 /**
  * Pavel Archaic AI.
- * @author Gnacik
+ * @author Gnacik, St3eT
  */
-public class PavelArchaic extends AbstractNpcAI
+public final class PavelArchaic extends AbstractNpcAI
 {
+	private static final int SAFETY_DEVICE = 18917; // Pavel Safety Device
+	private static final int PINCER_GOLEM = 22801; // Cruel Pincer Golem
+	private static final int PINCER_GOLEM2 = 22802; // Cruel Pincer Golem
+	private static final int PINCER_GOLEM3 = 22803; // Cruel Pincer Golem
+	private static final int JACKHAMMER_GOLEM = 22804; // Horrifying Jackhammer Golem
+	
 	private PavelArchaic()
 	{
 		super(PavelArchaic.class.getSimpleName(), "ai/group_template");
-		addKillId(22801, 22804);
-		addAttackId(18917);
+		addKillId(SAFETY_DEVICE, PINCER_GOLEM, JACKHAMMER_GOLEM);
 	}
 	
 	@Override
-	public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
+	public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
 	{
-		if (!npc.isDead())
+		if (getRandom(100) < 70)
 		{
-			npc.doDie(attacker);
+			final L2Attackable golem1 = (L2Attackable) addSpawn(PINCER_GOLEM2, npc.getX(), npc.getY(), npc.getZ() + 10, npc.getHeading(), false, 0, false);
+			attackPlayer(golem1, killer);
 			
-			if (getRandom(100) < 40)
-			{
-				L2Attackable golem1 = (L2Attackable) addSpawn(22801, npc.getLocation(), false, 0);
-				attackPlayer(golem1, attacker);
-				
-				L2Attackable golem2 = (L2Attackable) addSpawn(22804, npc.getLocation(), false, 0);
-				attackPlayer(golem2, attacker);
-			}
+			final L2Attackable golem2 = (L2Attackable) addSpawn(PINCER_GOLEM3, npc.getX(), npc.getY(), npc.getZ() + 10, npc.getHeading(), false, 0, false);
+			attackPlayer(golem2, killer);
 		}
-		return super.onAttack(npc, attacker, damage, isSummon);
-	}
-	
-	@Override
-	public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
-	{
-		L2Attackable golem = (L2Attackable) addSpawn(npc.getId() + 1, npc.getLocation(), false, 0);
-		attackPlayer(golem, killer);
 		return super.onKill(npc, killer, isSummon);
 	}
 	
-- 
GitLab