L2JMobius

C6 Bow animation when trying to move while hitting

G-hamsteR · 2 · 5868

Online G-hamsteR

  • Viscount
  • *****
    • Posts: 327
Hello,

The last commit caused a small issue on archers.

https://streamable.com/032cwv

Here is the fix. Now everything works perfectly :D

Code: [Select]
diff --git java/org/l2jmobius/gameserver/ai/CreatureAI.java java/org/l2jmobius/gameserver/ai/CreatureAI.java
index fca0476..3c46abe 100644
--- java/org/l2jmobius/gameserver/ai/CreatureAI.java
+++ java/org/l2jmobius/gameserver/ai/CreatureAI.java
@@ -306,23 +306,20 @@
  return;
  }
 
- if ((_actor instanceof PlayerInstance) && (_actor.isCastingNow()) && !_actor.isMoving())
- {
- // Cancel action client side by sending Server->Client packet ActionFailed to the PlayerInstance actor
- clientActionFailed();
- return;
- }
-
- // Set the Intention of this AbstractAI to AI_INTENTION_MOVE_TO
- changeIntention(AI_INTENTION_MOVE_TO, pos, null);
-
- // Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop (broadcast)
- clientStopAutoAttack();
-
- // Abort the attack of the Creature and send Server->Client ActionFailed packet
- if (_actor instanceof PlayerInstance)
+ if ((_actor.isPlayer()))
  {
  final ItemInstance rhand = ((PlayerInstance) _actor).getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
+ if ((_actor.isAttackingNow() && (rhand != null) && (rhand.getItemType() == WeaponType.BOW)) || (_actor.isCastingNow() && !_actor.isMoving()))
+ {
+ clientActionFailed();
+ return;
+ }
+
+ changeIntention(AI_INTENTION_MOVE_TO, pos, null);
+
+ // Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop (broadcast)
+ clientStopAutoAttack();
+
  if (((rhand != null) && (rhand.getItemType() == WeaponType.BOW)))
  {
  if (!_actor.isAttackingNow())
@@ -334,9 +331,14 @@
  {
  _actor.abortAttack();
  }
+
  }
  else // case Npc
  {
+ changeIntention(AI_INTENTION_MOVE_TO, pos, null);
+
+ // Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop (broadcast)
+ clientStopAutoAttack();
  _actor.abortAttack();
  }
 

Since I edited a few things and my patch may not be applicable to you, here is the full function.

Code: [Select]
/**
* Manage the Move To Intention : Stop current Attack and Launch a Move to Location Task.<br>
* <br>
* <b><u>Actions</u> : </b><br>
* <li>Stop the actor auto-attack server side AND client side by sending Server->Client packet AutoAttackStop (broadcast)</li>
* <li>Set the Intention of this AI to AI_INTENTION_MOVE_TO</li>
* <li>Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet CharMoveToLocation (broadcast)</li>
*/
@Override
protected void onIntentionMoveTo(Location pos)
{
if (getIntention() == AI_INTENTION_REST)
{
// Cancel action client side by sending Server->Client packet ActionFailed to the PlayerInstance actor
clientActionFailed();
return;
}

if ((_actor.isPlayer()))
{
final ItemInstance rhand = ((PlayerInstance) _actor).getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
if ((_actor.isAttackingNow() && (rhand != null) && (rhand.getItemType() == WeaponType.BOW)) || (_actor.isCastingNow() && !_actor.isMoving()))
{
clientActionFailed();
return;
}

changeIntention(AI_INTENTION_MOVE_TO, pos, null);

// Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop (broadcast)
clientStopAutoAttack();

if (((rhand != null) && (rhand.getItemType() == WeaponType.BOW)))
{
if (!_actor.isAttackingNow())
{
_actor.abortAttack();
}
}
else
{
_actor.abortAttack();
}

}
else // case Npc
{
changeIntention(AI_INTENTION_MOVE_TO, pos, null);

// Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop (broadcast)
clientStopAutoAttack();
_actor.abortAttack();
}

// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet CharMoveToLocation (broadcast)
moveTo(pos.getX(), pos.getY(), pos.getZ());
}