ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.66k stars 616 forks source link

[HL] Glitchy Hivehand #556

Open Matthaiks opened 11 years ago

Matthaiks commented 11 years ago

This is an old bug. The Hivehand sometimes behaves oddly when its magazine is empty.

In this video there are 3 examples. The first one seems rather normal. Check it out:

http://youtu.be/R4alKH4uEpQ

di57inct commented 11 years ago

I think this is the same kind of bug with the shotguns on CS and CZ that I just posted beneath(https://github.com/ValveSoftware/halflife/issues/555).

LevShisterov commented 11 years ago

@Matthaiks, can you give text description?

Matthaiks commented 11 years ago

Occasionally, there is a problem with sound when one shoots during hornets regeneration (and ammo counter shows 0). Sometimes there is a sound glitch, sometimes there are no sound and movement at all (except hornets).

SamVanheer commented 3 years ago

Most likely caused by #1621 due to the client hitting the <= 0 condition before the server does, resulting in the client simulating the attack twice instead of once.

SamVanheer commented 2 years ago

These bugs happen because the client is also simulating the ammo regeneration and not properly synchronizing the ammo value with the server. Because the reload time variable is an absolute time value it will vary and cause inconsistent regeneration intervals.

These bugs can be mostly fixed by making the following changes.

Change these lines: https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/hornetgun.cpp#L136 https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/hornetgun.cpp#L186

To this:

if (m_pPlayer->ammo_hornets <= 0)

Change this function: https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/hornetgun.cpp#L265-L275

To this:

void CHgun::Reload( void )
{
#ifndef CLIENT_DLL
    if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] >= HORNET_MAX_CARRY)
        return;

    while (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] < HORNET_MAX_CARRY && m_flRechargeTime < gpGlobals->time)
    {
        m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]++;
        m_flRechargeTime += 0.5;
    }

    m_pPlayer->TabulateAmmo();
#endif
}

I say mostly because with high ping the attack animation will sometimes not play. This is because the client isn't simulating ammo regeneration so the client thinks it's out of ammo. I tried to implement that, but it caused the client to simulate attacks at a higher rate than the server so i opted for this instead.