summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c6489a9)
raw | patch | inline | side by side (parent: c6489a9)
author | Stas'M <x86corez@gmail.com> | |
Fri, 10 Dec 2021 23:56:17 +0000 (02:56 +0300) | ||
committer | Stas'M <x86corez@gmail.com> | |
Sat, 11 Dec 2021 00:10:42 +0000 (03:10 +0300) |
- Do not use key down/key up scheme for it
- Make it work the same way how direct weapon change works
- Take advantage of repeated key binds that were added earlier
Addendum to dac16ad95.
- Make it work the same way how direct weapon change works
- Take advantage of repeated key binds that were added earlier
Addendum to dac16ad95.
diff --git a/src/game/g_console.pas b/src/game/g_console.pas
index 15497d913a59a0beb136e3909bd3a64e930d9d39..3dd754c56b0e24a2860d1bc4ecb3d494eb904b27 100644 (file)
--- a/src/game/g_console.pas
+++ b/src/game/g_console.pas
ACTION_SCORES = 6;
ACTION_ACTIVATE = 7;
ACTION_STRAFE = 8;
- ACTION_WEAPNEXT = 9;
- ACTION_WEAPPREV = 10;
FIRST_ACTION = ACTION_JUMP;
- LAST_ACTION = ACTION_WEAPPREV;
+ LAST_ACTION = ACTION_STRAFE;
procedure g_Console_Init;
procedure g_Console_SysInit;
function g_Console_Action (action: Integer): Boolean;
function g_Console_MatchBind (key: Integer; down: AnsiString; up: AnsiString = ''): Boolean;
function g_Console_FindBind (n: Integer; down: AnsiString; up: AnsiString = ''): Integer;
-procedure g_Console_BindKey (key: Integer; down: AnsiString; up: AnsiString = '');
+procedure g_Console_BindKey (key: Integer; down: AnsiString; up: AnsiString = ''; rep: Boolean = False);
procedure g_Console_ProcessBind (key: Integer; down: Boolean);
procedure g_Console_ProcessBindRepeat (key: Integer);
procedure g_Console_ResetBinds;
AddCommand('clientlist', GameCommands);
AddCommand('event', GameCommands);
AddCommand('screenshot', GameCommands);
+ AddCommand('weapnext', GameCommands);
+ AddCommand('weapprev', GameCommands);
AddCommand('weapon', GameCommands);
+ AddCommand('p1_weapnext', GameCommands);
+ AddCommand('p1_weapprev', GameCommands);
AddCommand('p1_weapon', GameCommands);
+ AddCommand('p2_weapnext', GameCommands);
+ AddCommand('p2_weapprev', GameCommands);
AddCommand('p2_weapon', GameCommands);
AddCommand('god', GameCheats);
AddAction('scores', ACTION_SCORES);
AddAction('activate', ACTION_ACTIVATE);
AddAction('strafe', ACTION_STRAFE);
- AddAction('weapnext', ACTION_WEAPNEXT);
- AddAction('weapprev', ACTION_WEAPPREV);
WhitelistCommand('say');
WhitelistCommand('tell');
Result := gConsoleShow
end;
-procedure g_Console_BindKey (key: Integer; down: AnsiString; up: AnsiString = '');
+procedure g_Console_BindKey (key: Integer; down: AnsiString; up: AnsiString = ''; rep: Boolean = False);
begin
//e_LogWritefln('bind "%s" "%s" <%s>', [LowerCase(e_KeyNames[key]), cmd, key]);
ASSERT(key >= 0);
ASSERT(key < e_MaxInputKeys);
if key > 0 then
begin
- gInputBinds[key].rep := False;
+ gInputBinds[key].rep := rep;
gInputBinds[key].down := ParseAlias(down);
gInputBinds[key].up := ParseAlias(up);
end;
g_Console_BindKey(IK_SPACE, '+p1_jump', '-p1_jump');
g_Console_BindKey(IK_H, '+p1_attack', '-p1_attack');
g_Console_BindKey(IK_J, '+p1_activate', '-p1_activate');
- g_Console_BindKey(IK_E, '+p1_weapnext', '-p1_weapnext');
- g_Console_BindKey(IK_Q, '+p1_weapprev', '-p1_weapprev');
g_Console_BindKey(IK_ALT, '+p1_strafe', '-p1_strafe');
+ g_Console_BindKey(IK_E, 'p1_weapnext', '', True);
+ g_Console_BindKey(IK_Q, 'p1_weapprev', '', True);
g_Console_BindKey(IK_1, 'p1_weapon 1');
g_Console_BindKey(IK_2, 'p1_weapon 2');
g_Console_BindKey(IK_3, 'p1_weapon 3');
g_Console_BindKey(e_JoyButtonToKey(i, 2), '+p' + IntToStr(i mod 2 + 1) + '_jump', '-p' + IntToStr(i mod 2 + 1) + '_jump');
g_Console_BindKey(e_JoyButtonToKey(i, 0), '+p' + IntToStr(i mod 2 + 1) + '_attack', '-p' + IntToStr(i mod 2 + 1) + '_attack');
g_Console_BindKey(e_JoyButtonToKey(i, 3), '+p' + IntToStr(i mod 2 + 1) + '_activate', '-p' + IntToStr(i mod 2 + 1) + '_activate');
- g_Console_BindKey(e_JoyButtonToKey(i, 1), '+p' + IntToStr(i mod 2 + 1) + '_weapnext', '-p' + IntToStr(i mod 2 + 1) + '_weapnext');
- g_Console_BindKey(e_JoyButtonToKey(i, 4), '+p' + IntToStr(i mod 2 + 1) + '_weapprev', '-p' + IntToStr(i mod 2 + 1) + '_weapprev');
g_Console_BindKey(e_JoyButtonToKey(i, 7), '+p' + IntToStr(i mod 2 + 1) + '_strafe', '-p' + IntToStr(i mod 2 + 1) + '_strafe');
+ g_Console_BindKey(e_JoyButtonToKey(i, 1), 'p' + IntToStr(i mod 2 + 1) + '_weapnext', '', True);
+ g_Console_BindKey(e_JoyButtonToKey(i, 4), 'p' + IntToStr(i mod 2 + 1) + '_weapprev', '', True);
g_Console_BindKey(e_JoyButtonToKey(i, 10), 'togglemenu');
end;
g_Console_BindKey(VK_JUMP, '+jump', '-jump');
g_Console_BindKey(VK_FIRE, '+attack', '-attack');
g_Console_BindKey(VK_OPEN, '+activate', '-activate');
- g_Console_BindKey(VK_NEXT, '+weapnext', '-weapnext');
- g_Console_BindKey(VK_PREV, '+weapprev', '-weapprev');
g_Console_BindKey(VK_STRAFE, '+strafe', '-strafe');
+ g_Console_BindKey(VK_NEXT, 'weapnext', '', True);
+ g_Console_BindKey(VK_PREV, 'weapprev', '', True);
g_Console_BindKey(VK_0, 'weapon 1');
g_Console_BindKey(VK_1, 'weapon 2');
g_Console_BindKey(VK_2, 'weapon 3');
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 2c8ae0fb8dcdc8507c2184aaccc0ca4a660b3183..e79845b5c88d12ebf3323269822cc25dacf81065 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
gDelayedEvents: Array of TDelayedEvent;
gUseChatSounds: Boolean = True;
gChatSounds: Array of TChatSound;
+ gWeaponAction: Array [0..1, WP_FACT..WP_LACT] of Boolean; // [player, weapon_action]
gSelectWeapon: Array [0..1, WP_FIRST..WP_LAST] of Boolean; // [player, weapon]
gInterReadyCount: Integer = 0;
if gPlayerAction[p, ACTION_LOOKUP] then plr.PressKey(KEY_UP, time);
if gPlayerAction[p, ACTION_LOOKDOWN] then plr.PressKey(KEY_DOWN, time);
if gPlayerAction[p, ACTION_ATTACK] then plr.PressKey(KEY_FIRE);
- if gPlayerAction[p, ACTION_WEAPNEXT] then plr.PressKey(KEY_NEXTWEAPON);
- if gPlayerAction[p, ACTION_WEAPPREV] then plr.PressKey(KEY_PREVWEAPON);
if gPlayerAction[p, ACTION_ACTIVATE] then plr.PressKey(KEY_OPEN);
- gPlayerAction[p, ACTION_WEAPNEXT] := False; // HACK, remove after readyweaon&pendinweapon implementation
- gPlayerAction[p, ACTION_WEAPPREV] := False; // HACK, remove after readyweaon&pendinweapon implementation
+ for i := WP_FACT to WP_LACT do
+ begin
+ if gWeaponAction[p, i] then
+ begin
+ plr.ProcessWeaponAction(i);
+ gWeaponAction[p, i] := False
+ end
+ end;
for i := WP_FIRST to WP_LAST do
begin
gSpectY := Max(gSpectY - gSpectStep, 0);
if gPlayerAction[0, ACTION_LOOKDOWN] then
gSpectY := Min(gSpectY + gSpectStep, gMapInfo.Height - gScreenHeight);
- if gPlayerAction[0, ACTION_WEAPPREV] then
+ if gWeaponAction[0, WP_PREV] then
begin
// decrease step
if gSpectStep > 4 then gSpectStep := gSpectStep shr 1;
- gSpectKeyPress := True;
+ gWeaponAction[0, WP_PREV] := False;
end;
- if gPlayerAction[0, ACTION_WEAPNEXT] then
+ if gWeaponAction[0, WP_NEXT] then
begin
// increase step
if gSpectStep < 64 then gSpectStep := gSpectStep shl 1;
- gSpectKeyPress := True;
+ gWeaponAction[0, WP_NEXT] := False;
end;
end;
if (gSpectMode = SPECT_PLAYERS)
gSpectPID1 := GetActivePlayerID_Next(gSpectPID1);
gSpectKeyPress := True;
end;
- if gPlayerAction[0, ACTION_WEAPPREV] then
+ if gWeaponAction[0, WP_PREV] then
begin
// prev player (view 2)
gSpectPID2 := GetActivePlayerID_Prev(gSpectPID2);
- gSpectKeyPress := True;
+ gWeaponAction[0, WP_PREV] := False;
end;
- if gPlayerAction[0, ACTION_WEAPNEXT] then
+ if gWeaponAction[0, WP_NEXT] then
begin
// next player (view 2)
gSpectPID2 := GetActivePlayerID_Next(gSpectPID2);
- gSpectKeyPress := True;
+ gWeaponAction[0, WP_NEXT] := False;
end;
end;
if gPlayerAction[0, ACTION_ATTACK] then
(not gPlayerAction[0, ACTION_MOVELEFT]) and
(not gPlayerAction[0, ACTION_MOVERIGHT]) and
(not gPlayerAction[0, ACTION_LOOKUP]) and
- (not gPlayerAction[0, ACTION_LOOKDOWN]) and
- (not gPlayerAction[0, ACTION_WEAPPREV]) and
- (not gPlayerAction[0, ACTION_WEAPNEXT]) then
+ (not gPlayerAction[0, ACTION_LOOKDOWN]) then
gSpectKeyPress := False;
if gSpectAuto then
begin
g_TakeScreenShot()
end
+ else if (cmd = 'weapnext') or (cmd = 'weapprev') then
+ begin
+ a := 1 - (ord(cmd[5]) - ord('n'));
+ if a = -1 then
+ gWeaponAction[0, WP_PREV] := True;
+ if a = 1 then
+ gWeaponAction[0, WP_NEXT] := True;
+ end
else if cmd = 'weapon' then
begin
if Length(p) = 2 then
gSelectWeapon[0, a] := True
end
end
+ else if (cmd = 'p1_weapnext') or (cmd = 'p1_weapprev')
+ or (cmd = 'p2_weapnext') or (cmd = 'p2_weapprev') then
+ begin
+ a := 1 - (ord(cmd[8]) - ord('n'));
+ b := ord(cmd[2]) - ord('1');
+ if a = -1 then
+ gWeaponAction[b, WP_PREV] := True;
+ if a = 1 then
+ gWeaponAction[b, WP_NEXT] := True;
+ end
else if (cmd = 'p1_weapon') or (cmd = 'p2_weapon') then
begin
if Length(p) = 2 then
diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas
index bd213148c20374d88faf9ef963fd0605124eac46..95a0da30f122c1634ea69c381f02d372d8097e8e 100644 (file)
--- a/src/game/g_menu.pas
+++ b/src/game/g_menu.pas
g_Console_BindKey(g_Console_FindBind(1, '+p1_lookdown', '-p1_lookdown'), '');
g_Console_BindKey(g_Console_FindBind(1, '+p1_attack', '-p1_attack'), '');
g_Console_BindKey(g_Console_FindBind(1, '+p1_jump', '-p1_jump'), '');
- g_Console_BindKey(g_Console_FindBind(1, '+p1_weapnext', '-p1_weapnext'), '');
- g_Console_BindKey(g_Console_FindBind(1, '+p1_weapprev', '-p1_weapprev'), '');
g_Console_BindKey(g_Console_FindBind(1, '+p1_activate', '-p1_activate'), '');
g_Console_BindKey(g_Console_FindBind(1, '+p1_strafe', '-p1_strafe'), '');
+ g_Console_BindKey(g_Console_FindBind(1, 'p1_weapnext', ''), '');
+ g_Console_BindKey(g_Console_FindBind(1, 'p1_weapprev', ''), '');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0, '+p1_moveright', '-p1_moveright');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0, '+p1_moveleft', '-p1_moveleft');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0, '+p1_lookup', '-p1_lookup');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0, '+p1_lookdown', '-p1_lookdown');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0, '+p1_attack', '-p1_attack');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0, '+p1_jump', '-p1_jump');
- g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0, '+p1_weapnext', '-p1_weapnext');
- g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0, '+p1_weapprev', '-p1_weapprev');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0, '+p1_activate', '-p1_activate');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0, '+p1_strafe', '-p1_strafe');
+ g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0, 'p1_weapnext', '', True);
+ g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0, 'p1_weapprev', '', True);
// second set
g_Console_BindKey(g_Console_FindBind(2, '+p1_moveright', '-p1_moveright'), '');
g_Console_BindKey(g_Console_FindBind(2, '+p1_moveleft', '-p1_moveleft'), '');
g_Console_BindKey(g_Console_FindBind(2, '+p1_lookdown', '-p1_lookdown'), '');
g_Console_BindKey(g_Console_FindBind(2, '+p1_attack', '-p1_attack'), '');
g_Console_BindKey(g_Console_FindBind(2, '+p1_jump', '-p1_jump'), '');
- g_Console_BindKey(g_Console_FindBind(2, '+p1_weapnext', '-p1_weapnext'), '');
- g_Console_BindKey(g_Console_FindBind(2, '+p1_weapprev', '-p1_weapprev'), '');
g_Console_BindKey(g_Console_FindBind(2, '+p1_activate', '-p1_activate'), '');
g_Console_BindKey(g_Console_FindBind(2, '+p1_strafe', '-p1_strafe'), '');
+ g_Console_BindKey(g_Console_FindBind(2, 'p1_weapnext', ''), '');
+ g_Console_BindKey(g_Console_FindBind(2, 'p1_weapprev', ''), '');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1, '+p1_moveright', '-p1_moveright');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1, '+p1_moveleft', '-p1_moveleft');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1, '+p1_lookup', '-p1_lookup');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1, '+p1_lookdown', '-p1_lookdown');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1, '+p1_attack', '-p1_attack');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1, '+p1_jump', '-p1_jump');
- g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1, '+p1_weapnext', '-p1_weapnext');
- g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1, '+p1_weapprev', '-p1_weapprev');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1, '+p1_activate', '-p1_activate');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1, '+p1_strafe', '-p1_strafe');
+ g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1, 'p1_weapnext', '', True);
+ g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1, 'p1_weapprev', '', True);
end;
menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
g_Console_BindKey(g_Console_FindBind(1, '+p2_lookdown', '-p2_lookdown'), '');
g_Console_BindKey(g_Console_FindBind(1, '+p2_attack', '-p2_attack'), '');
g_Console_BindKey(g_Console_FindBind(1, '+p2_jump', '-p2_jump'), '');
- g_Console_BindKey(g_Console_FindBind(1, '+p2_weapnext', '-p2_weapnext'), '');
- g_Console_BindKey(g_Console_FindBind(1, '+p2_weapprev', '-p2_weapprev'), '');
g_Console_BindKey(g_Console_FindBind(1, '+p2_activate', '-p2_activate'), '');
g_Console_BindKey(g_Console_FindBind(1, '+p2_strafe', '-p2_strafe'), '');
+ g_Console_BindKey(g_Console_FindBind(1, 'p2_weapnext', ''), '');
+ g_Console_BindKey(g_Console_FindBind(1, 'p2_weapprev', ''), '');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0, '+p2_moveright', '-p2_moveright');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0, '+p2_moveleft', '-p2_moveleft');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0, '+p2_lookup', '-p2_lookup');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0, '+p2_lookdown', '-p2_lookdown');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0, '+p2_attack', '-p2_attack');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0, '+p2_jump', '-p2_jump');
- g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0, '+p2_weapnext', '-p2_weapnext');
- g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0, '+p2_weapprev', '-p2_weapprev');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0, '+p2_activate', '-p2_activate');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0, '+p2_strafe', '-p2_strafe');
+ g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0, 'p2_weapnext', '', True);
+ g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0, 'p2_weapprev', '', True);
// second set
g_Console_BindKey(g_Console_FindBind(2, '+p2_moveright', '-p2_moveright'), '');
g_Console_BindKey(g_Console_FindBind(2, '+p2_moveleft', '-p2_moveleft'), '');
g_Console_BindKey(g_Console_FindBind(2, '+p2_lookdown', '-p2_lookdown'), '');
g_Console_BindKey(g_Console_FindBind(2, '+p2_attack', '-p2_attack'), '');
g_Console_BindKey(g_Console_FindBind(2, '+p2_jump', '-p2_jump'), '');
- g_Console_BindKey(g_Console_FindBind(2, '+p2_weapnext', '-p2_weapnext'), '');
- g_Console_BindKey(g_Console_FindBind(2, '+p2_weapprev', '-p2_weapprev'), '');
g_Console_BindKey(g_Console_FindBind(2, '+p2_activate', '-p2_activate'), '');
g_Console_BindKey(g_Console_FindBind(2, '+p2_strafe', '-p2_strafe'), '');
+ g_Console_BindKey(g_Console_FindBind(2, 'p2_weapnext', ''), '');
+ g_Console_BindKey(g_Console_FindBind(2, 'p2_weapprev', ''), '');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1, '+p2_moveright', '-p2_moveright');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1, '+p2_moveleft', '-p2_moveleft');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1, '+p2_lookup', '-p2_lookup');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1, '+p2_lookdown', '-p2_lookdown');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1, '+p2_attack', '-p2_attack');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1, '+p2_jump', '-p2_jump');
- g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1, '+p2_weapnext', '-p2_weapnext');
- g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1, '+p2_weapprev', '-p2_weapprev');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1, '+p2_activate', '-p2_activate');
g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1, '+p2_strafe', '-p2_strafe');
+ g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1, 'p2_weapnext', '', True);
+ g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1, 'p2_weapprev', '', True);
end;
menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := g_Console_FindBind(1, '+p1_lookdown', '-p1_lookdown');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := g_Console_FindBind(1, '+p1_attack', '-p1_attack');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := g_Console_FindBind(1, '+p1_jump', '-p1_jump');
- TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, '+p1_weapnext', '-p1_weapnext');
- TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, '+p1_weapprev', '-p1_weapprev');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := g_Console_FindBind(1, '+p1_activate', '-p1_activate');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := g_Console_FindBind(1, '+p1_strafe', '-p1_strafe');
+ TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, 'p1_weapnext', '');
+ TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, 'p1_weapprev', '');
// second set
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := g_Console_FindBind(2, '+p1_moveright', '-p1_moveright');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := g_Console_FindBind(2, '+p1_moveleft', '-p1_moveleft');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := g_Console_FindBind(2, '+p1_lookdown', '-p1_lookdown');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := g_Console_FindBind(2, '+p1_attack', '-p1_attack');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := g_Console_FindBind(2, '+p1_jump', '-p1_jump');
- TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2, '+p1_weapnext', '-p1_weapnext');
- TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, '+p1_weapprev', '-p1_weapprev');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := g_Console_FindBind(2, '+p1_activate', '-p1_activate');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := g_Console_FindBind(2, '+p1_strafe', '-p1_strafe');
+ TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2, 'p1_weapnext', '');
+ TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, 'p1_weapprev', '');
end;
menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := g_Console_FindBind(1, '+p2_lookdown', '-p2_lookdown');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := g_Console_FindBind(1, '+p2_attack', '-p2_attack');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := g_Console_FindBind(1, '+p2_jump', '-p2_jump');
- TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, '+p2_weapnext', '-p2_weapnext');
- TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, '+p2_weapprev', '-p2_weapprev');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := g_Console_FindBind(1, '+p2_activate', '-p2_activate');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := g_Console_FindBind(1, '+p2_strafe', '-p2_strafe');
+ TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, 'p2_weapnext', '');
+ TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, 'p2_weapprev', '');
// second set
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := g_Console_FindBind(2, '+p2_moveright', '-p2_moveright');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := g_Console_FindBind(2, '+p2_moveleft', '-p2_moveleft');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := g_Console_FindBind(2, '+p2_lookdown', '-p2_lookdown');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := g_Console_FindBind(2, '+p2_attack', '-p2_attack');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := g_Console_FindBind(2, '+p2_jump', '-p2_jump');
- TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2, '+p2_weapnext', '-p2_weapnext');
- TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, '+p2_weapprev', '-p2_weapprev');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := g_Console_FindBind(2, '+p2_activate', '-p2_activate');
TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := g_Console_FindBind(2, '+p2_strafe', '-p2_strafe');
+ TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2, 'p2_weapnext', '');
+ TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, 'p2_weapprev', '');
end;
menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
diff --git a/src/game/g_net.pas b/src/game/g_net.pas
index 63e4cb91ed172945f96137fe185d91895a5f6020..45f507a53dcccadfe604224d5fccaa1f90f7666d 100644 (file)
--- a/src/game/g_net.pas
+++ b/src/game/g_net.pas
e_log, e_msg, utils, ENet, Classes, md5, MAPDEF{$IFDEF USE_MINIUPNPC}, miniupnpc;{$ELSE};{$ENDIF}
const
- NET_PROTOCOL_VER = 185;
+ NET_PROTOCOL_VER = 186;
NET_MAXCLIENTS = 24;
NET_CHANS = 12;
diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas
index 0f57f84feeaf19f70148dae8ba60fcd250d53fe2..6d004e814fcb61fcb5aea62b26126a5cc3138778 100644 (file)
--- a/src/game/g_netmsg.pas
+++ b/src/game/g_netmsg.pas
g_language, g_monsters, g_netmaster, utils, wadreader, MAPDEF;
const
- NET_KEY_LEFT = 1;
- NET_KEY_RIGHT = 2;
- NET_KEY_UP = 4;
- NET_KEY_DOWN = 8;
- NET_KEY_JUMP = 16;
- NET_KEY_FIRE = 32;
- NET_KEY_OPEN = 64;
- NET_KEY_NW = 256;
- NET_KEY_PW = 512;
- NET_KEY_CHAT = 2048;
- NET_KEY_FORCEDIR = 4096;
+ NET_KEY_LEFT = 1 shl 0;
+ NET_KEY_RIGHT = 1 shl 1;
+ NET_KEY_UP = 1 shl 2;
+ NET_KEY_DOWN = 1 shl 3;
+ NET_KEY_JUMP = 1 shl 4;
+ NET_KEY_FIRE = 1 shl 5;
+ NET_KEY_OPEN = 1 shl 6;
+ NET_KEY_CHAT = 1 shl 7;
+ NET_KEY_FORCEDIR = 1 shl 8;
//var
//kBytePrev: Word = 0;
function MH_RECV_PlayerPos(C: pTNetClient; var M: TMsg): Word;
var
Dir, i: Byte;
+ WeaponAct: Byte;
WeaponSelect: Word;
PID: Word;
kByte: Word;
NetTime := GT;
kByte := M.ReadWord();
Dir := M.ReadByte();
+ WeaponAct := M.ReadByte();
WeaponSelect := M.ReadWord();
//e_WriteLog(Format('R:ws=%d', [WeaponSelect]), MSG_WARNING);
if Direction <> TDirection(Dir) then
if LongBool(kByte and NET_KEY_JUMP) then PressKey(KEY_JUMP, 10000);
if LongBool(kByte and NET_KEY_FIRE) then PressKey(KEY_FIRE, 10000);
if LongBool(kByte and NET_KEY_OPEN) then PressKey(KEY_OPEN, 10000);
- if LongBool(kByte and NET_KEY_NW) then PressKey(KEY_NEXTWEAPON, 10000);
- if LongBool(kByte and NET_KEY_PW) then PressKey(KEY_PREVWEAPON, 10000);
+
+ for i := 0 to 7 do
+ begin
+ if (WeaponAct and Byte(1 shl i)) <> 0 then
+ begin
+ //e_WriteLog(Format(' R:wn=%d', [i]), MSG_WARNING);
+ ProcessWeaponAction(i);
+ end;
+ end;
for i := 0 to 15 do
begin
kByte: Word;
Predict: Boolean;
strafeDir: Byte;
+ WeaponAct: Byte = 0;
WeaponSelect: Word = 0;
i: Integer;
begin
end;
if gPlayerAction[0, ACTION_ATTACK] then kByte := kByte or NET_KEY_FIRE;
if gPlayerAction[0, ACTION_ACTIVATE] then kByte := kByte or NET_KEY_OPEN;
- if gPlayerAction[0, ACTION_WEAPNEXT] then kByte := kByte or NET_KEY_NW;
- if gPlayerAction[0, ACTION_WEAPPREV] then kByte := kByte or NET_KEY_PW;
- gPlayerAction[0, ACTION_WEAPNEXT] := False; // HACK, remove after readyweaon&pendinweapon implementation
- gPlayerAction[0, ACTION_WEAPPREV] := False; // HACK, remove after readyweaon&pendinweapon implementation
+ for i := WP_FACT to WP_LACT do
+ begin
+ if gWeaponAction[0, i] then
+ begin
+ WeaponAct := WeaponAct or Byte(1 shl i);
+ gWeaponAction[0, i] := False
+ end
+ end;
for i := WP_FIRST to WP_LAST do
begin
NetOut.Write(gTime);
NetOut.Write(kByte);
NetOut.Write(Byte(gPlayer1.Direction));
+ NetOut.Write(WeaponAct);
NetOut.Write(WeaponSelect);
//e_WriteLog(Format('S:ws=%d', [WeaponSelect]), MSG_WARNING);
g_Net_Client_Send(True, NET_CHAN_PLAYERPOS);
diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index 28032e95d4ea5c2b767c165ff8b6993915e5af21..c1454c81d7b5a3454b011f716fc2460e87c8d314 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
KEY_UP = 3;
KEY_DOWN = 4;
KEY_FIRE = 5;
- KEY_NEXTWEAPON = 6;
- KEY_PREVWEAPON = 7;
- KEY_OPEN = 8;
- KEY_JUMP = 9;
- KEY_CHAT = 10;
+ KEY_OPEN = 6;
+ KEY_JUMP = 7;
+ KEY_CHAT = 8;
+
+ WP_PREV = 0;
+ WP_NEXT = 1;
+ WP_FACT = WP_PREV;
+ WP_LACT = WP_NEXT;
R_ITEM_BACKPACK = 0;
R_KEY_RED = 1;
procedure NetFire(Wpn: Byte; X, Y, AX, AY: Integer; WID: Integer = -1);
procedure DoLerp(Level: Integer = 2);
procedure SetLerp(XTo, YTo: Integer);
+ procedure ProcessWeaponAction(Action: Byte);
procedure QueueWeaponSwitch(Weapon: Byte);
procedure RealizeCurrentWeapon();
procedure FlamerOn;
FModel.Blood.R, FModel.Blood.G, FModel.Blood.B, FModel.Blood.Kind);
end;
+procedure TPlayer.ProcessWeaponAction(Action: Byte);
+begin
+ if g_Game_IsClient then Exit;
+ case Action of
+ WP_PREV: PrevWeapon();
+ WP_NEXT: NextWeapon();
+ end;
+end;
+
procedure TPlayer.QueueWeaponSwitch(Weapon: Byte);
begin
if g_Game_IsClient then Exit;
FIncCam := FIncCam*i;
end;
- // no need to do that each second frame, weapon queue will take care of it
- if FAlive and FKeys[KEY_NEXTWEAPON].Pressed and AnyServer then NextWeapon();
- if FAlive and FKeys[KEY_PREVWEAPON].Pressed and AnyServer then PrevWeapon();
-
if gTime mod (GAME_TICK*2) <> 0 then
begin
if (FObj.Vel.X = 0) and FAlive then
// Let alive player do some actions
if FKeys[KEY_LEFT].Pressed then Run(TDirection.D_LEFT);
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()
else
begin