Skip to content

Commit

Permalink
Make cough effect less annoying
Browse files Browse the repository at this point in the history
  • Loading branch information
gromchek committed Sep 8, 2024
1 parent ec0e41e commit 7eeabee
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/gtasa/effects/custom/ped/CoughEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class CoughEffect : public EffectBase
{
private:
int timer = 0;
const int MIN_COUGH_TIME_SEC = 3;
const int MIN_COUGH_TIME_SEC = 2;
const int MAX_COUGH_TIME_SEC = 4;
const int MAX_WAIT_TIME_SEC = 7;
const int MIN_WAIT_TIME_SEC = 5;
const int MAX_WAIT_TIME_SEC = 8;
const int MIN_WAIT_TIME_SEC = 6;
bool isPlayerOnly = false;

public:
Expand Down Expand Up @@ -60,11 +60,13 @@ class CoughEffect : public EffectBase
if (!ped) return;

auto *vehicle = ped->m_pVehicle;
if (vehicle && vehicle->m_pDriver == ped
&& vehicle->m_vecMoveSpeed.Magnitude () > 0.15f)
bool cond = vehicle && vehicle->m_pDriver == ped;
cond &= vehicle && vehicle->m_vecMoveSpeed.Magnitude () > 0.15f;
cond &= inst->Random (0, 100000) % 2 == 0;
if (cond)
{
auto speed = vehicle->m_vecMoveSpeed.Magnitude ()
* (inst->Random (0, 1) ? 0.12f : -0.12f);
* (inst->Random (0, 1) ? 0.08f : -0.08f);
vehicle->m_vecTurnSpeed.z = speed;
}
if (!ped->m_nPedFlags.bInVehicle)
Expand All @@ -74,13 +76,13 @@ class CoughEffect : public EffectBase
Command<eScriptCommands::COMMAND_TASK_PLAY_ANIM_NON_INTERRUPTABLE> (
ped, "gas_cwr", "ped", 4.0, 1, 1, 1, 0, sec);
}
ped->m_fHealth -= ped->m_fMaxHealth * 0.02f;
ped->m_fHealth -= ped->m_fMaxHealth * 0.05f;
ped->m_fHealth = std::max (0.0f, ped->m_fHealth);

int res = 0;
int speechBank = 340;
Command<eScriptCommands::COMMAND_SET_CHAR_SAY_CONTEXT_IMPORTANT> (
ped, speechBank, 1, 1, 1 & res);
ped, speechBank, 1, 1, 1, &res);
}
};

Expand Down

0 comments on commit 7eeabee

Please sign in to comment.