From: Dmitry Lyashuk Date: Fri, 25 Mar 2022 17:22:39 +0000 (+0300) Subject: Game: improving weapon autoswitch, added rotation by travi$ X-Git-Url: http://deadsoftware.ru/gitweb?p=d2df-sdl.git;a=commitdiff_plain;h=88999196d89648a7ba4f6367e2a882e0d56bc5b5 Game: improving weapon autoswitch, added rotation by travi$ --- diff --git a/src/game/g_console.pas b/src/game/g_console.pas index a4dddf3..8c0c41e 100644 --- a/src/game/g_console.pas +++ b/src/game/g_console.pas @@ -95,7 +95,7 @@ implementation uses g_textures, g_main, e_graphics, e_input, g_game, g_gfx, g_player, g_items, SysUtils, g_basic, g_options, Math, g_touch, e_res, - g_menu, g_gui, g_language, g_net, g_netmsg, e_log, conbuf; + g_menu, g_gui, g_language, g_net, g_netmsg, e_log, conbuf, g_weapons; const autoexecScript = 'autoexec.cfg'; @@ -1036,6 +1036,32 @@ begin AddCommand('p2_model', PlayerSettingsCVars); AddCommand('p1_team', PlayerSettingsCVars); AddCommand('p2_team', PlayerSettingsCVars); + AddCommand('p1_autoswitch', PlayerSettingsCVars); + AddCommand('p2_autoswitch', PlayerSettingsCVars); + AddCommand('p1_priority_kastet', PlayerSettingsCVars); + AddCommand('p2_priority_kastet', PlayerSettingsCVars); + AddCommand('p1_priority_saw', PlayerSettingsCVars); + AddCommand('p2_priority_saw', PlayerSettingsCVars); + AddCommand('p1_priority_pistol', PlayerSettingsCVars); + AddCommand('p2_priority_pistol', PlayerSettingsCVars); + AddCommand('p1_priority_shotgun1', PlayerSettingsCVars); + AddCommand('p2_priority_shotgun1', PlayerSettingsCVars); + AddCommand('p1_priority_shotgun2', PlayerSettingsCVars); + AddCommand('p2_priority_shotgun2', PlayerSettingsCVars); + AddCommand('p1_priority_chaingun', PlayerSettingsCVars); + AddCommand('p2_priority_chaingun', PlayerSettingsCVars); + AddCommand('p1_priority_rocketlauncher', PlayerSettingsCVars); + AddCommand('p2_priority_rocketlauncher', PlayerSettingsCVars); + AddCommand('p1_priority_plasma', PlayerSettingsCVars); + AddCommand('p2_priority_plasma', PlayerSettingsCVars); + AddCommand('p1_priority_bfg', PlayerSettingsCVars); + AddCommand('p2_priority_bfg', PlayerSettingsCVars); + AddCommand('p1_priority_super', PlayerSettingsCVars); + AddCommand('p2_priority_super', PlayerSettingsCVars); + AddCommand('p1_priority_flamethrower', PlayerSettingsCVars); + AddCommand('p2_priority_flamethrower', PlayerSettingsCVars); + AddCommand('p1_priority_berserk', PlayerSettingsCVars); + AddCommand('p2_priority_berserk', PlayerSettingsCVars); AddCommand('g_max_particles', GameCVars); AddCommand('g_max_shells', GameCVars); @@ -2178,6 +2204,20 @@ begin WriteLn(f, 'p1_color ', Color.R, ' ', Color.G, ' ', Color.B); WriteLn(f, 'p1_model ', QuoteStr(Model)); WriteLn(f, 'p1_team ', FormatTeam(Team)); + WriteLn(f, 'p1_autoswitch ', WeaponSwitch); + WriteLn(f, 'p1_priority_kastet ', Max(0, WeaponPreferences[WEAPON_KASTET])); + WriteLn(f, 'p1_priority_saw ', Max(0, WeaponPreferences[WEAPON_SAW])); + WriteLn(f, 'p1_priority_pistol ', Max(0, WeaponPreferences[WEAPON_PISTOL])); + WriteLn(f, 'p1_priority_shotgun1 ', Max(0, WeaponPreferences[WEAPON_SHOTGUN1])); + WriteLn(f, 'p1_priority_shotgun2 ', Max(0, WeaponPreferences[WEAPON_SHOTGUN2] )); + WriteLn(f, 'p1_priority_chaingun ', Max(0, WeaponPreferences[WEAPON_CHAINGUN])); + WriteLn(f, 'p1_priority_rocketlauncher ', Max(0, WeaponPreferences[WEAPON_ROCKETLAUNCHER])); + WriteLn(f, 'p1_priority_plasma ', Max(0, WeaponPreferences[WEAPON_PLASMA])); + WriteLn(f, 'p1_priority_bfg ', Max(0, WeaponPreferences[WEAPON_BFG])); + WriteLn(f, 'p1_priority_super ', Max(0, WeaponPreferences[WEAPON_SUPERPULEMET])); + WriteLn(f, 'p1_priority_flamethrower ', Max(0, WeaponPreferences[WEAPON_FLAMETHROWER])); + WriteLn(f, 'p1_priority_berserk ', Max(0, WeaponPreferences[WP_LAST+1])); + // end; with gPlayer2Settings do begin @@ -2185,6 +2225,19 @@ begin WriteLn(f, 'p2_color ', Color.R, ' ', Color.G, ' ', Color.B); WriteLn(f, 'p2_model ', QuoteStr(Model)); WriteLn(f, 'p2_team ', FormatTeam(Team)); + WriteLn(f, 'p2_autoswitch ', WeaponSwitch); + WriteLn(f, 'p2_priority_kastet ', Max(0, WeaponPreferences[WEAPON_KASTET])); + WriteLn(f, 'p2_priority_saw ', Max(0, WeaponPreferences[WEAPON_SAW])); + WriteLn(f, 'p2_priority_pistol ', Max(0, WeaponPreferences[WEAPON_PISTOL])); + WriteLn(f, 'p2_priority_shotgun1 ', Max(0, WeaponPreferences[WEAPON_SHOTGUN1])); + WriteLn(f, 'p2_priority_shotgun2 ', Max(0, WeaponPreferences[WEAPON_SHOTGUN1])); + WriteLn(f, 'p2_priority_chaingun ', Max(0, WeaponPreferences[WEAPON_CHAINGUN])); + WriteLn(f, 'p2_priority_rocketlauncher ', Max(0, WeaponPreferences[WEAPON_ROCKETLAUNCHER])); + WriteLn(f, 'p2_priority_plasma ', Max(0, WeaponPreferences[WEAPON_PLASMA])); + WriteLn(f, 'p2_priority_bfg ', Max(0, WeaponPreferences[WEAPON_BFG])); + WriteLn(f, 'p2_priority_super ', Max(0, WeaponPreferences[WEAPON_SUPERPULEMET])); + WriteLn(f, 'p2_priority_flamethrower ', Max(0, WeaponPreferences[WEAPON_FLAMETHROWER])); + WriteLn(f, 'p2_priority_berserk ', Max(0, WeaponPreferences[WP_LAST+1])); end; // all cvars diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 653ba53..7674db9 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -62,6 +62,8 @@ type Model: String; Color: TRGB; Team: Byte; + WeaponSwitch: Byte; + WeaponPreferences: Array[WP_FIRST..WP_LAST+1] of Byte; end; TMegaWADInfo = record @@ -5917,6 +5919,136 @@ begin g_Console_Add(_lc[I_MSG_ONMAPCHANGE]); end; end; + 'p1_autoswitch': + begin + if (Length(P) = 2) then + gPlayer1Settings.WeaponSwitch := EnsureRange(StrTointDef(P[1], 0), 0, 2); + end; + 'p2_autoswitch': + begin + if (Length(P) = 2) then + gPlayer2Settings.WeaponSwitch := EnsureRange(StrTointDef(P[1], 0), 0, 2); + end; + 'p1_priority_kastet': + begin + if (Length(P) = 2) then + gPlayer1Settings.WeaponPreferences[WEAPON_KASTET] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p2_priority_kastet': + begin + if (Length(P) = 2) then + gPlayer2Settings.WeaponPreferences[WEAPON_KASTET] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p1_priority_saw': + begin + if (Length(P) = 2) then + gPlayer1Settings.WeaponPreferences[WEAPON_SAW] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p2_priority_saw': + begin + if (Length(P) = 2) then + gPlayer2Settings.WeaponPreferences[WEAPON_SAW] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p1_priority_pistol': + begin + if (Length(P) = 2) then + gPlayer1Settings.WeaponPreferences[WEAPON_KASTET] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p2_priority_pistol': + begin + if (Length(P) = 2) then + gPlayer2Settings.WeaponPreferences[WEAPON_KASTET] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p1_priority_shotgun1': + begin + if (Length(P) = 2) then + gPlayer1Settings.WeaponPreferences[WEAPON_SHOTGUN1] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p2_priority_shotgun1': + begin + if (Length(P) = 2) then + gPlayer2Settings.WeaponPreferences[WEAPON_SHOTGUN1] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p1_priority_shotgun2': + begin + if (Length(P) = 2) then + gPlayer1Settings.WeaponPreferences[WEAPON_SHOTGUN2] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p2_priority_shotgun2': + begin + if (Length(P) = 2) then + gPlayer2Settings.WeaponPreferences[WEAPON_SHOTGUN2] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p1_priority_chaingun': + begin + if (Length(P) = 2) then + gPlayer1Settings.WeaponPreferences[WEAPON_CHAINGUN] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p2_priority_chaingun': + begin + if (Length(P) = 2) then + gPlayer2Settings.WeaponPreferences[WEAPON_CHAINGUN] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p1_priority_rocketlauncher': + begin + if (Length(P) = 2) then + gPlayer1Settings.WeaponPreferences[WEAPON_ROCKETLAUNCHER] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p2_priority_rocketlauncher': + begin + if (Length(P) = 2) then + gPlayer2Settings.WeaponPreferences[WEAPON_ROCKETLAUNCHER] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p1_priority_plasma': + begin + if (Length(P) = 2) then + gPlayer1Settings.WeaponPreferences[WEAPON_PLASMA] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p2_priority_plasma': + begin + if (Length(P) = 2) then + gPlayer2Settings.WeaponPreferences[WEAPON_PLASMA] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p1_priority_bfg': + begin + if (Length(P) = 2) then + gPlayer1Settings.WeaponPreferences[WEAPON_BFG] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p2_priority_bfg': + begin + if (Length(P) = 2) then + gPlayer2Settings.WeaponPreferences[WEAPON_BFG] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p1_priority_super': + begin + if (Length(P) = 2) then + gPlayer1Settings.WeaponPreferences[WEAPON_SUPERPULEMET] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p2_priority_super': + begin + if (Length(P) = 2) then + gPlayer2Settings.WeaponPreferences[WEAPON_SUPERPULEMET] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p1_priority_flamethrower': + begin + if (Length(P) = 2) then + gPlayer1Settings.WeaponPreferences[WEAPON_FLAMETHROWER] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p2_priority_flamethrower': + begin + if (Length(P) = 2) then + gPlayer2Settings.WeaponPreferences[WEAPON_FLAMETHROWER] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p1_priority_berserk': + begin + if (Length(P) = 2) then + gPlayer1Settings.WeaponPreferences[WP_LAST+1] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; + 'p2_priority_berserk': + begin + if (Length(P) = 2) then + gPlayer2Settings.WeaponPreferences[WP_LAST+1] := EnsureRange(StrToIntDef(P[1], WP_FIRST), WP_FIRST, WP_LAST+1); + end; end; end; diff --git a/src/game/g_language.pas b/src/game/g_language.pas index 362da8d..8d2060e 100644 --- a/src/game/g_language.pas +++ b/src/game/g_language.pas @@ -113,6 +113,7 @@ type I_GAME_WEAPON8, I_GAME_WEAPON9, I_GAME_WEAPON10, + I_GAME_WEAPON_BERSERK, I_MENU_START_GAME, I_MENU_MAIN_MENU, @@ -317,6 +318,13 @@ type I_MENU_PLAYER_RED, I_MENU_PLAYER_GREEN, I_MENU_PLAYER_BLUE, + I_MENU_WEAPON, + I_MENU_WEAPON_SWITCH, + I_MENU_WEAPON_SWITCH_LINEAR, + I_MENU_WEAPON_SWITCH_PREFERENCE, + I_MENU_WEAPON_SWITCH_PRIORITY, + I_MENU_WEAPON_PRIORITY_PLAYER_1, + I_MENU_WEAPON_PRIORITY_PLAYER_2, I_MENU_MODEL_INFO, I_MENU_MODEL_ANIMATION, @@ -849,6 +857,8 @@ const 'Ñóïåðïóëåì¸ò'), ('GAME WEAPON10', 'Flamethrower', 'Îãíåì¸ò'), + ('GAME WEAPON BERSERK', 'Berserk', + 'Áåðñåðê'), ('MENU START GAME', 'Start Game', 'ÍÀ×ÀÒÜ ÈÃÐÓ'), @@ -1243,7 +1253,20 @@ const 'Çåë¸íûé:'), ('MENU PLAYER BLUE', 'Blue:', 'Ñèíèé:'), - + ('MENU WEAPON', 'Weapon preferences', + 'Íàñòðîèòü îðóæèå'), + ('MENU WEAPON SWITCH', 'Weapon autoswitch', + 'Àâòîâûáîð îðóæèÿ'), + ('MENU WEAPON SWITCH LINEAR', 'On pickup', + 'Ïðè ïîäáîðå'), + ('MENU WEAPON SWITCH PREFERENCE', 'By priority', + 'Ïî ïðèîðèòåòíîñòè'), + ('MENU WEAPON SWITCH PRIORITY', 'Weapon priority', + 'Ïðèîðèòåòíîñòü îðóæèÿ'), + ('MENU WEAPON PRIORITY PLAYER 1', 'Player 1 Priority', + 'Ïðèîðèòåò îðóæèÿ (1)'), + ('MENU WEAPON PRIORITY PLAYER 2', 'Player 2 Priority', + 'Ïðèîðèòåò îðóæèÿ (2)'), ('MENU MODEL INFO', 'Model info', 'Èíôîðìàöèÿ î ìîäåëè'), ('MENU MODEL ANIMATION', 'Change animation', @@ -1251,7 +1274,7 @@ const ('MENU MODEL CHANGE WEAPON', 'Change weapon', 'Ñìåíèòü îðóæèå'), ('MENU MODEL ROTATE', 'Reflect model', - 'Ðàçâåðíóòü ìîäåëü'), + 'Ðàçâåðíóòü ìîäåëü'), ('MENU MODEL NAME', 'Name:', 'Èìÿ:'), ('MENU MODEL AUTHOR', 'Author:', diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas index 9e89ad9..2f6ce09 100644 --- a/src/game/g_menu.pas +++ b/src/game/g_menu.pas @@ -170,7 +170,6 @@ begin TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value; g_dbg_scale := TempScale + 1; end; - gWeaponAutoswitch := TGUISwitch(menu.GetControl('swWeaponAutoswitch')).ItemIndex = 0; menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu')); @@ -343,6 +342,42 @@ begin gPlayer1Settings.Color := Model.Color; end; + menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu')); + + gPlayer1Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP1Name')).Text); + gPlayer1Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP1Team')).ItemIndex = 0, + TEAM_RED, TEAM_BLUE); + + with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mvP1Model')) do + begin + gPlayer1Settings.Model := Model.Name; + gPlayer1Settings.Color := Model.Color; + end; + + menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1WeaponMenu').GetControl('mOptionsPlayersP1WeaponMenu')); + gPlayer1Settings.WeaponSwitch := TGUISwitch(menu.GetControl('swWeaponAutoswitch')).ItemIndex; + + menu := TGUIMenu(g_GUI_GetWindow('OptionsPreferencesP1WeaponMenu').GetControl('mOptionsPreferencesP1WeaponMenu')); + with menu do + begin + for i := WP_FIRST to WP_LAST+1 do + begin + gPlayer1Settings.WeaponPreferences[i] := TGUISwitch(menu.GetControl(IntToStr(i))).ItemIndex; + end; + end; + + menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2WeaponMenu').GetControl('mOptionsPlayersP2WeaponMenu')); + gPlayer2Settings.WeaponSwitch := TGUISwitch(menu.GetControl('swWeaponAutoswitch')).ItemIndex; + + menu := TGUIMenu(g_GUI_GetWindow('OptionsPreferencesP2WeaponMenu').GetControl('mOptionsPreferencesP2WeaponMenu')); + with menu do + begin + for i := WP_FIRST to WP_LAST+1 do + begin + gPlayer2Settings.WeaponPreferences[i] := TGUISwitch(menu.GetControl(IntToStr(i))).ItemIndex; + end; + end; + menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu')); gPlayer2Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP2Name')).Text); @@ -392,7 +427,7 @@ end; procedure ReadOptions(); var menu: TGUIMenu; - i: Integer; + i, a: Integer; begin menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu')); @@ -597,9 +632,6 @@ begin TempScale := Round(g_dbg_scale - 1); TGUIScroll(menu.GetControl('scScaleFactor')).Value := TempScale; - with TGUISwitch(menu.GetControl('swWeaponAutoswitch')) do - if gWeaponAutoswitch then ItemIndex := 0 else ItemIndex := 1; - menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu')); TGUIListBox(menu.GetControl('lsP1Model')).SelectItem(gPlayer1Settings.Model); @@ -612,6 +644,26 @@ begin TGUIScroll(menu.GetControl('scP1Green')).Value := Round(gPlayer1Settings.Color.G/16); TGUIScroll(menu.GetControl('scP1Blue')).Value := Round(gPlayer1Settings.Color.B/16); + menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1WeaponMenu').GetControl('mOptionsPlayersP1WeaponMenu')); + TGUISwitch(menu.GetControl('swWeaponAutoswitch')).ItemIndex := gPlayer1Settings.WeaponSwitch; + + menu := TGUIMenu(g_GUI_GetWindow('OptionsPreferencesP1WeaponMenu').GetControl('mOptionsPreferencesP1WeaponMenu')); + for i := WP_FIRST to WP_LAST+1 do + begin + if (gPlayer1Settings.WeaponPreferences[i] > 0) and (gPlayer1Settings.WeaponPreferences[i] <= WP_LAST+1) then TGUISwitch(menu.GetControl(IntToStr(i))).ItemIndex := gPlayer1Settings.WeaponPreferences[i] + else TGUISwitch(menu.GetControl(IntToStr(i))).ItemIndex := 0; + end; + + menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2WeaponMenu').GetControl('mOptionsPlayersP2WeaponMenu')); + TGUISwitch(menu.GetControl('swWeaponAutoswitch')).ItemIndex := gPlayer2Settings.WeaponSwitch; + + menu := TGUIMenu(g_GUI_GetWindow('OptionsPreferencesP2WeaponMenu').GetControl('mOptionsPreferencesP2WeaponMenu')); + for i := WP_FIRST to WP_LAST+1 do + begin + if (gPlayer2Settings.WeaponPreferences[i] > 0) and (gPlayer2Settings.WeaponPreferences[i] <= WP_LAST+1) then TGUISwitch(menu.GetControl(IntToStr(i))).ItemIndex := gPlayer2Settings.WeaponPreferences[i] + else TGUISwitch(menu.GetControl(IntToStr(i))).ItemIndex := 0; + end; + menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu')); TGUIListBox(menu.GetControl('lsP2Model')).SelectItem(gPlayer2Settings.Model); @@ -1402,6 +1454,34 @@ begin g_GUI_ShowWindow('OptionsPlayersMIMenu'); end; +procedure ProcOptionsPlayerP1WeaponMenu(); +var + a: string; +begin + a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+'P1'+'Menu')).GetControl('ls'+'P1'+'Model')).SelectedItem; + if a = '' then Exit; + g_GUI_ShowWindow('OptionsPlayersP1WeaponMenu'); +end; + +procedure ProcOptionsPlayerP1WeaponPreferencesMenu(); +begin + g_GUI_ShowWindow('OptionsPreferencesP1WeaponMenu'); +end; + +procedure ProcOptionsPlayerP2WeaponMenu(); +var + a: string; +begin + a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+'P2'+'Menu')).GetControl('ls'+'P2'+'Model')).SelectedItem; + if a = '' then Exit; + g_GUI_ShowWindow('OptionsPlayersP2WeaponMenu'); +end; + +procedure ProcOptionsPlayerP2WeaponPreferencesMenu(); +begin + g_GUI_ShowWindow('OptionsPreferencesP2WeaponMenu'); +end; + procedure ProcOptionsPlayersAnim(); var s: String; @@ -2074,7 +2154,8 @@ begin AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]); AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]); AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]); - + if s = 'P1' then AddButton(@ProcOptionsPlayerP1WeaponMenu, _lc[I_MENU_WEAPON]) + else AddButton(@ProcOptionsPlayerP2WeaponMenu, _lc[I_MENU_WEAPON]); with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do begin Name := 'mv'+s+'Model'; @@ -2090,7 +2171,7 @@ procedure CreateAllMenus(); var Menu: TGUIWindow; //SR: TSearchRec; - a, cx, _y, i: Integer; + a, cx, _y, i, x: Integer; //list: SSArray; begin Menu := TGUIWindow.Create('MainMenu'); @@ -2995,12 +3076,6 @@ begin Max := 10; OnChange := ProcChangeGameSettings; end; - with AddSwitch(_lc[I_MENU_GAME_WEAPON_AUTOSWITCH]) do - begin - Name := 'swWeaponAutoswitch'; - AddItem(_lc[I_MENU_YES]); - AddItem(_lc[I_MENU_NO]); - end; ReAlign(); end; Menu.DefControl := 'mOptionsGameMenu'; @@ -3186,6 +3261,99 @@ begin Menu.DefControl := 'mOptionsPlayersMIMenu'; g_GUI_AddWindow(Menu); + Menu := TGUIWindow.Create('OptionsPlayersP1WeaponMenu'); + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON]))) do + begin + Name := 'mOptionsPlayersP1WeaponMenu'; + with AddSwitch(_lc[I_MENU_WEAPON_SWITCH]) do + begin + Name := 'swWeaponAutoswitch'; + AddItem(_lc[I_MENU_NO]); + AddItem(_lc[I_MENU_WEAPON_SWITCH_LINEAR]); + AddItem(_lc[I_MENU_WEAPON_SWITCH_PREFERENCE]); + end; + AddButton(@ProcOptionsPlayerP1WeaponPreferencesMenu, _lc[I_MENU_WEAPON_SWITCH_PRIORITY]); + ReAlign(); + end; + Menu.DefControl := 'mOptionsPlayersP1WeaponMenu'; + g_GUI_AddWindow(Menu); + + Menu := TGUIWindow.Create('OptionsPreferencesP1WeaponMenu'); + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON_PRIORITY_PLAYER_1]))) do + begin + Name := 'mOptionsPreferencesP1WeaponMenu'; + for i := WP_FIRST to WP_LAST do + begin + with AddSwitch(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]) do + begin + Name := IntToStr(i); + for a := WP_FIRST to WP_LAST+1 do + begin + AddItem(IntToStr(a)); + end; + ItemIndex := i + end; + end; + with AddSwitch(_lc[I_GAME_WEAPON_BERSERK]) do + begin + Name := IntToStr(WP_LAST+1); + for a := WP_FIRST to WP_LAST+1 do + begin + AddItem(IntToStr(a)); + end; + ItemIndex := WP_LAST + 1; + end; + end; + Menu.DefControl := 'mOptionsPreferencesP1WeaponMenu'; + g_GUI_AddWindow(Menu); + + + Menu := TGUIWindow.Create('OptionsPlayersP2WeaponMenu'); + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON]))) do + begin + Name := 'mOptionsPlayersP2WeaponMenu'; + with AddSwitch(_lc[I_MENU_WEAPON_SWITCH]) do + begin + Name := 'swWeaponAutoswitch'; + AddItem(_lc[I_MENU_NO]); + AddItem(_lc[I_MENU_WEAPON_SWITCH_LINEAR]); + AddItem(_lc[I_MENU_WEAPON_SWITCH_PREFERENCE]); + end; + AddButton(@ProcOptionsPlayerP2WeaponPreferencesMenu, _lc[I_MENU_WEAPON_SWITCH_PRIORITY]); + ReAlign(); + end; + Menu.DefControl := 'mOptionsPlayersP2WeaponMenu'; + g_GUI_AddWindow(Menu); + + Menu := TGUIWindow.Create('OptionsPreferencesP2WeaponMenu'); + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON_PRIORITY_PLAYER_2]))) do + begin + Name := 'mOptionsPreferencesP2WeaponMenu'; + for i := WP_FIRST to WP_LAST do + begin + with AddSwitch(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]) do + begin + Name := IntToStr(i); + for a := WP_FIRST to WP_LAST+1 do + begin + AddItem(IntToStr(a)); + end; + ItemIndex := i + end; + end; + with AddSwitch(_lc[I_GAME_WEAPON_BERSERK]) do + begin + Name := IntToStr(WP_LAST+1); + for a := WP_FIRST to WP_LAST+1 do + begin + AddItem(IntToStr(a)); + end; + ItemIndex := WP_LAST + 1; + end; + end; + Menu.DefControl := 'mOptionsPreferencesP2WeaponMenu'; + g_GUI_AddWindow(Menu); + Menu := TGUIWindow.Create('OptionsLanguageMenu'); with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do begin diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas index 3701038..b7a0fdd 100644 --- a/src/game/g_netmsg.pas +++ b/src/game/g_netmsg.pas @@ -2471,16 +2471,25 @@ begin for I := WP_FIRST to WP_LAST do begin checkWeapon := (M.ReadByte() <> 0); - if ( ((PID = gPlayer1.UID) or ( (gPlayer2 <> nil) and (PID = gPlayer2.UID))) and (I <> WEAPON_PISTOL) and (I <> WEAPON_KASTET ) and (gWeaponAutoswitch = True)) then + if ( (gPlayer1Settings.WeaponSwitch = 0) and (gPlayer2Settings.WeaponSwitch = 0) ) or ( (I = WEAPON_KASTET) or (I = WEAPON_PISTOL) or (checkWeapon = False) or (FWeapon[I] = True) ) then + FWeapon[I] := checkWeapon + else begin - if ( (checkWeapon = True) and (FWeapon[I] = False) ) then - begin - FWeapon[I] := True; - if (PID = gPlayer1.UID) then gSelectWeapon[0, I] := True - else gSelectWeapon[1, I] := True; - end; + if ((PID = gPlayer1.UID) and (gPlayer1Settings.WeaponSwitch <> 0)) or ( (gPlayer2 <> nil) and (PID = gPlayer2.UID) and (gPlayer2Settings.WeaponSwitch <> 0) ) then + begin + FWeapon[I] := True; + if (PID = gPlayer1.UID) then + if (gPlayer1Settings.WeaponSwitch = 1) or ( (gPlayer1Settings.WeaponSwitch = 2) and (gPlayer1Settings.WeaponPreferences[I] > gPlayer1Settings.WeaponPreferences[CurrWeap]) ) then + begin + gSelectWeapon[0, I] := True; + end + else + if (gPlayer2Settings.WeaponSwitch = 1) or ( (gPlayer2Settings.WeaponSwitch = 2) and (gPlayer2Settings.WeaponPreferences[I] > gPlayer2Settings.WeaponPreferences[CurrWeap]) ) then + gSelectWeapon[1, I] := True; + end + else + FWeapon[I] := checkWeapon; end; - FWeapon[I] := checkWeapon; end; for I := A_BULLETS to A_HIGH do FAmmo[I] := M.ReadWord(); @@ -2500,8 +2509,28 @@ begin FRulez := FRulez + [R_KEY_GREEN]; if (M.ReadByte() <> 0) then FRulez := FRulez + [R_KEY_BLUE]; - if (M.ReadByte() <> 0) then + checkWeapon := M.ReadByte() <> 0; + if (checkWeapon) then + begin FRulez := FRulez + [R_BERSERK]; + if ((gPlayer2Settings.WeaponSwitch <> 0) and (gPlayer2Settings.WeaponSwitch <> 0)) and ((PID = gPlayer1.UID) or ( (gPlayer2 <> nil) and (PID = gPlayer2.UID) )) then + begin + if (PID = gPlayer1.UID) then + begin + if (gPlayer1Settings.WeaponSwitch = 1) or ( (gPlayer1Settings.WeaponSwitch = 2) and (gPlayer1Settings.WeaponPreferences[WP_LAST+1] > gPlayer1Settings.WeaponPreferences[CurrWeap]) ) then + begin + gSelectWeapon[0, WEAPON_KASTET] := True; + end; + end + else + begin + if (gPlayer2Settings.WeaponSwitch = 1) or ( (gPlayer2Settings.WeaponSwitch = 2) and (gPlayer2Settings.WeaponPreferences[WP_LAST+1] > gPlayer2Settings.WeaponPreferences[CurrWeap]) ) then + begin + gSelectWeapon[0, WEAPON_KASTET] := True; + end; + end; + end; + end; Frags := M.ReadLongInt(); Death := M.ReadLongInt(); @@ -3282,7 +3311,6 @@ begin NetOut.Write(gPlayer1Settings.Color.G); NetOut.Write(gPlayer1Settings.Color.B); NetOut.Write(gPlayer1Settings.Team); - g_Net_Client_Send(True, NET_CHAN_IMPORTANT); end; diff --git a/src/game/g_options.pas b/src/game/g_options.pas index 9cd3cbf..853c612 100644 --- a/src/game/g_options.pas +++ b/src/game/g_options.pas @@ -63,7 +63,6 @@ var gsSDLBufferSize: Integer; gDefaultMegawadStart: AnsiString; gBerserkAutoswitch: Boolean; - gWeaponAutoswitch: Boolean; glNPOTOverride: Boolean = false; (* Latched game settings *) @@ -256,7 +255,6 @@ begin e_FastScreenshots := True; gDefaultMegawadStart := DF_Default_Megawad_Start; gBerserkAutoswitch := True; - gWeaponAutoswitch := True; g_dbg_scale := 1.0; gSaveStats := False; diff --git a/src/game/g_player.pas b/src/game/g_player.pas index 80ab62e..ee0655c 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -3877,6 +3877,7 @@ function TPlayer.PickItem(ItemType: Byte; arespawn: Boolean; var remove: Boolean var a: Boolean; + switchWeapon: Byte; hadWeapon: Boolean; begin Result := False; @@ -3885,7 +3886,6 @@ begin // a = true - ìåñòî ñïàâíà ïðåäìåòà: a := LongBool(gGameSettings.Options and GAME_OPTION_WEAPONSTAY) and arespawn; remove := not a; - case ItemType of ITEM_MEDKIT_SMALL: if (FHealth < PLAYER_HP_SOFT) or (FFireTime > 0) then @@ -3951,18 +3951,9 @@ begin ITEM_WEAPON_SAW: if (not FWeapon[WEAPON_SAW]) or ((not arespawn) and (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF])) then begin - if ( (gWeaponAutoswitch = True) and ((g_Game_IsNet = False or (NetMode = NET_SERVER)) and ((Self = gPlayer1) or (Self = gPlayer2)))) then - begin - hadWeapon := FWeapon[WEAPON_SAW]; - FWeapon[WEAPON_SAW] := True; - if (hadWeapon = False) then - begin - FCurrWeap := WEAPON_SAW; - resetWeaponQueue(); - FModel.SetWeapon(WEAPON_SAW); - end; - end - else FWeapon[WEAPON_SAW] := True; + hadWeapon := FWeapon[WEAPON_SAW]; + switchWeapon := WEAPON_SAW; + FWeapon[WEAPON_SAW] := True; Result := True; if gFlash = 2 then Inc(FPickup, 5); if a and g_Game_IsNet then MH_SEND_Sound(GameX, GameY, 'SOUND_ITEM_GETWEAPON'); @@ -3973,19 +3964,10 @@ begin begin // Íóæíî, ÷òîáû íå âçÿòü âñå ïóëè ñðàçó: if a and FWeapon[WEAPON_SHOTGUN1] then Exit; + hadWeapon := FWeapon[WEAPON_SHOTGUN1]; + switchWeapon := WEAPON_SHOTGUN1; IncMax(FAmmo[A_SHELLS], 4, FMaxAmmo[A_SHELLS]); - if ( (gWeaponAutoswitch = True) and ((g_Game_IsNet = False or (NetMode = NET_SERVER)) and ((Self = gPlayer1) or (Self = gPlayer2)))) then - begin - hadWeapon := FWeapon[WEAPON_SHOTGUN1]; - FWeapon[WEAPON_SHOTGUN1] := True; - if (hadWeapon = False) then - begin - FCurrWeap := WEAPON_SHOTGUN1; - resetWeaponQueue(); - FModel.SetWeapon(WEAPON_SHOTGUN1); - end; - end - else FWeapon[WEAPON_SHOTGUN1] := True; + FWeapon[WEAPON_SHOTGUN1] := True; Result := True; if gFlash = 2 then Inc(FPickup, 5); if a and g_Game_IsNet then MH_SEND_Sound(GameX, GameY, 'SOUND_ITEM_GETWEAPON'); @@ -3995,19 +3977,10 @@ begin if (FAmmo[A_SHELLS] < FMaxAmmo[A_SHELLS]) or not FWeapon[WEAPON_SHOTGUN2] then begin if a and FWeapon[WEAPON_SHOTGUN2] then Exit; - if ( (gWeaponAutoswitch = True) and ((g_Game_IsNet = False or (NetMode = NET_SERVER)) and ((Self = gPlayer1) or (Self = gPlayer2)))) then - begin - hadWeapon := FWeapon[WEAPON_SHOTGUN2]; - FWeapon[WEAPON_SHOTGUN2] := True; - if (hadWeapon = False) then - begin - FCurrWeap := WEAPON_SHOTGUN2; - resetWeaponQueue(); - FModel.SetWeapon(WEAPON_SHOTGUN2); - end; - end - else FWeapon[WEAPON_SHOTGUN2] := True; + hadWeapon := FWeapon[WEAPON_SHOTGUN2]; + switchWeapon := WEAPON_SHOTGUN2; IncMax(FAmmo[A_SHELLS], 4, FMaxAmmo[A_SHELLS]); + FWeapon[WEAPON_SHOTGUN2] := True; Result := True; if gFlash = 2 then Inc(FPickup, 5); if a and g_Game_IsNet then MH_SEND_Sound(GameX, GameY, 'SOUND_ITEM_GETWEAPON'); @@ -4017,19 +3990,10 @@ begin if (FAmmo[A_BULLETS] < FMaxAmmo[A_BULLETS]) or not FWeapon[WEAPON_CHAINGUN] then begin if a and FWeapon[WEAPON_CHAINGUN] then Exit; - if ( (gWeaponAutoswitch = True) and ((g_Game_IsNet = False or (NetMode = NET_SERVER)) and ((Self = gPlayer1) or (Self = gPlayer2)))) then - begin - hadWeapon := FWeapon[WEAPON_CHAINGUN]; - FWeapon[WEAPON_CHAINGUN] := True; - if (hadWeapon = False) then - begin - FCurrWeap := WEAPON_CHAINGUN; - resetWeaponQueue(); - FModel.SetWeapon(WEAPON_CHAINGUN); - end; - end - else FWeapon[WEAPON_CHAINGUN] := True; + hadWeapon := FWeapon[WEAPON_CHAINGUN]; + switchWeapon := WEAPON_CHAINGUN; IncMax(FAmmo[A_BULLETS], 50, FMaxAmmo[A_BULLETS]); + FWeapon[WEAPON_CHAINGUN] := True; Result := True; if gFlash = 2 then Inc(FPickup, 5); if a and g_Game_IsNet then MH_SEND_Sound(GameX, GameY, 'SOUND_ITEM_GETWEAPON'); @@ -4039,19 +4003,10 @@ begin if (FAmmo[A_ROCKETS] < FMaxAmmo[A_ROCKETS]) or not FWeapon[WEAPON_ROCKETLAUNCHER] then begin if a and FWeapon[WEAPON_ROCKETLAUNCHER] then Exit; - if ( (gWeaponAutoswitch = True) and ((g_Game_IsNet = False or (NetMode = NET_SERVER)) and ((Self = gPlayer1) or (Self = gPlayer2)))) then - begin - hadWeapon := FWeapon[WEAPON_ROCKETLAUNCHER]; - FWeapon[WEAPON_ROCKETLAUNCHER] := True; - if (hadWeapon = False) then - begin - FCurrWeap := WEAPON_ROCKETLAUNCHER; - resetWeaponQueue(); - FModel.SetWeapon(WEAPON_ROCKETLAUNCHER); - end; - end - else FWeapon[WEAPON_ROCKETLAUNCHER] := True; + switchWeapon := WEAPON_ROCKETLAUNCHER; + hadWeapon := FWeapon[WEAPON_ROCKETLAUNCHER]; IncMax(FAmmo[A_ROCKETS], 2, FMaxAmmo[A_ROCKETS]); + FWeapon[WEAPON_ROCKETLAUNCHER] := True; Result := True; if gFlash = 2 then Inc(FPickup, 5); if a and g_Game_IsNet then MH_SEND_Sound(GameX, GameY, 'SOUND_ITEM_GETWEAPON'); @@ -4061,19 +4016,10 @@ begin if (FAmmo[A_CELLS] < FMaxAmmo[A_CELLS]) or not FWeapon[WEAPON_PLASMA] then begin if a and FWeapon[WEAPON_PLASMA] then Exit; - if ( (gWeaponAutoswitch = True) and ((g_Game_IsNet = False or (NetMode = NET_SERVER)) and ((Self = gPlayer1) or (Self = gPlayer2)))) then - begin - hadWeapon := FWeapon[WEAPON_PLASMA]; - FWeapon[WEAPON_PLASMA] := True; - if (hadWeapon = False) then - begin - FCurrWeap := WEAPON_PLASMA; - resetWeaponQueue(); - FModel.SetWeapon(WEAPON_PLASMA); - end; - end - else FWeapon[WEAPON_PLASMA] := True; + switchWeapon := WEAPON_PLASMA; + hadWeapon := FWeapon[WEAPON_PLASMA]; IncMax(FAmmo[A_CELLS], 40, FMaxAmmo[A_CELLS]); + FWeapon[WEAPON_PLASMA] := True; Result := True; if gFlash = 2 then Inc(FPickup, 5); if a and g_Game_IsNet then MH_SEND_Sound(GameX, GameY, 'SOUND_ITEM_GETWEAPON'); @@ -4083,19 +4029,10 @@ begin if (FAmmo[A_CELLS] < FMaxAmmo[A_CELLS]) or not FWeapon[WEAPON_BFG] then begin if a and FWeapon[WEAPON_BFG] then Exit; - if ( (gWeaponAutoswitch = True) and ((g_Game_IsNet = False or (NetMode = NET_SERVER)) and ((Self = gPlayer1) or (Self = gPlayer2)))) then - begin - hadWeapon := FWeapon[WEAPON_BFG]; - FWeapon[WEAPON_BFG] := True; - if (hadWeapon = False) then - begin - FCurrWeap := WEAPON_BFG; - resetWeaponQueue(); - FModel.SetWeapon(WEAPON_BFG); - end; - end - else FWeapon[WEAPON_BFG] := True; + switchWeapon := WEAPON_BFG; + hadWeapon := FWeapon[WEAPON_BFG]; IncMax(FAmmo[A_CELLS], 40, FMaxAmmo[A_CELLS]); + FWeapon[WEAPON_BFG] := True; Result := True; if gFlash = 2 then Inc(FPickup, 5); if a and g_Game_IsNet then MH_SEND_Sound(GameX, GameY, 'SOUND_ITEM_GETWEAPON'); @@ -4105,19 +4042,10 @@ begin if (FAmmo[A_SHELLS] < FMaxAmmo[A_SHELLS]) or not FWeapon[WEAPON_SUPERPULEMET] then begin if a and FWeapon[WEAPON_SUPERPULEMET] then Exit; - if ( (gWeaponAutoswitch = True) and ((g_Game_IsNet = False or (NetMode = NET_SERVER)) and ((Self = gPlayer1) or (Self = gPlayer2)))) then - begin - hadWeapon := FWeapon[WEAPON_SUPERPULEMET]; - FWeapon[WEAPON_SUPERPULEMET] := True; - if (hadWeapon = False) then - begin - FCurrWeap := WEAPON_SUPERPULEMET; - resetWeaponQueue(); - FModel.SetWeapon(WEAPON_SUPERPULEMET); - end; - end - else FWeapon[WEAPON_SUPERPULEMET] := True; + switchWeapon := WEAPON_SUPERPULEMET; + hadWeapon := FWeapon[WEAPON_SUPERPULEMET]; IncMax(FAmmo[A_SHELLS], 4, FMaxAmmo[A_SHELLS]); + FWeapon[WEAPON_SUPERPULEMET] := True; Result := True; if gFlash = 2 then Inc(FPickup, 5); if a and g_Game_IsNet then MH_SEND_Sound(GameX, GameY, 'SOUND_ITEM_GETWEAPON'); @@ -4127,19 +4055,10 @@ begin if (FAmmo[A_FUEL] < FMaxAmmo[A_FUEL]) or not FWeapon[WEAPON_FLAMETHROWER] then begin if a and FWeapon[WEAPON_FLAMETHROWER] then Exit; - if ( (gWeaponAutoswitch = True) and ((g_Game_IsNet = False or (NetMode = NET_SERVER)) and ((Self = gPlayer1) or (Self = gPlayer2)))) then - begin - hadWeapon := FWeapon[WEAPON_FLAMETHROWER]; - FWeapon[WEAPON_FLAMETHROWER] := True; - if (hadWeapon = False) then - begin - FCurrWeap := WEAPON_FLAMETHROWER; - resetWeaponQueue(); - FModel.SetWeapon(WEAPON_FLAMETHROWER); - end; - end - else FWeapon[WEAPON_FLAMETHROWER] := True; + switchWeapon := WEAPON_FLAMETHROWER; + hadWeapon := FWeapon[WEAPON_FLAMETHROWER]; IncMax(FAmmo[A_FUEL], 100, FMaxAmmo[A_FUEL]); + FWeapon[WEAPON_FLAMETHROWER] := True; Result := True; if gFlash = 2 then Inc(FPickup, 5); if a and g_Game_IsNet then MH_SEND_Sound(GameX, GameY, 'SOUND_ITEM_GETWEAPON'); @@ -4311,11 +4230,33 @@ begin if not (R_BERSERK in FRulez) then begin Include(FRulez, R_BERSERK); + (* if allowBerserkSwitching then begin FCurrWeap := WEAPON_KASTET; resetWeaponQueue(); FModel.SetWeapon(WEAPON_KASTET); + end; *) + if ( (g_Game_IsNet = False) or (NetMode = NET_SERVER) ) and ( ( (Self = gPlayer1) and (gPlayer1Settings.WeaponSwitch <> 0) ) or ( (gPlayer2 <> nil) and (Self = gPlayer2) and (gPlayer2Settings.WeaponSwitch <> 0) )) then + begin + if (Self = gPlayer1) then + begin + if (gPlayer1Settings.WeaponSwitch = 1) or ( (gPlayer1Settings.WeaponSwitch = 2) and (gPlayer1Settings.WeaponPreferences[WP_LAST+1] > gPlayer1Settings.WeaponPreferences[FCurrWeap]) ) then + begin + FCurrWeap := WEAPON_KASTET; + resetWeaponQueue(); + FModel.SetWeapon(WEAPON_KASTET); + end; + end + else + begin + if (gPlayer2Settings.WeaponSwitch = 1) or ( (gPlayer2Settings.WeaponSwitch = 2) and (gPlayer2Settings.WeaponPreferences[WP_LAST+1] > gPlayer2Settings.WeaponPreferences[FCurrWeap]) ) then + begin + FCurrWeap := WEAPON_KASTET; + resetWeaponQueue(); + FModel.SetWeapon(WEAPON_KASTET); + end; + end; end; if gFlash <> 0 then begin @@ -4384,6 +4325,26 @@ begin if gFlash = 2 then Inc(FPickup, 5); end; end; + if ( (g_Game_IsNet = False) or (NetMode = NET_SERVER) ) and ( ( (Self = gPlayer1) and (gPlayer1Settings.WeaponSwitch <> 0) ) or ( (gPlayer2 <> nil) and (Self = gPlayer2) and (gPlayer2Settings.WeaponSwitch <> 0) )) then + begin + if (hadWeapon = False) then + begin + if (Self = gPlayer1) and ( (gPlayer1Settings.WeaponSwitch = 1) or ( (gPlayer1Settings.WeaponSwitch = 2) + and (gPlayer1Settings.WeaponPreferences[switchWeapon] > gPlayer1Settings.WeaponPreferences[FCurrWeap]) ) ) then + begin + FCurrWeap := switchWeapon; + resetWeaponQueue(); + FModel.SetWeapon(switchWeapon); + end + else if (Self = gPlayer2) and ( (gPlayer2Settings.WeaponSwitch = 1) or ( (gPlayer2Settings.WeaponSwitch = 2) + and (gPlayer2Settings.WeaponPreferences[switchWeapon] > gPlayer2Settings.WeaponPreferences[FCurrWeap]) ) ) then + begin + FCurrWeap := switchWeapon; + resetWeaponQueue(); + FModel.SetWeapon(switchWeapon); + end; + end; + end; end; procedure TPlayer.Touch(); @@ -8012,5 +7973,4 @@ begin conRegVar('cheat_berserk_autoswitch', @gBerserkAutoswitch, 'autoswitch to fist when berserk pack taken', '', true, true); conRegVar('player_indicator', @gPlayerIndicator, 'Draw indicator only for current player, also for teammates, or not at all', 'Draw indicator only for current player, also for teammates, or not at all'); conRegVar('player_indicator_style', @gPlayerIndicatorStyle, 'Visual appearance of indicator', 'Visual appearance of indicator'); - conRegVar('weapon_autoswitch', @gWeaponAutoswitch, 'Automatically switch to a first time picked up weapon', ''); end.