]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/gamemode_nexball.qc
Replace `vector_[xyz]` with `vector.[xyz]` where possible
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / gamemode_nexball.qc
index 176fb1eac5e9fcee4270c01fdc705dd25e28d3f8..52533e2c8ae764fdbb6ec60e5efea53c2c96ed6c 100644 (file)
@@ -8,9 +8,9 @@ vector autocvar_g_nexball_viewmodel_offset;
 void basketball_touch();
 void football_touch();
 void ResetBall();
-#define NBM_NONE 0
-#define NBM_FOOTBALL 2
-#define NBM_BASKETBALL 4
+const float NBM_NONE = 0;
+const float NBM_FOOTBALL = 2;
+const float NBM_BASKETBALL = 4;
 float nexball_mode;
 
 float OtherTeam(float t)  //works only if there are two teams on the map!
@@ -22,6 +22,17 @@ float OtherTeam(float t)  //works only if there are two teams on the map!
        return e.team;
 }
 
+const float ST_NEXBALL_GOALS = 1;
+const float SP_NEXBALL_GOALS = 4;
+const float SP_NEXBALL_FAULTS = 5;
+void nb_ScoreRules(float teams)
+{
+       ScoreRules_basics(teams, 0, 0, TRUE);
+       ScoreInfo_SetLabel_TeamScore(   ST_NEXBALL_GOALS,  "goals", SFL_SORT_PRIO_PRIMARY);
+       ScoreInfo_SetLabel_PlayerScore( SP_NEXBALL_GOALS,  "goals", SFL_SORT_PRIO_PRIMARY);
+       ScoreInfo_SetLabel_PlayerScore(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
+       ScoreRules_basics_end();
+}
 
 void LogNB(string mode, entity actor)
 {
@@ -71,9 +82,9 @@ void relocate_nexball(void)
                if(!move_out_of_solid(self))
                        objerror("could not get out of solid at all!");
                print("^1NOTE: this map needs FIXING. ", self.classname, " at ", vtos(o - '0 0 1'));
-               print(" needs to be moved out of solid, e.g. by '", ftos(self.origin_x - o_x));
-               print(" ", ftos(self.origin_y - o_y));
-               print(" ", ftos(self.origin_z - o_z), "'\n");
+               print(" needs to be moved out of solid, e.g. by '", ftos(self.origin.x - o.x));
+               print(" ", ftos(self.origin.y - o.y));
+               print(" ", ftos(self.origin.z - o.z), "'\n");
                self.origin = o;
        }
 }
@@ -83,7 +94,7 @@ void DropOwner(void)
        entity ownr;
        ownr = self.owner;
        DropBall(self, ownr.origin, ownr.velocity);
-       makevectors(ownr.v_angle_y * '0 1 0');
+       makevectors(ownr.v_angle.y * '0 1 0');
        ownr.velocity += ('0 0 0.75' - v_forward) * 1000;
        ownr.flags &= ~FL_ONGROUND;
 }
@@ -270,7 +281,7 @@ void football_touch(void)
        }
        else if(autocvar_g_nexball_football_physics == 2)         // 2nd mod try: totally independant. Really playable!
        {
-               makevectors(other.v_angle_y * '0 1 0');
+               makevectors(other.v_angle.y * '0 1 0');
                self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
        }
        else     // Revenant's original style (from the original mod's disassembly, acknowledged by Revenant)
@@ -288,7 +299,7 @@ void basketball_touch(void)
                football_touch();
                return;
        }
