]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Clean up nexball gametype definition
authorMario <mario.mario@y7mail.com>
Mon, 19 Oct 2020 09:32:54 +0000 (19:32 +1000)
committerMario <mario.mario@y7mail.com>
Mon, 19 Oct 2020 09:32:54 +0000 (19:32 +1000)
qcsrc/common/gamemodes/gamemode/nexball/sv_nexball.qc
qcsrc/common/gamemodes/gamemode/nexball/sv_nexball.qh

index 2796f2b499fca0d1cecd8ca11c38bea3a5ca2251..b98a8a917303ef263031d8cf91f150787a15d8d4 100644 (file)
@@ -11,7 +11,7 @@
 .entity ballcarried;
 
 int autocvar_g_nexball_goalleadlimit;
-#define autocvar_g_nexball_goallimit cvar("g_nexball_goallimit")
+float autocvar_g_nexball_goallimit;
 
 bool autocvar_g_nexball_basketball_jumppad = true;
 float autocvar_g_nexball_basketball_bouncefactor;
@@ -940,36 +940,25 @@ MUTATOR_HOOKFUNCTION(nb, SendWaypoint)
        M_ARGV(2, int) &= ~0x80;
 }
 
-REGISTER_MUTATOR(nb, false)
+void nb_Initialize()
 {
-    MUTATOR_STATIC();
-       MUTATOR_ONADD
-       {
-               g_nexball_meter_period = autocvar_g_nexball_meter_period;
-               if(g_nexball_meter_period <= 0)
-                       g_nexball_meter_period = 2; // avoid division by zero etc. due to silly users
-               g_nexball_meter_period = rint(g_nexball_meter_period * 32) / 32; //Round to 1/32ths to send as a byte multiplied by 32
+       g_nexball_meter_period = autocvar_g_nexball_meter_period;
+       if(g_nexball_meter_period <= 0)
+               g_nexball_meter_period = 2; // avoid division by zero etc. due to silly users
+       g_nexball_meter_period = rint(g_nexball_meter_period * 32) / 32; //Round to 1/32ths to send as a byte multiplied by 32
 
-               // General settings
-               /*
-               CVTOV(g_nexball_football_boost_forward);   //100
-               CVTOV(g_nexball_football_boost_up);             //200
-               CVTOV(g_nexball_delay_idle);                       //10
-               CVTOV(g_nexball_football_physics);               //0
-               */
-               radar_showenemies = autocvar_g_nexball_radar_showallplayers;
+       // General settings
+       /*
+       CVTOV(g_nexball_football_boost_forward);   //100
+       CVTOV(g_nexball_football_boost_up);             //200
+       CVTOV(g_nexball_delay_idle);                       //10
+       CVTOV(g_nexball_football_physics);               //0
+       */
+       radar_showenemies = autocvar_g_nexball_radar_showallplayers;
 
-               InitializeEntity(NULL, nb_delayedinit, INITPRIO_GAMETYPE);
-               WEP_NEXBALL.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
+       GameRules_teams(true);
+       GameRules_limit_score(autocvar_g_nexball_goallimit);
+       GameRules_limit_lead(autocvar_g_nexball_goalleadlimit);
 
-               GameRules_teams(true);
-               GameRules_limit_score(autocvar_g_nexball_goallimit);
-               GameRules_limit_lead(autocvar_g_nexball_goalleadlimit);
-       }
-
-       MUTATOR_ONROLLBACK_OR_REMOVE
-       {
-               WEP_NEXBALL.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
-       }
-       return 0;
+       InitializeEntity(NULL, nb_delayedinit, INITPRIO_GAMETYPE);
 }
index 864e89138aef001775eb6434db52b55ac8a2f73d..902de157f89cbd60d58a056aad3c03653bcdd783 100644 (file)
@@ -1,5 +1,25 @@
 #pragma once
 
+#include "weapon.qh"
+
+void nb_Initialize();
+
+REGISTER_MUTATOR(nb, false)
+{
+    MUTATOR_STATIC();
+       MUTATOR_ONADD
+       {
+               nb_Initialize();
+               WEP_NEXBALL.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
+       }
+
+       MUTATOR_ONROLLBACK_OR_REMOVE
+       {
+               WEP_NEXBALL.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
+       }
+       return 0;
+}
+
 //EF_BRIGHTFIELD|EF_BRIGHTLIGHT|EF_DIMLIGHT|EF_BLUE|EF_RED|EF_FLAME
 const float BALL_EFFECTMASK = 1229;
 const vector BALL_MINS = '-16 -16 -16'; // The model is 24*24*24