Re-introduction of cast target and skill target check.

This commit is contained in:
MobiusDevelopment
2021-11-03 05:35:14 +00:00
parent 0b5708fd83
commit d9cb58d31c
164 changed files with 930 additions and 213 deletions

View File

@@ -109,7 +109,6 @@ public class Synergy extends AbstractEffect
if (partyBuffSkill != null)
{
final WorldObject target = partyBuffSkill.getTarget(effector, effected, false, false, false);
if ((target != null) && target.isCreature())
{
SkillCaster.triggerCast(effector, (Creature) target, partyBuffSkill);

View File

@@ -64,6 +64,7 @@ public abstract class AbstractAI implements Ctrl
/** Different targets this AI maintains */
private WorldObject _target;
private WorldObject _castTarget;
/** The skill we are currently casting by INTENTION_CAST */
protected Skill _skill;
@@ -671,6 +672,7 @@ public abstract class AbstractAI implements Ctrl
// Init AI
_intention = AI_INTENTION_IDLE;
_target = null;
_castTarget = null;
// Cancel the follow task if necessary
stopFollow();
@@ -749,6 +751,16 @@ public abstract class AbstractAI implements Ctrl
return _target;
}
protected void setCastTarget(WorldObject target)
{
_castTarget = target;
}
public WorldObject getCastTarget()
{
return _castTarget;
}
/**
* Stop all Ai tasks and futures.
*/

View File

@@ -274,6 +274,7 @@ public class AttackableAI extends CreatureAI
final WorldObject target = _skill.getTarget(_actor, getTarget(), _forceUse, _dontMove, false);
if (checkTargetLost(target))
{
setCastTarget(null);
return;
}

View File

@@ -155,6 +155,9 @@ public class CreatureAI extends AbstractAI
// Set the AI Intention to AI_INTENTION_IDLE
changeIntention(AI_INTENTION_IDLE);
// Init cast target
setCastTarget(null);
// Stop the actor movement server side AND client side by sending Server->Client packet StopMove/StopRotation (broadcast)
clientStopMoving(null);
@@ -183,6 +186,9 @@ public class CreatureAI extends AbstractAI
// Set the AI Intention to AI_INTENTION_ACTIVE
changeIntention(AI_INTENTION_ACTIVE);
// Init cast target
setCastTarget(null);
// Stop the actor movement server side AND client side by sending Server->Client packet StopMove/StopRotation (broadcast)
clientStopMoving(null);
@@ -317,6 +323,9 @@ public class CreatureAI extends AbstractAI
protected void changeIntentionToCast(Skill skill, WorldObject target, ItemInstance item, boolean forceUse, boolean dontMove)
{
// Set the AI cast target
setCastTarget(target);
// Set the AI skill used by INTENTION_CAST
_skill = skill;
@@ -791,6 +800,9 @@ public class CreatureAI extends AbstractAI
// Cancel AI target
setTarget(null);
// Init cast target
setCastTarget(null);
// Stop an AI Follow Task
stopFollow();
@@ -872,6 +884,7 @@ public class CreatureAI extends AbstractAI
// Init AI
_intention = AI_INTENTION_IDLE;
setTarget(null);
setCastTarget(null);
}
/**

View File

@@ -86,9 +86,10 @@ public class DoppelgangerAI extends CreatureAI
return;
}
final WorldObject target = _skill.getTarget(_actor, _forceUse, _dontMove, false);
final WorldObject target = getCastTarget();
if (checkTargetLost(target))
{
setCastTarget(null);
setTarget(null);
return;
}

View File

@@ -218,9 +218,10 @@ public class FriendlyNpcAI extends AttackableAI
@Override
protected void thinkCast()
{
final WorldObject target = _skill.getTarget(_actor, _forceUse, _dontMove, false);
final WorldObject target = getCastTarget();
if (checkTargetLost(target))
{
setCastTarget(null);
setTarget(null);
return;
}

View File

@@ -308,7 +308,7 @@ public class PlayerAI extends PlayableAI
private void thinkCast()
{
final WorldObject target = _skill.getTarget(_actor, _forceUse, _dontMove, false);
final WorldObject target = getCastTarget();
if ((_skill.getTargetType() == TargetType.GROUND) && _actor.isPlayer())
{
if (maybeMoveToPosition(((PlayerInstance) _actor).getCurrentSkillWorldPosition(), _actor.getMagicalAttackRange(_skill)))
@@ -323,6 +323,7 @@ public class PlayerAI extends PlayableAI
if (_skill.isBad() && (target != null))
{
// Notify the target
setCastTarget(null);
setTarget(null);
}
return;
@@ -333,6 +334,16 @@ public class PlayerAI extends PlayableAI
}
}
// Check if target has changed.
final WorldObject currentTarget = _actor.getTarget();
if ((currentTarget != target) && (currentTarget != null) && (target != null))
{
_actor.setTarget(target);
_actor.doCast(_skill, _item, _forceUse, _dontMove);
_actor.setTarget(currentTarget);
return;
}
_actor.doCast(_skill, _item, _forceUse, _dontMove);
}

View File

@@ -144,10 +144,11 @@ public class SummonAI extends PlayableAI implements Runnable
return;
}
final WorldObject target = _skill.getTarget(_actor, _skill.isBad(), _dontMove, false);
final WorldObject target = getCastTarget();
if (checkTargetLost(target))
{
setTarget(null);
setCastTarget(null);
summon.setFollowStatus(true);
return;
}