Skip to content
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

attack speed extra delay BUG #103

Open
LuisPro opened this issue Sep 30, 2016 · 17 comments
Open

attack speed extra delay BUG #103

LuisPro opened this issue Sep 30, 2016 · 17 comments
Labels
Milestone

Comments

@LuisPro
Copy link
Contributor

LuisPro commented Sep 30, 2016

atk speed = 2 sec
ofensive exhaust = 2 sec
distance_weapon_interrupt_swing = true
like on rl tibia

how its works now:
auto attack on 0sec0ms then i shot sd on 0sec300ms so now i broke auto attack speed and next auto attack should go on 2sec300ms but its go on ~2sec900ms (more than half second later)

how its should work:
testes on rl files:
auto attack on 6sec12frame, next auto attack on 8sec12frame, so next auto attack should be on 10sec12frame but i shot rune on 9sec20frame and i broke auto attack speed, and next bolt go exacly on 11sec20frame

30frame = 1000ms = 1 second

@peonso peonso added the bug label Sep 30, 2016
@peonso peonso added this to the Version 0.0.3 milestone Sep 30, 2016
@peonso
Copy link
Collaborator

peonso commented Oct 22, 2016

I tried to look on it some days ago, couldnt find a solution. I think it has to do with creature onThink, as if it just check for a new attack on onThink, and when you mess with the interval between attacks with any action you fuck up attack speed, because there is no trigger for a next attack on 2 seconds, it will need to wait for onThink event. I'm not sure though, just a conjecture.

@LuisPro
Copy link
Contributor Author

LuisPro commented Oct 22, 2016

i still think its somewhere here:
https://github.com/TwistedScorpio/OTHire/blob/master/source/player.cpp#L3713

i was think its becouse of OTSYS_TIME is not count miliseconds, i got similar problem here:
https://otland.net/threads/othire-use-on-yourself-use-on-target.245154/page-2#post-2385392
in manafluid case, next fluid was drinked randomly 0.01 second to 0.99 second, it depend how much time left to new second (in os.time)

and in our atk delay case its ALWAYS around 666ms delay! // edit. not always! read new posts!
never 100ms.. never 200ms, never 300ms and never 900ms...
always 600-733 ms delay
thats why now i think its not OTSYS_TIME related.

also its happend only when we use runes with offensive exhaust like sd, explo, magic wall, fire bomb.
its not happend when we use: uh, destroy field, exura vita, mana fluid.

@peonso
Copy link
Collaborator

peonso commented Oct 31, 2016

There is no relation at all with this other Lua issue you had, that was more related to proper use of Lua, OTSYS_TIME is not related to that in any way. Try to check when doAttacking is triggered, I'm nearby sure the actual issue is that it's triggered in an interval that is not related with attack speed once there is a interrupt swing action. As if what is happening is something along this lines:

0.0 sec -> whateverTriggerDoAttacking -> attack
1.0 sec -> whateverTriggerDoAttacking -> no
2.0 sec -> whateverTriggerDoAttacking -> attack
2.3 sec -> sd, interrupt attack, next one should be 4.3 sec
3.0 sec -> whateverTriggerDoAttacking -> no
4.0 sec -> whateverTriggerDoAttacking -> no
5.0 sec -> whateverTriggerDoAttacking -> attack

As if it never triggered in the proper time. Not that the interval is 1 sec, just to give the idea.

@LuisPro
Copy link
Contributor Author

LuisPro commented Nov 1, 2016

https://github.com/TwistedScorpio/OTHire/blob/master/source/player.cpp#L3743

if(!hasCondition(CONDITION_EXHAUST_COMBAT)){ result = weapon->useWeapon(this, tool, attackedCreature); }

Its clear say if not combat exhausted (2 sec in config) use weapon.
And this shit is always do after ~2.66 sec.

Weird things happend when we change combat exhaust for example from 2 sec to 1.7, Its not lower our delay to 2.33. it will not change anything.
Its working good, only when we decrese combat exhaust by ~0.6sec (our delay value).
So when we set combat exhause in config to ~1.4sec. when we shot auto atack after sd after ~2 sec.
But then out combat exhaust is focked up.

Its working like: if no combat exhaust then use weapon.
How about make it to ignore combat exhaust?
Something like; if ofensive rune/spell was used, sleep 2 sec. then use weapon? idk random ideas.

@up
whateverTriggerDoAttacking, attackspeed trigger do attacking
combat exhaust trigger delay if interrupt_swing = true
its simply do if not combat exhaust then use weapons
i dont know from where is that extra delay ;s

@LaloHao
Copy link

LaloHao commented Nov 2, 2016

I think we can blame Spell::postCastSpell, it uses player->addCombatExhaust, adding the exhaust on any combat weapon.

Maybe create a different exhaust condition for magic spells?

@peonso peonso modified the milestones: Version 1.0, Version 0.0.3 Nov 6, 2016
@LaloHao LaloHao mentioned this issue Nov 25, 2016
11 tasks
@LuisPro
Copy link
Contributor Author

LuisPro commented Jan 23, 2017

