]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a mutator hook to customize bullets
authorMario <zacjardine@y7mail.com>
Fri, 28 Aug 2015 07:01:21 +0000 (17:01 +1000)
committerMario <zacjardine@y7mail.com>
Fri, 28 Aug 2015 07:01:21 +0000 (17:01 +1000)
qcsrc/server/mutators/events.qh
qcsrc/server/weapons/tracing.qc

index fb3fbd107e247fd0db7f0a392b6b2724762c5854..2d10ee01cc956e2c78ed47612526fd92dda46777 100644 (file)
@@ -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
index 484ac35be48ae6a459dfd59827175c29cd00437c..5065b4af1b2e87b3c795f9d79e94346e0bdeafb6 100644 (file)
@@ -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