From 51b520cdc57b1d9a2b16b35a5caf0db7f7d1ea62 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Fri, 17 Feb 2023 22:21:43 +0100 Subject: [PATCH] q3compat: add support for the target_print entity --- qcsrc/server/compat/quake3.qc | 70 +++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/qcsrc/server/compat/quake3.qc b/qcsrc/server/compat/quake3.qc index 9333ebfed..3dd651e49 100644 --- a/qcsrc/server/compat/quake3.qc +++ b/qcsrc/server/compat/quake3.qc @@ -272,6 +272,76 @@ spawnfunc(target_fragsFilter) this.use = fragsfilter_use; } +#define PRINT_REDTEAM BIT(0) // Q3 only, not used in Q3DF +#define PRINT_BLUETEAM BIT(1) // Q3 only, not used in Q3DF +#define PRINT_PRIVATE BIT(2) // Q3 only, not used in Q3DF +#define PRINT_BROADCAST BIT(3) // Q3DF only, default behavior in Q3 + +void target_print_message(entity this, entity actor) +{ + centerprint(actor, this.message); + play2(actor, SND(TALK)); +} + +void target_print_use(entity this, entity actor, entity trigger) +{ + if(!IS_PLAYER(actor)) + return; + + if(this.message == "") + return; + + bool priv, red, blue; + if(g_cts || g_race) // use Q3DF spawnflags in race game modes + { + priv = !boolean(this.spawnflags & PRINT_BROADCAST); + red = blue = false; + } + else // use vanilla Q3 spawnflags otherwise + { + priv = boolean(this.spawnflags & PRINT_PRIVATE); + red = boolean(this.spawnflags & PRINT_REDTEAM); + blue = boolean(this.spawnflags & PRINT_BLUETEAM); + } + + if(priv) + { + target_print_message(this, actor); + } + else if(red || blue) + { + if(red) + { + FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it.team == NUM_TEAM_1, target_print_message(this, it)); + } + if(blue) + { + FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it.team == NUM_TEAM_2, target_print_message(this, it)); + } + } + else + { + FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), target_print_message(this, it)); + } +} + +/* + * ENTITY PARAMETERS: + * + * message: text string to print on screen. + * targetname: the activating trigger points to this. + */ +spawnfunc(target_print) +{ + this.use = target_print_use; +} + +// target_smallprint, Q3DF only +spawnfunc(target_smallprint) +{ + spawnfunc_target_print(this); +} + .bool notteam; .bool notsingle; .bool notfree; -- 2.39.2