-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix attack scheduler #1305
Fix attack scheduler #1305
Conversation
Hello @ranisalt, This change don't do effect in distance weapon. |
@brunominervino yes, distance attacks are treated differently (you can see the I will try my best. |
@ranisalt hmm, I understand, first thank you. |
@@ -3383,15 +3383,22 @@ void Player::doAttacking(uint32_t) | |||
Item* tool = getWeapon(); | |||
const Weapon* weapon = g_weapons->getWeapon(tool); | |||
if (weapon) { | |||
uint32_t delay; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (weapon->interruptSwing() && !canDoAction()) {
delay = getNextActionTime();
} else {
result = weapon->useWeapon(this, tool, attackedCreature);
delay = getAttackSpeed();
}
SchedulerTask* task = createSchedulerTask(delay, std::bind(&Game::checkCreatureAttack,
&g_game, getID()));
setNextActionTask(task);
Where this change affect distance weapons too :)
Thanks for pointing out, @brunominervino. I have fixed the code and it now works with distance weapons too :D just remember the MINIMUM attack speed is 100 ms, since it is hardcoded and setting it lower may break your server because too many actions will happen in a short amount of time. I have also squashed the commits. |
94426c0
to
efba09d
Compare
@ranisalt now is working 👍 :) |
How's that going? |
if character try to attack while running speed attack does not work |
@kanohn this is intended behavior. One can not swing a weapon or throw a spear while running away, not even in Tibia. Replace L3392 |
efba09d
to
d91ac32
Compare
ranisalt, I have added this commit to my server and after that I have noticed that sometimes when you are attacking a creature, it will be impossible to push it. I'm almost certain that this change is what causes it, are you aware of any fix for this? Also, it seems to be when I am fist fightning that it's possible for me to push the creature again I also did this change "Replace L3392 delay = getNextActionTime(); with delay = getAttackSpeed(); and it may work as you want." |
also attack speed behaves weirdly, both with this when you move, it puts a delay on the attack but it only happens sometimes, my attackspeed is 300ms. i'll give you a demonstration: http://gfycat.com/RashClearcutGannet as you can see when I move around I attack much slower |
That's because your attack speed is so abusive it breaks. The result = weapon->useWeapon(this, tool, attackedCreature);
SchedulerTask* task = createSchedulerTask(getAttackSpeed(), std::bind(&Game::checkCreatureAttack, &g_game, getID()));
setNextActionTask(task); That way the attack only cares for the last attack time, not if you are moving or whatever. |
your code ignored the fist fighting |
I have the same problem as grisig https://gfycat.com/RashClearcutGannet @ranisalt
It does not work! |
@zydent This is not a bug in his change, distance weapons have interrupt swing (even in real tibia), it stops your attack when you move. If you want to remove this you can change this line: The only problem with this pull request is it * completely ignored fist weapon. |
The PR is broken because I messed with the branch and I will reopen it. |
@Mkalo I made the change "return false;" The speed stop when I move. https://gfycat.com/ShorttermOptimisticFlamingo |
@zydent Then remove those lines: This may affect something else. |
@Mkalo Any action makes the fast attack stop, Of me emotion I hadn't noticed this big mistake. https://gfycat.com/SpicyQuarrelsomeIcelandichorse |
@zydent Alright just delete Also here: You can undo the last change about those 2 lines before with this change. If anything goes wrong please create a thread in the forum and tag me as this is just for your custom case not really a bug. |
Hi @Mkalo can you help me with issue that ranged weapons stop attack speed during movement and using runes on this distro https://github.com/TwistedScorpio/OTHire ? Thank you ! |
I have stumbled across this problem when I was trying to use an attack speed that was not a multiple of 1000. Apparently the server only checks if there is a new action every 1000 ms, but this limits attack speed to multiples of this time frame, as the server won't check if there is a new attack to calculate in between time frames.
This fix changes it by adding a new SchedulerTask when the attack is in the middle of a time frame. I haven't had time and resources to check if this is a heavy change and if this works properly 100% of the time, but I hope @marksamman can have a look and say somethind 😀