]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/nexball.qc
Merge remote branch 'origin/master' into samual/mutator_ctf
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / nexball.qc
index eb2bed54bd32ab7f55d1710d14427aaae72b24e8..d3f4b55f4a49acf42693df6e04df24942a1b99f3 100644 (file)
@@ -28,6 +28,9 @@ float nb_teams;
 
 .float teamtime;
 
+.float nb_dropperid;
+.float nb_droptime;
+
 void nb_delayedinit();
 void nb_init() // Called early (worldspawn stage)
 {
@@ -43,7 +46,7 @@ void nb_init() // Called early (worldspawn stage)
        CVTOV(g_nexball_delay_idle);               //10
        CVTOV(g_nexball_football_physics);         //0
 
-       radar_showennemies = cvar("g_nexball_radar_showallplayers");
+       radar_showennemies = autocvar_g_nexball_radar_showallplayers;
 
        InitializeEntity(world, nb_delayedinit, INITPRIO_GAMETYPE);
 }
@@ -62,7 +65,7 @@ void ResetBall();
 void LogNB(string mode, entity actor)
 {
        string s;
-       if(!cvar("sv_eventlog"))
+       if(!autocvar_sv_eventlog)
                return;
        s = strcat(":nexball:", mode);
        if(actor != world)
@@ -79,7 +82,7 @@ void ball_restart (void)
 
 void nexball_setstatus (void)
 {
-       local entity oldself;
+       entity oldself;
        self.items &~= IT_KEY1;
        if (self.ballcarried)
        {
@@ -118,7 +121,7 @@ void football_touch();
 
 void DropOwner (void)
 {
-       local entity ownr;
+       entity ownr;
        ownr = self.owner;
        DropBall(self, ownr.origin, ownr.velocity);
        makevectors(ownr.v_angle_y * '0 1 0');
@@ -128,7 +131,7 @@ void DropOwner (void)
 
 void GiveBall (entity plyr, entity ball)
 {
-       local entity ownr;
+       entity ownr;
 
        if ((ownr = ball.owner))
        {
@@ -155,7 +158,7 @@ void GiveBall (entity plyr, entity ball)
        ball.owner = ball.pusher = plyr; //"owner" is set to the player carrying, "pusher" to the last player who touched it
        ball.team = plyr.team;
        plyr.ballcarried = ball;
-       ball.dropperid = plyr.playerid;
+       ball.nb_dropperid = plyr.playerid;
 
        plyr.effects |= g_nexball_basketball_effects_default;
        ball.effects &~= g_nexball_basketball_effects_default;
@@ -166,9 +169,8 @@ void GiveBall (entity plyr, entity ball)
        ball.effects |= EF_NOSHADOW;
        ball.scale = 1; // scale down.
 
-       WaypointSprite_AttachCarrier("nb-ball", plyr);
+       WaypointSprite_AttachCarrier("nb-ball", plyr, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR);
        WaypointSprite_UpdateRule(plyr.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
-       WaypointSprite_UpdateTeamRadar(plyr.waypointsprite_attachedforcarrier, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR);
 
        if (g_nexball_basketball_delay_hold)
        {
@@ -189,7 +191,7 @@ void DropBall (entity ball, vector org, vector vel)
        ball.flags &~= FL_ONGROUND;
        ball.scale = ball_scale;
        ball.velocity = vel;
-       ball.ctf_droptime = time;
+       ball.nb_droptime = time;
        ball.touch = basketball_touch;
        ball.think = ResetBall;
        ball.nextthink = min(time + g_nexball_delay_idle, ball.teamtime);
@@ -201,10 +203,8 @@ void DropBall (entity ball, vector org, vector vel)
        }
 
        WaypointSprite_Kill(ball.owner.waypointsprite_attachedforcarrier);
-       //WaypointSprite_AttachCarrier("nb-ball", ball);
-       WaypointSprite_Spawn("nb-ball", 0, 0, ball, '0 0 64', world, ball.team, ball, waypointsprite_attachedforcarrier, FALSE); // no health bar please
+       WaypointSprite_Spawn("nb-ball", 0, 0, ball, '0 0 64', world, ball.team, ball, waypointsprite_attachedforcarrier, FALSE, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR); // no health bar please
        WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
-       WaypointSprite_UpdateTeamRadar(ball.waypointsprite_attachedforcarrier, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR);
 
        ball.owner.ballcarried = world;
        ball.owner = world;
@@ -225,7 +225,7 @@ void InitBall (void)
        self.teamtime = 0;
        self.pusher = world;
        self.team = FALSE;
-       sound (self, CHAN_PROJECTILE, self.noise1, VOL_BASE, ATTN_NORM);
+       sound (self, CH_TRIGGER, self.noise1, VOL_BASE, ATTN_NORM);
        WaypointSprite_Ping(self.waypointsprite_attachedforcarrier);
        LogNB("init", world);
 }
@@ -256,7 +256,7 @@ void ResetBall (void)
                setorigin(self, self.spawnorigin); // make sure it's positioned correctly anyway
                self.movetype = MOVETYPE_NONE;
                self.think = InitBall;
-               self.nextthink = max(time, game_starttime) + cvar("g_nexball_delay_start");
+               self.nextthink = max(time, game_starttime) + autocvar_g_nexball_delay_start;
        }
 }
 
@@ -265,7 +265,7 @@ void football_touch (void)
        if (other.solid == SOLID_BSP) {
                if (time > self.lastground + 0.1)
                {
-                       sound (self, CHAN_PROJECTILE, self.noise, VOL_BASE, ATTN_NORM);
+                       sound (self, CH_TRIGGER, self.noise, VOL_BASE, ATTN_NORM);
                        self.lastground = time;
                }
                if (vlen(self.velocity) && !self.cnt)
@@ -305,13 +305,13 @@ void basketball_touch (void)
                football_touch();
                return;
        }
-       if (!self.cnt && other.classname == "player" && (other.playerid != self.dropperid || time > self.ctf_droptime + cvar("g_nexball_delay_collect"))) {
+       if (!self.cnt && other.classname == "player" && (other.playerid != self.nb_dropperid || time > self.nb_droptime + autocvar_g_nexball_delay_collect)) {
                if (other.health <= 0)
                        return;
                LogNB("caught", other);
                GiveBall(other, self);
        } else if (other.solid == SOLID_BSP) {
-               sound (self, CHAN_PROJECTILE, self.noise, VOL_BASE, ATTN_NORM);
+               sound (self, CH_TRIGGER, self.noise, VOL_BASE, ATTN_NORM);
                if (vlen(self.velocity) && !self.cnt)
                        self.nextthink = min(time + g_nexball_delay_idle, self.teamtime);
        }
@@ -369,7 +369,7 @@ void GoalTouch (void)
                pscore = 1;
        }
 
-       sound (ball, CHAN_AUTO, self.noise, VOL_BASE, ATTN_NONE);
+       sound (ball, CH_TRIGGER, self.noise, VOL_BASE, ATTN_NONE);
 
        if(ball.team && pscore)
        {
@@ -395,7 +395,7 @@ void GoalTouch (void)
        ball.think = ResetBall;
        if (ball.classname == "nexball_basketball")
                ball.touch = football_touch; // better than SUB_Null: football control until the ball gets reset
-       ball.nextthink = time + cvar("g_nexball_delay_goal") * (self.team != GOAL_OUT);
+       ball.nextthink = time + autocvar_g_nexball_delay_goal * (self.team != GOAL_OUT);
 }
 
 //=======================//
@@ -410,14 +410,14 @@ void spawnfunc_nexball_team (void)
 void nb_spawnteam (string teamname, float teamcolor)
 {
        dprint("^2spawned team ", teamname, "\n");
-       local entity e;
+       entity e;
        e = spawn();
        e.classname = "nexball_team";
        e.netname = teamname;
        e.cnt = teamcolor;
        e.team = e.cnt + 1;
        nb_teams += 1;
-};
+}
 
 void nb_spawnteams (void)
 {
@@ -470,13 +470,13 @@ void SpawnBall (void)
 
        if (cvar(strcat("g_", self.classname, "_trail"))) //nexball_basketball :p
        {
-               self.glow_color = cvar("g_nexball_trail_color");
+               self.glow_color = autocvar_g_nexball_trail_color;
                self.glow_trail = TRUE;
        }
 
        self.movetype = MOVETYPE_FLY;
 
-       if (!cvar("g_nexball_sound_bounce"))
+       if (!autocvar_g_nexball_sound_bounce)
                self.noise = "";
        else if (!self.noise)
                self.noise = "sound/nexball/bounce.wav";
@@ -491,12 +491,11 @@ void SpawnBall (void)
        precache_sound (self.noise1);
        precache_sound (self.noise2);
 
-       WaypointSprite_AttachCarrier("nb-ball", self); // the ball's team is not set yet, no rule update needed
-       WaypointSprite_UpdateTeamRadar(self.waypointsprite_attachedforcarrier, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR);
+       WaypointSprite_AttachCarrier("nb-ball", self, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR); // the ball's team is not set yet, no rule update needed
 
        self.reset = ball_restart;
        self.think = InitBall;
-       self.nextthink = game_starttime + cvar("g_nexball_delay_start");
+       self.nextthink = game_starttime + autocvar_g_nexball_delay_start;
 }
 
 void spawnfunc_nexball_basketball (void)
@@ -514,8 +513,8 @@ void spawnfunc_nexball_basketball (void)
                self.effects = g_nexball_basketball_effects_default;
        self.solid = SOLID_TRIGGER;
        balls |= BALL_BASKET;
-       self.bouncefactor = cvar("g_nexball_basketball_bouncefactor");
-       self.bouncestop = cvar("g_nexball_basketball_bouncestop");
+       self.bouncefactor = autocvar_g_nexball_basketball_bouncefactor;
+       self.bouncestop = autocvar_g_nexball_basketball_bouncestop;
        SpawnBall();
 }
 
@@ -524,8 +523,8 @@ void spawnfunc_nexball_football (void)
        self.classname = "nexball_football";
        self.solid = SOLID_TRIGGER;
        balls |= BALL_FOOT;
-       self.bouncefactor = cvar("g_nexball_football_bouncefactor");
-       self.bouncestop = cvar("g_nexball_football_bouncestop");
+       self.bouncefactor = autocvar_g_nexball_football_bouncefactor;
+       self.bouncestop = autocvar_g_nexball_football_bouncestop;
        SpawnBall();
 }
 
@@ -596,19 +595,19 @@ void spawnfunc_ball_bound      (void) { spawnfunc_nexball_out(); }
 
 void W_Nexball_Touch (void)
 {
-       local entity ball, attacker;
+       entity ball, attacker;
        attacker = self.owner;
 
        PROJECTILE_TOUCH;
        if(attacker.team != other.team || g_nexball_basketball_teamsteal)
-       if((ball = other.ballcarried) && (attacker.classname == "player" || attacker.classname == "gib"))
+       if((ball = other.ballcarried) && (attacker.classname == "player"))
        {
-               other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * cvar("g_balance_nexball_secondary_force");
+               other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force;
                other.flags &~= FL_ONGROUND;
                if(!attacker.ballcarried)
                {
                        LogNB("stole", attacker);
-                       sound (other, CHAN_AUTO, ball.noise2, VOL_BASE, ATTN_NORM);
+                       sound (other, CH_TRIGGER, ball.noise2, VOL_BASE, ATTN_NORM);
 
                        if(attacker.team == other.team && time > attacker.teamkill_complain)
                        {
@@ -625,12 +624,12 @@ void W_Nexball_Touch (void)
 
 void W_Nexball_Attack (float t)
 {
-       local entity ball;
-       local float mul, mi, ma;
+       entity ball;
+       float mul, mi, ma;
        if (!(ball = self.ballcarried))
                return;
 
-       W_SetupShot (self, FALSE, 4, "nexball/shoot1.wav", CHAN_WEAPON, 0);
+       W_SetupShot (self, FALSE, 4, "nexball/shoot1.wav", CH_WEAPON_A, 0);
        tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, world);
        if(trace_startsolid)
        {
@@ -644,24 +643,24 @@ void W_Nexball_Attack (float t)
                mul = 1;
        else
        {
-               mi = cvar("g_nexball_basketball_meter_minpower");
-               ma = max(mi, cvar("g_nexball_basketball_meter_maxpower")); // avoid confusion
+               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;
                if (mul > 1)
                        mul = 2 - mul;
                mul = mi + (ma - mi) * mul; // range from the minimal power to the maximal power
        }
-       DropBall (ball, w_shotorg, W_CalculateProjectileVelocity(self.velocity, w_shotdir * cvar("g_balance_nexball_primary_speed") * mul, FALSE));
+       DropBall (ball, w_shotorg, W_CalculateProjectileVelocity(self.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, FALSE));
        //TODO: use the speed_up cvar too ??
 }
 
 void W_Nexball_Attack2 (void)
 {
-       local entity missile;
+       entity missile;
        if (!(balls & BALL_BASKET))
                return;
-       W_SetupShot (self, FALSE, 2, "nexball/shoot2.wav", CHAN_WEAPON, 0);
+       W_SetupShot (self, FALSE, 2, "nexball/shoot2.wav", CH_WEAPON_A, 0);
 //     pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
        missile = spawn ();
 
@@ -675,11 +674,11 @@ void W_Nexball_Attack2 (void)
        setsize (missile, '0 0 0', '0 0 0');
        setorigin (missile, w_shotorg);
 
-       W_SetupProjectileVelocity(missile, cvar("g_balance_nexball_secondary_speed"), 0);
+       W_SetupProjectileVelocity(missile, autocvar_g_balance_nexball_secondary_speed, 0);
        missile.angles = vectoangles (missile.velocity);
        missile.touch = W_Nexball_Touch;
        missile.think = SUB_Remove;
-       missile.nextthink = time + cvar("g_balance_nexball_secondary_lifetime"); //FIXME: use a distance instead?
+       missile.nextthink = time + autocvar_g_balance_nexball_secondary_lifetime; //FIXME: use a distance instead?
 
        missile.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
        missile.flags = FL_PROJECTILE;
@@ -690,41 +689,42 @@ float w_nexball_weapon(float req)
        if (req == WR_THINK)
        {
                if (self.BUTTON_ATCK)
-               if (weapon_prepareattack(0, cvar("g_balance_nexball_primary_refire")))
-               if (cvar("g_nexball_basketball_meter"))
+               if (weapon_prepareattack(0, autocvar_g_balance_nexball_primary_refire))
+               if (autocvar_g_nexball_basketball_meter)
                {
                        if (self.ballcarried && !self.metertime)
                                self.metertime = time;
                        else
-                               weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_nexball_primary_animtime"), w_ready);
+                               weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
                }
                else
                {
                        W_Nexball_Attack(-1);
-                       weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_nexball_primary_animtime"), w_ready);
+                       weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
                }
                if (self.BUTTON_ATCK2)
-               if (weapon_prepareattack(1, cvar("g_balance_nexball_secondary_refire")))
+               if (weapon_prepareattack(1, autocvar_g_balance_nexball_secondary_refire))
                {
                        W_Nexball_Attack2();
-                       weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_nexball_secondary_animtime"), w_ready);
+                       weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
                }
 
                if (!self.BUTTON_ATCK && self.metertime && self.ballcarried)
                {
                        W_Nexball_Attack(time - self.metertime);
                        // DropBall or stealing will set metertime back to 0
-                       weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_nexball_primary_animtime"), w_ready);
+                       weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
                }
        }
        else if (req == WR_PRECACHE)
        {
                precache_model ("models/weapons/g_porto.md3");
                precache_model ("models/weapons/v_porto.md3");
-               precache_model ("models/weapons/h_porto.dpm");
+               precache_model ("models/weapons/h_porto.iqm");
                precache_model ("models/elaser.mdl");
                precache_sound ("nexball/shoot1.wav");
                precache_sound ("nexball/shoot2.wav");
+               precache_sound ("misc/typehit.wav");
        }
        else if (req == WR_SETUP)
                weapon_setup(WEP_PORTO);