DEADSOFTWARE

Player: Add sounds for CTF game
authorStas'M <x86corez@gmail.com>
Mon, 28 Jan 2019 23:01:37 +0000 (02:01 +0300)
committerStas'M <x86corez@gmail.com>
Mon, 28 Jan 2019 23:01:37 +0000 (02:01 +0300)
src/game/g_game.pas
src/game/g_map.pas
src/game/g_netmsg.pas
src/game/g_player.pas

index 6ba4297d6f5b4c4b8e61f4559fd7deb0e9444cba..12c9824f0ba05c9617745d5b57a47f9bfd49f12b 100644 (file)
@@ -237,6 +237,10 @@ var
   goodsnd: array[0..3] of TPlayableSound;
   killsnd: array[0..3] of TPlayableSound;
   hahasnd: array[0..2] of TPlayableSound;
   goodsnd: array[0..3] of TPlayableSound;
   killsnd: array[0..3] of TPlayableSound;
   hahasnd: array[0..2] of TPlayableSound;
+  sound_get_flag: array[0..1] of TPlayableSound;
+  sound_lost_flag: array[0..1] of TPlayableSound;
+  sound_ret_flag: array[0..1] of TPlayableSound;
+  sound_cap_flag: array[0..1] of TPlayableSound;
   gBodyKillEvent: Integer = -1;
   gDefInterTime: ShortInt = -1;
   gInterEndTime: LongWord = 0;
   gBodyKillEvent: Integer = -1;
   gDefInterTime: ShortInt = -1;
   gInterEndTime: LongWord = 0;
@@ -2346,6 +2350,14 @@ begin
   g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD+':SOUNDS\MUHAHA1');
   g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD+':SOUNDS\MUHAHA2');
   g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD+':SOUNDS\MUHAHA3');
   g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD+':SOUNDS\MUHAHA1');
   g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD+':SOUNDS\MUHAHA2');
   g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD+':SOUNDS\MUHAHA3');
+  g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD+':SOUNDS\GETFLAG1');
+  g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD+':SOUNDS\GETFLAG2');
+  g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD+':SOUNDS\LOSTFLG1');
+  g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD+':SOUNDS\LOSTFLG2');
+  g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD+':SOUNDS\RETFLAG1');
+  g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD+':SOUNDS\RETFLAG2');
+  g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD+':SOUNDS\CAPFLAG1');
+  g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD+':SOUNDS\CAPFLAG2');
 
   goodsnd[0] := TPlayableSound.Create();
   goodsnd[1] := TPlayableSound.Create();
 
   goodsnd[0] := TPlayableSound.Create();
   goodsnd[1] := TPlayableSound.Create();
