]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/gamemode_nexball.qc
Weapons: remove useless weapon return values and implementations
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / gamemode_nexball.qc
index 5b116991317f2ffb0ea8bf282337333e10f96434..5d034870e67a0418c9814d3d18ca3158f07b2d85 100644 (file)
@@ -3,6 +3,21 @@
 
 #include "gamemode.qh"
 
+float autocvar_g_nexball_basketball_bouncefactor;
+float autocvar_g_nexball_basketball_bouncestop;
+float autocvar_g_nexball_basketball_carrier_highspeed;
+bool autocvar_g_nexball_basketball_meter;
+float autocvar_g_nexball_basketball_meter_maxpower;
+float autocvar_g_nexball_basketball_meter_minpower;
+float autocvar_g_nexball_delay_collect;
+float autocvar_g_nexball_delay_goal;
+float autocvar_g_nexball_delay_start;
+float autocvar_g_nexball_football_bouncefactor;
+float autocvar_g_nexball_football_bouncestop;
+bool autocvar_g_nexball_radar_showallplayers;
+bool autocvar_g_nexball_sound_bounce;
+int autocvar_g_nexball_trail_color;
+
 float autocvar_g_nexball_safepass_turnrate;
 float autocvar_g_nexball_safepass_maxdist;
 float autocvar_g_nexball_safepass_holdtime;
@@ -59,18 +74,16 @@ void ball_restart(void)
 
 void nexball_setstatus(void)
 {SELFPARAM();
-       entity oldself;
        self.items &= ~IT_KEY1;
        if(self.ballcarried)
        {
                if(self.ballcarried.teamtime && (self.ballcarried.teamtime < time))
                {
                        bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
-                       oldself = self;
                        setself(self.ballcarried);
                        DropBall(self, self.owner.origin, '0 0 0');
                        ResetBall();
-                       setself(oldself);
+                       setself(this);
                }
                else
                        self.items |= IT_KEY1;
@@ -153,15 +166,15 @@ void GiveBall(entity plyr, entity ball)
                ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
        }
 
-       ownr = self;
+       plyr.weaponentity.weapons = plyr.weapons;
+       plyr.weaponentity.switchweapon = plyr.weapon;
+       plyr.weapons = WEPSET_NEXBALL;
        setself(plyr);
-       self.weaponentity.weapons = self.weapons;
-       self.weaponentity.switchweapon = self.weapon;
-       self.weapons = WEPSET_PORTO;
-       WEP_ACTION(WEP_PORTO.m_id, WR_RESETPLAYER);
-       self.switchweapon = WEP_PORTO.m_id;
-       W_SwitchWeapon(WEP_PORTO.m_id);
-       setself(ownr);
+       Weapon w = WEP_NEXBALL;
+       w.wr_resetplayer(w);
+       plyr.switchweapon = WEP_NEXBALL.m_id;
+       W_SwitchWeapon(WEP_NEXBALL.m_id);
+       setself(this);
 }
 
 void DropBall(entity ball, vector org, vector vel)
@@ -210,7 +223,7 @@ void InitBall(void)
        self.teamtime = 0;
        self.pusher = world;
        self.team = false;
-       sound(self, CH_TRIGGER, self.noise1, VOL_BASE, ATTEN_NORM);
+       _sound(self, CH_TRIGGER, self.noise1, VOL_BASE, ATTEN_NORM);
        WaypointSprite_Ping(self.waypointsprite_attachedforcarrier);
        LogNB("init", world);
 }
@@ -257,7 +270,7 @@ void football_touch(void)
        {
                if(time > self.lastground + 0.1)
                {
-                       sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
+                       _sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
                        self.lastground = time;
                }
                if(vlen(self.velocity) && !self.cnt)
@@ -313,7 +326,7 @@ void basketball_touch(void)
        }
        else if(other.solid == SOLID_BSP)
        {
-               sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
+               _sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
                if(vlen(self.velocity) && !self.cnt)
                        self.nextthink = min(time + autocvar_g_nexball_delay_idle, self.teamtime);
        }
@@ -379,7 +392,7 @@ void GoalTouch(void)
                pscore = 1;
        }
 
