Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class FollowTask implements Runnable
- {
- private int _range = 70;
- private int _destX = 0;
- private int _destY = 0;
- public FollowTask()
- {
- }
- public FollowTask(int range)
- {
- _range = range;
- }
- @Override
- public void run()
- {
- try
- {
- if (_followTask == null)
- return;
- L2Character followTarget = _followTarget; // copy to prevent NPE
- if (followTarget == null)
- {
- if (_actor instanceof L2Summon)
- ((L2Summon) _actor).setFollowStatus(false);
- setIntention(AI_INTENTION_IDLE);
- return;
- }
- if (!_actor.isInsideRadius(followTarget, _range, true, false, false))
- {
- if (!_actor.isInsideRadius(followTarget, 3000, true, false, false))
- {
- // if the target is too far (maybe also teleported)
- if (_actor instanceof L2Summon)
- ((L2Summon) _actor).setFollowStatus(false);
- setIntention(AI_INTENTION_IDLE);
- return;
- }
- if (getIntention() == AI_INTENTION_ATTACK && !(_actor instanceof L2PcInstance) && !(_actor instanceof L2Summon))
- {
- if (followTarget.getXdestination() != _destX || followTarget.getYdestination() != _destY)
- {
- _destX = followTarget.getXdestination();
- _destY = followTarget.getYdestination();
- //if (_actor.isMoving())
- //_actor.stopMove(null);
- //moveTo(_destX+Rnd.get(-120, 120), _destY+Rnd.get(-120, 120), followTarget.getZdestination()+30);
- //Location _vector = _actor.getMyLocation().getVector(followTarget.getMyLocation());
- //, _destinyLoc;
- _actor.moveToLocation(_destX + Rnd.get(-60, 60), _destY + Rnd.get(-60, 60), followTarget.getZdestination() + _actor.getObjectCollisionHeight(), 0);
- }
- else if (followTarget.isMoving() && !_actor.isMoving())
- _actor.moveToLocation(followTarget.getXdestination() + Rnd.get(-60, 60), followTarget.getYdestination() + Rnd.get(-60, 60), followTarget.getZdestination() + _actor.getObjectCollisionHeight(), 0);
- }
- else
- {
- _destX = 0;
- _destY = 0;
- //moveToPawn(followTarget, _range);
- if (!(_actor instanceof L2PcInstance) && !(_actor instanceof L2Summon))
- _actor.moveToLocation(followTarget.getXdestination() + ((int) Rnd.get(-followTarget.getCollisionRadius() / 2, followTarget.getCollisionRadius() / 2)),
- followTarget.getYdestination() + ((int) Rnd.get(-followTarget.getCollisionRadius() / 2, followTarget.getCollisionRadius() / 2)),
- followTarget.getZdestination() + _actor.getObjectCollisionHeight(), 0);
- else
- _actor.moveToLocation(followTarget.getX(), followTarget.getY(), followTarget.getZ(), 0);
- }
- }
- }
- catch (Exception e)
- {
- _log.log(Level.WARNING, "", e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement