Browse Source

BETA: Added new AI
* Added '''Plains of Dion''' AI
* Updated '''Tepios''' spawn loc

Patch by: Gladicek, malyelfik

malyelfik 12 years ago
parent
commit
a38dc370a8

+ 1 - 0
L2J_DataPack_BETA/dist/game/data/scripts.cfg

@@ -64,6 +64,7 @@ ai/group_template/GiantScouts.java
 ai/group_template/Monastery.java
 ai/group_template/NonLethalableNpcs.java
 ai/group_template/PavelArchaic.java
+ai/group_template/PlainsOfDion.java
 ai/group_template/PlainsOfLizardman.java
 ai/group_template/PolymorphingAngel.java
 ai/group_template/PolymorphingOnAttack.java

+ 103 - 0
L2J_DataPack_BETA/dist/game/data/scripts/ai/group_template/PlainsOfDion.java

@@ -0,0 +1,103 @@
+/*
+ * 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 ai.group_template;
+
+import ai.npc.AbstractNpcAI;
+
+import com.l2jserver.gameserver.GeoData;
+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.util.Util;
+
+/**
+ * AI for mobs in Plains of Dion (near Floran Village)
+ * @author Gladicek
+ */
+public class PlainsOfDion extends AbstractNpcAI
+{
+	private static final int MONSTERS[] =
+	{
+		21104, // Delu Lizardman Supplier
+		21105, // Delu Lizardman Special Agent
+		21107, // Delu Lizardman Commander
+	};
+	
+	private static final NpcStringId[] MONSTERS_MSG =
+	{
+		NpcStringId.S1_HOW_DARE_YOU_INTERRUPT_OUR_FIGHT_HEY_GUYS_HELP,
+		NpcStringId.S1_HEY_WERE_HAVING_A_DUEL_HERE,
+		NpcStringId.THE_DUEL_IS_OVER_ATTACK,
+		NpcStringId.FOUL_KILL_THE_COWARD,
+		NpcStringId.HOW_DARE_YOU_INTERRUPT_A_SACRED_DUEL_YOU_MUST_BE_TAUGHT_A_LESSON
+	};
+	
+	private static final NpcStringId[] MONSTERS_ASSIST_MSG =
+	{
+		NpcStringId.DIE_YOU_COWARD,
+		NpcStringId.KILL_THE_COWARD,
+		NpcStringId.WHAT_ARE_YOU_LOOKING_AT
+	};
+	
+	@Override
+	public String onAttack(L2Npc npc, L2PcInstance player, int damage, boolean isPet)
+	{
+		if (npc.isScriptValue(0))
+		{
+			int i = getRandom(5);
+			if (i < 2)
+			{
+				broadcastNpcSay(npc, Say2.NPC_ALL, MONSTERS_MSG[i], player.getName());
+			}
+			else
+			{
+				broadcastNpcSay(npc, Say2.NPC_ALL, MONSTERS_MSG[i]);
+			}
+			
+			for (L2Character obj : npc.getKnownList().getKnownCharactersInRadius(npc.getFactionRange()))
+			{
+				if (obj.isMonster() && Util.contains(MONSTERS, ((L2MonsterInstance) obj).getNpcId()) && !obj.isAttackingNow() && !obj.isDead() && GeoData.getInstance().canSeeTarget(npc, obj))
+				{
+					final L2MonsterInstance monster = (L2MonsterInstance) obj;
+					attackPlayer(monster, player);
+					broadcastNpcSay(monster, Say2.NPC_ALL, MONSTERS_ASSIST_MSG[getRandom(3)]);
+				}
+			}
+            npc.setScriptValue(1);
+		}
+		return super.onAttack(npc, player, damage, isPet);
+	}
+	
+	@Override
+	public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet)
+	{
+		npc.setScriptValue(0);
+		return super.onKill(npc, killer, isPet);
+	}
+	
+	public PlainsOfDion(String name, String descr)
+	{
+		super(name, descr);
+		registerMobs(MONSTERS, QuestEventType.ON_ATTACK, QuestEventType.ON_KILL);
+	}
+	
+	public static void main(String[] args)
+	{
+		new PlainsOfDion(PlainsOfDion.class.getSimpleName(), "ai");
+	}
+}

+ 28 - 9
L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/AbstractNpcAI.java

@@ -54,13 +54,13 @@ public abstract class AbstractNpcAI extends L2Script
 	/**
 	 * Registers the fallowing events to the current script:<br>
 	 * <ul>
-	 * 	<li>ON_ATTACK</li>
-	 * 	<li>ON_KILL</li>
-	 * 	<li>ON_SPAWN</li>
-	 * 	<li>ON_SPELL_FINISHED</li>
-	 * 	<li>ON_SKILL_SEE</li>
-	 * 	<li>ON_FACTION_CALL</li>
-	 * 	<li>ON_AGGR_RANGE_ENTER</li>
+	 * <li>ON_ATTACK</li>
+	 * <li>ON_KILL</li>
+	 * <li>ON_SPAWN</li>
+	 * <li>ON_SPELL_FINISHED</li>
+	 * <li>ON_SKILL_SEE</li>
+	 * <li>ON_FACTION_CALL</li>
+	 * <li>ON_AGGR_RANGE_ENTER</li>
 	 * </ul>
 	 * @param mobs
 	 */
@@ -79,8 +79,7 @@ public abstract class AbstractNpcAI extends L2Script
 	}
 	
 	/**
-	 * This is used to register all monsters contained in mobs for a particular script
-	 * event types defined in types.
+	 * This is used to register all monsters contained in mobs for a particular script event types defined in types.
 	 * @param mobs
 	 * @param types
 	 */
@@ -128,6 +127,26 @@ public abstract class AbstractNpcAI extends L2Script
 		Broadcast.toKnownPlayers(npc, new NpcSay(npc.getObjectId(), type, npc.getTemplate().getIdTemplate(), stringId));
 	}
 	
+	/**
+	 * Broadcasts NpcSay packet to all known players with npc string id.
+	 * @param npc
+	 * @param type
+	 * @param stringId
+	 * @param parameters
+	 */
+	protected void broadcastNpcSay(L2Npc npc, int type, NpcStringId stringId, String... parameters)
+	{
+		final NpcSay say = new NpcSay(npc.getObjectId(), type, npc.getTemplate().getIdTemplate(), stringId);
+		if (parameters != null)
+		{
+			for (String parameter : parameters)
+			{
+				say.addStringParameter(parameter);
+			}
+		}
+		Broadcast.toKnownPlayers(npc, say);
+	}
+	
 	/**
 	 * Broadcasts NpcSay packet to all known players with custom string in specific radius.
 	 * @param npc

+ 1 - 1
L2J_DataPack_BETA/dist/sql/game/spawnlist.sql

@@ -699,7 +699,7 @@ INSERT INTO `spawnlist` VALUES
 -- Asyatei
 ("unset", 1, 32546, -183443, 206013, -12896, 0, 0, 24186, 60, 0, 0),
 -- Tepios
-("unset", 1, 32603, -183280, 205680, -12896, 0, 0, 16384, 60, 0, 0),
+("unset", 1, 32603, -183282, 205703, -12896, 0, 0, 16384, 60, 0, 0),
 
 -- [14_25]