Minor base AI class cleanup.

This commit is contained in:
MobiusDevelopment
2021-11-01 22:21:53 +00:00
parent 5f13d2db66
commit 0506c469a3
165 changed files with 564 additions and 658 deletions

View File

@@ -66,10 +66,10 @@ public abstract class AbstractAI implements Ctrl
private WorldObject _target;
/** The skill we are currently casting by INTENTION_CAST */
Skill _skill;
ItemInstance _item;
boolean _forceUse;
boolean _dontMove;
protected Skill _skill;
protected ItemInstance _item;
protected boolean _forceUse;
protected boolean _dontMove;
/** Different internal state flags */
protected int _moveToPawnTimeout;
@@ -182,7 +182,7 @@ public abstract class AbstractAI implements Ctrl
}
case AI_INTENTION_CAST:
{
onIntentionCast((Skill) args[0], (WorldObject) args[1], args.length > 2 ? (ItemInstance) args[2] : null, args.length > 3 ? (boolean) args[3] : false, args.length > 4 ? (boolean) args[4] : false);
onIntentionCast((Skill) args[0], (WorldObject) args[1], args.length > 2 ? (ItemInstance) args[2] : null, args.length > 3 && (boolean) args[3], args.length > 4 && (boolean) args[4]);
break;
}
case AI_INTENTION_MOVE_TO:

View File

@@ -114,8 +114,6 @@ public class AttackableAI extends CreatureAI
return false;
}
final Attackable me = getActiveChar();
// Check if the target isn't dead, is in the Aggro range and is at the same height
if (target.isAlikeDead())
{
@@ -123,6 +121,7 @@ public class AttackableAI extends CreatureAI
}
// Check if the target is a Playable and if the AI isn't a Raid Boss, can See Silent Moving players and the target isn't in silent move mode
final Attackable me = getActiveChar();
if (target.isPlayable() && !(me.isRaid()) && !(me.canSeeThroughSilentMove()) && ((Playable) target).isSilentMovingAffected())
{
return false;
@@ -545,10 +544,6 @@ public class AttackableAI extends CreatureAI
// Order to the MonsterInstance to random walk (1/100)
else if ((npc.getSpawn() != null) && (Rnd.get(RANDOM_WALK_RATE) == 0) && npc.isRandomWalkingEnabled())
{
int x1 = 0;
int y1 = 0;
int z1 = 0;
final int range = Config.MAX_DRIFT_RANGE;
for (Skill sk : npc.getTemplate().getAISkills(AISkillScope.BUFF))
{
target = skillTargetReconsider(sk, true);
@@ -560,9 +555,10 @@ public class AttackableAI extends CreatureAI
}
}
x1 = npc.getSpawn().getX();
y1 = npc.getSpawn().getY();
z1 = npc.getSpawn().getZ();
int x1 = npc.getSpawn().getX();
int y1 = npc.getSpawn().getY();
int z1 = npc.getSpawn().getZ();
final int range = Config.MAX_DRIFT_RANGE;
if (!npc.isInsideRadius2D(x1, y1, 0, range))
{
npc.setReturningToSpawnPoint(true);
@@ -761,7 +757,6 @@ public class AttackableAI extends CreatureAI
return;
}
final int combinedCollision = collision + target.getTemplate().getCollisionRadius();
final List<Skill> aiSuicideSkills = npc.getTemplate().getAISkills(AISkillScope.SUICIDE);
if (!aiSuicideSkills.isEmpty() && ((int) ((npc.getCurrentHp() / npc.getMaxHp()) * 100) < 30) && npc.hasSkillChance())
{
@@ -778,6 +773,7 @@ public class AttackableAI extends CreatureAI
// In case many mobs are trying to hit from same place, move a bit, circling around the target
// Note from Gnacik:
// On l2js because of that sometimes mobs don't attack player only running around player without any sense, so decrease chance for now
final int combinedCollision = collision + target.getTemplate().getCollisionRadius();
if (!npc.isMovementDisabled() && (Rnd.get(100) <= 3))
{
for (Attackable nearby : World.getInstance().getVisibleObjects(npc, Attackable.class))
@@ -1231,7 +1227,6 @@ public class AttackableAI extends CreatureAI
Creature creature = null;
for (AggroInfo aggro : npc.getAggroList().values())
{
searchValue = aggro.getHate();
if (checkTarget(aggro.getAttacker()) && (aggro.getHate() > searchValue))
{
searchValue = aggro.getHate();

View File

@@ -381,12 +381,13 @@ public class ControllableMobAI extends AttackableAI
{
return false;
}
final Attackable me = (Attackable) _actor;
if (target.isNpc() || target.isDoor())
{
return false;
}
final Attackable me = (Attackable) _actor;
if (target.isAlikeDead() || !me.isInsideRadius2D(target, me.getAggroRange()) || (Math.abs(_actor.getZ() - target.getZ()) > 100))
{
return false;

View File

@@ -92,11 +92,13 @@ public class DoppelgangerAI extends CreatureAI
setTarget(null);
return;
}
final boolean val = _startFollow;
if (maybeMoveToPawn(target, _actor.getMagicalAttackRange(_skill)))
{
return;
}
getActor().followSummoner(false);
setIntention(AI_INTENTION_IDLE);
_startFollow = val;

View File

@@ -33,7 +33,7 @@ import org.l2jmobius.gameserver.network.SystemMessageId;
*/
public abstract class PlayableAI extends CreatureAI
{
public PlayableAI(Playable playable)
protected PlayableAI(Playable playable)
{
super(playable);
}

View File

@@ -65,11 +65,6 @@ public class PlayerAI extends PlayableAI
@Override
protected synchronized void changeIntention(CtrlIntention intention, Object... args)
{
final Object localArg0 = args.length > 0 ? args[0] : null;
final Object localArg1 = args.length > 1 ? args[1] : null;
final Object globalArg0 = (_intentionArgs != null) && (_intentionArgs.length > 0) ? _intentionArgs[0] : null;
final Object globalArg1 = (_intentionArgs != null) && (_intentionArgs.length > 1) ? _intentionArgs[1] : null;
// do nothing unless CAST intention
// however, forget interrupted actions when starting to use an offensive skill
if ((intention != AI_INTENTION_CAST) || ((Skill) args[0]).isBad())
@@ -79,6 +74,11 @@ public class PlayerAI extends PlayableAI
return;
}
final Object localArg0 = args.length > 0 ? args[0] : null;
final Object localArg1 = args.length > 1 ? args[1] : null;
final Object globalArg0 = (_intentionArgs != null) && (_intentionArgs.length > 0) ? _intentionArgs[0] : null;
final Object globalArg1 = (_intentionArgs != null) && (_intentionArgs.length > 1) ? _intentionArgs[1] : null;
// do nothing if next intention is same as current one.
if ((intention == _intention) && (globalArg0 == localArg0) && (globalArg1 == localArg1))
{

View File

@@ -31,7 +31,7 @@ public abstract class VehicleAI extends CreatureAI
* Simple AI for vehicles
* @param vehicle
*/
public VehicleAI(Vehicle vehicle)
protected VehicleAI(Vehicle vehicle)
{
super(vehicle);
}