From 281969a1bea9afbf36babebcf9208549929a96f4 Mon Sep 17 00:00:00 2001 From: Stas'M Date: Thu, 31 Jan 2019 21:39:28 +0300 Subject: [PATCH] Add sounds for flamethrower --- src/game/g_game.pas | 2 ++ src/game/g_net.pas | 2 +- src/game/g_netmsg.pas | 6 +++- src/game/g_player.pas | 65 ++++++++++++++++++++++++++++++++++++++++- src/game/g_triggers.pas | 2 +- src/game/g_weapons.pas | 6 ++++ 6 files changed, 79 insertions(+), 4 deletions(-) diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 12c9824..7d660aa 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -2336,6 +2336,7 @@ begin g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD+':SOUNDS\BULK2'); g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD+':SOUNDS\BUBBLE1'); g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD+':SOUNDS\BUBBLE2'); + g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD+':SOUNDS\BURNING'); g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD+':SOUNDS\SWITCH1'); g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD+':SOUNDS\SWITCH0'); g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD+':SOUNDS\RADIO'); @@ -2455,6 +2456,7 @@ begin g_Sound_Delete('SOUND_GAME_BULK2'); g_Sound_Delete('SOUND_GAME_BUBBLE1'); g_Sound_Delete('SOUND_GAME_BUBBLE2'); + g_Sound_Delete('SOUND_GAME_BURNING'); g_Sound_Delete('SOUND_GAME_SWITCH1'); g_Sound_Delete('SOUND_GAME_SWITCH0'); diff --git a/src/game/g_net.pas b/src/game/g_net.pas index 1007f0f..c5bce96 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 = 177; + NET_PROTOCOL_VER = 178; NET_MAXCLIENTS = 24; NET_CHANS = 11; diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas index f5b30ef..a060162 100644 --- a/src/game/g_netmsg.pas +++ b/src/game/g_netmsg.pas @@ -1070,6 +1070,7 @@ begin NetOut.Write(Byte(FNoRespawn)); NetOut.Write(Byte(FJetpack)); NetOut.Write(FFireTime); + NetOut.Write(Byte(FFlaming)); end; g_Net_Host_Send(ID, True, NET_CHAN_PLAYER); @@ -2116,7 +2117,7 @@ var PID: Word; Pl: TPlayer; I: Integer; - OldJet: Boolean; + OldJet, Flam: Boolean; NewTeam: Byte; begin PID := M.ReadWord(); @@ -2192,10 +2193,13 @@ begin OldJet := FJetpack; FJetpack := M.ReadByte() <> 0; FFireTime := M.ReadLongInt(); + Flam := M.ReadByte() <> 0; if OldJet and not FJetpack then JetpackOff else if not OldJet and FJetpack then JetpackOn; + if FFlaming and not Flam then + FlamerOff; if Team <> NewTeam then Pl.ChangeTeam(NewTeam); end; diff --git a/src/game/g_player.pas b/src/game/g_player.pas index 5c8fdb7..5d1f863 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -191,6 +191,9 @@ type FSawSoundIdle: TPlayableSound; FSawSoundHit: TPlayableSound; FSawSoundSelect: TPlayableSound; + FFlameSoundOn: TPlayableSound; + FFlameSoundOff: TPlayableSound; + FFlameSoundWork: TPlayableSound; FJetSoundOn: TPlayableSound; FJetSoundOff: TPlayableSound; FJetSoundFly: TPlayableSound; @@ -253,6 +256,7 @@ type FWantsInGame: Boolean; FGhost: Boolean; FPhysics: Boolean; + FFlaming: Boolean; FJetpack: Boolean; FActualModelName: string; FClientID: SmallInt; @@ -325,6 +329,8 @@ type procedure SetLerp(XTo, YTo: Integer); procedure QueueWeaponSwitch(Weapon: Byte); procedure RealizeCurrentWeapon(); + procedure FlamerOn; + procedure FlamerOff; procedure JetpackOn; procedure JetpackOff; procedure CatchFire(Attacker: Word); @@ -2099,6 +2105,9 @@ begin FSawSoundIdle := TPlayableSound.Create(); FSawSoundHit := TPlayableSound.Create(); FSawSoundSelect := TPlayableSound.Create(); + FFlameSoundOn := TPlayableSound.Create(); + FFlameSoundOff := TPlayableSound.Create(); + FFlameSoundWork := TPlayableSound.Create(); FJetSoundFly := TPlayableSound.Create(); FJetSoundOn := TPlayableSound.Create(); FJetSoundOff := TPlayableSound.Create(); @@ -2107,6 +2116,9 @@ begin FSawSoundIdle.SetByName('SOUND_WEAPON_IDLESAW'); FSawSoundHit.SetByName('SOUND_WEAPON_HITSAW'); FSawSoundSelect.SetByName('SOUND_WEAPON_SELECTSAW'); + FFlameSoundOn.SetByName('SOUND_WEAPON_FLAMEON'); + FFlameSoundOff.SetByName('SOUND_WEAPON_FLAMEOFF'); + FFlameSoundWork.SetByName('SOUND_WEAPON_FLAMEWORK'); FJetSoundFly.SetByName('SOUND_PLAYER_JETFLY'); FJetSoundOn.SetByName('SOUND_PLAYER_JETON'); FJetSoundOff.SetByName('SOUND_PLAYER_JETOFF'); @@ -2267,6 +2279,9 @@ begin FSawSoundIdle.Free(); FSawSoundHit.Free(); FSawSoundSelect.Free(); + FFlameSoundOn.Free(); + FFlameSoundOff.Free(); + FFlameSoundWork.Free(); FJetSoundFly.Free(); FJetSoundOn.Free(); FJetSoundOff.Free(); @@ -3046,11 +3061,17 @@ begin if FAmmo[A_FUEL] > 0 then begin g_Weapon_flame(wx, wy, xd, yd, FUID); + FlamerOn; FReloading[FCurrWeap] := WEAPON_RELOAD[FCurrWeap]; Dec(FAmmo[A_FUEL]); FFireAngle := FAngle; f := True; DidFire := True; + end + else + begin + FlamerOff; + if g_Game_IsNet and g_Game_IsServer then MH_SEND_PlayerStats(FUID); end; end; @@ -3094,6 +3115,35 @@ begin PANEL_WATER or PANEL_ACID1 or PANEL_ACID2, True); end; +procedure TPlayer.FlamerOn; +begin + FFlameSoundOff.Stop(); + FFlameSoundOff.SetPosition(0); + if FFlaming then + begin + if (not FFlameSoundOn.IsPlaying()) and (not FFlameSoundWork.IsPlaying()) then + FFlameSoundWork.PlayAt(FObj.X, FObj.Y); + end + else + begin + FFlameSoundOn.PlayAt(FObj.X, FObj.Y); + FFlaming := True; + end; +end; + +procedure TPlayer.FlamerOff; +begin + if FFlaming then + begin + FFlameSoundOn.Stop(); + FFlameSoundOn.SetPosition(0); + FFlameSoundWork.Stop(); + FFlameSoundWork.SetPosition(0); + FFlameSoundOff.PlayAt(FObj.X, FObj.Y); + FFlaming := False; + end; +end; + procedure TPlayer.JetpackOn; begin FJetSoundFly.Stop; @@ -4522,6 +4572,7 @@ begin FDamageBuffer := 0; FJetpack := False; FCanJetpack := False; + FFlaming := False; FFireTime := 0; FFirePainTime := 0; FFireAttacker := 0; @@ -4923,7 +4974,15 @@ begin if FKeys[KEY_RIGHT].Pressed then Run(TDirection.D_RIGHT); //if FKeys[KEY_NEXTWEAPON].Pressed and AnyServer then NextWeapon(); //if FKeys[KEY_PREVWEAPON].Pressed and AnyServer then PrevWeapon(); - if FKeys[KEY_FIRE].Pressed and AnyServer then Fire(); + if FKeys[KEY_FIRE].Pressed and AnyServer then Fire() + else + begin + if AnyServer then + begin + FlamerOff; + if NetServer then MH_SEND_PlayerStats(FUID); + end; + end; if FKeys[KEY_OPEN].Pressed and AnyServer then Use(); if FKeys[KEY_JUMP].Pressed then Jump() else @@ -5491,6 +5550,7 @@ begin WEAPON_FLAMETHROWER: begin g_Weapon_flame(wx, wy, xd, yd, FUID, WID); + FlamerOn; FFireAngle := FAngle; f := True; end; @@ -6261,6 +6321,9 @@ begin FSawSoundIdle.Pause(Enable); FSawSoundHit.Pause(Enable); FSawSoundSelect.Pause(Enable); + FFlameSoundOn.Pause(Enable); + FFlameSoundOff.Pause(Enable); + FFlameSoundWork.Pause(Enable); FJetSoundFly.Pause(Enable); FJetSoundOn.Pause(Enable); FJetSoundOff.Pause(Enable); diff --git a/src/game/g_triggers.pas b/src/game/g_triggers.pas index e75d79f..1673cef 100644 --- a/src/game/g_triggers.pas +++ b/src/game/g_triggers.pas @@ -809,7 +809,7 @@ begin TRIGGER_SHOT_FLAME: begin g_Weapon_flame(wx, wy, dx, dy, 0, -1, True); - //snd := 'SOUND_WEAPON_FIREPLASMA'; + snd := 'SOUND_GAME_BURNING'; end; else exit; diff --git a/src/game/g_weapons.pas b/src/game/g_weapons.pas index 78965ef..5505731 100644 --- a/src/game/g_weapons.pas +++ b/src/game/g_weapons.pas @@ -1126,6 +1126,9 @@ begin g_Sound_CreateWADEx('SOUND_WEAPON_FIREBALL', GameWAD+':SOUNDS\FIREBALL'); g_Sound_CreateWADEx('SOUND_WEAPON_EXPLODEBALL', GameWAD+':SOUNDS\EXPLODEBALL'); g_Sound_CreateWADEx('SOUND_WEAPON_FIREREV', GameWAD+':SOUNDS\FIREREV'); + g_Sound_CreateWADEx('SOUND_WEAPON_FLAMEON', GameWAD+':SOUNDS\STARTFLM'); + g_Sound_CreateWADEx('SOUND_WEAPON_FLAMEOFF', GameWAD+':SOUNDS\STOPFLM'); + g_Sound_CreateWADEx('SOUND_WEAPON_FLAMEWORK', GameWAD+':SOUNDS\WORKFLM'); g_Sound_CreateWADEx('SOUND_PLAYER_JETFLY', GameWAD+':SOUNDS\WORKJETPACK'); g_Sound_CreateWADEx('SOUND_PLAYER_JETON', GameWAD+':SOUNDS\STARTJETPACK'); g_Sound_CreateWADEx('SOUND_PLAYER_JETOFF', GameWAD+':SOUNDS\STOPJETPACK'); @@ -1192,6 +1195,9 @@ begin g_Sound_Delete('SOUND_WEAPON_FIREBALL'); g_Sound_Delete('SOUND_WEAPON_EXPLODEBALL'); g_Sound_Delete('SOUND_WEAPON_FIREREV'); + g_Sound_Delete('SOUND_WEAPON_FLAMEON'); + g_Sound_Delete('SOUND_WEAPON_FLAMEOFF'); + g_Sound_Delete('SOUND_WEAPON_FLAMEWORK'); g_Sound_Delete('SOUND_PLAYER_JETFLY'); g_Sound_Delete('SOUND_PLAYER_JETON'); g_Sound_Delete('SOUND_PLAYER_JETOFF'); -- 2.29.2