phoenixprojectsoftware / zamnhlmp

The game files for Half-Life: Zombies Ate My Neighbours Multiplayer.
https://moddb.com/mods/zamnhlmp
Other
2 stars 2 forks source link

AURA energy regeneration feature should take into account player might be in Observer or Dead... #117

Open N7P0L3ON opened 3 hours ago

N7P0L3ON commented 3 hours ago

I was looking ta the code for the energy regeneration you have in Aura and I noticed few flaws...

  1. First the regeneration is too fast...
  2. The sound for the regen it a bit too annoying...
  3. The regen sound and all the sounds in general are not taking into account that the player might be dead or in Observer...

I will suggest the solutions to those here:

For 1: the solution is quite simple, increase the time for regen to say 0.5 / 0.3 secs.

For 2: Add a client CVAR to disable the sound or tone the sounds down more...

For 3: You should add some checks and few additional stops for the sounds. Let's start with the checks:

right after the statements: if (pev->armorvalue <= 0) , if (pev->armorvalue < 10) and if (sv_aura_regeneration.value != 0 && pev->armorvalue < MAX_NORMAL_BATTERY && m_flNextSuitRegenTime < gpGlobals->time)

add this:

        // only do this if we're NOT: In observer or dead...
        if ( IsObserver() || !IsAlive() )
        {
            return;
        }

The we need to add the stop for the sounds if we die or we get to Spectator/Observer:

In the functions: void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) and void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib )

add this:

    // make sure to stop the energy regen sounds on kill or observer enter...
    if (sv_aura_regeneration.value != 0 )
    {
        STOP_SOUND(ENT(pev), CHAN_STATIC, "items/suitcharge1.wav");
        STOP_SOUND(ENT(pev), CHAN_AUTO, "player/shield_empty.wav");
        STOP_SOUND(ENT(pev), CHAN_STATIC, "items/suitcharge_no_lp.wav");
        STOP_SOUND(ENT(pev), CHAN_STATIC, "player/shield_charge.wav");
        STOP_SOUND(ENT(pev), CHAN_AUTO, "player/shield_low.wav");

        isShieldLow = false;
        m_fRegenOn = false;
    }

And this should fix the issues... IF you have other functions like welcome camera etc you'll have to take that one into account as well.

More clean way would be to create a function to stop those sounds and to call it instead, but it's up to use to decide.

sabianroberts commented 2 hours ago

Hello @N7P0L3ON, thanks for the suggestions and for proposing a fix.

  1. The shield regeneration's purpose is to be rapid whilst the player is taking cover during combat, and to balance we've tried to make the wait before the shield starts regenerating as long as possible (it currently stands at 5.5 seconds). m_flNextSuitRegenTime = gpGlobals->time + 5.5 + sv_aura_regeneration_wait.value;
  2. Since cl_music_enabled has already been implemented, cl_aura_regeneration_sound_enabled or something like that won't be too hard to implement so thanks for the suggestion.
  3. Thanks for proposing this, it will be implemented.

Sabian

N7P0L3ON commented 2 hours ago

Maybe you can make it to count the time out of combat and after that to start regenerating; not to regenerate during combat.

sabianroberts commented 1 hour ago

instead of adding the if statements to each other one, I decided to nest the entire suit energy regeneration code in a single if else statement. I haven't been able to test this in-depth with more than one player but it should work okay, if there's any problems I'll do your proposed method.

https://github.com/phoenixprojectsoftware/Aura-SE/commit/f4712fd6f571d53ffd2514ec741c61228458f031#diff-dae8eaadc24decdf403b98675e70a85d9c3d20c0fffc5906a3c1203927275541R4673