/** * Manage the Cast Intention : Stop current Attack, Init the AI in order to cast and Launch Think * Event.<br> * <br> * <B><U> Actions</U> : </B><br> * <br> * <li>Set the AI cast target * <li>Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop * (broadcast) * <li>Cancel action client side by sending Server->Client packet ActionFailed to the L2Player * actor * <li>Set the AI skill used by INTENTION_CAST * <li>Set the Intention of this AI to AI_INTENTION_CAST * <li>Launch the Think Event <br> * <br> */ @Override protected void onIntentionCast(SkillUsageRequest request) { final L2Skill skill = request.getSkill(); if (getIntention() == AI_INTENTION_REST && skill.isMagic()) { clientActionFailed(); return; } // Stop actions client-side to cast the skill if (skill.getHitTime() > 50) { // Abort the attack of the L2Character and send Server->Client ActionFailed packet _actor.abortAttack(); // Cancel action client side by sending Server->Client packet ActionFailed to the L2Player // actor // no need for second ActionFailed packet, abortAttack() already sent it // clientActionFailed(); } final L2Object target = request.getSkill().getFirstOfTargetList(_actor); // Change the Intention of this AbstractAI to AI_INTENTION_CAST changeIntention(AI_INTENTION_CAST, request, target); final Point3D p = request.getSkillWorldPosition(); if (p != null) { // normally magicskilluse packet turns char client side but for these skills, it doesn't (even // with correct target) _actor.setHeading( Util.calculateHeadingFrom(_actor.getX(), _actor.getY(), p.getX(), p.getY())); _actor.broadcastPacket(new ValidateLocation(_actor)); } // Launch the Think Event notifyEvent(CtrlEvent.EVT_THINK, null); }