@@ -2375,6 +2387,24 @@ begin
   hahasnd[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
   hahasnd[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
 
   hahasnd[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
   hahasnd[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
 
+  sound_get_flag[0] := TPlayableSound.Create();
+  sound_get_flag[1] := TPlayableSound.Create();
+  sound_lost_flag[0] := TPlayableSound.Create();
+  sound_lost_flag[1] := TPlayableSound.Create();
+  sound_ret_flag[0] := TPlayableSound.Create();
+  sound_ret_flag[1] := TPlayableSound.Create();
+  sound_cap_flag[0] := TPlayableSound.Create();
+  sound_cap_flag[1] := TPlayableSound.Create();
+
+  sound_get_flag[0].SetByName('SOUND_CTF_GET1');
+  sound_get_flag[1].SetByName('SOUND_CTF_GET2');
+  sound_lost_flag[0].SetByName('SOUND_CTF_LOST1');
+  sound_lost_flag[1].SetByName('SOUND_CTF_LOST2');
+  sound_ret_flag[0].SetByName('SOUND_CTF_RETURN1');
+  sound_ret_flag[1].SetByName('SOUND_CTF_RETURN2');
+  sound_cap_flag[0].SetByName('SOUND_CTF_CAPTURE1');
+  sound_cap_flag[1].SetByName('SOUND_CTF_CAPTURE2');
+
   g_Game_LoadChatSounds(GameWAD+':CHATSND\SNDCFG');
 
   g_Game_SetLoadingText(_lc[I_LOAD_ITEMS_DATA], 0, False);
   g_Game_LoadChatSounds(GameWAD+':CHATSND\SNDCFG');
 
   g_Game_SetLoadingText(_lc[I_LOAD_ITEMS_DATA], 0, False);
@@ -2456,6 +2486,24 @@ begin
   g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
   g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
 
   g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
   g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
 
+  sound_get_flag[0].Free();
+  sound_get_flag[1].Free();
+  sound_lost_flag[0].Free();
+  sound_lost_flag[1].Free();
+  sound_ret_flag[0].Free();
+  sound_ret_flag[1].Free();
+  sound_cap_flag[0].Free();
+  sound_cap_flag[1].Free();
+
+  g_Sound_Delete('SOUND_CTF_GET1');
+  g_Sound_Delete('SOUND_CTF_GET2');
+  g_Sound_Delete('SOUND_CTF_LOST1');
+  g_Sound_Delete('SOUND_CTF_LOST2');
+  g_Sound_Delete('SOUND_CTF_RETURN1');
+  g_Sound_Delete('SOUND_CTF_RETURN2');
+  g_Sound_Delete('SOUND_CTF_CAPTURE1');
+  g_Sound_Delete('SOUND_CTF_CAPTURE2');
+
   g_Game_FreeChatSounds();
 
   DataLoaded := False;
   g_Game_FreeChatSounds();
 
   DataLoaded := False;
index be752f804f2116d93fb88ea8be5a251586225726..81eb17e904044c36be49914f5172380a7b8cbdd6 100644 (file)
@@ -2515,6 +2515,7 @@ var
   a, d, j: Integer;
   m: Word;
   s: String;
   a, d, j: Integer;
   m: Word;
   s: String;
+  b: Byte;
 
   procedure UpdatePanelArray(var panels: TPanelArray);
   var
 
   procedure UpdatePanelArray(var panels: TPanelArray);
   var
@@ -2565,6 +2566,15 @@ begin
               s := _lc[I_PLAYER_FLAG_BLUE];
             g_Game_Message(Format(_lc[I_MESSAGE_FLAG_RETURN], [AnsiUpperCase(s)]), 144);
 
               s := _lc[I_PLAYER_FLAG_BLUE];
             g_Game_Message(Format(_lc[I_MESSAGE_FLAG_RETURN], [AnsiUpperCase(s)]), 144);
 
+            if (((gPlayer1 <> nil) and (((gPlayer1.Team = TEAM_RED) and (a = FLAG_RED)) or ((gPlayer1.Team = TEAM_BLUE) and (a = FLAG_BLUE))))
+            or ((gPlayer2 <> nil) and (((gPlayer2.Team = TEAM_RED) and (a = FLAG_RED)) or ((gPlayer2.Team = TEAM_BLUE) and (a = FLAG_BLUE))))) then
+              b := 0
+            else
+              b := 1;
+
+            if not sound_ret_flag[b].IsPlaying() then
+              sound_ret_flag[b].Play();
+
             if g_Game_IsNet then
               MH_SEND_FlagEvent(FLAG_STATE_RETURNED, a, 0);
             Continue;
             if g_Game_IsNet then
               MH_SEND_FlagEvent(FLAG_STATE_RETURNED, a, 0);
             Continue;
index a7ff31a9639fe68fdf2efdae7e308b54a1683a5d..f5b30efa23c914c9ad02f9eee8c796e5df28fa6f 100644 (file)
@@ -1838,7 +1838,7 @@ var
   PID: Word;
   Pl: TPlayer;
   EvType: Byte;
   PID: Word;
   Pl: TPlayer;
   EvType: Byte;
-  Fl: Byte;
+  Fl, a: Byte;
   Quiet: Boolean;
   s, ts: string;
 begin
   Quiet: Boolean;
   s, ts: string;
 begin
@@ -1875,6 +1875,16 @@ begin
         s := _lc[I_PLAYER_FLAG_BLUE];
 
       g_Game_Message(Format(_lc[I_MESSAGE_FLAG_RETURN], [AnsiUpperCase(s)]), 144);
         s := _lc[I_PLAYER_FLAG_BLUE];
 
       g_Game_Message(Format(_lc[I_MESSAGE_FLAG_RETURN], [AnsiUpperCase(s)]), 144);
+
+      if ((Pl = gPlayer1) or (Pl = gPlayer2)
+      or ((gPlayer1 <> nil) and (gPlayer1.Team = Pl.Team))
+      or ((gPlayer2 <> nil) and (gPlayer2.Team = Pl.Team))) then
+        a := 0
+      else
+        a := 1;
+
+      if not sound_ret_flag[a].IsPlaying() then
+        sound_ret_flag[a].Play();
     end;
 
     FLAG_STATE_CAPTURED:
     end;
 
     FLAG_STATE_CAPTURED:
@@ -1890,6 +1900,16 @@ begin
 
       g_Console_Add(Format(_lc[I_PLAYER_FLAG_GET], [Pl.Name, s]), True);
       g_Game_Message(Format(_lc[I_MESSAGE_FLAG_GET], [AnsiUpperCase(s)]), 144);
 
       g_Console_Add(Format(_lc[I_PLAYER_FLAG_GET], [Pl.Name, s]), True);
       g_Game_Message(Format(_lc[I_MESSAGE_FLAG_GET], [AnsiUpperCase(s)]), 144);
+
+      if ((Pl = gPlayer1) or (Pl = gPlayer2)
+      or ((gPlayer1 <> nil) and (gPlayer1.Team = Pl.Team))
+      or ((gPlayer2 <> nil) and (gPlayer2.Team = Pl.Team))) then
+        a := 0
+      else
+        a := 1;
+
+      if not sound_get_flag[a].IsPlaying() then
+        sound_get_flag[a].Play();
     end;
 
     FLAG_STATE_DROPPED:
     end;
 
     FLAG_STATE_DROPPED:
@@ -1905,6 +1925,16 @@ begin
 
       g_Console_Add(Format(_lc[I_PLAYER_FLAG_DROP], [Pl.Name, s]), True);
       g_Game_Message(Format(_lc[I_MESSAGE_FLAG_DROP], [AnsiUpperCase(s)]), 144);
 
       g_Console_Add(Format(_lc[I_PLAYER_FLAG_DROP], [Pl.Name, s]), True);
       g_Game_Message(Format(_lc[I_MESSAGE_FLAG_DROP], [AnsiUpperCase(s)]), 144);
+
+      if ((Pl = gPlayer1) or (Pl = gPlayer2)
+      or ((gPlayer1 <> nil) and (gPlayer1.Team = Pl.Team))
+      or ((gPlayer2 <> nil) and (gPlayer2.Team = Pl.Team))) then
+        a := 0
+      else
+        a := 1;
+
+      if not sound_lost_flag[a].IsPlaying() then
+        sound_lost_flag[a].Play();
     end;
 
     FLAG_STATE_SCORED:
     end;
 
     FLAG_STATE_SCORED:
@@ -1923,6 +1953,16 @@ begin
       Insert('.', ts, Length(ts) + 1 - 3);
       g_Console_Add(Format(_lc[I_PLAYER_FLAG_CAPTURE], [Pl.Name, s, ts]), True);
       g_Game_Message(Format(_lc[I_MESSAGE_FLAG_CAPTURE], [AnsiUpperCase(s)]), 144);
       Insert('.', ts, Length(ts) + 1 - 3);
       g_Console_Add(Format(_lc[I_PLAYER_FLAG_CAPTURE], [Pl.Name, s, ts]), True);
       g_Game_Message(Format(_lc[I_MESSAGE_FLAG_CAPTURE], [AnsiUpperCase(s)]), 144);
+
+      if ((Pl = gPlayer1) or (Pl = gPlayer2)
+      or ((gPlayer1 <> nil) and (gPlayer1.Team = Pl.Team))
+      or ((gPlayer2 <> nil) and (gPlayer2.Team = Pl.Team))) then
+        a := 0
+      else
+        a := 1;
+
+      if not sound_cap_flag[a].IsPlaying() then
+        sound_cap_flag[a].Play();
     end;
 
     FLAG_STATE_RETURNED:
     end;
 
     FLAG_STATE_RETURNED:
@@ -1936,6 +1976,16 @@ begin
         s := _lc[I_PLAYER_FLAG_BLUE];
 
       g_Game_Message(Format(_lc[I_MESSAGE_FLAG_RETURN], [AnsiUpperCase(s)]), 144);
         s := _lc[I_PLAYER_FLAG_BLUE];
 
       g_Game_Message(Format(_lc[I_MESSAGE_FLAG_RETURN], [AnsiUpperCase(s)]), 144);
+
+      if ((Pl = gPlayer1) or (Pl = gPlayer2)
+      or ((gPlayer1 <> nil) and (gPlayer1.Team = Pl.Team))
+      or ((gPlayer2 <> nil) and (gPlayer2.Team = Pl.Team))) then
+        a := 0
+      else
+        a := 1;
+
+      if not sound_ret_flag[a].IsPlaying() then
+        sound_ret_flag[a].Play();
     end;
   end;
 end;
     end;
   end;
 end;
index 965d5d23adb33dc2184168564d45b25a46ffa2f0..854d8119b44c4f0b4fe27b264e7dd273dece20bc 100644 (file)
@@ -292,7 +292,7 @@ type
     procedure   BFGHit();
     function    GetFlag(Flag: Byte): Boolean;
     procedure   SetFlag(Flag: Byte);
     procedure   BFGHit();
     function    GetFlag(Flag: Byte): Boolean;
     procedure   SetFlag(Flag: Byte);
-    function    DropFlag(): Boolean;
+    function    DropFlag(Silent: Boolean = True): Boolean;
     procedure   AllRulez(Health: Boolean);
     procedure   RestoreHealthArmor();
     procedure   FragCombo();
     procedure   AllRulez(Health: Boolean);
     procedure   RestoreHealthArmor();
     procedure   FragCombo();
@@ -3403,7 +3403,7 @@ begin
     end;
 
 // Âûáðîñ ôëàãà:
     end;
 
 // Âûáðîñ ôëàãà:
-    DropFlag();
+    DropFlag(KillType = K_FALLKILL);
   end;
 
   g_Player_CreateCorpse(Self);
   end;
 
   g_Player_CreateCorpse(Self);
@@ -5546,7 +5546,7 @@ end;
 function TPlayer.GetFlag(Flag: Byte): Boolean;
 var
   s, ts: String;
 function TPlayer.GetFlag(Flag: Byte): Boolean;
 var
   s, ts: String;
-  evtype: Byte;
+  evtype, a: Byte;
 begin
   Result := False;
 
 begin
   Result := False;
 
@@ -5574,6 +5574,16 @@ begin
     g_Map_ResetFlag(FFlag);
     g_Game_Message(Format(_lc[I_MESSAGE_FLAG_CAPTURE], [AnsiUpperCase(s)]), 144);
 
     g_Map_ResetFlag(FFlag);
     g_Game_Message(Format(_lc[I_MESSAGE_FLAG_CAPTURE], [AnsiUpperCase(s)]), 144);
 
+    if ((Self = gPlayer1) or (Self = gPlayer2)
+    or ((gPlayer1 <> nil) and (gPlayer1.Team = FTeam))
+    or ((gPlayer2 <> nil) and (gPlayer2.Team = FTeam))) then
+      a := 0
+    else
+      a := 1;
+
+    if not sound_cap_flag[a].IsPlaying() then
+      sound_cap_flag[a].Play();
+
     gTeamStat[FTeam].Goals := gTeamStat[FTeam].Goals + 1;
 
     Result := True;
     gTeamStat[FTeam].Goals := gTeamStat[FTeam].Goals + 1;
 
     Result := True;
@@ -5605,6 +5615,16 @@ begin
     g_Map_ResetFlag(Flag);
     g_Game_Message(Format(_lc[I_MESSAGE_FLAG_RETURN], [AnsiUpperCase(s)]), 144);
 
     g_Map_ResetFlag(Flag);
     g_Game_Message(Format(_lc[I_MESSAGE_FLAG_RETURN], [AnsiUpperCase(s)]), 144);
 
+    if ((Self = gPlayer1) or (Self = gPlayer2)
+    or ((gPlayer1 <> nil) and (gPlayer1.Team = FTeam))
+    or ((gPlayer2 <> nil) and (gPlayer2.Team = FTeam))) then
+      a := 0
+    else
+      a := 1;
+
+    if not sound_ret_flag[a].IsPlaying() then
+      sound_ret_flag[a].Play();
+
     Result := True;
     if g_Game_IsNet then
     begin
     Result := True;
     if g_Game_IsNet then
     begin
@@ -5632,6 +5652,16 @@ begin
 
     gFlags[Flag].State := FLAG_STATE_CAPTURED;
 
 
     gFlags[Flag].State := FLAG_STATE_CAPTURED;
 
+    if ((Self = gPlayer1) or (Self = gPlayer2)
+    or ((gPlayer1 <> nil) and (gPlayer1.Team = FTeam))
+    or ((gPlayer2 <> nil) and (gPlayer2.Team = FTeam))) then
+      a := 0
+    else
+      a := 1;
+
+    if not sound_get_flag[a].IsPlaying() then
+      sound_get_flag[a].Play();
+
     Result := True;
     if g_Game_IsNet then
     begin
     Result := True;
     if g_Game_IsNet then
     begin
@@ -5648,9 +5678,10 @@ begin
     FModel.SetFlag(FFlag);
 end;
 
     FModel.SetFlag(FFlag);
 end;
 
-function TPlayer.DropFlag(): Boolean;
+function TPlayer.DropFlag(Silent: Boolean = True): Boolean;
 var
   s: String;
 var
   s: String;
+  a: Byte;
 begin
   Result := False;
   if (not g_Game_IsServer) or (FFlag = FLAG_NONE) then
 begin
   Result := False;
   if (not g_Game_IsServer) or (FFlag = FLAG_NONE) then
@@ -5675,6 +5706,16 @@ begin
     g_Console_Add(Format(_lc[I_PLAYER_FLAG_DROP], [FName, s]), True);
     g_Game_Message(Format(_lc[I_MESSAGE_FLAG_DROP], [AnsiUpperCase(s)]), 144);
 
     g_Console_Add(Format(_lc[I_PLAYER_FLAG_DROP], [FName, s]), True);
     g_Game_Message(Format(_lc[I_MESSAGE_FLAG_DROP], [AnsiUpperCase(s)]), 144);
 
+    if ((Self = gPlayer1) or (Self = gPlayer2)
+    or ((gPlayer1 <> nil) and (gPlayer1.Team = FTeam))
+    or ((gPlayer2 <> nil) and (gPlayer2.Team = FTeam))) then
+      a := 0
+    else
+      a := 1;
+
+    if (not Silent) and (not sound_lost_flag[a].IsPlaying()) then
+      sound_lost_flag[a].Play();
+
     if g_Game_IsNet then
       MH_SEND_FlagEvent(FLAG_STATE_DROPPED, Flag, FUID, False);
   end;
     if g_Game_IsNet then
       MH_SEND_FlagEvent(FLAG_STATE_DROPPED, Flag, FUID, False);
   end;