Skip to content

Damage System

tpan496 edited this page Apr 1, 2021 · 14 revisions

Horde has a built-in damage system that provides more depth to damage dealing in Gmod. Although you can use ScaleNPCDamage/EntityTakeDamage, if you want a more consistent result I highly recommend using Horde damage hooks.

Damage Dealing Mechanism

damage = (more1 * more2 * ...) * (1 + increase1 + increase2 + ...) * base_damage

Hook

"Horde_OnPlayerDamage", ply, npc, bonus, hitgroup, dmginfo.
"Horde_OnPlayerMinionDamage", ply, npc, bonus, hitgroup, dmginfo.
bonus = {increase=custom_increase, more=custom_more}

Damage Taken Mechanism

Evasion is first calculated and rolled. No damage is taken if evasion is successful.
damage taken = (less1 * less2 * ...) * (1 - (resistance1 + resistance2 + ...)) * base_damage_taken

Hook

"Horde_OnPlayerDamageTaken", ply, dmginfo, bonus
bonus = {resistance=custom_resistance, less=custom_less, evasion=custom_evasion}

Usage Examples

See https://github.com/tpan496/Horde/tree/main/gamemode/perks