]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/gamemode_nexball.qc
Merge branch 'master' into Mario/classname_checks
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / gamemode_nexball.qc
index f328162ff3f00a83b784646500613ffacd9ddd53..ba70a6cda8a5e301242f978430cf2c82d31a5e95 100644 (file)
@@ -49,7 +49,7 @@ void nexball_setstatus(void)
        {
                if(self.ballcarried.teamtime && (self.ballcarried.teamtime < time))
                {
-                       bprint("The ", ColoredTeamName(self.team), " held the ball for too long.\n");
+                       bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
                        oldself = self;
                        self = self.ballcarried;
                        DropBall(self, self.owner.origin, '0 0 0');
@@ -204,7 +204,8 @@ void ResetBall(void)
        if(self.cnt < 2)        // step 1
        {
                if(time == self.teamtime)
-                       bprint("The ", ColoredTeamName(self.team), " held the ball for too long.\n");
+                       bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
+
                self.touch = func_null;
                self.movetype = MOVETYPE_NOCLIP;
                self.velocity = '0 0 0'; // just in case?
@@ -247,7 +248,7 @@ void football_touch(void)
                        self.nextthink = time + autocvar_g_nexball_delay_idle;
                return;
        }
-       if(other.classname != "player")
+       if not(IS_PLAYER(other))
                return;
        if(other.health < 1)
                return;
@@ -287,7 +288,7 @@ void basketball_touch(void)
                football_touch();
                return;
        }
-       if(!self.cnt && other.classname == "player" && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect))
+       if(!self.cnt && IS_PLAYER(other) && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect))
        {
                if(other.health <= 0)
                        return;
@@ -326,7 +327,7 @@ void GoalTouch(void)
        else
                otherteam = 0;
 
-       if((isclient = ball.pusher.flags & FL_CLIENT))
+       if((isclient = IS_CLIENT(ball.pusher)))
                pname = ball.pusher.netname;
        else
                pname = "Someone (?)";
@@ -341,9 +342,9 @@ void GoalTouch(void)
        {
                LogNB("fault", ball.pusher);
                if(nb_teams == 2)
-                       bprint(ColoredTeamName(otherteam), " gets a point due to ", pname, "^7's silliness.\n");
+                       bprint(Team_ColoredFullName(otherteam), " gets a point due to ", pname, "^7's silliness.\n");
                else
-                       bprint(ColoredTeamName(ball.team), " loses a point due to ", pname, "^7's silliness.\n");
+                       bprint(Team_ColoredFullName(ball.team), " loses a point due to ", pname, "^7's silliness.\n");
                pscore = -1;
        }
        else if(self.team == GOAL_OUT)
@@ -358,7 +359,7 @@ void GoalTouch(void)
        else                                                       //score
        {
                LogNB(strcat("goal:", ftos(self.team)), ball.pusher);
-               bprint("Goaaaaal! ", pname, "^7 scored a point for the ", ColoredTeamName(ball.team), ".\n");
+               bprint("Goaaaaal! ", pname, "^7 scored a point for the ", Team_ColoredFullName(ball.team), ".\n");
                pscore = 1;
        }
 
@@ -424,28 +425,28 @@ void nb_spawnteams(void)
        {
                switch(e.team)
                {
-               case COLOR_TEAM1:
+               case NUM_TEAM_1:
                        if(!t_r)
                        {
                                nb_spawnteam("Red", e.team-1)   ;
                                t_r = 1;
                        }
                        break;
-               case COLOR_TEAM2:
+               case NUM_TEAM_2:
                        if(!t_b)
                        {
                                nb_spawnteam("Blue", e.team-1)  ;
                                t_b = 1;
                        }
                        break;
-               case COLOR_TEAM3:
+               case NUM_TEAM_3:
                        if(!t_y)
                        {
                                nb_spawnteam("Yellow", e.team-1);
                                t_y = 1;
                        }
                        break;
-               case COLOR_TEAM4:
+               case NUM_TEAM_4:
                        if(!t_p)
                        {
                                nb_spawnteam("Pink", e.team-1)  ;
@@ -575,22 +576,22 @@ void SpawnGoal(void)
 
 void spawnfunc_nexball_redgoal(void)
 {
-       self.team = COLOR_TEAM1;
+       self.team = NUM_TEAM_1;
        SpawnGoal();
 }
 void spawnfunc_nexball_bluegoal(void)
 {
-       self.team = COLOR_TEAM2;
+       self.team = NUM_TEAM_2;
        SpawnGoal();
 }
 void spawnfunc_nexball_yellowgoal(void)
 {
-       self.team = COLOR_TEAM3;
+       self.team = NUM_TEAM_3;
        SpawnGoal();
 }
 void spawnfunc_nexball_pinkgoal(void)
 {
-       self.team = COLOR_TEAM4;
+       self.team = NUM_TEAM_4;
        SpawnGoal();
 }
 
@@ -673,7 +674,7 @@ void W_Nexball_Touch(void)
        
        PROJECTILE_TOUCH;
        if(attacker.team != other.team || autocvar_g_nexball_basketball_teamsteal)
-               if((ball = other.ballcarried) && (attacker.classname == "player"))
+               if((ball = other.ballcarried) && (IS_PLAYER(attacker)))
                {
                        other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force;
                        other.flags &~= FL_ONGROUND;
@@ -773,14 +774,13 @@ void W_Nexball_Attack2(void)
        missile.flags = FL_PROJECTILE;
 }
 
-var const float() nullfunc;
 float ball_customize()
 {
        if(!self.owner)
        {
                self.effects &~= EF_FLAME;
                self.scale = 1;
-               self.customizeentityforclient = nullfunc;
+               self.customizeentityforclient = func_null;
                return TRUE;
        }               
        
@@ -844,14 +844,8 @@ float w_nexball_weapon(float req)
                precache_sound("misc/typehit.wav");
        }
        else if(req == WR_SETUP)
-               weapon_setup(WEP_PORTO);
-       else if(req == WR_SUICIDEMESSAGE)
-       {
-               w_deathtypestring = "is a weirdo";
-       }
-       else if(req == WR_KILLMESSAGE)
        {
-               w_deathtypestring = "got killed by #'s black magic";
+               weapon_setup(WEP_PORTO);
        }
        // No need to check WR_CHECKAMMO* or WR_AIM, it should always return TRUE
        return TRUE;
@@ -906,7 +900,7 @@ MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink)
                                //tracebox(self.origin + self.view_ofs, '-2 -2 -2', '2 2 2', self.origin + self.view_ofs + v_forward * autocvar_g_nexball_safepass_maxdist);
                                crosshair_trace(self);
                                if( trace_ent && 
-                                       trace_ent.flags & FL_CLIENT &&
+                                       IS_CLIENT(trace_ent) &&
                                        trace_ent.deadflag == DEAD_NO &&
                                        trace_ent.team == self.team &&
                                        vlen(trace_ent.origin - self.origin) <= autocvar_g_nexball_safepass_maxdist )
@@ -980,5 +974,18 @@ MUTATOR_DEFINITION(gamemode_nexball)
                InitializeEntity(world, nb_delayedinit, INITPRIO_GAMETYPE);
        }
 
+       MUTATOR_ONROLLBACK_OR_REMOVE
+       {
+               // we actually cannot roll back nb_delayedinit here
+               // BUT: we don't need to! If this gets called, adding always
+               // succeeds.
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               print("This is a game type and it cannot be removed at runtime.");
+               return -1;
+       }
+
        return 0;
 }