From b9fff06113ba543868354f87ee259be529f04740 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 19 Oct 2020 19:32:54 +1000 Subject: [PATCH] Clean up nexball gametype definition --- .../gamemodes/gamemode/nexball/sv_nexball.qc | 47 +++++++------------ .../gamemodes/gamemode/nexball/sv_nexball.qh | 20 ++++++++ 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/nexball/sv_nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/sv_nexball.qc index 2796f2b49..b98a8a917 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/sv_nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/sv_nexball.qc @@ -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); } diff --git a/qcsrc/common/gamemodes/gamemode/nexball/sv_nexball.qh b/qcsrc/common/gamemodes/gamemode/nexball/sv_nexball.qh index 864e89138..902de157f 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/sv_nexball.qh +++ b/qcsrc/common/gamemodes/gamemode/nexball/sv_nexball.qh @@ -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 -- 2.39.2