-       sound(ball, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NONE);
+       _sound(ball, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NONE);
 
        if(ball.team && pscore)
        {
@@ -498,7 +511,7 @@ void SpawnBall(void)
        }
 
        precache_model(self.model);
-       setmodel(self, self.model);
+       _setmodel(self, self.model);
        setsize(self, BALL_MINS, BALL_MAXS);
        ball_scale = self.scale;
 
@@ -518,13 +531,13 @@ void SpawnBall(void)
        if(!autocvar_g_nexball_sound_bounce)
                self.noise = "";
        else if(self.noise == "")
-               self.noise = "sound/nexball/bounce.wav";
+               self.noise = SND(NB_BOUNCE);
        //bounce sound placeholder (FIXME)
        if(self.noise1 == "")
-               self.noise1 = "sound/nexball/drop.wav";
+               self.noise1 = SND(NB_DROP);
        //ball drop sound placeholder (FIXME)
        if(self.noise2 == "")
-               self.noise2 = "sound/nexball/steal.wav";
+               self.noise2 = SND(NB_STEAL);
        //stealing sound placeholder (FIXME)
        if(self.noise) precache_sound(self.noise);
        precache_sound(self.noise1);
@@ -626,7 +639,7 @@ void spawnfunc_nexball_fault(void)
 {SELFPARAM();
        self.team = GOAL_FAULT;
        if(self.noise == "")
-               self.noise = "misc/typehit.wav";
+               self.noise = SND(TYPEHIT);
        SpawnGoal();
 }
 
@@ -634,7 +647,7 @@ void spawnfunc_nexball_out(void)
 {SELFPARAM();
        self.team = GOAL_OUT;
        if(self.noise == "")
-               self.noise = "misc/typehit.wav";
+               self.noise = SND(TYPEHIT);
        SpawnGoal();
 }
 
@@ -708,7 +721,7 @@ void W_Nexball_Touch(void)
                        if(!attacker.ballcarried)
                        {
                                LogNB("stole", attacker);
-                               sound(other, CH_TRIGGER, ball.noise2, VOL_BASE, ATTEN_NORM);
+                               _sound(other, CH_TRIGGER, ball.noise2, VOL_BASE, ATTEN_NORM);
 
                                if(SAME_TEAM(attacker, other) && time > attacker.teamkill_complain)
                                {
@@ -730,7 +743,7 @@ void W_Nexball_Attack(float t)
        if(!(ball = self.ballcarried))
                return;
 
-       W_SetupShot(self, false, 4, "nexball/shoot1.wav", CH_WEAPON_A, 0);
+       W_SetupShot(self, false, 4, SND(NB_SHOOT1), CH_WEAPON_A, 0);
        tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, world);
        if(trace_startsolid)
        {
@@ -764,7 +777,7 @@ void W_Nexball_Attack2(void)
        if(self.ballcarried.enemy)
        {
                entity _ball = self.ballcarried;
-               W_SetupShot(self, false, 4, "nexball/shoot1.wav", CH_WEAPON_A, 0);
+               W_SetupShot(self, false, 4, SND(NB_SHOOT1), CH_WEAPON_A, 0);
                DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32));
                _ball.think = W_Nexball_Think;
                _ball.nextthink = time;
@@ -777,7 +790,7 @@ void W_Nexball_Attack2(void)
        entity missile;
        if(!(balls & BALL_BASKET))
                return;
-       W_SetupShot(self, false, 2, "nexball/shoot2.wav", CH_WEAPON_A, 0);
+       W_SetupShot(self, false, 2, SND(NB_SHOOT2), CH_WEAPON_A, 0);
        missile = spawn();
 
        missile.owner = self;
@@ -829,12 +842,10 @@ float ball_customize()
        return true;
 }
 
