X-Git-Url: http://deadsoftware.ru/gitweb?p=d2df-sdl.git;a=blobdiff_plain;f=src%2Fgame%2Fg_game.pas;h=de729fae42e2b139d809d3e451dccd8c7afee1b2;hp=c38572befa771c29a3d575d8ddcf940aaf6dadf6;hb=0f19f863e4ed346794b6ce5a56571027b4c8cd0b;hpb=4df4eb483aa0a0abd74164d7f49c173743f6c84b diff --git a/src/game/g_game.pas b/src/game/g_game.pas index c38572b..de729fa 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -124,6 +124,7 @@ function g_Game_GetMegaWADInfo(WAD: String): TMegaWADInfo; procedure g_Game_ChatSound(Text: String; Taunt: Boolean = True); procedure g_Game_Announce_GoodShot(SpawnerUID: Word); procedure g_Game_Announce_KillCombo(Param: Integer); +procedure g_Game_Announce_BodyKill(SpawnerUID: Word); procedure g_Game_StartVote(Command, Initiator: string); procedure g_Game_CheckVote; procedure g_TakeScreenShot(); @@ -201,6 +202,7 @@ const DE_GLOBEVENT = 0; DE_BFGHIT = 1; DE_KILLCOMBO = 2; + DE_BODYKILL = 3; ANNOUNCE_NONE = 0; ANNOUNCE_ME = 1; @@ -234,6 +236,8 @@ var gAnnouncer: Byte = ANNOUNCE_NONE; goodsnd: array[0..3] of TPlayableSound; killsnd: array[0..3] of TPlayableSound; + hahasnd: array[0..2] of TPlayableSound; + gBodyKillEvent: Integer = -1; gDefInterTime: ShortInt = -1; gInterEndTime: LongWord = 0; gInterTime: LongWord = 0; @@ -1500,11 +1504,18 @@ 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; strafeDir: Byte; i: Integer; + rwk: Boolean; begin if (plr = nil) then exit; if (p2hack) then time := 1000 else time := 1; @@ -1548,13 +1559,42 @@ begin 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) then plr.PressKey(KEY_NEXTWEAPON); - if isKeyPressed(KeyPrevWeapon, KeyPrevWeapon2) then plr.PressKey(KEY_PREVWEAPON); + if isKeyPressed(KeyNextWeapon, KeyNextWeapon2) then + begin + rwk := plr.isWeaponSwitchKeyReleased(-1); + if rwk then plr.PressKey(KEY_NEXTWEAPON); + plr.weaponSwitchKeysStateChange(-1, true); + end + else + begin + plr.weaponSwitchKeysStateChange(-1, false); + end; + if isKeyPressed(KeyPrevWeapon, KeyPrevWeapon2) then + begin + rwk := plr.isWeaponSwitchKeyReleased(-2); + if rwk then plr.PressKey(KEY_PREVWEAPON); + plr.weaponSwitchKeysStateChange(-2, true); + end + else + begin + plr.weaponSwitchKeysStateChange(-2, false); + end; if isKeyPressed(KeyOpen, KeyOpen2) then plr.PressKey(KEY_OPEN); for i := 0 to High(KeyWeapon) do + begin if isKeyPressed(KeyWeapon[i], KeyWeapon2[i]) then - plr.QueueWeaponSwitch(i); // all choices are passed there, and god will take the best + begin + rwk := plr.isWeaponSwitchKeyReleased(i); + //writeln('rwk:', rwk); + plr.weaponSwitchKeysStateChange(i, true); + if rwk then plr.QueueWeaponSwitch(i); // all choices are passed there, and god will take the best + end + else + begin + plr.weaponSwitchKeysStateChange(i, false); + end; + end; end; // HACK: add dynlight here @@ -2184,6 +2224,9 @@ begin if g_Game_IsNet and g_Game_IsServer then MH_SEND_GameEvent(NET_EV_KILLCOMBO, gDelayedEvents[a].DENum); end; + DE_BODYKILL: + if gGameOn then + g_Game_Announce_BodyKill(gDelayedEvents[a].DENum); end; gDelayedEvents[a].Pending := False; end; @@ -2335,6 +2378,9 @@ begin g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD+':SOUNDS\KILL3X'); g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD+':SOUNDS\KILL4X'); g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD+':SOUNDS\KILLMX'); + 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'); goodsnd[0] := TPlayableSound.Create(); goodsnd[1] := TPlayableSound.Create(); @@ -2356,6 +2402,14 @@ begin killsnd[2].SetByName('SOUND_ANNOUNCER_KILL4X'); killsnd[3].SetByName('SOUND_ANNOUNCER_KILLMX'); + hahasnd[0] := TPlayableSound.Create(); + hahasnd[1] := TPlayableSound.Create(); + hahasnd[2] := TPlayableSound.Create(); + + hahasnd[0].SetByName('SOUND_ANNOUNCER_MUHAHA1'); + hahasnd[1].SetByName('SOUND_ANNOUNCER_MUHAHA2'); + hahasnd[2].SetByName('SOUND_ANNOUNCER_MUHAHA3'); + g_Game_LoadChatSounds(GameWAD+':CHATSND\SNDCFG'); g_Game_SetLoadingText(_lc[I_LOAD_ITEMS_DATA], 0, False); @@ -2429,6 +2483,14 @@ begin g_Sound_Delete('SOUND_ANNOUNCER_KILL4X'); g_Sound_Delete('SOUND_ANNOUNCER_KILLMX'); + hahasnd[0].Free(); + hahasnd[1].Free(); + hahasnd[2].Free(); + + g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1'); + g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2'); + g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3'); + g_Game_FreeChatSounds(); DataLoaded := False; @@ -7313,6 +7375,25 @@ begin killsnd[n].Play(); end; +procedure g_Game_Announce_BodyKill(SpawnerUID: Word); +var + a: Integer; +begin + case gAnnouncer of + ANNOUNCE_NONE: + Exit; + ANNOUNCE_ME, + ANNOUNCE_MEPLUS: + if not g_Game_IsWatchedPlayer(SpawnerUID) then + Exit; + end; + for a := 0 to 2 do + if hahasnd[a].IsPlaying() then + Exit; + + hahasnd[Random(3)].Play(); +end; + procedure g_Game_StartVote(Command, Initiator: string); var Need: Integer;