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:
    243
    Likes Received:
    5
    Best Answers:
    2
  2. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    243
    Likes Received:
    5
    Best Answers:
    2
  3. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    243
    Likes Received:
    5
    Best Answers:
    2
  4. Lopaskurwa

    Lopaskurwa Member

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

    Lopaskurwa Member

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

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    243
    Likes Received:
    5
    Best Answers:
    2
  7. Madzix

    Madzix Member

    Joined:
    Sep 8, 2016
    Messages:
    26
    Likes Received:
    28
    Best Answers:
    6
    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 at 3:37 PM
    Lopaskurwa likes this.
  8. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    243
    Likes Received:
    5
    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
     

Share This Page

Loading...