Sync between different project ai package classes.
This commit is contained in:
@@ -45,7 +45,6 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
|
||||
|
||||
/**
|
||||
* Mother class of all objects AI in the world.<br>
|
||||
* <br>
|
||||
* AbastractAI:<br>
|
||||
* <li>CreatureAI</li>
|
||||
*/
|
||||
@@ -93,7 +92,7 @@ abstract class AbstractAI implements Ctrl
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Creature managed by this Accessor AI.
|
||||
* @return the Creature managed by this Accessor AI.
|
||||
*/
|
||||
@Override
|
||||
public Creature getActor()
|
||||
@@ -103,12 +102,10 @@ abstract class AbstractAI implements Ctrl
|
||||
|
||||
/**
|
||||
* Set the Intention of this AbstractAI.<br>
|
||||
* <font color=#FF0000><b><u>Caution</u>: This method is USED by AI classes</b></font><br>
|
||||
* <br>
|
||||
* <b><u>Overriden in</u>:</b><br>
|
||||
* <br>
|
||||
* <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
|
||||
@@ -222,7 +219,7 @@ abstract class AbstractAI implements Ctrl
|
||||
|
||||
/**
|
||||
* 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>
|
||||
* <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>
|
||||
* @param evt The event whose the AI must be notified
|
||||
*/
|
||||
@Override
|
||||
@@ -592,7 +589,9 @@ abstract class AbstractAI implements Ctrl
|
||||
}
|
||||
}
|
||||
|
||||
// Client has already arrived to target, no need to force StopMove packet
|
||||
/**
|
||||
* Client has already arrived to target, no need to force StopMove packet.
|
||||
*/
|
||||
protected void clientStoppedMoving()
|
||||
{
|
||||
if (_clientMovingToPawnOffset > 0) // movetoPawn needs to be stopped
|
||||
|
@@ -89,35 +89,41 @@ public class AttackableAI extends CreatureAI
|
||||
}
|
||||
|
||||
/**
|
||||
* Return True if the target is autoattackable (depends on the actor type).<br>
|
||||
* <br>
|
||||
* <b><u>Actor is a GuardInstance</u>:</b><br>
|
||||
* <b><u>Actor is a GuardInstance</u>:</b>
|
||||
* <ul>
|
||||
* <li>The target isn't a Folk or a Door</li>
|
||||
* <li>The target isn't dead, isn't invulnerable, isn't in silent moving mode AND too far (>100)</li>
|
||||
* <li>The target is in the actor Aggro range and is at the same height</li>
|
||||
* <li>The PlayerInstance target has karma (=PK)</li>
|
||||
* <li>The MonsterInstance target is aggressive</li><br>
|
||||
* <li>The MonsterInstance target is aggressive</li>
|
||||
* </ul>
|
||||
* <br>
|
||||
* <b><u>Actor is a SiegeGuardInstance</u>:</b><br>
|
||||
* <b><u>Actor is a SiegeGuardInstance</u>:</b>
|
||||
* <ul>
|
||||
* <li>The target isn't a Folk or a Door</li>
|
||||
* <li>The target isn't dead, isn't invulnerable, isn't in silent moving mode AND too far (>100)</li>
|
||||
* <li>The target is in the actor Aggro range and is at the same height</li>
|
||||
* <li>A siege is in progress</li>
|
||||
* <li>The PlayerInstance target isn't a Defender</li><br>
|
||||
* <li>The PlayerInstance target isn't a Defender</li>
|
||||
* </ul>
|
||||
* <br>
|
||||
* <b><u>Actor is a FriendlyMobInstance</u>:</b><br>
|
||||
* <b><u>Actor is a FriendlyMobInstance</u>:</b>
|
||||
* <ul>
|
||||
* <li>The target isn't a Folk, a Door or another NpcInstance</li>
|
||||
* <li>The target isn't dead, isn't invulnerable, isn't in silent moving mode AND too far (>100)</li>
|
||||
* <li>The target is in the actor Aggro range and is at the same height</li>
|
||||
* <li>The PlayerInstance target has karma (=PK)</li><br>
|
||||
* <li>The PlayerInstance target has karma (=PK)</li>
|
||||
* </ul>
|
||||
* <br>
|
||||
* <b><u>Actor is a MonsterInstance</u>:</b><br>
|
||||
* <li>The target isn't a Folk, a Door or another NpcInstance</li>
|
||||
* <b><u>Actor is a MonsterInstance</u>:</b>
|
||||
* <ul>
|
||||
* <li>The target isn't a Folk, a Door or another Npc</li>
|
||||
* <li>The target isn't dead, isn't invulnerable, isn't in silent moving mode AND too far (>100)</li>
|
||||
* <li>The target is in the actor Aggro range and is at the same height</li>
|
||||
* <li>The actor is Aggressive</li><br>
|
||||
* <li>The actor is Aggressive</li>
|
||||
* </ul>
|
||||
* @param target The targeted WorldObject
|
||||
* @return
|
||||
* @return True if the target is autoattackable (depends on the actor type).
|
||||
*/
|
||||
private boolean autoAttackCondition(Creature target)
|
||||
{
|
||||
@@ -366,13 +372,13 @@ public class AttackableAI extends CreatureAI
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage AI standard thinks of a Attackable (called by onEvtThink).<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* Manage AI standard thinks of a Attackable (called by onEvtThink). <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Update every 1s the _globalAggro counter to come close to 0</li>
|
||||
* <li>If the actor is Aggressive and can attack, add all autoAttackable Creature in its Aggro Range to its _aggroList, chose a target and order to attack it</li>
|
||||
* <li>If the actor is a GuardInstance that can't attack, order to it to return to its home location</li>
|
||||
* <li>If the actor is a MonsterInstance that can't attack, order to it to random walk (1/100)</li>
|
||||
* </ul>
|
||||
*/
|
||||
private void thinkActive()
|
||||
{
|
||||
@@ -503,15 +509,13 @@ public class AttackableAI extends CreatureAI
|
||||
{
|
||||
int offset;
|
||||
|
||||
// for Raids - need correction
|
||||
if (_actor.isRaid())
|
||||
{
|
||||
offset = 500;
|
||||
offset = 500; // for Raids - need correction
|
||||
}
|
||||
else
|
||||
{
|
||||
// for normal minions - need correction :)
|
||||
offset = 200;
|
||||
offset = 200; // for normal minions - need correction :)
|
||||
}
|
||||
|
||||
if (((MinionInstance) _actor).getLeader().isRunning())
|
||||
@@ -591,12 +595,13 @@ public class AttackableAI extends CreatureAI
|
||||
/**
|
||||
* Manage AI attack thinks of a Attackable (called by onEvtThink).<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Update the attack timeout if actor is running</li>
|
||||
* <li>If target is dead or timeout is expired, stop this attack and set the Intention to AI_INTENTION_ACTIVE</li>
|
||||
* <li>Call all WorldObject of its Faction inside the Faction Range</li>
|
||||
* <li>Chose a target and order to attack it with magic skill or physical attack</li><br>
|
||||
* TODO: Manage casting rules to healer mobs (like Ant Nurses)
|
||||
* <li>Chose a target and order to attack it with magic skill or physical attack</li>
|
||||
* </ul>
|
||||
*/
|
||||
private void thinkAttack()
|
||||
{
|
||||
@@ -1034,10 +1039,12 @@ public class AttackableAI extends CreatureAI
|
||||
/**
|
||||
* Launch actions corresponding to the Event Attacked.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Init the attack : Calculate the attack timeout, Set the _globalAggro to 0, Add the attacker to the actor _aggroList</li>
|
||||
* <li>Set the Creature movement type to run and send Server->Client packet ChangeMoveType to all others PlayerInstance</li>
|
||||
* <li>Set the Intention to AI_INTENTION_ATTACK</li>
|
||||
* </ul>
|
||||
* @param attacker The Creature that attacks the actor
|
||||
*/
|
||||
@Override
|
||||
@@ -1080,9 +1087,11 @@ public class AttackableAI extends CreatureAI
|
||||
/**
|
||||
* Launch actions corresponding to the Event Aggression.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <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><br>
|
||||
* <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
|
||||
*/
|
||||
|
@@ -39,7 +39,8 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author littlecrow AI for controllable mobs
|
||||
* AI for controllable mobs
|
||||
* @author littlecrow
|
||||
*/
|
||||
public class ControllableMobAI extends AttackableAI
|
||||
{
|
||||
@@ -203,6 +204,7 @@ public class ControllableMobAI extends AttackableAI
|
||||
_accessor.doCast(sk);
|
||||
return;
|
||||
}
|
||||
|
||||
maxRange = Math.max(maxRange, castRange);
|
||||
}
|
||||
|
||||
@@ -239,6 +241,7 @@ public class ControllableMobAI extends AttackableAI
|
||||
_accessor.doCast(sk);
|
||||
return;
|
||||
}
|
||||
|
||||
maxRange = Math.max(maxRange, castRange);
|
||||
}
|
||||
|
||||
@@ -246,8 +249,10 @@ public class ControllableMobAI extends AttackableAI
|
||||
{
|
||||
moveToPawn(getForcedTarget(), _actor.getPhysicalAttackRange()/* range */);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_accessor.doAttack(getForcedTarget());
|
||||
}
|
||||
|
||||
@@ -261,7 +266,6 @@ public class ControllableMobAI extends AttackableAI
|
||||
final Attackable npc = (Attackable) _actor;
|
||||
npc.stopHating(getAttackTarget());
|
||||
}
|
||||
|
||||
setIntention(AI_INTENTION_ACTIVE);
|
||||
}
|
||||
else
|
||||
|
@@ -45,12 +45,13 @@ import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
|
||||
/**
|
||||
* This class manages AI of Creature.<br>
|
||||
* <br>
|
||||
* CreatureAI:<br>
|
||||
* CreatureAI :
|
||||
* <ul>
|
||||
* <li>AttackableAI</li>
|
||||
* <li>DoorAI</li>
|
||||
* <li>PlayerAI</li>
|
||||
* <li>SummonAI</li>
|
||||
* </ul>
|
||||
*/
|
||||
public class CreatureAI extends AbstractAI
|
||||
{
|
||||
@@ -75,12 +76,14 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Manage the Idle Intention : Stop Attack, Movement and Stand Up the actor.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Set the AI Intention to AI_INTENTION_IDLE</li>
|
||||
* <li>Init cast and attack target</li>
|
||||
* <li>Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop (broadcast)</li>
|
||||
* <li>Stop the actor movement server side AND client side by sending Server->Client packet StopMove/StopRotation (broadcast)</li>
|
||||
* <li>Stand up the actor server side AND client side by sending Server->Client packet ChangeWaitType (broadcast)</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onIntentionIdle()
|
||||
@@ -102,12 +105,14 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Manage the Active Intention : Stop Attack, Movement and Launch Think Event.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u> : <i>if the Intention is not already Active</i></b><br>
|
||||
* <b><u>Actions</u> : <i>if the Intention is not already Active</i></b>
|
||||
* <ul>
|
||||
* <li>Set the AI Intention to AI_INTENTION_ACTIVE</li>
|
||||
* <li>Init cast and attack target</li>
|
||||
* <li>Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop (broadcast)</li>
|
||||
* <li>Stop the actor movement server side AND client side by sending Server->Client packet StopMove/StopRotation (broadcast)</li>
|
||||
* <li>Launch the Think Event</li><br>
|
||||
* <li>Launch the Think Event</li>
|
||||
* </ul>
|
||||
* @param target
|
||||
*/
|
||||
protected void onIntentionActive(Creature target)
|
||||
@@ -143,8 +148,10 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Manage the Rest Intention.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u> : </b><br>
|
||||
* <b><u>Actions</u> : </b>
|
||||
* <ul>
|
||||
* <li>Set the AI Intention to AI_INTENTION_IDLE</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onIntentionRest()
|
||||
@@ -156,15 +163,19 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Manage the Attack Intention : Stop current Attack (if necessary), Start a new Attack and Launch Think Event.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u> : </b><br>
|
||||
* <b><u>Actions</u> : </b>
|
||||
* <ul>
|
||||
* <li>Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop (broadcast)</li>
|
||||
* <li>Set the Intention of this AI to AI_INTENTION_ATTACK</li>
|
||||
* <li>Set or change the AI attack target</li>
|
||||
* <li>Start the actor Auto Attack client side by sending Server->Client packet AutoAttackStart (broadcast)</li>
|
||||
* <li>Launch the Think Event</li><br>
|
||||
* <li>Launch the Think Event</li>
|
||||
* </ul>
|
||||
* <br>
|
||||
* <b><u>Overridden in</u>:</b><br>
|
||||
* <b><u>Overridden in</u>:</b>
|
||||
* <ul>
|
||||
* <li>AttackableAI : Calculate attack timeout</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onIntentionAttack(Creature target)
|
||||
@@ -226,13 +237,15 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Manage the Cast Intention : Stop current Attack, Init the AI in order to cast and Launch Think Event.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u> : </b><br>
|
||||
* <b><u>Actions</u> : </b>
|
||||
* <ul>
|
||||
* <li>Set the AI cast target</li>
|
||||
* <li>Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop (broadcast)</li>
|
||||
* <li>Cancel action client side by sending Server->Client packet ActionFailed to the PlayerInstance actor</li>
|
||||
* <li>Set the AI skill used by INTENTION_CAST</li>
|
||||
* <li>Set the Intention of this AI to AI_INTENTION_CAST</li>
|
||||
* <li>Launch the Think Event</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onIntentionCast(Skill skill, WorldObject target)
|
||||
@@ -291,10 +304,12 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Manage the Move To Intention : Stop current Attack and Launch a Move to Location Task.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u> : </b><br>
|
||||
* <b><u>Actions</u> : </b>
|
||||
* <ul>
|
||||
* <li>Stop the actor auto-attack server side AND client side by sending Server->Client packet AutoAttackStop (broadcast)</li>
|
||||
* <li>Set the Intention of this AI to AI_INTENTION_MOVE_TO</li>
|
||||
* <li>Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet CharMoveToLocation (broadcast)</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onIntentionMoveTo(Location pos)
|
||||
@@ -382,10 +397,12 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Manage the Follow Intention : Stop current Attack and Launch a Follow Task.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u> : </b><br>
|
||||
* <b><u>Actions</u> : </b>
|
||||
* <ul>
|
||||
* <li>Stop the actor auto-attack server side AND client side by sending Server->Client packet AutoAttackStop (broadcast)</li>
|
||||
* <li>Set the Intention of this AI to AI_INTENTION_FOLLOW</li>
|
||||
* <li>Create and Launch an AI Follow Task to execute every 1s</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onIntentionFollow(Creature target)
|
||||
@@ -438,10 +455,12 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Manage the PickUp Intention : Set the pick up target and Launch a Move To Pawn Task (offset=20).<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u> : </b><br>
|
||||
* <b><u>Actions</u> : </b>
|
||||
* <ul>
|
||||
* <li>Set the AI pick up target</li>
|
||||
* <li>Set the Intention of this AI to AI_INTENTION_PICK_UP</li>
|
||||
* <li>Move the actor to Pawn server side AND client side by sending Server->Client packet MoveToPawn (broadcast)</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onIntentionPickUp(WorldObject object)
|
||||
@@ -494,11 +513,13 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Manage the Interact Intention : Set the interact target and Launch a Move To Pawn Task (offset=60).<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u> : </b><br>
|
||||
* <b><u>Actions</u> : </b>
|
||||
* <ul>
|
||||
* <li>Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop (broadcast)</li>
|
||||
* <li>Set the AI interact target</li>
|
||||
* <li>Set the Intention of this AI to AI_INTENTION_INTERACT</li>
|
||||
* <li>Move the actor to Pawn server side AND client side by sending Server->Client packet MoveToPawn (broadcast)</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onIntentionInteract(WorldObject object)
|
||||
@@ -554,12 +575,14 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Launch actions corresponding to the Event Stunned then onAttacked Event.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop (broadcast)</li>
|
||||
* <li>Stop the actor movement server side AND client side by sending Server->Client packet StopMove/StopRotation (broadcast)</li>
|
||||
* <li>Break an attack and send Server->Client ActionFailed packet and a System Message to the Creature</li>
|
||||
* <li>Break a cast and send Server->Client ActionFailed packet and a System Message to the Creature</li>
|
||||
* <li>Launch actions corresponding to the Event onAttacked (only for AttackableAI after the stunning periode)</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onEvtStunned(Creature attacker)
|
||||
@@ -584,11 +607,13 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Launch actions corresponding to the Event Sleeping.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop (broadcast)</li>
|
||||
* <li>Stop the actor movement server side AND client side by sending Server->Client packet StopMove/StopRotation (broadcast)</li>
|
||||
* <li>Break an attack and send Server->Client ActionFailed packet and a System Message to the Creature</li>
|
||||
* <li>Break a cast and send Server->Client ActionFailed packet and a System Message to the Creature</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onEvtSleeping(Creature attacker)
|
||||
@@ -610,9 +635,11 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Launch actions corresponding to the Event Rooted.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Stop the actor movement server side AND client side by sending Server->Client packet StopMove/StopRotation (broadcast)</li>
|
||||
* <li>Launch actions corresponding to the Event onAttacked</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onEvtRooted(Creature attacker)
|
||||
@@ -632,9 +659,11 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Launch actions corresponding to the Event Confused.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Stop the actor movement server side AND client side by sending Server->Client packet StopMove/StopRotation (broadcast)</li>
|
||||
* <li>Launch actions corresponding to the Event onAttacked</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onEvtConfused(Creature attacker)
|
||||
@@ -649,8 +678,10 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Launch actions corresponding to the Event Muted.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Break a cast and send Server->Client ActionFailed packet and a System Message to the Creature</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onEvtMuted(Creature attacker)
|
||||
@@ -662,8 +693,10 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Launch actions corresponding to the Event ReadyToAct.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Launch actions corresponding to the Event Think</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onEvtReadyToAct()
|
||||
@@ -684,9 +717,11 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Launch actions corresponding to the Event Arrived.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>If the Intention was AI_INTENTION_MOVE_TO, set the Intention to AI_INTENTION_ACTIVE</li>
|
||||
* <li>Launch actions corresponding to the Event Think</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onEvtArrived()
|
||||
@@ -726,8 +761,10 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Launch actions corresponding to the Event ArrivedRevalidate.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Launch actions corresponding to the Event Think</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onEvtArrivedRevalidate()
|
||||
@@ -739,10 +776,12 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Launch actions corresponding to the Event ArrivedBlocked.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Stop the actor movement server side AND client side by sending Server->Client packet StopMove/StopRotation (broadcast)</li>
|
||||
* <li>If the Intention was AI_INTENTION_MOVE_TO, set the Intention to AI_INTENTION_ACTIVE</li>
|
||||
* <li>Launch actions corresponding to the Event Think</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onEvtArrivedBlocked(Location location)
|
||||
@@ -763,12 +802,14 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Launch actions corresponding to the Event ForgetObject.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>If the object was targeted and the Intention was AI_INTENTION_INTERACT or AI_INTENTION_PICK_UP, set the Intention to AI_INTENTION_ACTIVE</li>
|
||||
* <li>If the object was targeted to attack, stop the auto-attack, cancel target and set the Intention to AI_INTENTION_ACTIVE</li>
|
||||
* <li>If the object was targeted to cast, cancel target and set the Intention to AI_INTENTION_ACTIVE</li>
|
||||
* <li>If the object was targeted to follow, stop the movement, cancel AI Follow Task and set the Intention to AI_INTENTION_ACTIVE</li>
|
||||
* <li>If the targeted object was the actor , cancel AI target, stop AI Follow Task, stop the movement and set the Intention to AI_INTENTION_IDLE</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onEvtForgetObject(WorldObject object)
|
||||
@@ -822,30 +863,34 @@ public class CreatureAI extends AbstractAI
|
||||
}
|
||||
|
||||
// Check if the targeted object was the actor
|
||||
if (_actor == object)
|
||||
if (_actor != object)
|
||||
{
|
||||
// Cancel AI target
|
||||
setTarget(null);
|
||||
setAttackTarget(null);
|
||||
setCastTarget(null);
|
||||
|
||||
// Stop an AI Follow Task
|
||||
stopFollow();
|
||||
|
||||
// Stop the actor movement server side AND client side by sending Server->Client packet StopMove/StopRotation (broadcast)
|
||||
clientStopMoving(null);
|
||||
|
||||
// Set the Intention of this AbstractAI to AI_INTENTION_IDLE
|
||||
changeIntention(AI_INTENTION_IDLE, null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
// Cancel AI target
|
||||
setTarget(null);
|
||||
setAttackTarget(null);
|
||||
setCastTarget(null);
|
||||
|
||||
// Stop an AI Follow Task
|
||||
stopFollow();
|
||||
|
||||
// Stop the actor movement server side AND client side by sending Server->Client packet StopMove/StopRotation (broadcast)
|
||||
clientStopMoving(null);
|
||||
|
||||
// Set the Intention of this AbstractAI to AI_INTENTION_IDLE
|
||||
changeIntention(AI_INTENTION_IDLE, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch actions corresponding to the Event Cancel.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Stop an AI Follow Task</li>
|
||||
* <li>Launch actions corresponding to the Event Think</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onEvtCancel()
|
||||
@@ -865,9 +910,11 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Launch actions corresponding to the Event Dead.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Stop an AI Follow Task</li>
|
||||
* <li>Kill the actor client side by sending Server->Client packet AutoAttackStop, StopMove/StopRotation, Die (broadcast)</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onEvtDead()
|
||||
@@ -887,8 +934,10 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Launch actions corresponding to the Event Fake Death.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Stop an AI Follow Task</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
protected void onEvtFakeDeath()
|
||||
@@ -918,13 +967,17 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Manage the Move to Pawn action in function of the distance and of the Interact area.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Get the distance between the current position of the Creature and the target (x,y)</li>
|
||||
* <li>If the distance > offset+20, move the actor (by running) to Pawn server side AND client side by sending Server->Client packet MoveToPawn (broadcast)</li>
|
||||
* <li>If the distance <= offset+20, Stop the actor movement server side AND client side by sending Server->Client packet StopMove/StopRotation (broadcast)</li><br>
|
||||
* <li>If the distance <= offset+20, Stop the actor movement server side AND client side by sending Server->Client packet StopMove/StopRotation (broadcast)</li>
|
||||
* </ul>
|
||||
* <br>
|
||||
* <b><u>Example of use</u>:</b><br>
|
||||
* <li>PLayerAI, SummonAI</li><br>
|
||||
* <b><u>Example of use</u>:</b>
|
||||
* <ul>
|
||||
* <li>PLayerAI, SummonAI</li>
|
||||
* </ul>
|
||||
* @param target The targeted WorldObject
|
||||
* @param offsetValue The Interact area radius
|
||||
* @return True if a movement must be done
|
||||
@@ -937,11 +990,9 @@ public class CreatureAI extends AbstractAI
|
||||
// LOGGER.warning("maybeMoveToPawn: target == NULL!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// skill radius -1
|
||||
if (offsetValue < 0)
|
||||
{
|
||||
return false;
|
||||
return false; // skill radius -1
|
||||
}
|
||||
|
||||
int offsetWithCollision = offsetValue + _actor.getTemplate().getCollisionRadius();
|
||||
@@ -1031,15 +1082,17 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Modify current Intention and actions if the target is lost or dead.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u> : <i>If the target is lost or dead</i></b><br>
|
||||
* <b><u>Actions</u> : <i>If the target is lost or dead</i></b>
|
||||
* <ul>
|
||||
* <li>Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop (broadcast)</li>
|
||||
* <li><br>
|
||||
* Stop the actor movement server side AND client side by sending Server->Client packet StopMove/StopRotation<br>
|
||||
* (broadcast)</li>
|
||||
* <li>Set the Intention of this AbstractAI to AI_INTENTION_ACTIVE</li><br>
|
||||
* <li>Stop the actor movement server side AND client side by sending Server->Client packet StopMove/StopRotation (broadcast)</li>
|
||||
* <li>Set the Intention of this AbstractAI to AI_INTENTION_ACTIVE</li>
|
||||
* </ul>
|
||||
* <br>
|
||||
* <b><u>Example of use</u>:</b><br>
|
||||
* <li>PLayerAI, SummonAI</li><br>
|
||||
* <b><u>Example of use</u>:</b>
|
||||
* <ul>
|
||||
* <li>PLayerAI, SummonAI</li>
|
||||
* </ul>
|
||||
* @param target The targeted WorldObject
|
||||
* @return True if the target is lost or dead (false if fakedeath)
|
||||
*/
|
||||
@@ -1056,7 +1109,6 @@ public class CreatureAI extends AbstractAI
|
||||
|
||||
// Set the Intention of this AbstractAI to AI_INTENTION_ACTIVE
|
||||
setIntention(AI_INTENTION_ACTIVE);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -1065,13 +1117,17 @@ public class CreatureAI extends AbstractAI
|
||||
/**
|
||||
* Modify current Intention and actions if the target is lost.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u> : <i>If the target is lost</i></b><br>
|
||||
* <b><u>Actions</u> : <i>If the target is lost</i></b>
|
||||
* <ul>
|
||||
* <li>Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop (broadcast)</li>
|
||||
* <li>Stop the actor movement server side AND client side by sending Server->Client packet StopMove/StopRotation (broadcast)</li>
|
||||
* <li>Set the Intention of this AbstractAI to AI_INTENTION_ACTIVE</li><br>
|
||||
* <li>Set the Intention of this AbstractAI to AI_INTENTION_ACTIVE</li>
|
||||
* </ul>
|
||||
* <br>
|
||||
* <b><u>Example of use</u>:</b><br>
|
||||
* <li>PLayerAI, SummonAI</li><br>
|
||||
* <b><u>Example of use</u>:</b>
|
||||
* <ul>
|
||||
* <li>PlayerAI, SummonAI</li>
|
||||
* </ul>
|
||||
* @param target The targeted WorldObject
|
||||
* @return True if the target is lost
|
||||
*/
|
||||
|
@@ -19,48 +19,86 @@ package org.l2jmobius.gameserver.ai;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
|
||||
/**
|
||||
* Interface of AI and client state. To correctly send messages to client we need it's state. For example, if we've sent 'StartAutoAttack' message, we need to send 'StopAutoAttack' message before any other action. Or if we've sent 'MoveToPawn', we need to send 'StopMove' when the movement of a
|
||||
* character is canceled (by Root spell or any other reason). Thus, we need to know the state of client, i.e. which messages we've sent and how the client will show the scene. Close to this task is the task of AI. If a player's character is attacking a mob, his ATTACK may be interrupted by an event,
|
||||
* that temporary disable attacking. But when the possibility to ATTACK will be enabled, the character must continue the ATTACK. For mobs it may be more complex, since we want them to decide when to use magic, or when to follow the player for physical combat, or when to escape, to help another mob,
|
||||
* etc. This interface is hiding complexity of server<->client interaction and multiple states of a character. It allows to set a desired, simple "wish" of a character, and the implementation of this interface will take care about the rest. The goal of a character may be like "ATTACK", "random walk"
|
||||
* and so on. To reach the goal implementation will split it into several small actions, several steps (possibly repeatable). Like "run to target" then "hit it", then if target is not dead - repeat. This flow of simpler steps may be interrupted by incoming events. Like a character's movement was
|
||||
* disabled (by Root spell, for instance). Depending on character's ability AI may choose to wait, or to use magic ATTACK and so on. Additionally incoming events are compared with client's state of the character, and required network messages are sent to client's, i.e. if we have incoming event that
|
||||
* character's movement was disabled, it causes changing if its Behavior, and if client's state for the character is "moving" we send messages to clients to stop the avatar/mob.
|
||||
* Interface of AI and client state.<br>
|
||||
* To correctly send messages to client we need it's state.<br>
|
||||
* For example, if we've sent 'StartAutoAttack' message, we need to send 'StopAutoAttack' message before any other action.<br>
|
||||
* Or if we've sent 'MoveToPawn', we need to send 'StopMove' when the movement of a character is canceled (by Root spell or any other reason).<br>
|
||||
* Thus, we need to know the state of client, i.e. which messages we've sent and how the client will show the scene.<br>
|
||||
* Close to this task is the task of AI.<br>
|
||||
* If a player's character is attacking a mob, his ATTACK may be interrupted by an event, that temporary disable attacking.<br>
|
||||
* But when the possibility to ATTACK will be enabled, the character must continue the ATTACK.<br>
|
||||
* For mobs it may be more complex, since we want them to decide when to use magic, or when to follow the player for physical combat, or when to escape, to help another mob, etc.<br>
|
||||
* This interface is hiding complexity of server<->client interaction and multiple states of a character.<br>
|
||||
* It allows to set a desired, simple "wish" of a character, and the implementation of this interface will take care about the rest.<br>
|
||||
* The goal of a character may be like "ATTACK", "random walk" and so on.<br>
|
||||
* To reach the goal implementation will split it into several small actions, several steps (possibly repeatable).<br>
|
||||
* Like "run to target" then "hit it", then if target is not dead - repeat.<br>
|
||||
* This flow of simpler steps may be interrupted by incoming events.<br>
|
||||
* Like a character's movement was disabled (by Root spell, for instance).<br>
|
||||
* Depending on character's ability AI may choose to wait, or to use magic ATTACK and so on.<br>
|
||||
* Additionally incoming events are compared with client's state of the character,<br>
|
||||
* and required network messages are sent to client's, i.e. if we have incoming event that character's movement was disabled, it causes changing if its behavior,<br>
|
||||
* and if client's state for the character is "moving" we send messages to clients to stop the avatar/mob.
|
||||
*/
|
||||
public interface Ctrl
|
||||
{
|
||||
/**
|
||||
* @return the character this AI serves
|
||||
* Gets the actor.
|
||||
* @return the actor
|
||||
*/
|
||||
Creature getActor();
|
||||
|
||||
/**
|
||||
* @return the current intention.
|
||||
* Gets the intention.
|
||||
* @return the intention
|
||||
*/
|
||||
CtrlIntention getIntention();
|
||||
|
||||
/**
|
||||
* @return the current attack target.
|
||||
* Gets the attack target.
|
||||
* @return the attack target
|
||||
*/
|
||||
Creature getAttackTarget();
|
||||
|
||||
/**
|
||||
* Set general state/intention for AI, with optional data
|
||||
* @param intention
|
||||
* Set general state/intention for AI, with optional data.
|
||||
* @param intention the new intention
|
||||
*/
|
||||
void setIntention(CtrlIntention intention);
|
||||
|
||||
/**
|
||||
* Sets the intention.
|
||||
* @param intention the intention
|
||||
* @param arg0 the arg0
|
||||
*/
|
||||
void setIntention(CtrlIntention intention, Object arg0);
|
||||
|
||||
/**
|
||||
* Sets the intention.
|
||||
* @param intention the intention
|
||||
* @param arg0 the arg0
|
||||
* @param arg1 the arg1
|
||||
*/
|
||||
void setIntention(CtrlIntention intention, Object arg0, Object arg1);
|
||||
|
||||
/**
|
||||
* Event, that notifies about previous step result, or user command, that does not change current general intention
|
||||
* @param evt
|
||||
* Event, that notifies about previous step result, or user command, that does not change current general intention.
|
||||
* @param evt the event
|
||||
*/
|
||||
void notifyEvent(CtrlEvent evt);
|
||||
|
||||
/**
|
||||
* Notify an event.
|
||||
* @param evt the event
|
||||
* @param arg0 the arg0
|
||||
*/
|
||||
void notifyEvent(CtrlEvent evt, Object arg0);
|
||||
|
||||
/**
|
||||
* Notify an event.
|
||||
* @param evt the event
|
||||
* @param arg0 the arg0
|
||||
* @param arg1 the arg1
|
||||
*/
|
||||
void notifyEvent(CtrlEvent evt, Object arg0, Object arg1);
|
||||
}
|
||||
|
@@ -17,31 +17,40 @@
|
||||
package org.l2jmobius.gameserver.ai;
|
||||
|
||||
/**
|
||||
* This class contains an enum of each possibles evenements that can happen on an AI character.
|
||||
* This class contains an enum of each possibles events that can happen on an AI character.
|
||||
*/
|
||||
|
||||
public enum CtrlEvent
|
||||
{
|
||||
/**
|
||||
* Something has changed, usually a previous step has being completed or maybe was completed, the AI must thing on next action
|
||||
* 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 attack was done on the actor. NPC may start attack in responce, or ignore this event if they already attack someone, or change target and so on.
|
||||
* 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 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,
|
||||
|
||||
/**
|
||||
@@ -60,40 +69,61 @@ public enum CtrlEvent
|
||||
EVT_ARRIVED,
|
||||
|
||||
/**
|
||||
* The actor arrived to an intermidiate point, and needs revalidate destination. This is sent when follow/move to pawn if destination is far away.
|
||||
* 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. For example, the actor was putted into a stun, so it's current attack or movement has to be canceled. But after the stun state expired, the actor may try to attack again. Another usage for CANCEL is a user's attempt to
|
||||
* cancel a cast/bow attack and so on.
|
||||
* 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>
|
||||
* or movement has to be canceled. But after the stun state expired,<br>
|
||||
* the actor may try to attack again. Another usage for CANCEL is a user's<br>
|
||||
* 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 randoms directions **/
|
||||
EVT_AFFRAID,
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
|
@@ -17,9 +17,8 @@
|
||||
package org.l2jmobius.gameserver.ai;
|
||||
|
||||
/**
|
||||
* Enumaration of generic intentions of an NPC/PC, an intention may require several steps to be completed
|
||||
* Enumeration of generic intentions of an NPC/PC, an intention may require several steps to be completed.
|
||||
*/
|
||||
|
||||
public enum CtrlIntention
|
||||
{
|
||||
/** Do nothing, disconnect AI of NPC if no players around */
|
||||
@@ -31,9 +30,7 @@ public enum CtrlIntention
|
||||
/** 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 peacefull zone and so on
|
||||
*/
|
||||
/** 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 */
|
||||
|
@@ -35,144 +35,120 @@ public class DoorAI extends CreatureAI
|
||||
super(accessor);
|
||||
}
|
||||
|
||||
// rather stupid AI... well, it's for doors :D
|
||||
@Override
|
||||
protected void onIntentionIdle()
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onIntentionActive()
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onIntentionRest()
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onIntentionAttack(Creature target)
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onIntentionCast(Skill skill, WorldObject target)
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onIntentionMoveTo(Location destination)
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onIntentionFollow(Creature target)
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onIntentionPickUp(WorldObject item)
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onIntentionInteract(WorldObject object)
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvtThink()
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvtAttacked(Creature attacker)
|
||||
{
|
||||
final DoorInstance me = (DoorInstance) _actor;
|
||||
ThreadPool.execute(new onEventAttackedDoorTask(me, attacker));
|
||||
ThreadPool.execute(new onEventAttackedDoorTask((DoorInstance) _actor, attacker));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvtAggression(Creature target, int aggro)
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvtStunned(Creature attacker)
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvtSleeping(Creature attacker)
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvtRooted(Creature attacker)
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvtReadyToAct()
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvtUserCmd(Object arg0, Object arg1)
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvtArrived()
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvtArrivedRevalidate()
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvtArrivedBlocked(Location blocked_at_pos)
|
||||
protected void onEvtArrivedBlocked(Location blocked_at_loc)
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvtForgetObject(WorldObject object)
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvtCancel()
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvtDead()
|
||||
{
|
||||
// null;
|
||||
}
|
||||
|
||||
private class onEventAttackedDoorTask implements Runnable
|
||||
|
@@ -104,35 +104,41 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
|
||||
}
|
||||
|
||||
/**
|
||||
* Return True if the target is autoattackable (depends on the actor type).<br>
|
||||
* <br>
|
||||
* <b><u>Actor is a GuardInstance</u>:</b><br>
|
||||
* <b><u>Actor is a GuardInstance</u>:</b>
|
||||
* <ul>
|
||||
* <li>The target isn't a Folk or a Door</li>
|
||||
* <li>The target isn't dead, isn't invulnerable, isn't in silent moving mode AND too far (>100)</li>
|
||||
* <li>The target is in the actor Aggro range and is at the same height</li>
|
||||
* <li>The PlayerInstance target has karma (=PK)</li>
|
||||
* <li>The MonsterInstance target is aggressive</li><br>
|
||||
* <li>The MonsterInstance target is aggressive</li>
|
||||
* </ul>
|
||||
* <br>
|
||||
* <b><u>Actor is a SiegeGuardInstance</u>:</b><br>
|
||||
* <b><u>Actor is a SiegeGuardInstance</u>:</b>
|
||||
* <ul>
|
||||
* <li>The target isn't a Folk or a Door</li>
|
||||
* <li>The target isn't dead, isn't invulnerable, isn't in silent moving mode AND too far (>100)</li>
|
||||
* <li>The target is in the actor Aggro range and is at the same height</li>
|
||||
* <li>A siege is in progress</li>
|
||||
* <li>The PlayerInstance target isn't a Defender</li><br>
|
||||
* <li>The PlayerInstance target isn't a Defender</li>
|
||||
* </ul>
|
||||
* <br>
|
||||
* <b><u>Actor is a FriendlyMobInstance</u>:</b><br>
|
||||
* <b><u>Actor is a FriendlyMobInstance</u>:</b>
|
||||
* <ul>
|
||||
* <li>The target isn't a Folk, a Door or another NpcInstance</li>
|
||||
* <li>The target isn't dead, isn't invulnerable, isn't in silent moving mode AND too far (>100)</li>
|
||||
* <li>The target is in the actor Aggro range and is at the same height</li>
|
||||
* <li>The PlayerInstance target has karma (=PK)</li><br>
|
||||
* <li>The PlayerInstance target has karma (=PK)</li>
|
||||
* </ul>
|
||||
* <br>
|
||||
* <b><u>Actor is a MonsterInstance</u>:</b><br>
|
||||
* <b><u>Actor is a MonsterInstance</u>:</b>
|
||||
* <ul>
|
||||
* <li>The target isn't a Folk, a Door or another NpcInstance</li>
|
||||
* <li>The target isn't dead, isn't invulnerable, isn't in silent moving mode AND too far (>100)</li>
|
||||
* <li>The target is in the actor Aggro range and is at the same height</li>
|
||||
* <li>The actor is Aggressive</li><br>
|
||||
* <li>The actor is Aggressive</li>
|
||||
* </ul>
|
||||
* @param target The targeted WorldObject
|
||||
* @return
|
||||
* @return True if the target is autoattackable (depends on the actor type).
|
||||
*/
|
||||
private boolean autoAttackCondition(Creature target)
|
||||
{
|
||||
@@ -268,10 +274,12 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
|
||||
/**
|
||||
* Manage AI standard thinks of a Attackable (called by onEvtThink).<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Update every 1s the _globalAggro counter to come close to 0</li>
|
||||
* <li>If the actor is Aggressive and can attack, add all autoAttackable Creature in its Aggro Range to its _aggroList, chose a target and order to attack it</li>
|
||||
* <li>If the actor can't attack, order to it to return to its home location</li>
|
||||
* </ul>
|
||||
*/
|
||||
private void thinkActive()
|
||||
{
|
||||
@@ -362,11 +370,13 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
|
||||
/**
|
||||
* Manage AI attack thinks of a Attackable (called by onEvtThink).<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Update the attack timeout if actor is running</li>
|
||||
* <li>If target is dead or timeout is expired, stop this attack and set the Intention to AI_INTENTION_ACTIVE</li>
|
||||
* <li>Call all WorldObject of its Faction inside the Faction Range</li>
|
||||
* <li>Chose a target and order to attack it with magic skill or physical attack</li><br>
|
||||
* <li>Chose a target and order to attack it with magic skill or physical attack</li>
|
||||
* </ul>
|
||||
* TODO: Manage casting rules to healer mobs (like Ant Nurses)
|
||||
*/
|
||||
private void thinkAttack()
|
||||
@@ -592,7 +602,6 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
|
||||
FortSiegeGuardInstance sGuard;
|
||||
sGuard = (FortSiegeGuardInstance) _actor;
|
||||
Creature attackTarget = getAttackTarget();
|
||||
|
||||
try
|
||||
{
|
||||
_actor.setTarget(attackTarget);
|
||||
@@ -854,10 +863,12 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
|
||||
/**
|
||||
* Launch actions corresponding to the Event Attacked.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Init the attack : Calculate the attack timeout, Set the _globalAggro to 0, Add the attacker to the actor _aggroList</li>
|
||||
* <li>Set the Creature movement type to run and send Server->Client packet ChangeMoveType to all others PlayerInstance</li>
|
||||
* <li>Set the Intention to AI_INTENTION_ATTACK</li>
|
||||
* </ul>
|
||||
* @param attacker The Creature that attacks the actor
|
||||
*/
|
||||
@Override
|
||||
@@ -893,9 +904,11 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
|
||||
/**
|
||||
* Launch actions corresponding to the Event Aggression.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <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><br>
|
||||
* <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
|
||||
*/
|
||||
|
@@ -143,18 +143,18 @@ public class PlayerAI extends CreatureAI
|
||||
@Override
|
||||
protected void onIntentionRest()
|
||||
{
|
||||
if (getIntention() != AI_INTENTION_REST)
|
||||
if (getIntention() == AI_INTENTION_REST)
|
||||
{
|
||||
changeIntention(AI_INTENTION_REST, null, null);
|
||||
setTarget(null);
|
||||
|
||||
if (getAttackTarget() != null)
|
||||
{
|
||||
setAttackTarget(null);
|
||||
}
|
||||
|
||||
clientStopMoving(null);
|
||||
return;
|
||||
}
|
||||
|
||||
changeIntention(AI_INTENTION_REST, null, null);
|
||||
setTarget(null);
|
||||
if (getAttackTarget() != null)
|
||||
{
|
||||
setAttackTarget(null);
|
||||
}
|
||||
clientStopMoving(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -46,14 +46,12 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
|
||||
*/
|
||||
public class SiegeGuardAI extends CreatureAI implements Runnable
|
||||
{
|
||||
// protected static final Logger LOGGER = Logger.getLogger(SiegeGuardAI.class);
|
||||
|
||||
private static final int MAX_ATTACK_TIMEOUT = 300; // int ticks, i.e. 30 seconds
|
||||
|
||||
/** The Attackable AI task executed every 1s (call onEvtThink method) */
|
||||
private Future<?> _aiTask;
|
||||
|
||||
/** The delay after wich the attacked is stopped */
|
||||
/** The delay after which the attacked is stopped */
|
||||
private int _attackTimeout;
|
||||
|
||||
/** The Attackable aggro counter */
|
||||
@@ -85,35 +83,41 @@ public class SiegeGuardAI extends CreatureAI implements Runnable
|
||||
}
|
||||
|
||||
/**
|
||||
* Return True if the target is autoattackable (depends on the actor type).<br>
|
||||
* <br>
|
||||
* <b><u>Actor is a GuardInstance</u>:</b><br>
|
||||
* <b><u>Actor is a GuardInstance</u>:</b>
|
||||
* <ul>
|
||||
* <li>The target isn't a Folk or a Door</li>
|
||||
* <li>The target isn't dead, isn't invulnerable, isn't in silent moving mode AND too far (>100)</li>
|
||||
* <li>The target is in the actor Aggro range and is at the same height</li>
|
||||
* <li>The PlayerInstance target has karma (=PK)</li>
|
||||
* <li>The MonsterInstance target is aggressive</li><br>
|
||||
* <li>The MonsterInstance target is aggressive</li>
|
||||
* </ul>
|
||||
* <br>
|
||||
* <b><u>Actor is a SiegeGuardInstance</u>:</b><br>
|
||||
* <b><u>Actor is a SiegeGuardInstance</u>:</b>
|
||||
* <ul>
|
||||
* <li>The target isn't a Folk or a Door</li>
|
||||
* <li>The target isn't dead, isn't invulnerable, isn't in silent moving mode AND too far (>100)</li>
|
||||
* <li>The target is in the actor Aggro range and is at the same height</li>
|
||||
* <li>A siege is in progress</li>
|
||||
* <li>The PlayerInstance target isn't a Defender</li><br>
|
||||
* <li>The PlayerInstance target isn't a Defender</li>
|
||||
* </ul>
|
||||
* <br>
|
||||
* <b><u>Actor is a FriendlyMobInstance</u>:</b><br>
|
||||
* <b><u>Actor is a FriendlyMobInstance</u>:</b>
|
||||
* <ul>
|
||||
* <li>The target isn't a Folk, a Door or another NpcInstance</li>
|
||||
* <li>The target isn't dead, isn't invulnerable, isn't in silent moving mode AND too far (>100)</li>
|
||||
* <li>The target is in the actor Aggro range and is at the same height</li>
|
||||
* <li>The PlayerInstance target has karma (=PK)</li><br>
|
||||
* <li>The PlayerInstance target has karma (=PK)</li>
|
||||
* </ul>
|
||||
* <br>
|
||||
* <b><u>Actor is a MonsterInstance</u>:</b><br>
|
||||
* <b><u>Actor is a MonsterInstance</u>:</b>
|
||||
* <ul>
|
||||
* <li>The target isn't a Folk, a Door or another NpcInstance</li>
|
||||
* <li>The target isn't dead, isn't invulnerable, isn't in silent moving mode AND too far (>100)</li>
|
||||
* <li>The target is in the actor Aggro range and is at the same height</li>
|
||||
* <li>The actor is Aggressive</li><br>
|
||||
* <li>The actor is Aggressive</li>
|
||||
* </ul>
|
||||
* @param target The targeted WorldObject
|
||||
* @return
|
||||
* @return True if the target is autoattackable (depends on the actor type).
|
||||
*/
|
||||
private boolean autoAttackCondition(Creature target)
|
||||
{
|
||||
@@ -221,10 +225,12 @@ public class SiegeGuardAI extends CreatureAI implements Runnable
|
||||
/**
|
||||
* Manage AI standard thinks of a Attackable (called by onEvtThink).<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Update every 1s the _globalAggro counter to come close to 0</li>
|
||||
* <li>If the actor is Aggressive and can attack, add all autoAttackable Creature in its Aggro Range to its _aggroList, chose a target and order to attack it</li>
|
||||
* <li>If the actor can't attack, order to it to return to its home location</li>
|
||||
* </ul>
|
||||
*/
|
||||
private void thinkActive()
|
||||
{
|
||||
@@ -661,10 +667,12 @@ public class SiegeGuardAI extends CreatureAI implements Runnable
|
||||
/**
|
||||
* Launch actions corresponding to the Event Attacked.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <li>Init the attack : Calculate the attack timeout, Set the _globalAggro to 0, Add the attacker to the actor _aggroList</li>
|
||||
* <li>Set the Creature movement type to run and send Server->Client packet ChangeMoveType to all others PlayerInstance</li>
|
||||
* <li>Set the Intention to AI_INTENTION_ATTACK</li>
|
||||
* </ul>
|
||||
* @param attacker The Creature that attacks the actor
|
||||
*/
|
||||
@Override
|
||||
@@ -700,10 +708,11 @@ public class SiegeGuardAI extends CreatureAI implements Runnable
|
||||
/**
|
||||
* Launch actions corresponding to the Event Aggression.<br>
|
||||
* <br>
|
||||
* <b><u>Actions</u>:</b><br>
|
||||
* <b><u>Actions</u>:</b>
|
||||
* <ul>
|
||||
* <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><br>
|
||||
* @param target The Creature that attacks
|
||||
* <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 aggro The value of hate to add to the actor against the target
|
||||
*/
|
||||
@Override
|
||||
|
@@ -17,11 +17,8 @@
|
||||
package org.l2jmobius.gameserver.ai;
|
||||
|
||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_CAST;
|
||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_FOLLOW;
|
||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
|
||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_INTERACT;
|
||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_PICK_UP;
|
||||
|
||||
import org.l2jmobius.gameserver.model.Skill;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@@ -162,21 +159,28 @@ public class SummonAI extends CreatureAI
|
||||
|
||||
try
|
||||
{
|
||||
if (getIntention() == AI_INTENTION_ATTACK)
|
||||
switch (getIntention())
|
||||
{
|
||||
thinkAttack();
|
||||
}
|
||||
else if (getIntention() == AI_INTENTION_CAST)
|
||||
{
|
||||
thinkCast();
|
||||
}
|
||||
else if (getIntention() == AI_INTENTION_PICK_UP)
|
||||
{
|
||||
thinkPickUp();
|
||||
}
|
||||
else if (getIntention() == AI_INTENTION_INTERACT)
|
||||
{
|
||||
thinkInteract();
|
||||
case AI_INTENTION_ATTACK:
|
||||
{
|
||||
thinkAttack();
|
||||
break;
|
||||
}
|
||||
case AI_INTENTION_CAST:
|
||||
{
|
||||
thinkCast();
|
||||
break;
|
||||
}
|
||||
case AI_INTENTION_PICK_UP:
|
||||
{
|
||||
thinkPickUp();
|
||||
break;
|
||||
}
|
||||
case AI_INTENTION_INTERACT:
|
||||
{
|
||||
thinkInteract();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
@@ -3321,7 +3321,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
public void startFear()
|
||||
{
|
||||
setAfraid(true);
|
||||
getAI().notifyEvent(CtrlEvent.EVT_AFFRAID);
|
||||
getAI().notifyEvent(CtrlEvent.EVT_AFRAID);
|
||||
updateAbnormalEffect();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user