DEADSOFTWARE

Player: Add sounds for CTF game
[d2df-sdl.git] / src / game / g_game.pas
index f92af351077aaa34fee47dc16dbb0d6eb9a1056f..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;
+  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;
@@ -1504,12 +1508,6 @@ begin
   result := false;
 end;
 
-function isOneKeyPressed (key1: Word): Boolean;
-begin
-  if (key1 <> 0) and e_KeyPressed(key1) then begin result := true; exit; end;
-  result := false;
-end;
-
 procedure processPlayerControls (plr: TPlayer; var ctrl: TPlayerControl; var MoveButton: Byte; p2hack: Boolean=false);
 var
   time: Word;
@@ -1553,34 +1551,20 @@ begin
     // fix movebutton state
     MoveButton := MoveButton or (strafeDir shl 4);
 
-    plr.weaponSwitchKeysStateChange(-1, isKeyPressed(KeyNextWeapon, KeyNextWeapon2));
-    plr.weaponSwitchKeysStateChange(-2, isKeyPressed(KeyPrevWeapon, KeyPrevWeapon2));
-
     // Îñòàëüíûå êëàâèøè:
     if isKeyPressed(KeyJump, KeyJump2) then plr.PressKey(KEY_JUMP, time);
     if isKeyPressed(KeyUp, KeyUp2) then plr.PressKey(KEY_UP, time);
     if isKeyPressed(KeyDown, KeyDown2) then plr.PressKey(KEY_DOWN, time);
     if isKeyPressed(KeyFire, KeyFire2) then plr.PressKey(KEY_FIRE);
-    if isKeyPressed(KeyNextWeapon, KeyNextWeapon2) and plr.isWeaponSwitchKeyReleased(-1) then plr.PressKey(KEY_NEXTWEAPON);
-    if isKeyPressed(KeyPrevWeapon, KeyPrevWeapon2) and plr.isWeaponSwitchKeyReleased(-2) then plr.PressKey(KEY_PREVWEAPON);
+    if isKeyPressed(KeyNextWeapon, KeyNextWeapon2) then plr.PressKey(KEY_NEXTWEAPON);
+    if isKeyPressed(KeyPrevWeapon, KeyPrevWeapon2) then plr.PressKey(KEY_PREVWEAPON);
     if isKeyPressed(KeyOpen, KeyOpen2) then plr.PressKey(KEY_OPEN);
 
     for i := 0 to High(KeyWeapon) do
-    begin
       if isKeyPressed(KeyWeapon[i], KeyWeapon2[i]) then
-      begin
-        plr.weaponSwitchKeysStateChange(i, true);
-        if plr.isWeaponSwitchKeyReleased(i) then plr.QueueWeaponSwitch(i); // all choices are passed there, and god will take the best
-      end
-      else
-      begin
-        plr.weaponSwitchKeysStateChange(i, false);
-      end;
-    end;
+        plr.QueueWeaponSwitch(i); // all choices are passed there, and god will take the best
   end;
 
-  plr.weaponSwitchKeysShiftNewStates();
-
   // HACK: add dynlight here
   if gwin_k8_enable_light_experiments then
   begin
@@ -2313,6 +2297,7 @@ begin
   g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD+':TEXTURES\FLAGHUD_B_DROP');
   g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD+':TEXTURES\TALKBUBBLE');
   g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD+':TEXTURES\PENTA');
+  g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD+':TEXTURES\PLRIND');
 
   hasPBarGfx := true;
   if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD+':TEXTURES\LLEFT') then hasPBarGfx := false;
@@ -2365,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_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();
@@ -2394,6 +2387,24 @@ begin
   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);
@@ -2475,6 +2486,24 @@ begin
   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;
@@ -3053,10 +3082,10 @@ begin
             aY2 := aY + aY2 - 1;
 
             case LiftType of
-              0: e_DrawFillQuad(aX, aY, aX2, aY2, 116,  72,  36, 0);
-              1: e_DrawFillQuad(aX, aY, aX2, aY2, 116, 124,  96, 0);
-              2: e_DrawFillQuad(aX, aY, aX2, aY2, 200,  80,   4, 0);
-              3: e_DrawFillQuad(aX, aY, aX2, aY2, 252, 140,  56, 0);
+              LIFTTYPE_UP:    e_DrawFillQuad(aX, aY, aX2, aY2, 116,  72,  36, 0);
+              LIFTTYPE_DOWN:  e_DrawFillQuad(aX, aY, aX2, aY2, 116, 124,  96, 0);
+              LIFTTYPE_LEFT:  e_DrawFillQuad(aX, aY, aX2, aY2, 200,  80,   4, 0);
+              LIFTTYPE_RIGHT: e_DrawFillQuad(aX, aY, aX2, aY2, 252, 140,  56, 0);
             end;
           end;
     end;
@@ -3585,6 +3614,8 @@ begin
 
   renderMapInternal(-c, -d, true);
 
+  if (gGameSettings.GameMode <> GM_SINGLE) and gPlayerIndicator then
+    p.DrawIndicator();
   if p.FSpectator then
     e_TextureFontPrintEx(p.GameX + PLAYER_RECT_CX - 4,
                          p.GameY + PLAYER_RECT_CY - 4,