There is not even single distro with this working...
All developers dont give shit about this. Who care if idiots play anyway.
I had same situation before, with other critical bug.
Checked all distros everywhere was that bug "monsters casting spells through walls".
Ekhm...
Everyone got "distance_weapon_interrupt_swing = false" hardcoded to avoid this problem.
And these distros are called "Real tibia ~7.7", "Cipsoft tibia" bla bla bla
Someone ever play on ots with this stuff working properly? Let me know i want to check!

Hmm, i back to theory about its OTSYS_TIME() related. Becouse when i turn off interrupt. Then after shot sd, bolt got random delay (with interrupt off!) sometimes just 33ms and sometimes 966ms (depend how many time left to new second).
examples with interrupt off:
bolt > 2 sec > bolt
bolt > 1.9 sec > sd > 0.9 sec > bolt
bolt > 0.1 sec > sd > 2 sec > bolt

Then. I turn interrupt ON again and added print time in console every bolt (to more easy testing purposes, before i made video and do that on miliseconds in video editor).
Then i just do observation.
Results are WTF:
2017-01-24 00_38_00-d__pobrane firefox_othire-master_server exe
Why when i add simple 'print attack time' this shit changed attack speed to 3 sec mostly (i dont touch anything more)(without shooting sd's) and just sometimes 2 sec.
Can someone test it also to confirm it? wth is going on?

Btw.
No diference, interrupt on or off, everything is wrong...

Double checked:
2017-01-24 01_04_12-d__pobrane firefox_othire-master_server exe

I again checked delays on video..
Sometimes are 200ms, sometimes 500 ms. depend on whitch moment i shoot sd beetween bolts.
Before it was always ~666ms becouse i always shoot sd ~100ms before next bolt.
So its next argument that it is related to otsys time.

@LuisPro
Copy link
Contributor Author

LuisPro commented Feb 10, 2017

@diegorodriguesvieira
Copy link
Contributor

@LuisPro
Copy link
Contributor Author

LuisPro commented Feb 10, 2017

nothing change, its just enchantment for fast attack ots's.
still random delay (33ms-966ms)
when i test it on rl files, in~99% delay never happen (it was perfect 2 sec to next auto attack after shot sd) and in ~1% there was 1 frame (33ms) delay

@diegorodriguesvieira
Copy link
Contributor

void Player::doAttacking(uint32_t interval)
{
    if(lastAttack == 0){
        // - 1 to compensate for timer resolution etc.
        lastAttack = OTSYS_TIME() - getAttackSpeed() - 1;
    }
 
    // Can't attack while pacified
    if(hasCondition(CONDITION_PACIFIED))
    {
        return;
    }
 
    if((OTSYS_TIME() - lastAttack) >= getAttackSpeed() ){
        Item* tool = getWeapon();
        bool result = false;
        const Weapon* weapon = g_weapons->getWeapon(tool);
        uint32_t delay = getAttackSpeed();
 
        if(weapon){
            if(!weapon->interruptSwing()){
                result = weapon->useWeapon(this, tool, attackedCreature);
            }
            else if(!canDoAction()){
                delay = getNextActionTime();
            }
            else {
                // If the player is not exhausted OR if the player's weapon
                // does not have hasExhaust, use the weapon.
                if(!hasCondition(CONDITION_EXHAUST_COMBAT))
                {
                    result = weapon->useWeapon(this, tool, attackedCreature);
                }
            }
        }
        else{
            result = Weapon::useFist(this, attackedCreature);
        }
 
        SchedulerTask* task = createSchedulerTask(50, boost::bind(&Game::checkCreatureAttack,
                                                    &g_game, getID()));
                                                    setNextActionTask(task);
 
        if(result){
            lastAttack = OTSYS_TIME();
        }
    }
}

@LuisPro this works?

@LuisPro
Copy link
Contributor Author

LuisPro commented Feb 15, 2017

@diegorodriguesvieira
yes
looks rly nice, good job, works great, like on rl tibia
mostly there is no delay or 33 ms (1 frame) delay like on rl tibia.
sometimes 66 ms (2 frame) delay.
and rare max delay i observed was 99 ms (3 frames) what is preety acceptable i think

@diegorodriguesvieira
Copy link
Contributor

@peonso
I'll make a pull request later.
thanks!

@diegorodriguesvieira
Copy link
Contributor

@peonso see here, otland/forgottenserver#2109

@peonso peonso closed this as completed in 1dc53ad Feb 17, 2017
@diegorodriguesvieira
Copy link
Contributor

@peonso peonso reopened this Sep 3, 2017
@peonso
Copy link
Collaborator

peonso commented Sep 3, 2017

#160

@peonso
Copy link
Collaborator

peonso commented Oct 17, 2017

Just updating the issue to say it's totally what I said earlier, since attacks are triggered on onThink event, things won't be correctly synchronized. onThink event will happens always each second despite some other event that should need it to resync at a different time frame.

@Roniox12
Copy link

Good Morning,

Dear @peonso,

Can you convert this fix otland/forgottenserver#2109 into OTHire? There are some difference e.g in configmanager.cpp there are all on "m_confInteger" not "boolean" and in luascript.cpp there aren't any line with "registerEnumIn". Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants