For some reason attack speed didn't change

Discussion in 'Support' started by Lopaskurwa, Mar 29, 2018.

  1. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    445
    Likes Received:
    10
    Best Answers:
    2
  2. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    445
    Likes Received:
    10
    Best Answers:
    2
  3. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    445
    Likes Received:
    10
    Best Answers:
    2
  4. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    445
    Likes Received:
    10
    Best Answers:
    2
  5. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    445
    Likes Received:
    10
    Best Answers:
    2
  6. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    445
    Likes Received:
    10
    Best Answers:
    2
  7. Madzix

    Madzix Member

    Joined:
    Sep 8, 2016
    Messages:
    41
    Likes Received:
    54
    Best Answers:
    9
    Player.cpp:
    Change:
    Code (Text):
    1. void Player::doAttacking(uint32_t)
    2. {
    3.     if (lastAttack == 0) {
    4.         lastAttack = OTSYS_TIME() - getAttackSpeed() - 1;
    5.     }
    6.  
    7.     if (hasCondition(CONDITION_PACIFIED)) {
    8.         return;
    9.     }
    10.  
    11.     if ((OTSYS_TIME() - lastAttack) >= getAttackSpeed()) {
    12.         bool result = false;
    13.  
    14.         Item* tool = getWeapon();
    15.         const Weapon* weapon = g_weapons->getWeapon(tool);
    16.         if (weapon) {
    17.             if (!weapon->interruptSwing()) {
    18.                 result = weapon->useWeapon(this, tool, attackedCreature);
    19.             } else if (!canDoAction()) {
    20.                 uint32_t delay = getNextActionTime();
    21.                 SchedulerTask* task = createSchedulerTask(delay, std::bind(&Game::checkCreatureAttack,
    22.                                       &g_game, getID()));
    23.                 setNextActionTask(task);
    24.             } else {
    25.                 result = weapon->useWeapon(this, tool, attackedCreature);
    26.             }
    27.         } else {
    28.             result = Weapon::useFist(this, attackedCreature);
    29.         }
    30.  
    31.         if (result) {
    32.             lastAttack = OTSYS_TIME();
    33.         }
    34.     }
    35. }
    To:
    Code (Text):
    1. void Player::doAttacking(uint32_t)
    2. {
    3.     if (lastAttack == 0) {
    4.         lastAttack = OTSYS_TIME() - getAttackSpeed() - 1;
    5.     }
    6.  
    7.     if (hasCondition(CONDITION_PACIFIED)) {
    8.         return;
    9.     }
    10.  
    11.     if ((OTSYS_TIME() - lastAttack) >= getAttackSpeed()) {
    12.         bool result = false;
    13.  
    14.         Item* tool = getWeapon();
    15.         const Weapon* weapon = g_weapons->getWeapon(tool);
    16.         if (weapon) {
    17.             if (!weapon->interruptSwing()) {
    18.                 result = weapon->useWeapon(this, tool, attackedCreature);
    19.             } else if (!canDoAction()) {
    20.                 uint32_t delay = getNextActionTime();
    21.                 SchedulerTask* task = createSchedulerTask(delay, std::bind(&Game::checkCreatureAttack,
    22.                                       &g_game, getID()));
    23.                 setNextActionTask(task);
    24.             } else {
    25.                 result = weapon->useWeapon(this, tool, attackedCreature);
    26.             }
    27.         } else {
    28.             result = Weapon::useFist(this, attackedCreature);
    29.         }
    30.  
    31.         g_scheduler.addEvent(createSchedulerTask(std::max<uint32_t>(SCHEDULER_MINTICKS, getAttackSpeed()), std::bind(&Game::checkCreatureAttack, &g_game, getID())));
    32.         if (result) {
    33.             lastAttack = OTSYS_TIME();
    34.         }
    35.     }
    36. }
    With this your attack speed should work without making creatures thinks too much(xD).

    @Lopaskurwa
    How the hell scheduling next attack after the previous might not work when you stand? Devs even added this in 1.3 for custom servers with "custom attack speed"
     
    Last edited: Apr 19, 2018
    Lopaskurwa likes this.
  8. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    445
    Likes Received:
    10
    Best Answers:
    2
    Thanks for answer but this script doesn't change exactly what i meant. So now it attacks faster if monster moves :D But i need the same attack speed when i stand, run, or monster run/stand. Because now i only attack fast if i run around or monster run around :D
     
  9. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    445
    Likes Received:
    10
    Best Answers:
    2
  10. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    445
    Likes Received:
    10
    Best Answers:
    2
  11. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    445
    Likes Received:
    10
    Best Answers:
    2
  12. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    445
    Likes Received:
    10
    Best Answers:
    2
  13. jestem pro

    jestem pro That is the question

    Joined:
    Apr 20, 2013
    Messages:
    529
    Likes Received:
    57
    Best Answers:
    8
    Take the fucking original function from the original 8.6 and exchange it.
     
  14. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    445
    Likes Received:
    10
    Best Answers:
    2
    Its fucking original function.
     
  15. jestem pro

    jestem pro That is the question

    Joined:
    Apr 20, 2013
    Messages:
    529
    Likes Received:
    57
    Best Answers:
    8
    Normally it should work, may you skiped something or take the original 8.6 and have fun.

    God knows what and how they did that.
     
  16. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    445
    Likes Received:
    10
    Best Answers:
    2
    Maybe creator of this downgraded tfs version did something i have no idea. I think i cant use original 1.2 player.cpp source file because mine is downgraded.
     
  17. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    445
    Likes Received:
    10
    Best Answers:
    2
  18. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    445
    Likes Received:
    10
    Best Answers:
    2
  19. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    445
    Likes Received:
    10
    Best Answers:
    2
  20. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    445
    Likes Received:
    10
    Best Answers:
    2

Share This Page

Loading...