浏览代码

added AI handler for skill finished casting..and fixed onEvent calls from completed state of a Quest - by kerberos_20

nBd 16 年之前
父节点
当前提交
cb39a01c92

+ 15 - 0
L2_GameServer/java/net/sf/l2j/gameserver/model/L2Character.java

@@ -5727,6 +5727,21 @@ public abstract class L2Character extends L2Object
         // Notify the AI of the L2Character with EVT_FINISH_CASTING
 		getAI().notifyEvent(CtrlEvent.EVT_FINISH_CASTING);
 
+		if (this instanceof L2NpcInstance)
+		{
+			if (((L2NpcTemplate) getTemplate()).getEventQuests(Quest.QuestEventType.ON_SPELL_FINISHED) != null)
+			{
+				L2PcInstance player = null;
+				if (target instanceof L2PcInstance)
+					player = (L2PcInstance)target;
+				else if (target instanceof L2Summon)
+					player = ((L2Summon)target).getOwner();
+				for (Quest quest: ((L2NpcTemplate) getTemplate()).getEventQuests(Quest.QuestEventType.ON_SPELL_FINISHED))
+				{
+					quest.notifySpellFinished(((L2NpcInstance)this), player, skill);
+				}
+			}
+		}
         /*
          * If character is a player, then wipe their current cast state and
          * check if a skill is queued.

+ 1 - 1
L2_GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java

@@ -1365,7 +1365,7 @@ public final class L2PcInstance extends L2PlayableInstance
 					{
 						for (QuestState state : states)
 						{
-							if ((state.getQuest().getQuestIntId() == qs.getQuest().getQuestIntId()) && !qs.isCompleted())
+							if ((state.getQuest().getQuestIntId() == qs.getQuest().getQuestIntId()))
 							{
 								if (qs.getQuest().notifyEvent(event, npc, this))
 									showQuestWindow(quest, State.getStateName(qs.getState()));

+ 26 - 2
L2_GameServer/java/net/sf/l2j/gameserver/model/quest/Quest.java

@@ -135,7 +135,8 @@ public class Quest extends ManagedScript
 		ON_SPAWN(true), // onSpawn action triggered when an NPC is spawned or respawned.
 		ON_SKILL_SEE(true), // NPC or Mob saw a person casting a skill (regardless what the target is). 
 		ON_FACTION_CALL(true), // NPC or Mob saw a person casting a skill (regardless what the target is). 
-		ON_AGGRO_RANGE_ENTER(true); // a person came within the Npc/Mob's range 
+		ON_AGGRO_RANGE_ENTER(true), // a person came within the Npc/Mob's range
+		ON_SPELL_FINISHED(true);  // on spell finished action when npc finish casting skill  
 		
 		// control whether this event type is allowed for the same npc template in multiple quests
 		// or if the npc must be registered in at most one quest for the specified event 
@@ -361,6 +362,20 @@ public class Quest extends ManagedScript
 		return showResult(qs.getPlayer(), res);
 	}
 	
+    public final boolean notifySpellFinished(L2NpcInstance instance, L2PcInstance player, L2Skill skill)
+    {
+		String res = null;
+		try
+		{
+			res = onSpellFinished(instance, player, skill);
+		}
+		catch (Exception e)
+		{
+			return showError(player, e);
+		}
+		return showResult(player, res);
+	    
+    }
 	public final boolean notifySpawn(L2NpcInstance npc)
 	{
 		try
@@ -557,6 +572,11 @@ public class Quest extends ManagedScript
 		return null;
 	}
 	
+	public String onSpellFinished(L2NpcInstance npc, L2PcInstance player, L2Skill skill)
+	{
+		return null;
+	}
+	
 	public String onSpawn(L2NpcInstance npc)
 	{
 		return null;
@@ -1153,7 +1173,11 @@ public class Quest extends ManagedScript
 	{
 		return addEventId(npcId, Quest.QuestEventType.ON_SKILL_SEE);
 	}
-	
+
+	public L2NpcTemplate addSpellFinishedId(int npcId)
+	{
+		return addEventId(npcId, Quest.QuestEventType.ON_SPELL_FINISHED);
+	}
 	/**
 	 * Add this quest to the list of quests that the passed npc will respond to for Faction Call Events.<BR><BR>
 	 * @param talkId : ID of the NPC