L2JMobius

Interlude Pause between Shots

dramaa · 13 · 2001

Offline dramaa

  • Baron
  • *****
    • Posts: 267
    • L2Equinox

fix: IT'S NOT RECOMMENDED TO USE, USE ONLY IF YOU DON'T SEE OTHER WAY!
gameserver/model/actor/Creature.java find this private boolean canUseRangeWeapon() and change with that (topic can be closed)

Code: [Select]
private boolean canUseRangeWeapon()
{

// Check for arrows and MP
if (isPlayer())
{
final Weapon weaponItem = getActiveWeaponItem();
if ((weaponItem == null) || !weaponItem.isBow())
{
return false;
}

if (!checkAndEquipArrows())
{
getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
sendPacket(ActionFailed.STATIC_PACKET);
sendPacket(SystemMessageId.YOU_HAVE_RUN_OUT_OF_ARROWS);
return false;
}

if (GameTimeTaskManager.getInstance().getGameTicks() >= (_disableBowAttackEndTime - 1))
{
int mpConsume = weaponItem.getMpConsume();
if ((weaponItem.getReducedMpConsume() > 0) && (Rnd.get(100) < weaponItem.getReducedMpConsumeChance()))
{
mpConsume = weaponItem.getReducedMpConsume();
}
mpConsume = (int) calcStat(Stat.BOW_MP_CONSUME_RATE, mpConsume, null, null);
if (_status.getCurrentMp() < mpConsume)
{
ThreadPool.schedule(new NotifyAITask(this, CtrlEvent.EVT_READY_TO_ACT), 1000);
sendPacket(SystemMessageId.NOT_ENOUGH_MP);
sendPacket(ActionFailed.STATIC_PACKET);
return false;
}

if (mpConsume > 0)
{
_status.reduceMp(mpConsume);
}

final int gameTicks = GameTimeTaskManager.getInstance().getGameTicks();
_disableBowAttackEndTime = (5 * GameTimeTaskManager.TICKS_PER_SECOND) + gameTicks;
}
else
{
return false;
}
}
else if (isNpc())
{
if (_disableBowAttackEndTime > GameTimeTaskManager.getInstance().getGameTicks())
{
return false;
}
}
return true;
}



Online Skache

  • Distinguished King
  • *****
    • Posts: 825
    • l2skale.com

Online Mobius

  • Distinguished King
  • *****
    • Posts: 19655
gameserver/model/actor/Creature.java find this private boolean canUseRangeWeapon() and change with that (topic can be closed)

Code: [Select]
private boolean canUseRangeWeapon()
{

// Check for arrows and MP
if (isPlayer())
{
final Weapon weaponItem = getActiveWeaponItem();
if ((weaponItem == null) || !weaponItem.isBow())
{
return false;
}

if (!checkAndEquipArrows())
{
getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
sendPacket(ActionFailed.STATIC_PACKET);
sendPacket(SystemMessageId.YOU_HAVE_RUN_OUT_OF_ARROWS);
return false;
}

if (GameTimeTaskManager.getInstance().getGameTicks() >= (_disableBowAttackEndTime - 1))
{
int mpConsume = weaponItem.getMpConsume();
if ((weaponItem.getReducedMpConsume() > 0) && (Rnd.get(100) < weaponItem.getReducedMpConsumeChance()))
{
mpConsume = weaponItem.getReducedMpConsume();
}
mpConsume = (int) calcStat(Stat.BOW_MP_CONSUME_RATE, mpConsume, null, null);
if (_status.getCurrentMp() < mpConsume)
{
ThreadPool.schedule(new NotifyAITask(this, CtrlEvent.EVT_READY_TO_ACT), 1000);
sendPacket(SystemMessageId.NOT_ENOUGH_MP);
sendPacket(ActionFailed.STATIC_PACKET);
return false;
}

if (mpConsume > 0)
{
_status.reduceMp(mpConsume);
}

final int gameTicks = GameTimeTaskManager.getInstance().getGameTicks();
_disableBowAttackEndTime = (5 * GameTimeTaskManager.TICKS_PER_SECOND) + gameTicks;
}
else
{
return false;
}
}
else if (isNpc())
{
if (_disableBowAttackEndTime > GameTimeTaskManager.getInstance().getGameTicks())
{
return false;
}
}
return true;
}

