]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc
Add a mutator hook for customizing the eventchase effect; onslaught now makes use...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / onslaught / onslaught.qc
index 36926b754b0bcb8f0c92b4f1c734d8391c3cafc6..a30dd7d07e1c2da7b91a20edf9478d4a15e8e0d4 100644 (file)
@@ -1 +1,46 @@
 #include "onslaught.qh"
+
+#ifdef CSQC
+
+REGISTER_MUTATOR(cl_ons, true);
+
+float ons_roundlost;
+vector generator_origin;
+vector autocvar_cl_eventchase_generator_viewoffset = '0 0 80';
+float autocvar_cl_eventchase_generator_distance = 400;
+MUTATOR_HOOKFUNCTION(cl_ons, WantEventchase)
+{
+       ons_roundlost = STAT(ROUNDLOST);
+       entity gen = NULL;
+       if(ons_roundlost)
+       {
+               IL_EACH(g_onsgenerators, it.health <= 0,
+               {
+                       gen = it;
+                       break;
+               });
+               if(!gen)
+                       ons_roundlost = false; // don't enforce the 3rd person camera if there is no dead generator to show
+       }
+
+       if(ons_roundlost)
+       {
+               generator_origin = gen.origin;
+               return true;
+       }
+       return false;
+}
+
+MUTATOR_HOOKFUNCTION(cl_ons, CustomizeEventchase)
+{
+       if(ons_roundlost)
+       {
+               M_ARGV(0, vector) = generator_origin;
+               M_ARGV(1, vector) = autocvar_cl_eventchase_generator_viewoffset;
+               M_ARGV(0, float) = autocvar_cl_eventchase_generator_distance;
+               return true;
+       }
+       return false;
+}
+
+#endif