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;
}

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;
}

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;
}

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;
}

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;
}

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;
}

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;
}

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;
}

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;
}

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;
}

View File

@ -72,7 +72,7 @@ abstract class AbstractAI implements Ctrl
/** Different targets this AI maintains */
private WorldObject _target;
private Creature _castTarget;
private WorldObject _castTarget;
private Creature _attackTarget;
private Creature _followTarget;
@ -765,15 +765,12 @@ abstract class AbstractAI implements Ctrl
_target = target;
}
protected synchronized void setCastTarget(Creature target)
protected synchronized void setCastTarget(WorldObject target)
{
_castTarget = target;
}
/**
* @return the current cast target.
*/
public synchronized Creature getCastTarget()
public synchronized WorldObject getCastTarget()
{
return _castTarget;
}
@ -783,9 +780,6 @@ abstract class AbstractAI implements Ctrl
_attackTarget = target;
}
/**
* Return current attack target.
*/
@Override
public synchronized Creature getAttackTarget()
{

View File

@ -278,7 +278,7 @@ public class CreatureAI extends AbstractAI
}
// Set the AI cast target
setCastTarget((Creature) target);
setCastTarget(target);
// Stop actions client-side to cast the skill
if (skill.getHitTime() > 50)

View File

@ -196,9 +196,8 @@ public class PlayerAI extends CreatureAI
private void thinkCast()
{
final Creature target = getCastTarget();
final WorldObject target = getCastTarget();
final Skill skill = getSkill();
// if (Config.DEBUG) LOGGER.warning("PlayerAI: thinkCast -> Start");
if (checkTargetLost(target))
{
if (skill.isOffensive() && (getAttackTarget() != null))
@ -219,28 +218,17 @@ public class PlayerAI extends CreatureAI
clientStopMoving(null);
}
final WorldObject oldTarget = _actor.getTarget();
if (oldTarget != null)
// Check if target has changed.
final WorldObject currentTarget = _actor.getTarget();
if ((currentTarget != target) && (currentTarget != null) && (target != null))
{
// Replace the current target by the cast target
if ((target != null) && (oldTarget != target))
{
_actor.setTarget(getCastTarget());
}
// Launch the Cast of the skill
_accessor.doCast(getSkill());
// Restore the initial target
if ((target != null) && (oldTarget != target))
{
_actor.setTarget(oldTarget);
}
}
else
{
_accessor.doCast(skill);
_actor.setTarget(target);
_actor.doCast(skill);
_actor.setTarget(currentTarget);
return;
}
_actor.doCast(skill);
}
private void thinkPickUp()

View File

@ -85,7 +85,7 @@ public class SummonAI extends CreatureAI
private void thinkCast()
{
final Creature target = getCastTarget();
final WorldObject target = getCastTarget();
if (checkTargetLost(target))
{
setCastTarget(null);

View File

@ -72,7 +72,7 @@ abstract class AbstractAI implements Ctrl
/** Different targets this AI maintains */
private WorldObject _target;
private Creature _castTarget;
private WorldObject _castTarget;
private Creature _attackTarget;
private Creature _followTarget;
@ -765,15 +765,12 @@ abstract class AbstractAI implements Ctrl
_target = target;
}
protected synchronized void setCastTarget(Creature target)
protected synchronized void setCastTarget(WorldObject target)
{
_castTarget = target;
}
/**
* @return the current cast target.
*/
public synchronized Creature getCastTarget()
public synchronized WorldObject getCastTarget()
{
return _castTarget;
}
@ -783,9 +780,6 @@ abstract class AbstractAI implements Ctrl
_attackTarget = target;
}
/**
* Return current attack target.
*/
@Override
public synchronized Creature getAttackTarget()
{

View File

@ -278,7 +278,7 @@ public class CreatureAI extends AbstractAI
}
// Set the AI cast target
setCastTarget((Creature) target);
setCastTarget(target);
// Stop actions client-side to cast the skill
if (skill.getHitTime() > 50)

View File