So your solution is this?
Code: (diff) [Select]
Index: java/org/l2jmobius/gameserver/model/actor/Creature.java
===================================================================
--- java/org/l2jmobius/gameserver/model/actor/Creature.java (revision 17493)
+++ java/org/l2jmobius/gameserver/model/actor/Creature.java (working copy)
@@ -927,8 +927,8 @@
  else
  {
  // Cancel the action because the bow can't be re-use at this moment
- ThreadPool.schedule(new NotifyAITask(this, Action.READY_TO_ACT), 1000);
- sendPacket(ActionFailed.STATIC_PACKET);
+ // ThreadPool.schedule(new NotifyAITask(this, CtrlEvent.EVT_READY_TO_ACT), 1000);
+ // sendPacket(ActionFailed.STATIC_PACKET);
  return false;
  }
  }


Offline dramaa

  • Baron
  • *****
    • Posts: 267
    • L2Equinox
maybe not a huge changes, but since its not getting bugged anymore, these are the changes

Code: [Select]
- if (_disableBowAttackEndTime <= GameTimeTaskManager.getInstance().getGameTicks())
+ if (GameTimeTaskManager.getInstance().getGameTicks() >= (_disableBowAttackEndTime - 1))

i know it's not a big deal but this "1" changed a lot of things  ;D


Online Mobius

  • Distinguished King
  • *****
    • Posts: 19655
maybe not a huge changes, but since its not getting bugged anymore, these are the changes

Code: [Select]
- if (_disableBowAttackEndTime <= GameTimeTaskManager.getInstance().getGameTicks())
+ if (GameTimeTaskManager.getInstance().getGameTicks() >= (_disableBowAttackEndTime - 1))

i know it's not a big deal but this "1" changed a lot of things  ;D
_disableBowAttackEndTime - 1
That is wrong? End time needs at least 100 more ms to end.


Offline dramaa

  • Baron
  • *****
    • Posts: 267
    • L2Equinox
i dont know mobius this - 1 fixed problem in my case, it's not stopping anymore, when i used debugs to detect where was the problem, this part was coming up


Online Mobius

  • Distinguished King
  • *****
    • Posts: 19655

Offline dramaa

  • Baron
  • *****
    • Posts: 267
    • L2Equinox
And the removal of READY_TO_ACT?

yes, i am just curious, why are you asking so many questions?  i will explain something, i am not very good in java, i can read bcs of i was learning but not very strong in coding, but i am using AI pretty well, if you are getting there, yes i used AI to get the problem and fix it. and when i mentioned you in my comment i did not meant to use this fix, just told you like that, that there is a problem, nothing else   :)


Online Mobius

  • Distinguished King
  • *****
    • Posts: 19655
Because I want to find what the actual issue is and not just "fix" it.


Offline klz

  • Heir
  • **
    • Posts: 19
yes, i am just curious, why are you asking so many questions?  i will explain something, i am not very good in java, i can read bcs of i was learning but not very strong in coding, but i am using AI pretty well, if you are getting there, yes i used AI to get the problem and fix it. and when i mentioned you in my comment i did not meant to use this fix, just told you like that, that there is a problem, nothing else   :)

Knowledge comes from questioning. It's okay to "fix things" just as long as you understand why and how you are fixing them.
Of course, for me, the fix is always welcomed, and i thank you for that, but it's better to try to reach the root cause of the problem than just patching things out.

Thank you btw!


Online Mobius

  • Distinguished King
  • *****
    • Posts: 19655
Knowledge comes from questioning. It's okay to "fix things" just as long as you understand why and how you are fixing them.
Of course, for me, the fix is always welcomed, and i thank you for that, but it's better to try to reach the root cause of the problem than just patching things out.

Thank you btw!
It is not always welcomed.
A fix not knowing what it does, can and will cause other issues.
Any fix shared for any project, will have to be checked for it's validity on 35 more projects.


Offline klz

  • Heir
  • **
    • Posts: 19
It is not always welcomed.
A fix not knowing what it does, can and will cause other issues.
Any fix shared for any project, will have to be checked for it's validity on 35 more projects.

That's why i prepended the "for me". I do understand that for stability reasons not every fix should be welcomed. But at least the fix starts the drilldown to the root cause.


Offline dramaa

  • Baron
  • *****
    • Posts: 267
    • L2Equinox
It is not always welcomed.
A fix not knowing what it does, can and will cause other issues.
Any fix shared for any project, will have to be checked for it's validity on 35 more projects.

my apologies, i will update my post  accordingly