]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Buffs: make team field available for item teaming, some polishing
authorbones_was_here <bones_was_here@xa.org.au>
Fri, 2 Oct 2020 03:51:12 +0000 (13:51 +1000)
committerbones_was_here <bones_was_here@xa.org.au>
Fri, 2 Oct 2020 03:51:12 +0000 (13:51 +1000)
qcsrc/common/mutators/mutator/buffs/buffs.qh
qcsrc/common/mutators/mutator/buffs/sv_buffs.qc
qcsrc/common/mutators/mutator/buffs/sv_buffs.qh
qcsrc/server/teamplay.qc
qcsrc/server/teamplay.qh

index c0ccf5803278a2aab53db5accfa180e50d3011ae..f88cda3a24d229ac7902be9cae9f632ef77487ea 100644 (file)
@@ -49,7 +49,8 @@ STATIC_INIT(REGISTER_BUFFS) {
        void buff_Init_Compat(entity ent, entity replacement);
        #define BUFF_SPAWNFUNC(e, b, t) spawnfunc(item_buff_##e) { \
                STAT(BUFFS, this) = b.m_itemid; \
-               this.team = t; \
+               if(teamplay) \
+                       this.team_forced = t; \
                buff_Init(this); \
        }
        #define BUFF_SPAWNFUNCS(e, b)                       \
index be310669d1c5fed1923c0ec9ba86f3c8bca649fd..88fd6aa73128469763ef254fb227682798a0425a 100644 (file)
@@ -59,7 +59,7 @@ void buffs_BuffModel_Spawn(entity player)
 
 vector buff_GlowColor(entity buff)
 {
-       //if(buff.team) { return Team_ColorRGB(buff.team); }
+       //if(buff.team_forced) { return Team_ColorRGB(buff.team_forced); }
        return buff.m_color;
 }
 
@@ -93,7 +93,7 @@ void buff_Waypoint_Spawn(entity e)
        if(autocvar_g_buffs_waypoint_distance <= 0) return;
 
        entity buff = buff_FirstFromFlags(STAT(BUFFS, e));
-       entity wp = WaypointSprite_Spawn(WP_Buff, 0, autocvar_g_buffs_waypoint_distance, e, '0 0 1' * e.maxs.z, NULL, e.team, e, buff_waypoint, true, RADARICON_Buff);
+       entity wp = WaypointSprite_Spawn(WP_Buff, 0, autocvar_g_buffs_waypoint_distance, e, '0 0 1' * e.maxs.z, NULL, e.team_forced, e, buff_waypoint, true, RADARICON_Buff);
        wp.wp_extra = buff.m_id;
        WaypointSprite_UpdateTeamRadar(e.buff_waypoint, RADARICON_Buff, e.glowmod);
        e.buff_waypoint.waypointsprite_visible_for_player = buff_Waypoint_visible_for_player;
@@ -168,7 +168,7 @@ void buff_Touch(entity this, entity toucher)
        if(!IS_PLAYER(toucher))
                return; // incase mutator changed toucher
 
-       if((this.team && DIFF_TEAM(toucher, this))
+       if((this.team_forced && toucher.team != this.team_forced)
        || (STAT(FROZEN, toucher))
        || (toucher.vehicle)
        || (time < PS(toucher).buff_shield)
@@ -301,7 +301,7 @@ void buff_Think(entity this)
 
        if(this.buff_active)
        {
-               if(this.team && !this.buff_waypoint)
+               if(this.team_forced && !this.buff_waypoint)
                        buff_Waypoint_Spawn(this);
 
                if(this.lifetime && time >= this.lifetime)
@@ -335,7 +335,7 @@ void buff_Reset(entity this)
 bool buff_Customize(entity this, entity client)
 {
        entity player = WaypointSprite_getviewentity(client);
-       if(!this.buff_active || (this.team && DIFF_TEAM(player, this)))
+       if(!this.buff_active || (this.team_forced && player.team != this.team_forced))
        {
                this.alpha = 0.3;
                if(this.effects & EF_FULLBRIGHT) { this.effects &= ~(EF_FULLBRIGHT); }
@@ -361,8 +361,6 @@ void buff_Init(entity this)
 {
        if(!cvar("g_buffs")) { delete(this); return; }
 
-       if(!teamplay && this.team) { this.team = 0; }
-
        entity buff = buff_FirstFromFlags(STAT(BUFFS, this));
 
        if(!STAT(BUFFS, this) || !buff_Available(buff))
@@ -409,10 +407,13 @@ void buff_Init(entity this)
 
 void buff_Init_Compat(entity ent, entity replacement)
 {
-       if (ent.spawnflags & 2)
-               ent.team = NUM_TEAM_1;
-       else if (ent.spawnflags & 4)
-               ent.team = NUM_TEAM_2;
+       if (teamplay)
+       {
+               if (ent.spawnflags & 2)
+                       ent.team_forced = NUM_TEAM_1;
+               else if (ent.spawnflags & 4)
+                       ent.team_forced = NUM_TEAM_2;
+       }
 
        STAT(BUFFS, ent) = replacement.m_itemid;
 
@@ -905,7 +906,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
                player.alpha = ((autocvar_g_buffs_invisible_alpha) ? autocvar_g_buffs_invisible_alpha : -1); // powerups reset alpha, so we must enforce this (TODO)
 
        if(STAT(BUFFS, player) & BUFF_MEDIC.m_itemid)
-       if(time >= player.buff_medic_healtime)
+       if(teamplay && time >= player.buff_medic_healtime)
        {
                buff_Medic_Heal(player);
                player.buff_medic_healtime = time + autocvar_g_buffs_medic_heal_delay;
index b585811873758a94aee4a68592364f36ca749005..b3a8ddc649f865d67ccd7d17bff9dbad42f28e47 100644 (file)
@@ -69,9 +69,9 @@ float autocvar_g_buffs_luck_damagemultiplier = 3;
 .float buff_effect_delay;
 
 // buff definitions
-.float buff_active;
+.bool buff_active;
 .float buff_activetime;
-.float buff_activetime_updated;
+.bool buff_activetime_updated;
 .entity buff_waypoint;
 .int oldbuffs; // for updating effects
 .float buff_shield; // delay for players to keep them from spamming buff pickups
index 1c436da9691b0d555225ef9453286dfab73b9212..adad55b7499d99706b23f494798d47fa18509850 100644 (file)
@@ -30,8 +30,6 @@ enum
 /// \brief Indicates that the player is not allowed to join a team.
 const int TEAM_NOT_ALLOWED = -1;
 
-.float team_forced; // can be a team number to force a team, or 0 for default action, or -1 for forced spectator
-
 .int m_team_balance_state; ///< Holds the state of the team balance entity.
 .entity m_team_balance_team[NUM_TEAMS]; ///< ???
 
index 33f9d02d7e6b01da87c6dd86e6217b3ab546aa95..9faaaa521353b22a8ab8ed7f104df46214a27657 100644 (file)
@@ -10,6 +10,8 @@ bool autocvar_g_balance_teams_prevent_imbalance;
 
 bool lockteams;
 
+.int team_forced; // can be a team number to force a team, or 0 for default action, or -1 for forced spectator
+
 // ========================== Global teams API ================================
 
 /// \brief Returns the global team entity at the given index.