From a915e2e4edce0f3e5f1df6a12b2a356f45f6b446 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 28 Aug 2015 17:01:21 +1000 Subject: [PATCH] Add a mutator hook to customize bullets --- qcsrc/server/mutators/events.qh | 16 ++++++++++++++++ qcsrc/server/weapons/tracing.qc | 2 ++ 2 files changed, 18 insertions(+) diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index fb3fbd107..2d10ee01c 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -547,4 +547,20 @@ MUTATOR_HOOKABLE(ClearModelParams, EV_NO_ARGS); /**/ string checkmodel_input, checkmodel_command; MUTATOR_HOOKABLE(GetModelParams, EV_GetModelParams); + +/** called when a bullet has hit a target */ +#define EV_FireBullet_Hit(i, o) \ + /**/ i(entity, self) \ + /**/ i(entity, bullet_hit) \ + /**/ i(vector, bullet_startpos) \ + /**/ i(vector, bullet_endpos) \ + /**/ i(float, frag_damage) \ + /**/ o(float, frag_damage) \ + /**/ +entity bullet_hit; +//vector bullet_hitloc; // the end pos matches the hit location, apparently +vector bullet_startpos; +vector bullet_endpos; +//float frag_damage; +MUTATOR_HOOKABLE(FireBullet_Hit, EV_FireBullet_Hit); #endif diff --git a/qcsrc/server/weapons/tracing.qc b/qcsrc/server/weapons/tracing.qc index 484ac35be..5065b4af1 100644 --- a/qcsrc/server/weapons/tracing.qc +++ b/qcsrc/server/weapons/tracing.qc @@ -422,6 +422,8 @@ void fireBullet(vector start, vector dir, float spread, float max_solid_penetrat { fireBullet_last_hit = hit; yoda = 0; + MUTATOR_CALLHOOK(FireBullet_Hit, self, hit, start, end, damage); + damage = frag_damage; float g = accuracy_isgooddamage(self, hit); Damage(hit, self, self, damage * solid_penetration_left, dtype, start, force * dir * solid_penetration_left); // calculate hits for ballistic weapons -- 2.39.2