From d8c63c1a6eec80ee1df03d81124bd4f43da12b7e Mon Sep 17 00:00:00 2001 From: Stas'M Date: Wed, 20 Feb 2019 16:53:26 +0300 Subject: [PATCH] Game: Add secret notification --- src/game/g_game.pas | 2 ++ src/game/g_language.pas | 3 +++ src/game/g_net.pas | 2 +- src/game/g_netmsg.pas | 11 +++++++++++ src/game/g_player.pas | 5 +++++ src/game/g_triggers.pas | 10 ++++++++-- 6 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 7d660aa..3014b68 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -2330,6 +2330,7 @@ begin g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD+':WEAPONS\PUNCHB_DN', 64, 64, 4, False); g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD+':SOUNDS\TELEPORT'); g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD+':SOUNDS\NOTELEPORT'); + g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD+':SOUNDS\SECRET'); g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD+':SOUNDS\DOOROPEN'); g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD+':SOUNDS\DOORCLOSE'); g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD+':SOUNDS\BULK1'); @@ -2450,6 +2451,7 @@ begin g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN'); g_Sound_Delete('SOUND_GAME_TELEPORT'); g_Sound_Delete('SOUND_GAME_NOTELEPORT'); + g_Sound_Delete('SOUND_GAME_SECRET'); g_Sound_Delete('SOUND_GAME_DOOROPEN'); g_Sound_Delete('SOUND_GAME_DOORCLOSE'); g_Sound_Delete('SOUND_GAME_BULK1'); diff --git a/src/game/g_language.pas b/src/game/g_language.pas index 49a5885..267fcd0 100644 --- a/src/game/g_language.pas +++ b/src/game/g_language.pas @@ -414,6 +414,7 @@ type I_PLAYER_NAME, I_PLAYER_CHTEAM_RED, I_PLAYER_CHTEAM_BLUE, + I_PLAYER_SECRET, I_PLAYER_SPECT, I_PLAYER_SPECT1, @@ -1381,6 +1382,8 @@ const '%s ïåðåøåë â Êðàñíóþ êîìàíäó.'), ('PLAYER CHTEAM BLUE', '%s is now on Blue.', '%s ïåðåøåë â Ñèíþþ êîìàíäó.'), + ('PLAYER SECRET', '%s found a secret!', + '%s íàø¸ë ñåêðåò!'), ('PLAYER SPECT', 'Spectating', 'Íàáëþäåíèå'), diff --git a/src/game/g_net.pas b/src/game/g_net.pas index c5bce96..7c21ea5 100644 --- a/src/game/g_net.pas +++ b/src/game/g_net.pas @@ -22,7 +22,7 @@ uses e_log, e_msg, ENet, Classes, MAPDEF{$IFDEF USE_MINIUPNPC}, miniupnpc;{$ELSE};{$ENDIF} const - NET_PROTOCOL_VER = 178; + NET_PROTOCOL_VER = 179; NET_MAXCLIENTS = 24; NET_CHANS = 11; diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas index 6e825fe..a721912 100644 --- a/src/game/g_netmsg.pas +++ b/src/game/g_netmsg.pas @@ -109,6 +109,7 @@ const NET_EV_LMS_DRAW = 16; NET_EV_KILLCOMBO = 17; NET_EV_PLAYER_TOUCH = 18; + NET_EV_SECRET = 19; NET_VE_STARTED = 1; NET_VE_PASSED = 2; @@ -1831,6 +1832,16 @@ begin pl.Touch(); end; + NET_EV_SECRET: + begin + pl := g_Player_Get(EvNum); + if pl <> nil then + begin + g_Console_Add(Format(_lc[I_PLAYER_SECRET], [pl.Name]), True); + g_Sound_PlayEx('SOUND_GAME_SECRET'); + end; + end; + end; end; diff --git a/src/game/g_player.pas b/src/game/g_player.pas index 4d87ded..f644d6b 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -5788,6 +5788,11 @@ end; procedure TPlayer.GetSecret(); begin + if (self = gPlayer1) or (self = gPlayer2) then + begin + g_Console_Add(Format(_lc[I_PLAYER_SECRET], [FName]), True); + g_Sound_PlayEx('SOUND_GAME_SECRET'); + end; Inc(FSecrets); end; diff --git a/src/game/g_triggers.pas b/src/game/g_triggers.pas index 1673cef..af000f0 100644 --- a/src/game/g_triggers.pas +++ b/src/game/g_triggers.pas @@ -1352,9 +1352,15 @@ begin Result := True; if gLMSRespawn = LMS_RESPAWN_NONE then begin - g_Player_Get(ActivateUID).GetSecret(); + p := g_Player_Get(ActivateUID); + p.GetSecret(); Inc(gCoopSecretsFound); - if g_Game_IsNet then MH_SEND_GameStats(); + if g_Game_IsNet then + begin + MH_SEND_GameStats(); + if p.FClientID >= 0 then + MH_SEND_GameEvent(NET_EV_SECRET, p.UID, '', p.FClientID); + end; end; end; -- 2.29.2