@ -196,9 +196,8 @@ public class PlayerAI extends CreatureAI
private void thinkCast()
{
final Creature target = getCastTarget();
final WorldObject target = getCastTarget();
final Skill skill = getSkill();
// if (Config.DEBUG) LOGGER.warning("PlayerAI: thinkCast -> Start");
if (checkTargetLost(target))
{
if (skill.isOffensive() && (getAttackTarget() != null))
@ -219,28 +218,17 @@ public class PlayerAI extends CreatureAI
clientStopMoving(null);
}
final WorldObject oldTarget = _actor.getTarget();
if (oldTarget != null)
// Check if target has changed.
final WorldObject currentTarget = _actor.getTarget();
if ((currentTarget != target) && (currentTarget != null) && (target != null))
{
// Replace the current target by the cast target
if ((target != null) && (oldTarget != target))
{
_actor.setTarget(getCastTarget());
}
// Launch the Cast of the skill
_accessor.doCast(getSkill());
// Restore the initial target
if ((target != null) && (oldTarget != target))
{
_actor.setTarget(oldTarget);
}
}
else
{
_accessor.doCast(skill);
_actor.setTarget(target);
_actor.doCast(skill);
_actor.setTarget(currentTarget);
return;
}
_actor.doCast(skill);
}
private void thinkPickUp()

View File

@ -85,7 +85,7 @@ public class SummonAI extends CreatureAI
private void thinkCast()
{
final Creature target = getCastTarget();
final WorldObject target = getCastTarget();
if (checkTargetLost(target))
{
setCastTarget(null);

View File

@ -117,32 +117,7 @@ public abstract class AbstractAI implements Ctrl
return _intention;
}
protected void setCastTarget(Creature target)
{
_castTarget = target;
}
/**
* @return the current cast target.
*/
public Creature getCastTarget()
{
return _castTarget;
}
protected void setAttackTarget(Creature target)
{
_attackTarget = target;
}
/**
* @return current attack target.
*/
@Override
public Creature getAttackTarget()
{
return _attackTarget;
}
/**
* Set the Intention of this AbstractAI.<br>
@ -834,6 +809,27 @@ public abstract class AbstractAI implements Ctrl
_target = target;
}
protected void setCastTarget(Creature target)
{
_castTarget = target;
}
public Creature getCastTarget()
{
return _castTarget;
}
protected void setAttackTarget(Creature target)
{
_attackTarget = target;
}
@Override
public Creature getAttackTarget()
{
return _attackTarget;
}
/**
* Stop all Ai tasks and futures.
*/

View File

@ -298,6 +298,16 @@ public class PlayerAI extends PlayableAI
clientStopMoving(null);
}
// Check if target has changed.
final WorldObject currentTarget = _actor.getTarget();
if ((currentTarget != target) && (currentTarget != null) && (target != null))
{
_actor.setTarget(target);
_actor.doCast(_skill);
_actor.setTarget(currentTarget);
return;
}
_actor.doCast(_skill);
}

View File

@ -117,32 +117,7 @@ public abstract class AbstractAI implements Ctrl
return _intention;
}
protected void setCastTarget(Creature target)
{
_castTarget = target;
}
/**
* @return the current cast target.
*/
public Creature getCastTarget()
{
return _castTarget;
}
protected void setAttackTarget(Creature target)
{
_attackTarget = target;
}
/**
* @return current attack target.
*/
@Override
public Creature getAttackTarget()
{
return _attackTarget;
}
/**
* Set the Intention of this AbstractAI.<br>
@ -834,6 +809,27 @@ public abstract class AbstractAI implements Ctrl
_target = target;
}
protected void setCastTarget(Creature target)
{
_castTarget = target;
}
public Creature getCastTarget()
{
return _castTarget;
}
protected void setAttackTarget(Creature target)
{
_attackTarget = target;
}
@Override
public Creature getAttackTarget()
{
return _attackTarget;
}
/**
* Stop all Ai tasks and futures.
*/

View File

@ -298,6 +298,16 @@ public class PlayerAI extends PlayableAI
clientStopMoving(null);
}
// Check if target has changed.
final WorldObject currentTarget = _actor.getTarget();
if ((currentTarget != target) && (currentTarget != null) && (target != null))
{
_actor.setTarget(target);
_actor.doCast(_skill);
_actor.setTarget(currentTarget);
return;
}
_actor.doCast(_skill);
}

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;
}

Some files were not shown because too many files have changed in this diff Show More