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

Fix damage calculation #306

Open
wants to merge 1 commit into
base: 3.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 19 additions & 25 deletions src/gtasa/effects/custom/unsorted/DeadlyBulletsEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ template <float dmgMult> class DeadlyBulletsEffect : public EffectBase
{
if (!isPlayerOnly)
{
HOOK_METHOD_ARGS (inst, Hooked_ComputeWillKillPed_everyone,
void (CPedDamageResponseCalculator *, CPed *,
uint8_t *, char),
0x4B5B27);

HOOK_METHOD_ARGS (inst, Hooked_VehicleInflictDamage_everyone,
void (CVehicle *, CEntity *, eWeaponType, float,
CVector),
0x6D7C90);

HOOK_METHOD_ARGS (inst, Hooked_AccountForPedArmour_everyone,
void (CPedDamageResponseCalculator *, CPed *,
uint8_t *),
0x4B5B19);
}
else
{
HOOK_METHOD_ARGS (inst, Hooked_ComputeWillKillPed_player,
void (CPedDamageResponseCalculator *, CPed *,
uint8_t *, char),
0x4B5B27);

HOOK_METHOD_ARGS (inst, Hooked_VehicleInflictDamage_player,
void (CVehicle *, CEntity *, eWeaponType, float,
CVector),
0x6D7C90);

HOOK_METHOD_ARGS (inst, Hooked_AccountForPedArmour_player,
void (CPedDamageResponseCalculator *, CPed *,
uint8_t *),
0x4B5B19);
}
}

Expand Down Expand Up @@ -73,14 +73,11 @@ template <float dmgMult> class DeadlyBulletsEffect : public EffectBase
}

static void
Hooked_ComputeWillKillPed_player (auto &&cb,
CPedDamageResponseCalculator *thisCalc,
CPed *ped, uint8_t *cDamageResponseInfo,
char a4)
Hooked_AccountForPedArmour_player (auto &&cb,
CPedDamageResponseCalculator *thisCalc,
CPed *ped, uint8_t *data)
{
if (thisCalc->m_pDamager != FindPlayerPed ()) return;

if (thisCalc->m_weaponType >= WEAPON_PISTOL
if (ped != FindPlayerPed () && thisCalc->m_weaponType >= WEAPON_PISTOL
&& thisCalc->m_weaponType <= WEAPON_SNIPERRIFLE)
{
thisCalc->m_fDamageFactor *= dmgMult;
Expand All @@ -90,10 +87,9 @@ template <float dmgMult> class DeadlyBulletsEffect : public EffectBase
}

static void
Hooked_ComputeWillKillPed_everyone (auto &&cb,
CPedDamageResponseCalculator *thisCalc,
CPed *ped, uint8_t *cDamageResponseInfo,
char a4)
Hooked_AccountForPedArmour_everyone (auto &&cb,
CPedDamageResponseCalculator *thisCalc,
CPed *ped, uint8_t *data)
{
if (thisCalc->m_weaponType >= WEAPON_PISTOL
&& thisCalc->m_weaponType <= WEAPON_SNIPERRIFLE)
Expand All @@ -108,8 +104,6 @@ template <float dmgMult> class DeadlyBulletsEffect : public EffectBase
using DeadlyBulletsEffectQuad = DeadlyBulletsEffect<4.0f>;

/* clang-format off */
DEFINE_EFFECT (DeadlyBulletsEffectQuad, "effect_deadly_bullets_quad_dmg_everyone",
GROUP_WEAPONS, false);
DEFINE_EFFECT (DeadlyBulletsEffectQuad, "effect_deadly_bullets_quad_dmg_player",
GROUP_WEAPONS, true);
DEFINE_EFFECT (DeadlyBulletsEffectQuad, "effect_deadly_bullets_quad_dmg_everyone", GROUP_WEAPONS, false);
DEFINE_EFFECT (DeadlyBulletsEffectQuad, "effect_deadly_bullets_quad_dmg_player", GROUP_WEAPONS, true);
/* clang-format on */
Loading