-float w_nexball_weapon(float req)
-{SELFPARAM();
-       if(req == WR_THINK)
+       METHOD(BallStealer, wr_think, void(BallStealer thiswep, bool fire1, bool fire2))
        {
-               if(self.BUTTON_ATCK)
-                       if(weapon_prepareattack(0, autocvar_g_balance_nexball_primary_refire))
+               if(fire1)
+                       if(weapon_prepareattack(false, autocvar_g_balance_nexball_primary_refire))
                                if(autocvar_g_nexball_basketball_meter)
                                {
                                        if(self.ballcarried && !self.metertime)
@@ -847,37 +858,32 @@ float w_nexball_weapon(float req)
                                        W_Nexball_Attack(-1);
                                        weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
                                }
-               if(self.BUTTON_ATCK2)
-                       if(weapon_prepareattack(1, autocvar_g_balance_nexball_secondary_refire))
+               if(fire2)
+                       if(weapon_prepareattack(true, autocvar_g_balance_nexball_secondary_refire))
                        {
                                W_Nexball_Attack2();
                                weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
                        }
 
-               if(!self.BUTTON_ATCK && self.metertime && self.ballcarried)
+               if(!fire1 && self.metertime && self.ballcarried)
                {
                        W_Nexball_Attack(time - self.metertime);
                        // DropBall or stealing will set metertime back to 0
                        weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
                }
        }
-       else if(req == WR_INIT)
+       METHOD(BallStealer, wr_setup, void(BallStealer thiswep))
        {
-               precache_model(W_Model("g_porto.md3"));
-               precache_model(W_Model("v_porto.md3"));
-               precache_model(W_Model("h_porto.iqm"));
-               precache_model("models/elaser.mdl");
-               precache_sound("nexball/shoot1.wav");
-               precache_sound("nexball/shoot2.wav");
-               precache_sound("misc/typehit.wav");
+               //weapon_setup(WEP_PORTO.m_id);
        }
-       else if(req == WR_SETUP)
+       METHOD(BallStealer, wr_checkammo1, bool(BallStealer thiswep))
        {
-               //weapon_setup(WEP_PORTO.m_id);
+               return true;
+       }
+       METHOD(BallStealer, wr_checkammo2, bool(BallStealer thiswep))
+       {
+               return true;
        }
-       // No need to check WR_CHECKAMMO* or WR_AIM, it should always return true
-       return true;
-}
 
 MUTATOR_HOOKFUNCTION(nexball_BallDrop)
 {SELFPARAM();
@@ -936,7 +942,8 @@ MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink)
                        if(self.weaponentity.weapons)
                        {
                                self.weapons = self.weaponentity.weapons;
-                               WEP_ACTION(WEP_PORTO.m_id, WR_RESETPLAYER);
+                               Weapon w = WEP_NEXBALL;
+                               w.wr_resetplayer(w);
                                self.switchweapon = self.weaponentity.switchweapon;
                                W_SwitchWeapon(self.switchweapon);
 
@@ -956,7 +963,7 @@ MUTATOR_HOOKFUNCTION(nexball_PlayerSpawn)
        self.weaponentity.weapons = '0 0 0';
 
        if(nexball_mode & NBM_BASKETBALL)
-               self.weapons |= WEPSET_PORTO;
+               self.weapons |= WEPSET_NEXBALL;
        else
                self.weapons = '0 0 0';
 
@@ -973,13 +980,6 @@ MUTATOR_HOOKFUNCTION(nexball_PlayerPhysics)
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(nexball_SetStartItems)
-{
-       start_items |= IT_UNLIMITED_SUPERWEAPONS; // FIXME BAD BAD BAD BAD HACK, NEXBALL SHOULDN'T ABUSE PORTO'S WEAPON SLOT
-
-       return false;
-}
-
 MUTATOR_HOOKFUNCTION(nexball_ForbidThrowing)
 {SELFPARAM();
        if(self.weapon == WEP_MORTAR.m_id)
@@ -1005,7 +1005,6 @@ MUTATOR_DEFINITION(gamemode_nexball)
        MUTATOR_HOOK(PlayerSpawn, nexball_PlayerSpawn, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerPreThink, nexball_PlayerPreThink, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerPhysics, nexball_PlayerPhysics, CBC_ORDER_ANY);
-       MUTATOR_HOOK(SetStartItems, nexball_SetStartItems, CBC_ORDER_ANY);
        MUTATOR_HOOK(ForbidThrowCurrentWeapon, nexball_ForbidThrowing, CBC_ORDER_ANY);
        MUTATOR_HOOK(FilterItem, nexball_FilterItem, CBC_ORDER_ANY);