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) if (partyBuffSkill != null)
{ {
final WorldObject target = partyBuffSkill.getTarget(effector, effected, false, false, false); final WorldObject target = partyBuffSkill.getTarget(effector, effected, false, false, false);
if ((target != null) && target.isCreature()) if ((target != null) && target.isCreature())
{ {
SkillCaster.triggerCast(effector, (Creature) target, partyBuffSkill); SkillCaster.triggerCast(effector, (Creature) target, partyBuffSkill);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -117,32 +117,7 @@ public abstract class AbstractAI implements Ctrl
return _intention; 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> * Set the Intention of this AbstractAI.<br>
@@ -834,6 +809,27 @@ public abstract class AbstractAI implements Ctrl
_target = target; _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. * Stop all Ai tasks and futures.
*/ */

View File

@@ -298,6 +298,16 @@ public class PlayerAI extends PlayableAI
clientStopMoving(null); 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); _actor.doCast(_skill);
} }

View File

@@ -117,32 +117,7 @@ public abstract class AbstractAI implements Ctrl
return _intention; 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> * Set the Intention of this AbstractAI.<br>
@@ -834,6 +809,27 @@ public abstract class AbstractAI implements Ctrl
_target = target; _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. * Stop all Ai tasks and futures.
*/ */

View File

@@ -298,6 +298,16 @@ public class PlayerAI extends PlayableAI
clientStopMoving(null); 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); _actor.doCast(_skill);
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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