Sync between different project ai package classes.
This commit is contained in:
@@ -149,7 +149,7 @@ public abstract class AbstractAI implements Ctrl
|
||||
* <font color=#FF0000><b><u>Caution</u>: This method is USED by AI classes</b></font><b><u><br>
|
||||
* Overridden in</u>:</b><br>
|
||||
* <b>AttackableAI</b> : Create an AI Task executed every 1s (if necessary)<br>
|
||||
* <b>L2PlayerAI</b> : Stores the current AI intention parameters to later restore it if necessary.
|
||||
* <b>PlayerAI</b> : Stores the current AI intention parameters to later restore it if necessary.
|
||||
* @param intention The new Intention to set to the AI
|
||||
* @param arg0 The first parameter of the Intention
|
||||
* @param arg1 The second parameter of the Intention
|
||||
@@ -184,6 +184,13 @@ public abstract class AbstractAI implements Ctrl
|
||||
setIntention(intention, arg0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch the CreatureAI onIntention method corresponding to the new Intention.<br>
|
||||
* <font color=#FF0000><b><u>Caution</u>: Stop the FOLLOW mode if necessary</b></font>
|
||||
* @param intention The new Intention to set to the AI
|
||||
* @param arg0 The first parameter of the Intention (optional target)
|
||||
* @param arg1 The second parameter of the Intention (optional target)
|
||||
*/
|
||||
@Override
|
||||
public void setIntention(CtrlIntention intention, Object arg0, Object arg1)
|
||||
{
|
||||
@@ -262,7 +269,8 @@ public abstract class AbstractAI implements Ctrl
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch the CreatureAI onEvt method corresponding to the Event. <font color=#FF0000><b><u>Caution</u>: The current general intention won't be change (ex : If the character attack and is stunned, he will attack again after the stunned period)</b></font>
|
||||
* Launch the CreatureAI onEvt method corresponding to the Event.<br>
|
||||
* <font color=#FF0000><b><u>Caution</u>: The current general intention won't be change (ex : If the character attack and is stunned, he will attack again after the stunned periode)</b></font>
|
||||
* @param evt The event whose the AI must be notified
|
||||
* @param arg0 The first parameter of the Event (optional target)
|
||||
*/
|
||||
@@ -273,8 +281,10 @@ public abstract class AbstractAI implements Ctrl
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch the CreatureAI onEvt method corresponding to the Event. <font color=#FF0000><b><u>Caution</u>: The current general intention won't be change (ex : If the character attack and is stunned, he will attack again after the stunned period)</b></font>
|
||||
* Launch the CreatureAI onEvt method corresponding to the Event.<br>
|
||||
* <font color=#FF0000><b><u>Caution</u>: The current general intention won't be change (ex : If the character attack and is stunned, he will attack again after the stunned periode)</b></font>
|
||||
* @param evt The event whose the AI must be notified
|
||||
* @param args The arguments of the Event
|
||||
*/
|
||||
@Override
|
||||
public void notifyEvent(CtrlEvent evt, Object... args)
|
||||
@@ -472,7 +482,8 @@ public abstract class AbstractAI implements Ctrl
|
||||
protected abstract void onEvtAfraid(Creature effector, boolean start);
|
||||
|
||||
/**
|
||||
* Cancel action client side by sending Server->Client packet ActionFailed to the PlayerInstance actor. <font color=#FF0000><b><u>Caution</u>: Low level function, used by AI subclasses</b></font>
|
||||
* Cancel action client side by sending Server->Client packet ActionFailed to the PlayerInstance actor.<br>
|
||||
* <font color=#FF0000><b><u>Caution</u>: Low level function, used by AI subclasses</b></font>
|
||||
*/
|
||||
protected void clientActionFailed()
|
||||
{
|
||||
@@ -510,6 +521,7 @@ public abstract class AbstractAI implements Ctrl
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sendPacket = false;
|
||||
}
|
||||
else if (_actor.isOnGeodataPath() && (GameTimeTaskManager.getInstance().getGameTicks() < (_moveToPawnTimeout + 10)))
|
||||
|
@@ -170,6 +170,7 @@ public class AttackableAI extends CreatureAI
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Attackable me = getActiveChar();
|
||||
|
||||
// Check if the target isn't invulnerable
|
||||
@@ -180,6 +181,7 @@ public class AttackableAI extends CreatureAI
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (target.isSummon() && ((Summon) target).getOwner().isGM())
|
||||
{
|
||||
return false;
|
||||
@@ -2353,6 +2355,7 @@ public class AttackableAI extends CreatureAI
|
||||
* <li>Add the target to the actor _aggroList or update hate if already present</li>
|
||||
* <li>Set the actor Intention to AI_INTENTION_ATTACK (if actor is GuardInstance check if it isn't too far from its home location)</li>
|
||||
* </ul>
|
||||
* @param target the Creature that attacks
|
||||
* @param aggro The value of hate to add to the actor against the target
|
||||
*/
|
||||
@Override
|
||||
|
@@ -216,7 +216,6 @@ public class ControllableMobAI extends AttackableAI
|
||||
{
|
||||
moveToPawn(target, range);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
_actor.doAttack(target);
|
||||
|
@@ -426,6 +426,7 @@ public class CreatureAI extends AbstractAI
|
||||
|
||||
// Set the AI pick up target
|
||||
setTarget(object);
|
||||
|
||||
if ((object.getX() == 0) && (object.getY() == 0))
|
||||
{
|
||||
// LOGGER.warning("Object in coords 0,0 - using a temporary fix");
|
||||
@@ -1134,7 +1135,7 @@ public class CreatureAI extends AbstractAI
|
||||
* <br>
|
||||
* <b><u>Example of use</u>:</b>
|
||||
* <ul>
|
||||
* <li>PLayerAI, SummonAI</li>
|
||||
* <li>PlayerAI, SummonAI</li>
|
||||
* </ul>
|
||||
* @param target The targeted WorldObject
|
||||
* @return True if the target is lost
|
||||
|
@@ -25,44 +25,74 @@ public enum CtrlEvent
|
||||
* Something has changed, usually a previous step has being completed or maybe was completed, the AI must thing on next action.
|
||||
*/
|
||||
EVT_THINK,
|
||||
|
||||
/**
|
||||
* The actor was attacked. This event comes each time a physical or magical<br>
|
||||
* attack was done on the actor. NPC may start attack in response, or ignore<br>
|
||||
* this event if they already attack someone, or change target and so on.
|
||||
*/
|
||||
EVT_ATTACKED,
|
||||
/** Increase/decrease aggression towards a target, or reduce global aggression if target is null */
|
||||
|
||||
/**
|
||||
* Increase/decrease aggression towards a target, or reduce global aggression if target is null
|
||||
*/
|
||||
EVT_AGGRESSION,
|
||||
/** Actor is in stun state */
|
||||
|
||||
/**
|
||||
* Actor is in stun state
|
||||
*/
|
||||
EVT_STUNNED,
|
||||
/** Actor is paralyzed or petrified */
|
||||
|
||||
/**
|
||||
* Actor is paralyzed or petrified
|
||||
*/
|
||||
EVT_PARALYZED,
|
||||
/** Actor starts/stops sleeping */
|
||||
|
||||
/**
|
||||
* Actor starts/stops sleeping
|
||||
*/
|
||||
EVT_SLEEPING,
|
||||
/** Actor is in rooted state (cannot move) */
|
||||
|
||||
/**
|
||||
* Actor is in rooted state (cannot move)
|
||||
*/
|
||||
EVT_ROOTED,
|
||||
/** Actor evaded hit **/
|
||||
|
||||
/**
|
||||
* Actor evaded hit
|
||||
*/
|
||||
EVT_EVADED,
|
||||
|
||||
/**
|
||||
* An event that previous action was completed. The action may be an attempt to physically/magically hit an enemy, or an action that discarded attack attempt has finished.
|
||||
*/
|
||||
EVT_READY_TO_ACT,
|
||||
|
||||
/**
|
||||
* User's command, like using a combat magic or changing weapon, etc. The command is not intended to change final goal
|
||||
*/
|
||||
EVT_USER_CMD,
|
||||
|
||||
/**
|
||||
* The actor arrived to assigned location, or it's a time to modify movement destination (follow, interact, random move and others intentions).
|
||||
*/
|
||||
EVT_ARRIVED,
|
||||
|
||||
/**
|
||||
* The actor arrived to an intermediate point, and needs to revalidate destination. This is sent when follow/move to pawn if destination is far away.
|
||||
*/
|
||||
EVT_ARRIVED_REVALIDATE,
|
||||
/** The actor cannot move anymore. */
|
||||
|
||||
/**
|
||||
* The actor cannot move anymore.
|
||||
*/
|
||||
EVT_ARRIVED_BLOCKED,
|
||||
/** Forgets an object (if it's used as attack target, follow target and so on */
|
||||
|
||||
/**
|
||||
* Forgets an object (if it's used as attack target, follow target and so on
|
||||
*/
|
||||
EVT_FORGET_OBJECT,
|
||||
|
||||
/**
|
||||
* Attempt to cancel current step execution, but not change the intention.<br>
|
||||
* For example, the actor was put into a stun, so it's current attack<br>
|
||||
@@ -71,18 +101,39 @@ public enum CtrlEvent
|
||||
* attempt to cancel a cast/bow attack and so on.
|
||||
*/
|
||||
EVT_CANCEL,
|
||||
/** The creature is dead */
|
||||
|
||||
/**
|
||||
* The creature is dead
|
||||
*/
|
||||
EVT_DEAD,
|
||||
/** The creature looks like dead */
|
||||
|
||||
/**
|
||||
* The creature looks like dead
|
||||
*/
|
||||
EVT_FAKE_DEATH,
|
||||
/** The creature attack anyone randomly **/
|
||||
|
||||
/**
|
||||
* The creature attack anyone randomly
|
||||
*/
|
||||
EVT_CONFUSED,
|
||||
/** The creature cannot cast spells anymore **/
|
||||
|
||||
/**
|
||||
* The creature cannot cast spells anymore
|
||||
*/
|
||||
EVT_MUTED,
|
||||
/** The creature flee in random directions **/
|
||||
|
||||
/**
|
||||
* The creature flee in random directions
|
||||
*/
|
||||
EVT_AFRAID,
|
||||
/** The creature finish casting **/
|
||||
|
||||
/**
|
||||
* The creature finish casting
|
||||
*/
|
||||
EVT_FINISH_CASTING,
|
||||
/** The creature betrayed its master */
|
||||
|
||||
/**
|
||||
* The creature betrayed its master
|
||||
*/
|
||||
EVT_BETRAYED
|
||||
}
|
||||
|
@@ -23,20 +23,28 @@ public enum CtrlIntention
|
||||
{
|
||||
/** Do nothing, disconnect AI of NPC if no players around */
|
||||
AI_INTENTION_IDLE,
|
||||
|
||||
/** Alerted state without goal : scan attackable targets, random walk, etc */
|
||||
AI_INTENTION_ACTIVE,
|
||||
|
||||
/** Rest (sit until attacked) */
|
||||
AI_INTENTION_REST,
|
||||
|
||||
/** Attack target (cast combat magic, go to target, combat), may be ignored, if target is locked on another character or a peaceful zone and so on. */
|
||||
AI_INTENTION_ATTACK,
|
||||
|
||||
/** Cast a spell, depending on the spell - may start or stop attacking */
|
||||
AI_INTENTION_CAST,
|
||||
|
||||
/** Just move to another location */
|
||||
AI_INTENTION_MOVE_TO,
|
||||
|
||||
/** Like move, but check target's movement and follow it */
|
||||
AI_INTENTION_FOLLOW,
|
||||
|
||||
/** PickUp and item, (got to item, pickup it, become idle */
|
||||
AI_INTENTION_PICK_UP,
|
||||
|
||||
/** Move to target, then interact */
|
||||
AI_INTENTION_INTERACT;
|
||||
}
|
||||
|
@@ -418,6 +418,7 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final int chance = 4;
|
||||
if (chance >= Rnd.get(100))
|
||||
{
|
||||
@@ -427,6 +428,7 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
final WorldObject oldTarget = _actor.getTarget();
|
||||
_actor.setTarget(npc);
|
||||
clientStopMoving(null);
|
||||
@@ -715,6 +717,7 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
|
||||
* <li>Add the target to the actor _aggroList or update hate if already present</li>
|
||||
* <li>Set the actor Intention to AI_INTENTION_ATTACK (if actor is GuardInstance check if it isn't too far from its home location)</li>
|
||||
* </ul>
|
||||
* @param target The Creature that attacks
|
||||
* @param aggro The value of hate to add to the actor against the target
|
||||
*/
|
||||
@Override
|
||||
@@ -724,6 +727,7 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Attackable me = (Attackable) _actor;
|
||||
if (target != null)
|
||||
{
|
||||
|
@@ -170,6 +170,7 @@ public class PlayerAI extends PlayableAI
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
changeIntention(AI_INTENTION_REST, null, null);
|
||||
setTarget(null);
|
||||
if (getAttackTarget() != null)
|
||||
@@ -245,12 +246,14 @@ public class PlayerAI extends PlayableAI
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkTargetLostOrDead(target))
|
||||
{
|
||||
// Notify the target
|
||||
setAttackTarget(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (maybeMoveToPawn(target, _actor.getPhysicalAttackRange()))
|
||||
{
|
||||
return;
|
||||
@@ -304,11 +307,13 @@ public class PlayerAI extends PlayableAI
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldObject target = getTarget();
|
||||
if (checkTargetLost(target) || maybeMoveToPawn(target, 36))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setIntention(AI_INTENTION_IDLE);
|
||||
_actor.getActingPlayer().doPickupItem(target);
|
||||
}
|
||||
@@ -319,15 +324,18 @@ public class PlayerAI extends PlayableAI
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldObject target = getTarget();
|
||||
if (checkTargetLost(target) || maybeMoveToPawn(target, 36))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(target instanceof StaticObjectInstance))
|
||||
{
|
||||
_actor.getActingPlayer().doInteract((Creature) target);
|
||||
}
|
||||
|
||||
setIntention(AI_INTENTION_IDLE);
|
||||
}
|
||||
|
||||
|
@@ -725,6 +725,7 @@ public class SiegeGuardAI extends CreatureAI implements Runnable
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Attackable me = (Attackable) _actor;
|
||||
if (target != null)
|
||||
{
|
||||
|
@@ -106,10 +106,12 @@ public class SummonAI extends PlayableAI implements Runnable
|
||||
setAttackTarget(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (maybeMoveToPawn(getAttackTarget(), _actor.getPhysicalAttackRange()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
clientStopMoving(null);
|
||||
_actor.doAttack(getAttackTarget());
|
||||
}
|
||||
@@ -122,11 +124,13 @@ public class SummonAI extends PlayableAI implements Runnable
|
||||
setCastTarget(null);
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean val = _startFollow;
|
||||
if (maybeMoveToPawn(getCastTarget(), _actor.getMagicalAttackRange(_skill)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
clientStopMoving(null);
|
||||
summon.setFollowStatus(false);
|
||||
setIntention(AI_INTENTION_IDLE);
|
||||
@@ -140,6 +144,7 @@ public class SummonAI extends PlayableAI implements Runnable
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setIntention(AI_INTENTION_IDLE);
|
||||
((Summon) _actor).doPickupItem(getTarget());
|
||||
}
|
||||
@@ -150,6 +155,7 @@ public class SummonAI extends PlayableAI implements Runnable
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setIntention(AI_INTENTION_IDLE);
|
||||
}
|
||||
|
||||
@@ -160,7 +166,9 @@ public class SummonAI extends PlayableAI implements Runnable
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_thinking = true;
|
||||
|
||||
try
|
||||
{
|
||||
switch (getIntention())
|
||||
|
Reference in New Issue
Block a user