]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add Hunter black screen feature
authorLegendaryGuard <rootuser999@gmail.com>
Mon, 29 Nov 2021 23:51:35 +0000 (00:51 +0100)
committerLegendaryGuard <rootuser999@gmail.com>
Mon, 29 Nov 2021 23:51:35 +0000 (00:51 +0100)
gamemodes-server.cfg
qcsrc/common/gamemodes/gamemode/mh/TODO.txt
qcsrc/common/gamemodes/gamemode/mh/mh.qh
qcsrc/common/gamemodes/gamemode/mh/sv_mh.qc
qcsrc/common/gamemodes/gamemode/mh/sv_mh.qh

index 6a6cf234adc9cc57d21538e95b0d9ca834fc5071..d6716f7fc74c58619ecf7068ea148b8b78bda52c 100644 (file)
@@ -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
index 67a12d06f6a8bf9074be921c5b2a7f62b3d2ee0a..3a2845e713addc16848147a56cf39227984222c7 100644 (file)
@@ -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
index eacfa51cf80eede7e3356ed1d1494eea028ad027..7f1b0a34a2dd6646219e19906ec6044ef6666c63 100644 (file)
@@ -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 <client/draw.qh>
+#include <client/hud/hud.qh>
+
+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 <server/command/common.qh>
+
+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
index 90225878a870a953577b56f888979873f2a2730f..4f954d1dd452e33f28d8dd9a43e3cec9572a7c94 100644 (file)
@@ -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);
index 56d75421ebdd880c0ec53dd8661b442e34af4ffb..e8e43a206a75039e8a125c0df7bf83e073966317 100644 (file)
@@ -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;