From a1317740d2075c2b08f15d1c0b800f8480af7b17 Mon Sep 17 00:00:00 2001 From: LegendaryGuard Date: Tue, 30 Nov 2021 00:51:35 +0100 Subject: [PATCH] Add Hunter black screen feature --- gamemodes-server.cfg | 1 + qcsrc/common/gamemodes/gamemode/mh/TODO.txt | 5 +- qcsrc/common/gamemodes/gamemode/mh/mh.qh | 92 +++++++++++++++++++++ qcsrc/common/gamemodes/gamemode/mh/sv_mh.qc | 14 +++- qcsrc/common/gamemodes/gamemode/mh/sv_mh.qh | 1 + 5 files changed, 109 insertions(+), 4 deletions(-) diff --git a/gamemodes-server.cfg b/gamemodes-server.cfg index 6a6cf234a..d6716f7fc 100644 --- a/gamemodes-server.cfg +++ b/gamemodes-server.cfg @@ -585,3 +585,4 @@ set g_mh_weaponarena " " "starting weapons - takes the same options as g_weapona set g_mh_weapons_damage 0 "0: no damage, 1: only self-damage for runners, 2: only damage opposing team, 3: only allow hunters to damage runners, 4: self-damage and opposing team damage" set g_mh_weapons_force 1 "0: no force, 1: only self-force, 2: self-force and opposing team force" set g_mh_limited_ammunition 0 "do players consume ammunition when firing" +set g_mh_hunterblind 1 "when this is set, hunters can't see anything until the round starts" \ No newline at end of file diff --git a/qcsrc/common/gamemodes/gamemode/mh/TODO.txt b/qcsrc/common/gamemodes/gamemode/mh/TODO.txt index 67a12d06f..3a2845e71 100644 --- a/qcsrc/common/gamemodes/gamemode/mh/TODO.txt +++ b/qcsrc/common/gamemodes/gamemode/mh/TODO.txt @@ -12,12 +12,13 @@ on-screen notification for getting tagged on-screen indication for your role -gamemode icon +gamemode icon (WIP) more dynamicity for the code :) add more TODO: notes - +it might need to improve something in Hunter black screen in mh.qh, sv_mh.qc uses HunterEyesStart function to execute black screen +g_mh_hunterblind 1 // to activate hunter black screen fix waypoint visibility, currently they are always visible to everyone. Fix them to not be visible for spectators of that player. \ No newline at end of file diff --git a/qcsrc/common/gamemodes/gamemode/mh/mh.qh b/qcsrc/common/gamemodes/gamemode/mh/mh.qh index eacfa51cf..7f1b0a34a 100644 --- a/qcsrc/common/gamemodes/gamemode/mh/mh.qh +++ b/qcsrc/common/gamemodes/gamemode/mh/mh.qh @@ -50,3 +50,95 @@ REGISTER_GAMETYPE(MANHUNT, NEW(Manhunt)); const int MH_STATUS_HUNTER = 1; const int MH_STATUS_RUNNER = 2; #endif + +// Hunters can't look anything until round starts +REGISTER_NET_TEMP(TE_CSQC_HUNTEREYES); + +#ifdef CSQC +#include +#include + +float huntereyes_appeartime; +float huntereyes_fadetime; + +void HUD_HunterEyes() +{ + vector bottomright = vec2(vid_conwidth, vid_conheight); + // drawfill function parameters (qcsrc/dpdefs/menudefs.qc): + // float drawfill(vector position, vector size, vector rgb, float alpha, float flag) + drawfill('0 0 0', bottomright, '0 0 0', 1, DRAWFLAG_NORMAL); +} + +#elif defined(SVQC) +#include + +void HunterEyesStart(entity e) +{ + if(e == NULL) + return; + + int accepted = VerifyClientEntity(e, true, false); + + if(accepted > 0) + { + msg_entity = e; + WriteHeader(MSG_ONE, TE_CSQC_HUNTEREYES); + } +} +#endif + +#ifdef CSQC + +bool eyesblinded; + +REGISTER_MUTATOR(cl_hunteryes, true); + +MUTATOR_HOOKFUNCTION(cl_hunteryes, DrawScoreboard) +{ + return eyesblinded; +} + +MUTATOR_HOOKFUNCTION(cl_hunteryes, HUD_Draw_overlay) +{ + if(!eyesblinded) + return false; + + if(time <= huntereyes_fadetime) + { + HUD_HunterEyes(); + return false; + } + else + eyesblinded = false; + + return false; +} + +NET_HANDLE(TE_CSQC_HUNTEREYES, bool isNew) +{ + return = true; + + if(eyesblinded) + return; + + eyesblinded = true; + huntereyes_appeartime = time; + float time_mh_roundstart = (time * 2 + cvar("g_mh_warmup")) / 1.655; + if(time <= cvar("g_mh_warmup")) // if it's the first time round starts + { + huntereyes_fadetime = time_mh_roundstart; + // LOG_INFOF("if ENTERED time: %f", time); + } + else + { + huntereyes_fadetime = time + cvar("g_mh_warmup"); + // LOG_INFOF("else ENTERED time: %f", time); + } + + // just another test + // if(huntereyes_fadetime > time) + // huntereyes_fadetime = time; LOG_INFOF("time: %f", time); + + // LOG_INFOF("huntereyes_fadetime: %f", huntereyes_fadetime); +} +#endif \ No newline at end of file diff --git a/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qc b/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qc index 90225878a..4f954d1dd 100644 --- a/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qc +++ b/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qc @@ -315,7 +315,7 @@ MUTATOR_HOOKFUNCTION(mh, ClientDisconnect) return true; } -// when players want to spec, clear team HUD +// when players want to spec, clear HUD MUTATOR_HOOKFUNCTION(mh, MakePlayerObserver) { entity player = M_ARGV(0, entity); @@ -655,6 +655,13 @@ MUTATOR_HOOKFUNCTION(mh, PlayerSpawn) entity player = M_ARGV(0, entity); player.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP; MH_count_players(); + + if(autocvar_g_mh_hunterblind) + { + if(player.team == Team_IndexToTeam(1)) + HunterEyesStart(player); // Hunters can't see anything until round starts + } + if(player.team == Team_IndexToTeam(2) && !allowed_to_spawn_untagged && Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(2)) > 1 && round_handler_IsActive() && round_handler_IsRoundStarted()){ player.mh_status = MH_STATUS_RUNNER; player.deadflag = 1; // avoid a crash when a spectator joins runners mid-round and gets sent to hunters @@ -672,7 +679,6 @@ MUTATOR_HOOKFUNCTION(mh, PlayerSpawn) if(autocvar_g_mh_player_waypoints == 2){ if(player.team == Team_IndexToTeam(1)) { - player.mh_status = MH_STATUS_HUNTER; WaypointSprite_AttachCarrier(WP_Null, player, RADARICON_FLAGCARRIER); //player.waypointsprite_attachedforcarrier.waypointsprite_visible_for_player = mh_waypointsprite_visible_for_player; WaypointSprite_UpdateRule(player.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT); @@ -690,7 +696,11 @@ MUTATOR_HOOKFUNCTION(mh, reset_map_players) CS(it).killcount = 0; MH_FakeTimeLimit(it, -1); if(it.team == Team_IndexToTeam(1)) + { + if(autocvar_g_mh_hunterblind) + HunterEyesStart(it); // Hunters can't see anything until round starts it.mh_status = MH_STATUS_HUNTER; + } else if(it.team == Team_IndexToTeam(2)) it.mh_status = MH_STATUS_RUNNER; PutClientInServer(it); diff --git a/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qh b/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qh index 56d75421e..e8e43a206 100644 --- a/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qh +++ b/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qh @@ -14,6 +14,7 @@ string autocvar_g_mh_weaponarena; int autocvar_g_mh_weapons_damage; int autocvar_g_mh_weapons_force; bool autocvar_g_mh_limited_ammunition; +bool autocvar_g_mh_hunterblind; int mh_teams; bool allowed_to_spawn_untagged = 1; -- 2.39.2