-       if(!self.cnt && IS_PLAYER(other) && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect))
+       if(!self.cnt && IS_PLAYER(other) && !other.frozen && !other.deadflag && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect))
        {
                if(other.health <= 0)
                        return;
@@ -419,54 +430,44 @@ void nb_spawnteam(string teamname, float teamcolor)
 
 void nb_spawnteams(void)
 {
-       float t_r = 0, t_b = 0, t_y = 0, t_p = 0;
+       bool t_red = false, t_blue = false, t_yellow = false, t_pink = false;
        entity e;
        for(e = world; (e = find(e, classname, "nexball_goal"));)
        {
                switch(e.team)
                {
                case NUM_TEAM_1:
-                       if(!t_r)
+                       if(!t_red)
                        {
                                nb_spawnteam("Red", e.team-1)   ;
-                               t_r = 1;
+                               t_red = true;
                        }
                        break;
                case NUM_TEAM_2:
-                       if(!t_b)
+                       if(!t_blue)
                        {
                                nb_spawnteam("Blue", e.team-1)  ;
-                               t_b = 1;
+                               t_blue = true;
                        }
                        break;
                case NUM_TEAM_3:
-                       if(!t_y)
+                       if(!t_yellow)
                        {
                                nb_spawnteam("Yellow", e.team-1);
-                               t_y = 1;
+                               t_yellow = true;
                        }
                        break;
                case NUM_TEAM_4:
-                       if(!t_p)
+                       if(!t_pink)
                        {
                                nb_spawnteam("Pink", e.team-1)  ;
-                               t_p = 1;
+                               t_pink = true;
                        }
                        break;
                }
        }
 }
 
-// scoreboard setup
-void nb_ScoreRules(float teams)
-{
-       ScoreRules_basics(teams, 0, 0, TRUE);
-       ScoreInfo_SetLabel_TeamScore(   ST_NEXBALL_GOALS,  "goals", SFL_SORT_PRIO_PRIMARY);
-       ScoreInfo_SetLabel_PlayerScore( SP_NEXBALL_GOALS,  "goals", SFL_SORT_PRIO_PRIMARY);
-       ScoreInfo_SetLabel_PlayerScore(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
-       ScoreRules_basics_end();
-}
-
 void nb_delayedinit(void)
 {
        if(find(world, classname, "nexball_team") == world)
@@ -694,7 +695,7 @@ void W_Nexball_Touch(void)
 
        PROJECTILE_TOUCH;
        if(attacker.team != other.team || autocvar_g_nexball_basketball_teamsteal)
-               if((ball = other.ballcarried) && !other.deadflag && (IS_PLAYER(attacker)))
+               if((ball = other.ballcarried) && !other.frozen && !other.deadflag && (IS_PLAYER(attacker)))
                {
                        other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force;
                        other.flags &= ~FL_ONGROUND;
@@ -740,7 +741,7 @@ void W_Nexball_Attack(float t)
                mi = autocvar_g_nexball_basketball_meter_minpower;
                ma = max(mi, autocvar_g_nexball_basketball_meter_maxpower); // avoid confusion
                //One triangle wave period with 1 as max
-               mul = 2 * mod(t, g_nexball_meter_period) / g_nexball_meter_period;
+               mul = 2 * (t % g_nexball_meter_period) / g_nexball_meter_period;
                if(mul > 1)
                        mul = 2 - mul;
                mul = mi + (ma - mi) * mul; // range from the minimal power to the maximal power
@@ -893,9 +894,9 @@ MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink)
                        self.ballcarried.customizeentityforclient = ball_customize;
 
                        setorigin(self.ballcarried, self.origin + self.view_ofs +
-                                         v_forward * autocvar_g_nexball_viewmodel_offset_x +
-                                         v_right * autocvar_g_nexball_viewmodel_offset_y +
-                                         v_up * autocvar_g_nexball_viewmodel_offset_z);
+                                         v_forward * autocvar_g_nexball_viewmodel_offset.x +
+                                         v_right * autocvar_g_nexball_viewmodel_offset.y +
+                                         v_up * autocvar_g_nexball_viewmodel_offset.z);
 
                        // 'safe passing'
                        if(autocvar_g_nexball_safepass_maxdist)
@@ -1011,8 +1012,6 @@ MUTATOR_DEFINITION(gamemode_nexball)
                g_nexball_meter_period = rint(g_nexball_meter_period * 32) / 32; //Round to 1/32ths to send as a byte multiplied by 32
                addstat(STAT_NB_METERSTART, AS_FLOAT, metertime);
 
-               W_Porto(WR_INIT); // abuse
-
                // General settings
                /*
                CVTOV(g_nexball_football_boost_forward);   //100