rendered paste bodyIndex: C:/java/net/sf/l2j/gameserver/model/quest/Quest.java
===================================================================
--- C:/java/net/sf/l2j/gameserver/model/quest/Quest.java (revision 1516)
+++ C:/java/net/sf/l2j/gameserver/model/quest/Quest.java (working copy)
@@ -30,6 +30,7 @@
import net.sf.l2j.Config;
import net.sf.l2j.L2DatabaseFactory;
import net.sf.l2j.gameserver.NpcTable;
+import net.sf.l2j.gameserver.model.L2Character;
import net.sf.l2j.gameserver.model.L2NpcInstance;
import net.sf.l2j.gameserver.model.L2PcInstance;
import net.sf.l2j.gameserver.model.quest.jython.QuestJython;
@@ -201,6 +202,11 @@
try { res = onAttack(npc, qs); } catch (Exception e) { return showError(qs, e); }
return showResult(qs, res);
}
+ public final boolean notifyDeath(L2NpcInstance npc, L2Character character, QuestState qs) {
+ String res = null;
+ try { res = onDeath(npc, character, qs); } catch (Exception e) { return showError(qs, e); }
+ return showResult(qs, res);
+ }
public final boolean notifyEvent(String event, QuestState qs) {
String res = null;
try { res = onEvent(event, qs); } catch (Exception e) { return showError(qs, e); }
@@ -220,6 +226,7 @@
// these are methods that java calls to invoke scripts
@SuppressWarnings("unused") public String onAttack(L2NpcInstance npc, QuestState qs) { return onEvent("", qs); }
+ @SuppressWarnings("unused") public String onDeath (L2NpcInstance npc, L2Character character, QuestState qs) { return onEvent("", qs); }
@SuppressWarnings("unused") public String onEvent(String event, QuestState qs) { return null; }
@SuppressWarnings("unused") public String onKill (L2NpcInstance npc, QuestState qs) { return onEvent("", qs); }
@SuppressWarnings("unused") public String onTalk (L2NpcInstance npc, QuestState qs) { return onEvent("", qs); }
Index: C:/Development/l2j/eclipse/workspace/L2_GameserverSVN/java/net/sf/l2j/gameserver/model/quest/QuestState.java
===================================================================
--- C:/Development/l2j/eclipse/workspace/L2_GameserverSVN/java/net/sf/l2j/gameserver/model/quest/QuestState.java (revision 1516)
+++ C:/Development/l2j/eclipse/workspace/L2_GameserverSVN/java/net/sf/l2j/gameserver/model/quest/QuestState.java (working copy)
@@ -30,6 +30,7 @@
import net.sf.l2j.gameserver.ItemTable;
import net.sf.l2j.gameserver.NpcTable;
import net.sf.l2j.gameserver.lib.Rnd;
+import net.sf.l2j.gameserver.model.L2Character;
import net.sf.l2j.gameserver.model.L2DropData;
import net.sf.l2j.gameserver.model.L2ItemInstance;
import net.sf.l2j.gameserver.model.L2NpcInstance;
@@ -353,6 +354,14 @@
}
return false;
}
+
+ /**
+ * Add player to get notification of characters death
+ * @param character : L2Character of the character to get notification of death
+ */
+ public void addNotifyOfDeath(L2Character character)
+ {
+ }
/**
* Add drop to the list of drops for the quest
Index: C:/Development/l2j/eclipse/workspace/L2_GameserverSVN/java/net/sf/l2j/gameserver/model/L2Character.java
===================================================================
--- C:/Development/l2j/eclipse/workspace/L2_GameserverSVN/java/net/sf/l2j/gameserver/model/L2Character.java (revision 1516)
+++ C:/Development/l2j/eclipse/workspace/L2_GameserverSVN/java/net/sf/l2j/gameserver/model/L2Character.java (working copy)
@@ -40,6 +40,7 @@
import net.sf.l2j.gameserver.handler.SkillHandler;
import net.sf.l2j.gameserver.lib.JBForth;
import net.sf.l2j.gameserver.lib.Rnd;
+import net.sf.l2j.gameserver.model.quest.QuestState;
import net.sf.l2j.gameserver.model.L2Skill.SkillTargetType;
import net.sf.l2j.gameserver.model.L2Skill.SkillType;
import net.sf.l2j.gameserver.serverpackets.ActionFailed;
@@ -484,11 +485,14 @@
/** Attacking L2Character (the L2Character that attacks this one) */
private L2Character _attackingChar;
+ /** Attacking L2Character's Skill */
+ private L2Skill _attackingCharSkill;
+
/** List of all L2Character instance that attacked (would be used for quest) */
private ArrayList<L2Character> _AttackByList = new ArrayList<L2Character>();
- /** Attacking L2Character's Skill */
- private L2Skill _attackingCharSkill;
+ /** List of all QuestState instance that needs to be notified of this character's death */
+ private ArrayList<QuestState> _NotifyQuestOfDeathList = new ArrayList<QuestState>();
/** Orientation of the L2Character */
private int _heading;
@@ -727,6 +731,31 @@
return _AttackByList;
}
+ /**
+ * Add QuestState instance that is to be notified of character's death.<BR><BR>
+ *
+ * @param qs The QuestState that subscribe to this event
+ *
+ */
+ public void addNotifyQuestOfDeath (QuestState qs)
+ {
+ if (qs == null || _NotifyQuestOfDeathList.contains(qs))
+ return;
+
+ _NotifyQuestOfDeathList.add(qs);
+ }
+
+ /**
+ * Return a list of L2Character that attacked.<BR><BR>
+ */
+ public ArrayList<QuestState> getNotifyQuestOfDeath ()
+ {
+ if (_NotifyQuestOfDeathList == null)
+ _NotifyQuestOfDeathList = new ArrayList<QuestState>();
+
+ return _NotifyQuestOfDeathList;
+ }
+
/**
* Return the L2CharacterAI of the L2Character and if its null create a new one.<BR><BR>
*/
@@ -2865,7 +2894,15 @@
// Notify L2Character AI
getAI().notifyEvent(CtrlEvent.EVT_DEAD, null);
- }
+ // Notify Quest of character's death
+ L2NpcInstance npc = null;
+ if (killer instanceof L2NpcInstance)
+ npc = (L2NpcInstance)killer;
+ for (QuestState qs: getNotifyQuestOfDeath())
+ {
+ qs.getQuest().notifyDeath(npc, this, qs);
+ }
+ }
// called from AIAccessor only
/**