From ecf72dab2f936077c14fb9d8e9f2a79897b7f64e Mon Sep 17 00:00:00 2001 From: otta8634 Date: Sun, 9 Mar 2025 16:27:00 +0800 Subject: [PATCH] Improve when waypoints are shown in ka/tka/kh/ctf Hid the waypoint from enemies when the player is "invisible." Defined IS_INVISIBLE as alpha <= 0.25, has Invisibility powerup, or Cloaked mutator enabled, in qcsrc/server/utils.qh. Showed waypoints in warmup in ka/tka/kh, and to spectators (unless they're spectating a key/ball carrier, so the waypoint isn't constantly shown at the top of the screen). Allowed g_balance_keyhunt_delay_tracking to be negative, so that the tracking waypoints never appear. Added cvars g_keepawayball_tracking and g_tkaball_tracking to customize when waypoints show in ka/tka. - 0 means they never show. - 1 means they always show. - 2 means they show only on the dropped ball. --- gamemodes-server.cfg | 4 ++- qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc | 6 ++-- .../gamemode/keepaway/sv_keepaway.qc | 30 ++++++++++++------- .../gamemodes/gamemode/keyhunt/sv_keyhunt.qc | 28 +++++++++-------- qcsrc/common/gamemodes/gamemode/tka/sv_tka.qc | 30 ++++++++++++------- qcsrc/server/utils.qh | 1 + 6 files changed, 62 insertions(+), 37 deletions(-) diff --git a/gamemodes-server.cfg b/gamemodes-server.cfg index df9a3efb4..0a8c51eb6 100644 --- a/gamemodes-server.cfg +++ b/gamemodes-server.cfg @@ -451,6 +451,7 @@ set g_keepawayball_effects 8 "add together the numbers you want; EF_ADDITIVE (32 set g_keepawayball_trail_color 254 "particle trail color from player/ball" set g_keepawayball_damageforcescale 2 "scale of force which is applied to the ball by weapons/explosions/etc" set g_keepawayball_respawntime 10 "if no one picks up the ball, how long to wait until the ball respawns" +set g_keepawayball_tracking 1 "\"0\" = don't show a waypoint on the ball/ballcarrier, \"1\" = always show a waypoint, \"2\" = only show a waypoint if the ball is dropped" // ========== @@ -461,7 +462,7 @@ set g_balance_keyhunt_return_when_unreachable 1 "automatically destroy a key if set g_balance_keyhunt_delay_damage_return 5 "time a key takes to automatically destroy itself if it falls into lava/slime/trigger hurt" set g_balance_keyhunt_delay_return 60 "time a key takes to destroy itself if dropped" set g_balance_keyhunt_delay_round 5 -set g_balance_keyhunt_delay_tracking 10 +set g_balance_keyhunt_delay_tracking 10 "time after which waypoints show on keys and key carriers, if negative they don't show" set g_balance_keyhunt_delay_fadeout 2 set g_balance_keyhunt_delay_collect 1.5 set g_balance_keyhunt_maxdist 150 @@ -690,6 +691,7 @@ set g_tkaball_effects 8 "add together the numbers you want; EF_ADDITIVE (32) / E set g_tkaball_trail_color 254 "particle trail color from player/ball" set g_tkaball_damageforcescale 2 "scale of force which is applied to the ball by weapons/explosions/etc" set g_tkaball_respawntime 10 "if no one picks up the ball, how long to wait until the ball respawns" +set g_tkaball_tracking 1 "\"0\" = don't show a waypoint on the ball/ballcarrier, \"1\" = always show a waypoint, \"2\" = only show a waypoint if the ball is dropped" // ========== // survival diff --git a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc index 858b3a862..203595694 100644 --- a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc +++ b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc @@ -876,8 +876,10 @@ bool ctf_Stalemate_Customize(entity this, entity client) // team waypoints //if(CTF_SAMETEAM(wp_owner.flagcarried, wp_owner)) { return false; } - if(SAME_TEAM(wp_owner, e)) { return false; } - if(!IS_PLAYER(e)) { return false; } + if(SAME_TEAM(wp_owner, e) || !IS_PLAYER(e)) + return false; + if(IS_INVISIBLE(wp_owner)) + return false; // hide the waypointsprite if the owner is invisible return true; } diff --git a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc index bba3baa3c..37054373d 100644 --- a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc +++ b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc @@ -30,16 +30,18 @@ float autocvar_g_keepawayball_damageforcescale; int autocvar_g_keepawayball_effects; float autocvar_g_keepawayball_respawntime; int autocvar_g_keepawayball_trail_color; +int autocvar_g_keepawayball_tracking; bool ka_ballcarrier_waypointsprite_visible_for_player(entity this, entity player, entity view) // runs on waypoints which are attached to ballcarriers, updates once per frame { - if(view.ballcarried) - if(IS_SPEC(player)) - return false; // we don't want spectators of the ballcarrier to see the attached waypoint on the top of their screen - - // TODO: Make the ballcarrier lack a waypointsprite whenever they have the invisibility powerup + if(view.ballcarried && IS_SPEC(player)) + return false; // we don't want spectators of the ballcarrier to see the attached waypoint on the top of their screen + if(IS_SPEC(player) || warmup_stage) + return true; + if(IS_INVISIBLE(this.owner)) + return false; // hide the waypointsprite if the owner is invisible - return true; + return autocvar_g_keepawayball_tracking == 1; } void ka_EventLog(string mode, entity actor) // use an alias for easy changing and quick editing later @@ -68,8 +70,11 @@ void ka_RespawnBall(entity this) // runs whenever the ball needs to be relocated Send_Effect(EFFECT_KA_BALL_RESPAWN, oldballorigin, '0 0 0', 1); Send_Effect(EFFECT_KA_BALL_RESPAWN, this.origin, '0 0 0', 1); - WaypointSprite_Spawn(WP_KaBall, 0, 0, this, '0 0 64', NULL, this.team, this, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER); - WaypointSprite_Ping(this.waypointsprite_attachedforcarrier); + if(autocvar_g_keepawayball_tracking || warmup_stage) + { + WaypointSprite_Spawn(WP_KaBall, 0, 0, this, '0 0 64', NULL, this.team, this, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER); + WaypointSprite_Ping(this.waypointsprite_attachedforcarrier); + } sound(this, CH_TRIGGER, SND_KA_RESPAWN, VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere) } @@ -215,9 +220,12 @@ void ka_DropEvent(entity player) // runs any time that a player is supposed to l sound(NULL, CH_TRIGGER, SND_KA_DROPPED, VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere) // waypoints - WaypointSprite_Spawn(WP_KaBall, 0, 0, ball, '0 0 64', NULL, ball.team, ball, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER); - WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT); - WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier); + if(autocvar_g_keepawayball_tracking || warmup_stage) + { + WaypointSprite_Spawn(WP_KaBall, 0, 0, ball, '0 0 64', NULL, ball.team, ball, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER); + WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT); + WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier); + } ka_PlayerReset(player); } diff --git a/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc b/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc index 89997b8bd..04433c597 100644 --- a/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc +++ b/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc @@ -70,7 +70,6 @@ int kh_Team_ByID(int t) } entity kh_controller; -//bool kh_tracking_enabled; int kh_teams; int kh_interferemsg_team; float kh_interferemsg_time; @@ -100,22 +99,24 @@ void kh_ScoreRules(int teams) bool kh_KeyCarrier_waypointsprite_visible_for_player(entity this, entity player, entity view) // runs all the time { - if(!IS_PLAYER(view) || DIFF_TEAM(this, view)) - if(!kh_tracking_enabled) - return false; + if(view.kh_next && IS_SPEC(player)) + return false; // we don't want spectators of key carriers to see the attached waypoint on the top of their screen + if(IS_SPEC(player) || warmup_stage || SAME_TEAM(player, this.owner)) + return true; + if(IS_INVISIBLE(this.owner)) + return false; // hide the waypointsprite if the owner is invisible - return true; + return kh_tracking_enabled; } bool kh_Key_waypointsprite_visible_for_player(entity this, entity player, entity view) { + if(IS_SPEC(player) || warmup_stage) + return true; if(!kh_tracking_enabled) return false; - if(!this.owner) - return true; - if(!this.owner.owner) - return true; - return false; // draw only when key is not owned + + return !this.owner || !this.owner.owner; // draw only when key is not owned } void kh_update_state() @@ -946,8 +947,11 @@ void kh_StartRound() // runs at the start of each round } kh_tracking_enabled = false; - Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_KEYHUNT_SCAN, autocvar_g_balance_keyhunt_delay_tracking); - kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_tracking, kh_EnableTrackingDevice); + if(autocvar_g_balance_keyhunt_delay_tracking >= 0) + { + Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_KEYHUNT_SCAN, autocvar_g_balance_keyhunt_delay_tracking); + kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_tracking, kh_EnableTrackingDevice); + } } float kh_HandleFrags(entity attacker, entity targ, float f) // adds to the player score diff --git a/qcsrc/common/gamemodes/gamemode/tka/sv_tka.qc b/qcsrc/common/gamemodes/gamemode/tka/sv_tka.qc index 62aff020d..df807f430 100644 --- a/qcsrc/common/gamemodes/gamemode/tka/sv_tka.qc +++ b/qcsrc/common/gamemodes/gamemode/tka/sv_tka.qc @@ -26,16 +26,18 @@ float autocvar_g_tkaball_damageforcescale; int autocvar_g_tkaball_effects; float autocvar_g_tkaball_respawntime; int autocvar_g_tkaball_trail_color; +int autocvar_g_tkaball_tracking; bool tka_ballcarrier_waypointsprite_visible_for_player(entity this, entity player, entity view) // runs on waypoints which are attached to ballcarriers, updates once per frame { - if(view.ballcarried) - if(IS_SPEC(player)) - return false; // we don't want spectators of the ballcarrier to see the attached waypoint on the top of their screen - - // TODO: Make the ballcarrier lack a waypointsprite whenever they have the invisibility powerup + if(view.ballcarried && IS_SPEC(player)) + return false; // we don't want spectators of the ballcarrier to see the attached waypoint on the top of their screen + if(IS_SPEC(player) || warmup_stage || SAME_TEAM(player, this.owner)) + return true; + if(IS_INVISIBLE(this.owner)) + return false; // hide the waypointsprite if the owner is invisible - return true; + return autocvar_g_tkaball_tracking == 1; } void tka_EventLog(string mode, entity actor) // use an alias for easy changing and quick editing later @@ -65,8 +67,11 @@ void tka_RespawnBall(entity this) // runs whenever the ball needs to be relocate Send_Effect(EFFECT_KA_BALL_RESPAWN, oldballorigin, '0 0 0', 1); Send_Effect(EFFECT_KA_BALL_RESPAWN, this.origin, '0 0 0', 1); - WaypointSprite_Spawn(WP_KaBall, 0, 0, this, '0 0 64', NULL, this.team, this, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER); - WaypointSprite_Ping(this.waypointsprite_attachedforcarrier); + if(autocvar_g_tkaball_tracking || warmup_stage) + { + WaypointSprite_Spawn(WP_KaBall, 0, 0, this, '0 0 64', NULL, this.team, this, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER); + WaypointSprite_Ping(this.waypointsprite_attachedforcarrier); + } sound(this, CH_TRIGGER, SND_KA_RESPAWN, VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere) } @@ -196,9 +201,12 @@ void tka_DropEvent(entity player) // runs any time that a player is supposed to sound(NULL, CH_TRIGGER, SND_KA_DROPPED, VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere) // waypoints - WaypointSprite_Spawn(WP_KaBall, 0, 0, ball, '0 0 64', NULL, ball.team, ball, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER); - WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT); - WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier); + if(autocvar_g_tkaball_tracking || warmup_stage) + { + WaypointSprite_Spawn(WP_KaBall, 0, 0, ball, '0 0 64', NULL, ball.team, ball, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER); + WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT); + WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier); + } tka_PlayerReset(player); } diff --git a/qcsrc/server/utils.qh b/qcsrc/server/utils.qh index ae0c284fe..fee006ab2 100644 --- a/qcsrc/server/utils.qh +++ b/qcsrc/server/utils.qh @@ -24,6 +24,7 @@ const string STR_OBSERVER = "observer"; #define IS_MOVABLE(v) ((IS_PLAYER(v) || IS_MONSTER(v)) && !STAT(FROZEN, v)) #define IS_DEAD(s) ((s).deadflag != DEAD_NO) +#define IS_INVISIBLE(v) (v.alpha <= 0.25 || StatusEffects_active(STATUSEFFECT_Invisibility, v) || MUTATOR_IS_ENABLED(cloaked)) #define CENTER_OR_VIEWOFS(ent) (ent.origin + (IS_PLAYER(ent) ? ent.view_ofs : ((ent.mins + ent.maxs) * 0.5))) -- 2.39.5