From: bones_was_here Date: Fri, 2 Oct 2020 03:51:12 +0000 (+1000) Subject: Buffs: make team field available for item teaming, some polishing X-Git-Tag: xonotic-v0.8.5~352^2~20 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3481a3a1135d1692d37cf5b2342134abdbab4660;p=xonotic%2Fxonotic-data.pk3dir.git Buffs: make team field available for item teaming, some polishing --- diff --git a/qcsrc/common/mutators/mutator/buffs/buffs.qh b/qcsrc/common/mutators/mutator/buffs/buffs.qh index c0ccf5803..f88cda3a2 100644 --- a/qcsrc/common/mutators/mutator/buffs/buffs.qh +++ b/qcsrc/common/mutators/mutator/buffs/buffs.qh @@ -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) \ diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index be310669d..88fd6aa73 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -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; diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh index b58581187..b3a8ddc64 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh @@ -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 diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index 1c436da96..adad55b74 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -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]; ///< ??? diff --git a/qcsrc/server/teamplay.qh b/qcsrc/server/teamplay.qh index 33f9d02d7..9faaaa521 100644 --- a/qcsrc/server/teamplay.qh +++ b/qcsrc/server/teamplay.qh @@ -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.