Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: java/com/l2jserver/gameserver/enums/QuestEventType.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- java/com/l2jserver/gameserver/enums/QuestEventType.java (revision 6319)
- +++ java/com/l2jserver/gameserver/enums/QuestEventType.java (revision )
- @@ -42,7 +42,10 @@
- ON_MOVE_FINISHED(true), // onMoveFinished action, triggered when NPC stops after moving
- ON_NODE_ARRIVED(true), // onNodeArrived action, triggered when NPC, controlled by Walking Manager, arrives to next node
- ON_SEE_CREATURE(true), // onSeeCreature action, triggered when NPC's known list include the character
- - ON_ROUTE_FINISHED(true); // onRouteFinished action, triggered when NPC, controlled by Walking Manager, arrives to last node
- + ON_ROUTE_FINISHED(true), // onRouteFinished action, triggered when NPC, controlled by Walking Manager, arrives to last node
- + ON_AI_TASK_RUN(true), // Executed before L2AttackableAI task run
- + ON_AI_INTENTION(true), // Executed as first in AI's "setIntention()". Allows custom AI control.
- + ON_AI_EVENT(true); // Executed as first, in AI's "notifyEvent()". Allows custom AI control.
- // 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
- Index: java/com/l2jserver/gameserver/ai/IntentionCommand.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- java/com/l2jserver/gameserver/ai/IntentionCommand.java (revision )
- +++ java/com/l2jserver/gameserver/ai/IntentionCommand.java (revision )
- @@ -0,0 +1,44 @@
- +/*
- + * 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 com.l2jserver.gameserver.ai;
- +
- +public class IntentionCommand
- +{
- + protected final CtrlIntention _crtlIntention;
- +
- + protected final Object _arg0, _arg1;
- +
- + protected IntentionCommand(CtrlIntention pIntention, Object pArg0, Object pArg1)
- + {
- + _crtlIntention = pIntention;
- + _arg0 = pArg0;
- + _arg1 = pArg1;
- + }
- +
- + public CtrlIntention getCtrlIntention()
- + {
- + return _crtlIntention;
- + }
- +
- + public Object getArg0()
- + {
- + return _arg0;
- + }
- +
- + public Object getArg1()
- + {
- + return _arg1;
- + }
- +}
- \ No newline at end of file
- Index: java/com/l2jserver/gameserver/ai/L2AttackableAI.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- java/com/l2jserver/gameserver/ai/L2AttackableAI.java (revision 6319)
- +++ java/com/l2jserver/gameserver/ai/L2AttackableAI.java (revision )
- @@ -18,15 +18,6 @@
- */
- package com.l2jserver.gameserver.ai;
- -import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
- -import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
- -import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
- -
- -import java.util.ArrayList;
- -import java.util.Collection;
- -import java.util.List;
- -import java.util.concurrent.Future;
- -
- import com.l2jserver.Config;
- import com.l2jserver.gameserver.GameTimeController;
- import com.l2jserver.gameserver.GeoData;
- @@ -34,34 +25,30 @@
- import com.l2jserver.gameserver.datatables.NpcTable;
- import com.l2jserver.gameserver.datatables.TerritoryTable;
- import com.l2jserver.gameserver.enums.AIType;
- +import com.l2jserver.gameserver.enums.QuestEventControl;
- import com.l2jserver.gameserver.enums.QuestEventType;
- import com.l2jserver.gameserver.instancemanager.DimensionalRiftManager;
- import com.l2jserver.gameserver.model.L2Object;
- import com.l2jserver.gameserver.model.Location;
- -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.L2Playable;
- -import com.l2jserver.gameserver.model.actor.L2Summon;
- -import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
- -import com.l2jserver.gameserver.model.actor.instance.L2FestivalMonsterInstance;
- -import com.l2jserver.gameserver.model.actor.instance.L2FriendlyMobInstance;
- -import com.l2jserver.gameserver.model.actor.instance.L2GrandBossInstance;
- -import com.l2jserver.gameserver.model.actor.instance.L2GuardInstance;
- -import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
- -import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- -import com.l2jserver.gameserver.model.actor.instance.L2RaidBossInstance;
- -import com.l2jserver.gameserver.model.actor.instance.L2RiftInvaderInstance;
- -import com.l2jserver.gameserver.model.actor.instance.L2StaticObjectInstance;
- +import com.l2jserver.gameserver.model.actor.*;
- +import com.l2jserver.gameserver.model.actor.instance.*;
- import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
- import com.l2jserver.gameserver.model.effects.L2EffectType;
- import com.l2jserver.gameserver.model.quest.Quest;
- +import com.l2jserver.gameserver.model.quest.QuestEventRunResult;
- import com.l2jserver.gameserver.model.skills.L2Skill;
- import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
- import com.l2jserver.gameserver.model.zone.ZoneId;
- import com.l2jserver.gameserver.util.Util;
- import com.l2jserver.util.Rnd;
- +import java.util.ArrayList;
- +import java.util.Collection;
- +import java.util.List;
- +import java.util.concurrent.Future;
- +
- +import static com.l2jserver.gameserver.ai.CtrlIntention.*;
- +
- /**
- * This class manages AI of L2Attackable.
- */
- @@ -109,8 +96,25 @@
- @Override
- public void run()
- {
- + boolean breakExec = false;
- + final L2Npc me = getNpc();
- + List<Quest> qe = me.getTemplate().getEventQuests(QuestEventType.ON_AI_TASK_RUN);
- + if (qe != null)
- + {
- + for (Quest quest : qe)
- + {
- + QuestEventRunResult r = quest.notifyAITaskRun(me);
- + if (!breakExec && r.getCallerExecControl() == QuestEventControl.BREAK)
- + breakExec = true;
- + if (r.getLoopControl() == QuestEventControl.BREAK) // dp script resulted in request to abort loop.
- + break;
- + }
- + }
- + if (breakExec) // one of dp scripts resulted in request to abort caller method execution.
- + return;
- +
- // Launch actions corresponding to the Event Think
- - onEvtThink();
- + notifyEvent(CtrlEvent.EVT_THINK); // NOTE: Szponiasty: using notifyEvent instead of onEvtThink(), to allow running dp side quest scripts that control AI on ev
- }
- /**
- Index: java/com/l2jserver/gameserver/enums/QuestEventControl.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- java/com/l2jserver/gameserver/enums/QuestEventControl.java (revision )
- +++ java/com/l2jserver/gameserver/enums/QuestEventControl.java (revision )
- @@ -0,0 +1,30 @@
- +/*
- + * 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 com.l2jserver.gameserver.enums;
- +
- +/**
- + * ==============================================<br>
- + * QuestEventControl - Quest event result used for controlling core behavior, depending on scipts.<br>
- + * ==============================================<br>
- + * @author Szponiasty
- + */
- +public enum QuestEventControl
- +{
- + /** Informs AI, to continue certain task. */
- + CONTINUE,
- + /** Informs AI, to break certain task. */
- + BREAK,
- + UNDETERMINED;
- +}
- Index: java/com/l2jserver/gameserver/model/quest/QuestEventRunResult.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- java/com/l2jserver/gameserver/model/quest/QuestEventRunResult.java (revision )
- +++ java/com/l2jserver/gameserver/model/quest/QuestEventRunResult.java (revision )
- @@ -0,0 +1,102 @@
- +/*
- + * 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 com.l2jserver.gameserver.model.quest;
- +
- +import com.l2jserver.gameserver.enums.QuestEventControl;
- +
- +import java.util.logging.Logger;
- +
- +/**
- + * ==============================================<br>
- + * QuestEventRunResult - Quest result holder, for passing more info back to core and allowing better control over AI's.<br>
- + * ==============================================<br>
- + * @author Szponiasty
- + */
- +public class QuestEventRunResult
- +{
- + protected static final Logger _log = Logger.getLogger(QuestEventRunResult.class.getSimpleName());
- +
- + /* ========================== FIELDS ================================= */
- +
- + private final QuestEventControl _loopControl;
- + private final QuestEventControl _callerExecControl;
- +
- + private final String _debugInfo;
- +
- + private final Object[] _additionalData;
- +
- + /* ========================== CONSTRUCTORS =========================== */
- +
- + /**
- + * This class is used to pass more extensive result information from DP AI/Quest events, back to core, to allow better control over behaviors.
- + * @param loopControl determines, if next existing event of the same type, should be executed, or execution loop should be breaked.
- + * @param callerExecControl determines if further execution of code that called event, should be continued, or method should be aborted.
- + * @param debugInfo some short descriptive info, to be logged/showed while debugging, for better understanding.
- + * @param additionalData any additional data (if any), to be passed back.
- + */
- + public QuestEventRunResult(QuestEventControl loopControl, QuestEventControl callerExecControl, String debugInfo, Object... additionalData)
- + {
- + _loopControl = loopControl;
- + _callerExecControl = callerExecControl;
- + _debugInfo = debugInfo;
- + if (additionalData != null)
- + {
- + _additionalData = new Object[additionalData.length];
- + int i = 0;
- + for (Object data : additionalData)
- + _additionalData[i++] = data;
- + }
- + else
- + _additionalData = null;
- + }
- +
- + /* ========================== MAIN BODY ============================== */
- +
- + /**
- + * Get all additional (if any) datas, returned by event.
- + * @return
- + */
- + public final Object[] getAdditionalData()
- + {
- + return _additionalData;
- + }
- +
- + /**
- + * Get additional info used for debugging (if any), returned by event.
- + * @return
- + */
- + public final String getDebugInfo()
- + {
- + return _debugInfo;
- + }
- +
- + /**
- + * Get execution of next events of same type, in current loop, control.
- + * @return
- + */
- + public final QuestEventControl getLoopControl()
- + {
- + return _loopControl;
- + }
- +
- + /**
- + * Get caller method execution control.
- + * @return
- + */
- + public final QuestEventControl getCallerExecControl()
- + {
- + return _callerExecControl;
- + }
- +}
- Index: java/com/l2jserver/gameserver/model/quest/Quest.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- java/com/l2jserver/gameserver/model/quest/Quest.java (revision 6319)
- +++ java/com/l2jserver/gameserver/model/quest/Quest.java (revision )
- @@ -18,30 +18,17 @@
- */
- package com.l2jserver.gameserver.model.quest;
- -import java.sql.Connection;
- -import java.sql.PreparedStatement;
- -import java.sql.ResultSet;
- -import java.util.ArrayList;
- -import java.util.Collection;
- -import java.util.HashMap;
- -import java.util.HashSet;
- -import java.util.List;
- -import java.util.Map;
- -import java.util.Set;
- -import java.util.concurrent.locks.ReentrantReadWriteLock;
- -import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
- -import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
- -import java.util.logging.Level;
- -import java.util.logging.Logger;
- -
- import com.l2jserver.Config;
- import com.l2jserver.L2DatabaseFactory;
- import com.l2jserver.gameserver.GameTimeController;
- import com.l2jserver.gameserver.ThreadPoolManager;
- +import com.l2jserver.gameserver.ai.CtrlEvent;
- +import com.l2jserver.gameserver.ai.IntentionCommand;
- import com.l2jserver.gameserver.cache.HtmCache;
- import com.l2jserver.gameserver.datatables.DoorTable;
- import com.l2jserver.gameserver.datatables.ItemTable;
- import com.l2jserver.gameserver.datatables.NpcTable;
- +import com.l2jserver.gameserver.enums.QuestEventControl;
- import com.l2jserver.gameserver.enums.QuestEventType;
- import com.l2jserver.gameserver.enums.QuestSound;
- import com.l2jserver.gameserver.enums.TrapAction;
- @@ -78,14 +65,7 @@
- import com.l2jserver.gameserver.model.zone.L2ZoneType;
- import com.l2jserver.gameserver.network.NpcStringId;
- import com.l2jserver.gameserver.network.SystemMessageId;
- -import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
- -import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;
- -import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
- -import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
- -import com.l2jserver.gameserver.network.serverpackets.NpcQuestHtmlMessage;
- -import com.l2jserver.gameserver.network.serverpackets.SpecialCamera;
- -import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
- -import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
- +import com.l2jserver.gameserver.network.serverpackets.*;
- import com.l2jserver.gameserver.scripting.ManagedScript;
- import com.l2jserver.gameserver.scripting.ScriptManager;
- import com.l2jserver.gameserver.util.MinionList;
- @@ -93,6 +73,16 @@
- import com.l2jserver.util.Rnd;
- import com.l2jserver.util.Util;
- +import java.sql.Connection;
- +import java.sql.PreparedStatement;
- +import java.sql.ResultSet;
- +import java.util.*;
- +import java.util.concurrent.locks.ReentrantReadWriteLock;
- +import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
- +import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
- +import java.util.logging.Level;
- +import java.util.logging.Logger;
- +
- /**
- * Quest main class.
- * @author Luis Arias
- @@ -124,7 +114,10 @@
- private static final String DEFAULT_NO_QUEST_MSG = "<html><body>You are either not on a quest that involves this NPC, or you don't meet this NPC's minimum quest requirements.</body></html>";
- private static final String DEFAULT_ALREADY_COMPLETED_MSG = "<html><body>This quest has already been completed.</body></html>";
- -
- +
- + public static final QuestEventRunResult UNDETERMINED_RESULT = new QuestEventRunResult(QuestEventControl.CONTINUE, QuestEventControl.CONTINUE, null);
- + public static final QuestEventRunResult UNDETERMINED_RESULT_WITH_EXCEPTION = new QuestEventRunResult(QuestEventControl.CONTINUE, QuestEventControl.CONTINUE, "Exception on onNotifyAI...() in notifyAI...().");
- +
- private static final String QUEST_DELETE_FROM_CHAR_QUERY = "DELETE FROM character_quests WHERE charId=? AND name=?";
- private static final String QUEST_DELETE_FROM_CHAR_QUERY_NON_REPEATABLE_QUERY = "DELETE FROM character_quests WHERE charId=? AND name=? AND var!=?";
- @@ -543,9 +536,94 @@
- _log.log(Level.WARNING, "Exception on onSpawn() in notifySpawn(): " + e.getMessage(), e);
- }
- }
- -
- +
- /**
- + * @param npc the NPC
- + */
- + public final QuestEventRunResult notifyAITaskRun(L2Npc npc)
- + {
- + try
- + {
- + QuestEventRunResult r = onNotifyAITaskRun(npc);
- + return r != null ? r : UNDETERMINED_RESULT;
- + }
- + catch (Exception e)
- + {
- + _log.log(Level.WARNING, "Exception on onNotifyAITaskRun() in notifyAITaskRun(): " + e.getMessage(), e);
- + return UNDETERMINED_RESULT_WITH_EXCEPTION;
- + }
- + }
- +
- + /**
- + * Executed by L2Attackable.run(), before evtThink().
- + * @param npc
- + * @return
- + */
- + public QuestEventRunResult onNotifyAITaskRun(final L2Npc npc)
- + {
- + return null;
- + }
- +
- + /**
- + * @param npc the NPC
- + */
- + public final QuestEventRunResult notifyAIIntention(L2Npc npc, IntentionCommand intentionCommand)
- + {
- + try
- + {
- + QuestEventRunResult r = onNotifyAIIntention(npc, intentionCommand);
- + return r != null ? r : UNDETERMINED_RESULT;
- + }
- + catch (Exception e)
- + {
- + _log.log(Level.WARNING, "Exception on onNotifyAIIntention() in notifyAIIntention(): " + e.getMessage(), e);
- + return UNDETERMINED_RESULT_WITH_EXCEPTION;
- + }
- + }
- +
- + /**
- + * Executed by AI's, in setIntention() before anything else.
- + * @param npc
- + * @param intentionCommand
- + * @return
- + */
- + public QuestEventRunResult onNotifyAIIntention(final L2Npc npc, final IntentionCommand intentionCommand)
- + {
- + return null;
- + }
- +
- + /**
- + * @param npc the NPC
- + */
- + public final QuestEventRunResult notifyAIEvent(L2Npc npc, CtrlEvent event, Object arg0, Object arg1)
- + {
- + try
- + {
- + QuestEventRunResult r = onNotifyAIEvent(npc, event, arg0, arg1);
- + return r != null ? r : UNDETERMINED_RESULT;
- + }
- + catch (Exception e)
- + {
- + _log.log(Level.WARNING, "Exception on onNotifyAIEvent() in notifyAIEvent(): " + e.getMessage(), e);
- + return UNDETERMINED_RESULT_WITH_EXCEPTION;
- + }
- + }
- +
- + /**
- + * Executed by as first thing, in AbstractAI.notifyEvent().
- + * @param npc
- * @param event
- + * @param arg0
- + * @param arg1
- + * @return
- + */
- + public QuestEventRunResult onNotifyAIEvent(final L2Npc npc, final CtrlEvent event, final Object arg0, final Object arg1)
- + {
- + return null;
- + }
- +
- + /**
- + * @param event
- * @param npc
- * @param player
- * @return {@code false} if there was an error or the message was sent, {@code true} otherwise
- @@ -1819,8 +1897,64 @@
- public void addAttackId(int npcId)
- {
- addEventId(QuestEventType.ON_ATTACK, npcId);
- + }
- +
- + /**
- + * See {@link Quest#addAITaskRun(int)}
- + * @param npcIds
- + */
- + public void addAITaskRun(int... npcIds)
- + {
- + for (int npcId : npcIds)
- + addAITaskRun(npcId);
- + }
- +
- + /**
- + * Add the quest to the NPC's AI task run (executed by active L2AttackableAI's)
- + */
- + public void addAITaskRun(int npcId)
- + {
- + addEventId(QuestEventType.ON_AI_TASK_RUN, npcId);
- + }
- +
- + /**
- + * See {@link Quest#addAIIntention(int)}
- + * @param npcIds
- + */
- + public void addAIIntention(int... npcIds)
- + {
- + for (int npcId : npcIds)
- + addAIIntention(npcId);
- + }
- +
- + /**
- + * Add the quest to the NPC's AI setIntention() run
- + * @param npcId
- + */
- + public void addAIIntention(int npcId)
- + {
- + addEventId(QuestEventType.ON_AI_INTENTION, npcId);
- + }
- +
- + /**
- + * See {@link Quest#addAIEvent(int)}
- + * @param npcIds
- + */
- + public void addAIEvent(int... npcIds)
- + {
- + for (int npcId : npcIds)
- + addAIEvent(npcId);
- + }
- +
- + /**
- + * Add the quest to the NPC's AI notify event run
- + * @param npcId
- + */
- + public void addAIEvent(int npcId)
- + {
- + addEventId(QuestEventType.ON_AI_EVENT, npcId);
- }
- -
- +
- /**
- * Add the quest to the NPC's startQuest
- * @param npcIds
- Index: java/com/l2jserver/gameserver/ai/L2CharacterAI.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- java/com/l2jserver/gameserver/ai/L2CharacterAI.java (revision 6319)
- +++ java/com/l2jserver/gameserver/ai/L2CharacterAI.java (revision )
- @@ -18,20 +18,6 @@
- */
- package com.l2jserver.gameserver.ai;
- -import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
- -import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
- -import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_CAST;
- -import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_FOLLOW;
- -import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
- -import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_INTERACT;
- -import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_MOVE_TO;
- -import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_PICK_UP;
- -import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_REST;
- -
- -import java.util.List;
- -
- -import javolution.util.FastList;
- -
- import com.l2jserver.Config;
- import com.l2jserver.gameserver.GameTimeController;
- import com.l2jserver.gameserver.GeoData;
- @@ -62,7 +48,12 @@
- import com.l2jserver.gameserver.network.serverpackets.AutoAttackStop;
- import com.l2jserver.gameserver.taskmanager.AttackStanceTaskManager;
- import com.l2jserver.util.Rnd;
- +import javolution.util.FastList;
- +import java.util.List;
- +
- +import static com.l2jserver.gameserver.ai.CtrlIntention.*;
- +
- /**
- * This class manages AI of L2Character.<br>
- * L2CharacterAI :
- @@ -75,24 +66,6 @@
- */
- public class L2CharacterAI extends AbstractAI
- {
- - public static class IntentionCommand
- - {
- - protected final CtrlIntention _crtlIntention;
- - protected final Object _arg0, _arg1;
- -
- - protected IntentionCommand(CtrlIntention pIntention, Object pArg0, Object pArg1)
- - {
- - _crtlIntention = pIntention;
- - _arg0 = pArg0;
- - _arg1 = pArg1;
- - }
- -
- - public CtrlIntention getCtrlIntention()
- - {
- - return _crtlIntention;
- - }
- - }
- -
- /**
- * Cast Task
- * @author Zoey76
- @@ -211,7 +184,7 @@
- }
- // Launch the Think Event
- - onEvtThink();
- + notifyEvent(CtrlEvent.EVT_THINK); // NOTE: Szponiasty: using notifyEvent instead of onEvtThink(), to allow running dp side quest scripts that control AI on event trigger.
- }
- }
- @@ -707,7 +680,7 @@
- protected void onEvtReadyToAct()
- {
- // Launch actions corresponding to the Event Think
- - onEvtThink();
- + notifyEvent(CtrlEvent.EVT_THINK); // NOTE: Szponiasty: using notifyEvent instead of onEvtThink(), to allow running dp side quest scripts that control AI on ev
- }
- /**
- @@ -765,7 +738,7 @@
- }
- // Launch actions corresponding to the Event Think
- - onEvtThink();
- + notifyEvent(CtrlEvent.EVT_THINK);
- }
- /**
- @@ -779,7 +752,7 @@
- protected void onEvtArrivedRevalidate()
- {
- // Launch actions corresponding to the Event Think
- - onEvtThink();
- + notifyEvent(CtrlEvent.EVT_THINK);
- }
- /**
- @@ -804,7 +777,7 @@
- clientStopMoving(blocked_at_loc);
- // Launch actions corresponding to the Event Think
- - onEvtThink();
- + notifyEvent(CtrlEvent.EVT_THINK);
- }
- /**
- @@ -906,7 +879,7 @@
- }
- // Launch actions corresponding to the Event Think
- - onEvtThink();
- + notifyEvent(CtrlEvent.EVT_THINK);
- }
- /**
- Index: java/com/l2jserver/gameserver/ai/AbstractAI.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- java/com/l2jserver/gameserver/ai/AbstractAI.java (revision 6319)
- +++ java/com/l2jserver/gameserver/ai/AbstractAI.java (revision )
- @@ -18,31 +18,28 @@
- */
- package com.l2jserver.gameserver.ai;
- -import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
- -import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_FOLLOW;
- -import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
- -
- -import java.util.concurrent.Future;
- -import java.util.logging.Logger;
- -
- import com.l2jserver.gameserver.GameTimeController;
- import com.l2jserver.gameserver.ThreadPoolManager;
- +import com.l2jserver.gameserver.enums.QuestEventControl;
- +import com.l2jserver.gameserver.enums.QuestEventType;
- import com.l2jserver.gameserver.model.L2Object;
- import com.l2jserver.gameserver.model.Location;
- import com.l2jserver.gameserver.model.actor.L2Character;
- +import com.l2jserver.gameserver.model.actor.L2Npc;
- import com.l2jserver.gameserver.model.actor.L2Summon;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jserver.gameserver.model.quest.Quest;
- +import com.l2jserver.gameserver.model.quest.QuestEventRunResult;
- import com.l2jserver.gameserver.model.skills.L2Skill;
- -import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
- -import com.l2jserver.gameserver.network.serverpackets.AutoAttackStart;
- -import com.l2jserver.gameserver.network.serverpackets.AutoAttackStop;
- -import com.l2jserver.gameserver.network.serverpackets.Die;
- -import com.l2jserver.gameserver.network.serverpackets.MoveToLocation;
- -import com.l2jserver.gameserver.network.serverpackets.MoveToPawn;
- -import com.l2jserver.gameserver.network.serverpackets.StopMove;
- -import com.l2jserver.gameserver.network.serverpackets.StopRotation;
- +import com.l2jserver.gameserver.network.serverpackets.*;
- import com.l2jserver.gameserver.taskmanager.AttackStanceTaskManager;
- +import java.util.List;
- +import java.util.concurrent.Future;
- +import java.util.logging.Logger;
- +
- +import static com.l2jserver.gameserver.ai.CtrlIntention.*;
- +
- /**
- * Mother class of all objects AI in the world.<br>
- * AbastractAI :<br>
- @@ -184,8 +181,19 @@
- {
- return _actor;
- }
- -
- +
- /**
- + * If actor is L2Npc insrance, returns (L2Npc)getActor(). Otherwise returns null.
- + * @return
- + */
- + public final L2Npc getNpc()
- + {
- + if (_actor instanceof L2Npc)
- + return (L2Npc)_actor;
- + return null;
- + }
- +
- + /**
- * @return the current Intention.
- */
- @Override
- @@ -264,6 +272,23 @@
- @Override
- public final void setIntention(CtrlIntention intention, Object arg0, Object arg1)
- {
- + boolean breakExec = false;
- + final L2Npc me = getNpc();
- + List<Quest> qe = null;
- + if (me != null && (qe = me.getTemplate().getEventQuests(QuestEventType.ON_AI_INTENTION)) != null)
- + {
- + for (Quest quest : qe)
- + {
- + QuestEventRunResult r = quest.notifyAIIntention(me, new IntentionCommand(intention, arg0, arg1));
- + if (!breakExec && r.getCallerExecControl() == QuestEventControl.BREAK)
- + breakExec = true;
- + if (r.getLoopControl() == QuestEventControl.BREAK) // dp script resulted in request to abort loop.
- + break;
- + }
- + }
- + if (breakExec) // one of dp scripts resulted in request to abort caller method execution.
- + return;
- +
- // Stop the follow mode if necessary
- if ((intention != AI_INTENTION_FOLLOW) && (intention != AI_INTENTION_ATTACK))
- {
- @@ -340,6 +365,23 @@
- @Override
- public final void notifyEvent(CtrlEvent evt, Object arg0, Object arg1)
- {
- + boolean breakExec = false;
- + final L2Npc me = getNpc();
- + List<Quest> qe = null;
- + if (me != null && (qe = me.getTemplate().getEventQuests(QuestEventType.ON_AI_EVENT)) != null)
- + {
- + for (Quest quest : qe)
- + {
- + QuestEventRunResult r = quest.notifyAIEvent(me, evt, arg0, arg1);
- + if (!breakExec && r.getCallerExecControl() == QuestEventControl.BREAK)
- + breakExec = true;
- + if (r.getLoopControl() == QuestEventControl.BREAK) // dp script resulted in request to abort loop.
- + break;
- + }
- + }
- + if (breakExec) // one of dp scripts resulted in request to abort caller method execution.
- + return;
- +
- if ((!_actor.isVisible() && !_actor.isTeleporting()) || !_actor.hasAI())
- {
- return;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement