]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/gamemode_nexball.qc
Merge branch 'master' into TimePath/global_self
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / gamemode_nexball.qc
index 9844875b3d9eb27ac56efc69049e59aed1a70f2c..fad911386c1bed56b6cf86a5f8fd90e74d77c42f 100644 (file)
@@ -51,26 +51,24 @@ void LogNB(string mode, entity actor)
 }
 
 void ball_restart(void)
-{
+{SELFPARAM();
        if(self.owner)
                DropBall(self, self.owner.origin, '0 0 0');
        ResetBall();
 }
 
 void nexball_setstatus(void)
-{
-       entity oldself;
+{SELFPARAM();
        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;
-                       self = self.ballcarried;
+                       setself(self.ballcarried);
                        DropBall(self, self.owner.origin, '0 0 0');
                        ResetBall();
-                       self = oldself;
+                       setself(this);
                }
                else
                        self.items |= IT_KEY1;
@@ -78,7 +76,7 @@ void nexball_setstatus(void)
 }
 
 void relocate_nexball(void)
-{
+{SELFPARAM();
        tracebox(self.origin, BALL_MINS, BALL_MAXS, self.origin, true, self);
        if(trace_startsolid)
        {
@@ -86,16 +84,16 @@ void relocate_nexball(void)
                o = self.origin;
                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");
+               LOG_INFO("^1NOTE: this map needs FIXING. ", self.classname, " at ", vtos(o - '0 0 1'));
+               LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(self.origin.x - o.x));
+               LOG_INFO(" ", ftos(self.origin.y - o.y));
+               LOG_INFO(" ", ftos(self.origin.z - o.z), "'\n");
                self.origin = o;
        }
 }
 
 void DropOwner(void)
-{
+{SELFPARAM();
        entity ownr;
        ownr = self.owner;
        DropBall(self, ownr.origin, ownr.velocity);
@@ -105,7 +103,7 @@ void DropOwner(void)
 }
 
 void GiveBall(entity plyr, entity ball)
-{
+{SELFPARAM();
        entity ownr;
 
        if((ownr = ball.owner))
@@ -144,7 +142,7 @@ void GiveBall(entity plyr, entity ball)
        ball.effects |= EF_NOSHADOW;
        ball.scale = 1; // scale down.
 
-       WaypointSprite_AttachCarrier("nb-ball", plyr, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR);
+       WaypointSprite_AttachCarrier(WP_NbBall, plyr, RADARICON_FLAGCARRIER);
        WaypointSprite_UpdateRule(plyr.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
 
        if(autocvar_g_nexball_basketball_delay_hold)
@@ -153,15 +151,14 @@ void GiveBall(entity plyr, entity ball)
                ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
        }
 
-       ownr = self;
-       self = plyr;
-       self.weaponentity.weapons = self.weapons;
-       self.weaponentity.switchweapon = self.weapon;
-       self.weapons = WEPSET_PORTO;
-       WEP_ACTION(WEP_PORTO, WR_RESETPLAYER);
-       self.switchweapon = WEP_PORTO;
-       W_SwitchWeapon(WEP_PORTO);
-       self = ownr;
+       plyr.weaponentity.weapons = plyr.weapons;
+       plyr.weaponentity.switchweapon = plyr.weapon;
+       plyr.weapons = WEPSET_PORTO;
+       setself(plyr);
+       WEP_ACTION(WEP_PORTO.m_id, WR_RESETPLAYER);
+       plyr.switchweapon = WEP_PORTO.m_id;
+       W_SwitchWeapon(WEP_PORTO.m_id);
+       setself(this);
 }
 
 void DropBall(entity ball, vector org, vector vel)
@@ -188,7 +185,7 @@ void DropBall(entity ball, vector org, vector vel)
        }
 
        WaypointSprite_Kill(ball.owner.waypointsprite_attachedforcarrier);
-       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_Spawn(WP_NbBall, 0, 0, ball, '0 0 64', world, ball.team, ball, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER); // no health bar please
        WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
 
        ball.owner.ballcarried = world;
@@ -196,7 +193,7 @@ void DropBall(entity ball, vector org, vector vel)
 }
 
 void InitBall(void)
-{
+{SELFPARAM();
        if(gameover) return;
        self.flags &= ~FL_ONGROUND;
        self.movetype = MOVETYPE_BOUNCE;
@@ -216,7 +213,7 @@ void InitBall(void)
 }
 
 void ResetBall(void)
-{
+{SELFPARAM();
        if(self.cnt < 2)        // step 1
        {
                if(time == self.teamtime)
@@ -241,7 +238,7 @@ void ResetBall(void)
        {
 //             dprint("Step 4: time: ", ftos(time), "\n");
                if(vlen(self.origin - self.spawnorigin) > 10)  // should not happen anymore
-                       dprint("The ball moved too far away from its spawn origin.\nOffset: ",
+                       LOG_TRACE("The ball moved too far away from its spawn origin.\nOffset: ",
                                   vtos(self.origin - self.spawnorigin), " Velocity: ", vtos(self.velocity), "\n");
                self.velocity = '0 0 0';
                setorigin(self, self.spawnorigin); // make sure it's positioned correctly anyway
@@ -252,7 +249,7 @@ void ResetBall(void)
 }
 
 void football_touch(void)
-{
+{SELFPARAM();
        if(other.solid == SOLID_BSP)
        {
                if(time > self.lastground + 0.1)
@@ -298,7 +295,7 @@ void football_touch(void)
 }
 
 void basketball_touch(void)
-{
+{SELFPARAM();
        if(other.ballcarried)
        {
                football_touch();
@@ -320,7 +317,7 @@ void basketball_touch(void)
 }
 
 void GoalTouch(void)
-{
+{SELFPARAM();
        entity ball;
        float isclient, pscore, otherteam;
        string pname;
@@ -412,7 +409,7 @@ void GoalTouch(void)
 //        team ents       //
 //=======================//
 void spawnfunc_nexball_team(void)
-{
+{SELFPARAM();
        if(!g_nexball)
        {
                remove(self);
@@ -423,7 +420,7 @@ void spawnfunc_nexball_team(void)
 
 void nb_spawnteam(string teamname, float teamcolor)
 {
-       dprint("^2spawned team ", teamname, "\n");
+       LOG_TRACE("^2spawned team ", teamname, "\n");
        entity e;
        e = spawn();
        e.classname = "nexball_team";
@@ -486,7 +483,7 @@ void nb_delayedinit(void)
 //=======================//
 
 void SpawnBall(void)
-{
+{SELFPARAM();
        if(!g_nexball) { remove(self); return; }
 
 //     balls += 4; // using the remaining bits to count balls will leave more than the max edict count, so it's fine
@@ -530,7 +527,7 @@ void SpawnBall(void)
        precache_sound(self.noise1);
        precache_sound(self.noise2);
 
-       WaypointSprite_AttachCarrier("nb-ball", self, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR); // the ball's team is not set yet, no rule update needed
+       WaypointSprite_AttachCarrier(WP_NbBall, self, RADARICON_FLAGCARRIER); // the ball's team is not set yet, no rule update needed
 
        self.reset = ball_restart;
        self.think = InitBall;
@@ -538,7 +535,7 @@ void SpawnBall(void)
 }
 
 void spawnfunc_nexball_basketball(void)
-{
+{SELFPARAM();
        nexball_mode |= NBM_BASKETBALL;
        self.classname = "nexball_basketball";
        if (!(balls & BALL_BASKET))
@@ -561,7 +558,7 @@ void spawnfunc_nexball_basketball(void)
 }
 
 void spawnfunc_nexball_football(void)
-{
+{SELFPARAM();
        nexball_mode |= NBM_FOOTBALL;
        self.classname = "nexball_football";
        self.solid = SOLID_TRIGGER;
@@ -572,7 +569,7 @@ void spawnfunc_nexball_football(void)
 }
 
 float nb_Goal_Customize()
-{
+{SELFPARAM();
        entity e, wp_owner;
        e = WaypointSprite_getviewentity(other);
        wp_owner = self.owner;
@@ -582,14 +579,15 @@ float nb_Goal_Customize()
 }
 
 void SpawnGoal(void)
-{
+{SELFPARAM();
        if(!g_nexball) { remove(self); return; }
 
        EXACTTRIGGER_INIT;
 
        if(self.team != GOAL_OUT && Team_TeamToNumber(self.team) != -1)
        {
-               WaypointSprite_SpawnFixed("goal", (self.absmin + self.absmax) * 0.5, self, sprite, RADARICON_NONE, ((self.team) ? Team_ColorRGB(self.team) : '1 0.5 0'));
+               entity wp = WaypointSprite_SpawnFixed(WP_NbGoal, (self.absmin + self.absmax) * 0.5, self, sprite, RADARICON_NONE);
+               wp.colormod = ((self.team) ? Team_ColorRGB(self.team) : '1 0.5 0');
                self.sprite.customizeentityforclient = nb_Goal_Customize;
        }
 
@@ -601,28 +599,28 @@ void SpawnGoal(void)
 }
 
 void spawnfunc_nexball_redgoal(void)
-{
+{SELFPARAM();
        self.team = NUM_TEAM_1;
        SpawnGoal();
 }
 void spawnfunc_nexball_bluegoal(void)
-{
+{SELFPARAM();
        self.team = NUM_TEAM_2;
        SpawnGoal();
 }
 void spawnfunc_nexball_yellowgoal(void)
-{
+{SELFPARAM();
        self.team = NUM_TEAM_3;
        SpawnGoal();
 }
 void spawnfunc_nexball_pinkgoal(void)
-{
+{SELFPARAM();
        self.team = NUM_TEAM_4;
        SpawnGoal();
 }
 
 void spawnfunc_nexball_fault(void)
-{
+{SELFPARAM();
        self.team = GOAL_FAULT;
        if(self.noise == "")
                self.noise = "misc/typehit.wav";
@@ -630,7 +628,7 @@ void spawnfunc_nexball_fault(void)
 }
 
 void spawnfunc_nexball_out(void)
-{
+{SELFPARAM();
        self.team = GOAL_OUT;
        if(self.noise == "")
                self.noise = "misc/typehit.wav";
@@ -677,7 +675,7 @@ void spawnfunc_ball_bound(void)
 
 
 void W_Nexball_Think()
-{
+{SELFPARAM();
        //dprint("W_Nexball_Think\n");
        //vector new_dir = steerlib_arrive(self.enemy.origin, 2500);
        vector new_dir = normalize(self.enemy.origin + '0 0 50' - self.origin);
@@ -692,7 +690,7 @@ void W_Nexball_Think()
 }
 
 void W_Nexball_Touch(void)
-{
+{SELFPARAM();
        entity ball, attacker;
        attacker = self.owner;
        //self.think = func_null;
@@ -723,7 +721,7 @@ void W_Nexball_Touch(void)
 }
 
 void W_Nexball_Attack(float t)
-{
+{SELFPARAM();
        entity ball;
        float mul, mi, ma;
        if(!(ball = self.ballcarried))
@@ -759,7 +757,7 @@ void W_Nexball_Attack(float t)
 }
 
 void W_Nexball_Attack2(void)
-{
+{SELFPARAM();
        if(self.ballcarried.enemy)
        {
                entity _ball = self.ballcarried;
@@ -777,7 +775,6 @@ void W_Nexball_Attack2(void)
        if(!(balls & BALL_BASKET))
                return;
        W_SetupShot(self, false, 2, "nexball/shoot2.wav", CH_WEAPON_A, 0);
-//     pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
        missile = spawn();
 
        missile.owner = self;
@@ -803,7 +800,7 @@ void W_Nexball_Attack2(void)
 }
 
 float ball_customize()
-{
+{SELFPARAM();
        if(!self.owner)
        {
                self.effects &= ~EF_FLAME;
@@ -830,7 +827,7 @@ float ball_customize()
 }
 
 float w_nexball_weapon(float req)
-{
+{SELFPARAM();
        if(req == WR_THINK)
        {
                if(self.BUTTON_ATCK)
@@ -863,9 +860,9 @@ float w_nexball_weapon(float req)
        }
        else if(req == WR_INIT)
        {
-               precache_model("models/weapons/g_porto.md3");
-               precache_model("models/weapons/v_porto.md3");
-               precache_model("models/weapons/h_porto.iqm");
+               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");
@@ -873,14 +870,14 @@ float w_nexball_weapon(float req)
        }
        else if(req == WR_SETUP)
        {
-               //weapon_setup(WEP_PORTO);
+               //weapon_setup(WEP_PORTO.m_id);
        }
        // No need to check WR_CHECKAMMO* or WR_AIM, it should always return true
        return true;
 }
 
 MUTATOR_HOOKFUNCTION(nexball_BallDrop)
-{
+{SELFPARAM();
        if(self.ballcarried && g_nexball)
                DropBall(self.ballcarried, self.origin, self.velocity);
 
@@ -888,7 +885,7 @@ MUTATOR_HOOKFUNCTION(nexball_BallDrop)
 }
 
 MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink)
-{
+{SELFPARAM();
        makevectors(self.v_angle);
        if(nexball_mode & NBM_BASKETBALL)
        {
@@ -936,7 +933,7 @@ MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink)
                        if(self.weaponentity.weapons)
                        {
                                self.weapons = self.weaponentity.weapons;
-                               WEP_ACTION(WEP_PORTO, WR_RESETPLAYER);
+                               WEP_ACTION(WEP_PORTO.m_id, WR_RESETPLAYER);
                                self.switchweapon = self.weaponentity.switchweapon;
                                W_SwitchWeapon(self.switchweapon);
 
@@ -952,7 +949,7 @@ MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink)
 }
 
 MUTATOR_HOOKFUNCTION(nexball_PlayerSpawn)
-{
+{SELFPARAM();
        self.weaponentity.weapons = '0 0 0';
 
        if(nexball_mode & NBM_BASKETBALL)
@@ -964,7 +961,7 @@ MUTATOR_HOOKFUNCTION(nexball_PlayerSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(nexball_PlayerPhysics)
-{
+{SELFPARAM();
        if(self.ballcarried)
        {
                self.stat_sv_airspeedlimit_nonqw *= autocvar_g_nexball_basketball_carrier_highspeed;
@@ -981,17 +978,17 @@ MUTATOR_HOOKFUNCTION(nexball_SetStartItems)
 }
 
 MUTATOR_HOOKFUNCTION(nexball_ForbidThrowing)
-{
-       if(self.weapon == WEP_MORTAR)
+{SELFPARAM();
+       if(self.weapon == WEP_MORTAR.m_id)
                return true;
 
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(nexball_FilterItem)
-{
+{SELFPARAM();
        if(self.classname == "droppedweapon")
-       if(self.weapon == WEP_MORTAR)
+       if(self.weapon == WEP_MORTAR.m_id)
                return true;
 
        return false;
@@ -1038,7 +1035,7 @@ MUTATOR_DEFINITION(gamemode_nexball)
 
        MUTATOR_ONREMOVE
        {
-               print("This is a game type and it cannot be removed at runtime.");
+               LOG_INFO("This is a game type and it cannot be removed at runtime.");
                return -1;
        }