]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/gamemode_keepaway.qc
Merge branch 'master' into samual/keepaway
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / gamemode_keepaway.qc
index c771ab173f9d1881076ae69f058d13377e7c0023..04939e8398fe42dc06e7bdc98ed41c347c76279e 100644 (file)
@@ -28,7 +28,7 @@ void ka_Reset() // used to clear the ballcarrier whenever the match switches fro
        ka_RespawnBall();
 }
 
-void ka_SpawnBall() // loads various values for the ball
+void ka_SpawnBall() // loads various values for the ball, runs only once at start of match
 {
        if(!g_keepaway) { return; }
        
@@ -40,9 +40,9 @@ void ka_SpawnBall() // loads various values for the ball
        setmodel(e, e.model);
        setsize(e, '-16 -16 -20', '16 16 20'); // 20 20 20 was too big, player is only 16 16 24... gotta cheat with the Z (20) axis so that the particle isn't cut off
        e.classname = "keepawayball";
-       e.damageforcescale = cvar("g_keepawayball_damageforcescale");
+       e.damageforcescale = autocvar_g_keepawayball_damageforcescale;
        e.takedamage = DAMAGE_YES;
-       e.glow_color = cvar("g_keepawayball_trail_color");
+       e.glow_color = autocvar_g_keepawayball_trail_color;
        e.glow_trail = TRUE;
        e.movetype = MOVETYPE_BOUNCE;
        e.touch = ka_TouchEvent;
@@ -65,7 +65,7 @@ void ka_RespawnBall() // runs whenever the ball needs to be relocated
                self.angles = '0 0 0';
                self.solid = SOLID_TRIGGER;
                self.think = ka_RespawnBall;
-               self.nextthink = time + cvar("g_keepawayball_respawntime");
+               self.nextthink = time + autocvar_g_keepawayball_respawntime;
                
                pointparticles(particleeffectnum("electro_combo"), oldballorigin, '0 0 0', 1);
                pointparticles(particleeffectnum("electro_combo"), self.origin, '0 0 0', 1);
@@ -103,7 +103,7 @@ void ka_TouchEvent() // runs any time that the ball comes in contact with someth
        self.owner = other;
        other.ballcarried = self;
        setattachment(self, other, "");
-       setorigin(self, '3 0 20');
+       setorigin(self, '3 0 20'); // wtf why is this not '0 0 0' ? 
        
        // make the ball invisible/unable to do anything
        self.velocity = '0 0 0';
@@ -115,11 +115,11 @@ void ka_TouchEvent() // runs any time that the ball comes in contact with someth
        self.takedamage = DAMAGE_NO;
 
        // apply effects to player
-       other.glow_color = cvar("g_keepawayball_trail_color");
+       other.glow_color = autocvar_g_keepawayball_trail_color;
        other.glow_trail = TRUE;
        other.effects |= EF_DIMLIGHT;
-       other.alpha = cvar("g_keepaway_ballcarrier_alpha");
-       other.exteriorweaponentity.alpha = cvar("g_keepaway_ballcarrier_alpha");
+       other.alpha = autocvar_g_keepaway_ballcarrier_alpha;
+       other.exteriorweaponentity.alpha = autocvar_g_keepaway_ballcarrier_alpha;
 
        // messages and sounds
        Send_KillNotification(other.netname, "", "", KA_PICKUPBALL, MSG_KA);
@@ -152,7 +152,7 @@ void ka_DropEvent(entity plyr) // runs any time that a player is supposed to los
        ball.solid = SOLID_TRIGGER; // is this needed? 
        ball.wait = time + 1; 
        ball.think = ka_RespawnBall;
-       ball.nextthink = time + cvar("g_keepawayball_respawntime");
+       ball.nextthink = time + autocvar_g_keepawayball_respawntime;
        ball.touch = ka_TouchEvent;
        ball.takedamage = DAMAGE_YES;
        ball.effects &~= EF_NODRAW; 
@@ -162,10 +162,10 @@ void ka_DropEvent(entity plyr) // runs any time that a player is supposed to los
        ball.owner = world;
        
        // reset the player effects
+       plyr.glow_trail = FALSE;
        plyr.effects &~= EF_DIMLIGHT;
        plyr.alpha = default_player_alpha;
        plyr.exteriorweaponentity.alpha = default_weapon_alpha; 
-       plyr.glow_trail = FALSE;
        
        // messages and sounds
        Send_KillNotification(plyr.netname, "", "", KA_DROPBALL, MSG_KA);
@@ -187,12 +187,10 @@ void ka_DropEvent(entity plyr) // runs any time that a player is supposed to los
 float ka_ballcarrier_waypointsprite_visible_for_player(entity e) // runs on waypoints which are attached to ballcarriers, updates once per frame 
 {
        if(e.ballcarried)
-       {
                if(other.classname == "spectator") 
                        return FALSE; // we don't want spectators of the ballcarrier to see the attached waypoint on the top of their screen
-               else if(g_minstagib && (e.items & IT_STRENGTH))
-                       return FALSE; // if the ballcarrier has invisibility, don't draw the waypoint as this is the function of invisibility in keepaway
-       }
+               
+       // TODO: Make the ballcarrier lack a waypointsprite whenever they have the invisibility powerup
 
        return TRUE;
 }
@@ -209,11 +207,11 @@ MUTATOR_HOOKFUNCTION(ka_Scoring)
        {
                if(frag_target.ballcarried) { // add to amount of times killing carrier
                        PlayerScore_Add(frag_attacker, SP_KEEPAWAY_CARRIERKILLS, 1);
-                       if(cvar("g_keepaway_bckillscore")) // add bckills to the score
+                       if(autocvar_g_keepaway_bckillscore) // add bckills to the score
                                PlayerScore_Add(frag_attacker, SP_KEEPAWAY_SCORE, 1);
                }
                else if(!frag_attacker.ballcarried)
-                       if(cvar("g_keepaway_noncarrier_warn"))
+                       if(autocvar_g_keepaway_noncarrier_warn)
                                centerprint_atprio(frag_attacker, (CENTERPRIO_SPAM + 5), "Killing people while you don't have the ball gives no points!");
 
                if(frag_attacker.ballcarried) // add to amount of kills while ballcarrier
@@ -252,26 +250,26 @@ MUTATOR_HOOKFUNCTION(ka_PlayerDamage) // for changing damage and force values th
        {
                if(frag_target == frag_attacker) // damage done to yourself
                {
-                       frag_damage *= cvar("g_keepaway_ballcarrier_selfdamage");
-                       frag_force *= cvar("g_keepaway_ballcarrier_selfforce");
+                       frag_damage *= autocvar_g_keepaway_ballcarrier_selfdamage;
+                       frag_force *= autocvar_g_keepaway_ballcarrier_selfforce;
                }
                else // damage done to noncarriers
                {
-                       frag_damage *= cvar("g_keepaway_ballcarrier_damage");
-                       frag_force *= cvar("g_keepaway_ballcarrier_force");
+                       frag_damage *= autocvar_g_keepaway_ballcarrier_damage;
+                       frag_force *= autocvar_g_keepaway_ballcarrier_force;
                }
        }
        else if not(frag_target.ballcarried) // if the target is a noncarrier
        {
                if(frag_target == frag_attacker) // damage done to yourself
                {
-                       frag_damage *= cvar("g_keepaway_noncarrier_selfdamage");
-                       frag_force *= cvar("g_keepaway_noncarrier_selfforce");
+                       frag_damage *= autocvar_g_keepaway_noncarrier_selfdamage;
+                       frag_force *= autocvar_g_keepaway_noncarrier_selfforce;
                }
                else // damage done to other noncarriers
                {
-                       frag_damage *= cvar("g_keepaway_noncarrier_damage");
-                       frag_force *= cvar("g_keepaway_noncarrier_force");
+                       frag_damage *= autocvar_g_keepaway_noncarrier_damage;
+                       frag_force *= autocvar_g_keepaway_noncarrier_force;
                }
        }
        return 0;
@@ -279,29 +277,25 @@ MUTATOR_HOOKFUNCTION(ka_PlayerDamage) // for changing damage and force values th
 
 MUTATOR_HOOKFUNCTION(ka_PlayerPowerups)
 {
+       // right now this hook doesn't make much sense (It's actually useless this way except for minstagib invisibility alpha) 
+       // but in the future it's supposed to allow me to do some extra stuff with waypointsprites and invisibility powerup
+       // So bare with me until I can fix a certain bug with ka_ballcarrier_waypointsprite_visible_for_player() 
+       
+       // also note that this structure makes no sense (Rather there is a better way to do it) the way it's currently applied
+       // again just bare with me as this is for a future feature. 
+
        if(self.ballcarried)
        { 
-               // if the player has the ball, force ballcarrier alpha upon them
-               self.alpha = cvar("g_keepaway_ballcarrier_alpha");
-               self.exteriorweaponentity.alpha = cvar("g_keepaway_ballcarrier_alpha");
+               // force the default ballcarrier alpha on the player if they have the ball
+               self.alpha = autocvar_g_keepaway_ballcarrier_alpha;
+               self.exteriorweaponentity.alpha = autocvar_g_keepaway_ballcarrier_alpha;
        
-               // if we're in minstagib and a ballcarrier has just picked up invisibility, 
-               // notify all the other players that the ballcarrier no longer has a waypoint
                if(g_minstagib)
                {
                        if(olditems & IT_STRENGTH) 
-                       {
-                               if(time > self.strength_finished) 
-                               {       // this only runs ONCE right after the player loses invisibility
-                                       bprint(self.netname, "^7 isn't invisible from radar anymore.\n");
-                               }
-                       }
-                       else 
-                       {
-                               if(time < self.strength_finished)
-                               {       // this only runs ONCE right after the player gains invisibility
-                                       bprint(self.netname, "^7 has picked up invisibility and can no longer be seen on radar!\n");
-                               }
+                       { // if the player has the ball and they also have the invisibility powerup, apply alpha accordingly
+                               self.alpha = g_minstagib_invis_alpha;
+                               self.exteriorweaponentity.alpha = g_minstagib_invis_alpha;
                        }
                }
        }
@@ -351,4 +345,4 @@ MUTATOR_DEFINITION(gamemode_keepaway)
        }
 
        return 0;
-}
\ No newline at end of file
+}