summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 681c1fa)
raw | patch | inline | side by side (parent: 681c1fa)
author | fgsfds <pvt.fgsfds@gmail.com> | |
Tue, 1 Aug 2017 15:05:14 +0000 (18:05 +0300) | ||
committer | fgsfds <pvt.fgsfds@gmail.com> | |
Tue, 1 Aug 2017 15:05:14 +0000 (18:05 +0300) |
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 6a11291bb77bfecb12ecb029a8b0d4b295c7ab3b..c3f4b589684658007dcc4e7d63a9b96a33e20c18 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
@@ -1233,6 +1233,7 @@ procedure processPlayerControls (plr: TPlayer; var ctrl: TPlayerControl; var Mov
var
time: Word;
strafeDir: Byte;
+ i: Integer;
begin
if (plr = nil) then exit;
if (p2hack) then time := 1000 else time := 1;
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
+ if isKeyPressed(KeyWeapon[i], KeyWeapon2[i]) then
+ begin
+ plr.ForceWeapon(i);
+ Break;
+ end;
end;
end;
index d340408dccfb1ef8d46c8714fcb9c90333cbcfe2..5f73c2d45667e3345ed201c502ebb89405122ccb 100644 (file)
--- a/src/game/g_language.pas
+++ b/src/game/g_language.pas
I_GAME_CHEAT_AIMLINE,
I_GAME_CHEAT_AUTOMAP,
+ I_GAME_WEAPON0,
+ I_GAME_WEAPON1,
+ I_GAME_WEAPON2,
+ I_GAME_WEAPON3,
+ I_GAME_WEAPON4,
+ I_GAME_WEAPON5,
+ I_GAME_WEAPON6,
+ I_GAME_WEAPON7,
+ I_GAME_WEAPON8,
+ I_GAME_WEAPON9,
+
I_MENU_START_GAME,
I_MENU_MAIN_MENU,
I_MENU_NEW_GAME,
I_MENU_PLAYER_2,
I_MENU_PLAYER_1_ALT,
I_MENU_PLAYER_2_ALT,
+ I_MENU_PLAYER_1_WEAPONS,
+ I_MENU_PLAYER_2_WEAPONS,
I_MENU_CONTROL_JOYSTICKS,
I_MENU_CONTROL_DEADZONE,
('GAME CHEAT AUTOMAP', 'ID2DT',
'ID2DT'),
+ ('GAME WEAPON0', 'Fist',
+ 'Êàñòåò'),
+ ('GAME WEAPON1', 'Chainsaw',
+ 'Áåíçîïèëà'),
+ ('GAME WEAPON2', 'Pistol',
+ 'Ïèñòîëåò'),
+ ('GAME WEAPON3', 'Shotgun',
+ 'Äðîáîâèê'),
+ ('GAME WEAPON4', 'Super Shotgun',
+ 'Äâóñòâîëêà'),
+ ('GAME WEAPON5', 'Chaingun',
+ 'Ïóëåìåò'),
+ ('GAME WEAPON6', 'Rocket Launcher',
+ 'Ðàêåòíèöà'),
+ ('GAME WEAPON7', 'Plasma Gun',
+ 'Ïëàçìàãàí'),
+ ('GAME WEAPON8', 'BFG9000',
+ 'BFG9000'),
+ ('GAME WEAPON9', 'Super Chaingun',
+ 'Ñóïåðïóëåìåò'),
+
('MENU START GAME', 'Start Game',
'ÍÀ×ÀÒÜ ÈÃÐÓ'),
('MENU MAIN MENU', 'Menu',
'Ïåðâûé èãðîê, êëàâèàòóðà'),
('MENU PLAYER 2', 'Player 2 KEYBOARD',
'Âòîðîé èãðîê, êëàâèàòóðà'),
- ('MENU PLAYER 1 ALT', 'Player 1 GAMEPAD',
- 'Ïåðâûé èãðîê GAMEPAD'),
- ('MENU PLAYER 2 ALT', 'Player 2 GAMEPAD',
- 'Âòîðîé èãðîê GAMEPAD'),
+ ('MENU PLAYER 1 ALT', 'Player 1, GAMEPAD',
+ 'Ïåðâûé èãðîê, GAMEPAD'),
+ ('MENU PLAYER 2 ALT', 'Player 2, GAMEPAD',
+ 'Âòîðîé èãðîê, GAMEPAD'),
+ ('MENU PLAYER 1 WEAPONS', 'Player 1, Weapons',
+ 'Ïåðâûé èãðîê, îðóæèå'),
+ ('MENU PLAYER 2 WEAPONS', 'Player 2, Weapons',
+ 'Âòîðîé èãðîê, îðóæèå'),
('MENU CONTROL JOYSTICKS', 'Joystick Settings',
'Íàñòðîéêè äæîéñòèêîâ'),
diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas
index 5cd389bf42ff5b970267fe35e77ca35e9cb9cac5..2f216ff47182e46907e4e15adde1e95ab30e66c5 100644 (file)
--- a/src/game/g_menu.pas
+++ b/src/game/g_menu.pas
KeyStrafe2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key;
end;
+ menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
+ with menu, gGameControls.P1Control do
+ begin
+ for i := 0 to 9 do
+ KeyWeapon[i] := TGUIKeyRead(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key;
+ end;
+
menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
with menu, gGameControls.P2Control do
begin
KeyStrafe2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key;
end;
+ menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
+ with menu, gGameControls.P2Control do
+ begin
+ for i := 0 to 9 do
+ KeyWeapon[i] := TGUIKeyRead(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key;
+ end;
+
if e_JoysticksAvailable > 0 then
begin
menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
AddSpace();
AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsControlsP1Menu');
AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');
+ AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsControlsP2Menu');
AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');
+ AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
AddSpace();
if e_JoysticksAvailable <> 0 then
AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
g_GUI_AddWindow(Menu);
Menu := TGUIWindow.Create('OptionsControlsP1MenuAlt');
- with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1]))) do
+ with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_ALT]))) do
begin
Name := 'mOptionsControlsP1MenuAlt';
AddKeyRead(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
Menu.DefControl := 'mOptionsControlsP1MenuAlt';
g_GUI_AddWindow(Menu);
+ Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
+ with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
+ begin
+ Name := 'mOptionsControlsP1MenuWeapons';
+ for i := 0 to 9 do
+ AddKeyRead(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
+ _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
+ end;
+ Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
+ g_GUI_AddWindow(Menu);
+
Menu := TGUIWindow.Create('OptionsControlsP2Menu');
with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2]))) do
begin
g_GUI_AddWindow(Menu);
Menu := TGUIWindow.Create('OptionsControlsP2MenuAlt');
- with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2]))) do
+ with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_ALT]))) do
begin
Name := 'mOptionsControlsP2MenuAlt';
AddKeyRead(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
Menu.DefControl := 'mOptionsControlsP2MenuAlt';
g_GUI_AddWindow(Menu);
+
+ Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
+ with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
+ begin
+ Name := 'mOptionsControlsP2MenuWeapons';
+ for i := 0 to 9 do
+ AddKeyRead(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
+ _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
+ end;
+ Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
+ g_GUI_AddWindow(Menu);
+
Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
begin
diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas
index 64377a61057e6bdb31f473bf08f0d88fd07a94b0..abc65a04102c45ca288b87fd6a2caeeac914fa00 100644 (file)
--- a/src/game/g_netmsg.pas
+++ b/src/game/g_netmsg.pas
function MH_RECV_PlayerPos(C: pTNetClient; P: Pointer): Word;
var
- Dir: Byte;
+ Dir, WeaponSelect: Byte;
PID: Word;
kByte: Word;
Pl: TPlayer;
NetTime := GT;
kByte := e_Raw_Read_Word(P);
Dir := e_Raw_Read_Byte(P);
+ WeaponSelect := e_Raw_Read_Byte(P);
if Direction <> TDirection(Dir) then
JustTeleported := False;
+
SetDirection(TDirection(Dir));
ReleaseKeys;
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);
+
+ if WeaponSelect <> 255 then
+ ForceWeapon(WeaponSelect);
end;
// MH_SEND_PlayerPos(False, PID, C^.ID);
kByte: Word;
Predict: Boolean;
strafeDir: Byte;
+ WeaponSelect: Byte = 255;
+ I: Integer;
begin
if not gGameOn then Exit;
if gPlayers = nil then Exit;
if isKeyPressed(KeyOpen, KeyOpen2) then kByte := kByte or NET_KEY_OPEN;
if isKeyPressed(KeyNextWeapon, KeyNextWeapon2) then kByte := kByte or NET_KEY_NW;
if isKeyPressed(KeyPrevWeapon, KeyPrevWeapon2) then kByte := kByte or NET_KEY_PW;
+ for I := 0 to High(KeyWeapon) do
+ if isKeyPressed(KeyWeapon[I], KeyWeapon2[I]) then
+ WeaponSelect := I;
end;
// fix movebutton state
P1MoveButton := P1MoveButton or (strafeDir shl 4);
e_Buffer_Write(@NetOut, gTime);
e_Buffer_Write(@NetOut, kByte);
e_Buffer_Write(@NetOut, Byte(gPlayer1.Direction));
+ e_Buffer_Write(@NetOut, WeaponSelect);
g_Net_Client_Send(True, NET_CHAN_PLAYERPOS);
//kBytePrev := kByte;
diff --git a/src/game/g_options.pas b/src/game/g_options.pas
index 2ad3e6e497fd99f58d1b45c16d61a0b93dd83c9f..5caaf40f9520fe1659381f53515e480b10f11934 100644 (file)
--- a/src/game/g_options.pas
+++ b/src/game/g_options.pas
KeyPrevWeapon: Word;
KeyOpen: Word;
KeyStrafe: Word;
+ KeyWeapon: array [0..9] of Word;
KeyRight2: Word;
KeyLeft2: Word;
KeyPrevWeapon2: Word;
KeyOpen2: Word;
KeyStrafe2: Word;
+ KeyWeapon2: array [0..9] of Word;
end;
TGameControls = record
KeyPrevWeapon := 71;
KeyOpen := 54;
KeyStrafe := 0;
+ for i := 0 to High(KeyWeapon) do
+ KeyWeapon[i] := 0;
KeyRight2 := 0;
KeyLeft2 := 0;
KeyPrevWeapon2 := 0;
KeyOpen2 := 0;
KeyStrafe2 := 0;
+ for i := 0 to High(KeyWeapon2) do
+ KeyWeapon2[i] := 0;
end;
with gGameControls.P2Control do
KeyPrevWeapon := 17;
KeyOpen := 58;
KeyStrafe := 0;
+ for i := 0 to High(KeyWeapon) do
+ KeyWeapon[i] := 0;
KeyRight2 := 0;
KeyLeft2 := 0;
KeyPrevWeapon2 := 0;
KeyOpen2 := 0;
KeyStrafe2 := 0;
+ for i := 0 to High(KeyWeapon2) do
+ KeyWeapon2[i] := 0;
end;
with gPlayer1Settings do
KeyPrevWeapon := ReadInt('Player1', 'KeyPrevWeapon', 17);
KeyOpen := ReadInt('Player1', 'KeyOpen', 58);
KeyStrafe := ReadInt('Player1', 'KeyStrafe', 0);
+ for i := 0 to High(KeyWeapon) do
+ KeyWeapon[i] := ReadInt('Player1', 'KeyWeapon' + IntToStr(i), 0);
KeyRight2 := ReadInt('Player1', 'KeyRight2', 0);
KeyLeft2 := ReadInt('Player1', 'KeyLeft2', 0);
KeyPrevWeapon2 := ReadInt('Player1', 'KeyPrevWeapon2', 0);
KeyOpen2 := ReadInt('Player1', 'KeyOpen2', 0);
KeyStrafe2 := ReadInt('Player1', 'KeyStrafe2', 0);
+ for i := 0 to High(KeyWeapon2) do
+ KeyWeapon2[i] := ReadInt('Player1', 'KeyWeapon2' + IntToStr(i), 0);
end;
with gPlayer1Settings, config do
KeyPrevWeapon := ReadInt('Player2', 'KeyPrevWeapon', 71);
KeyOpen := ReadInt('Player2', 'KeyOpen', 54);
KeyStrafe := ReadInt('Player2', 'KeyStrafe', 0);
+ for i := 0 to High(KeyWeapon) do
+ KeyWeapon[i] := ReadInt('Player2', 'KeyWeapon' + IntToStr(i), 0);
KeyRight2 := ReadInt('Player2', 'KeyRight2', 0);
KeyLeft2 := ReadInt('Player2', 'KeyLeft2', 0);
KeyPrevWeapon2 := ReadInt('Player2', 'KeyPrevWeapon2', 0);
KeyOpen2 := ReadInt('Player2', 'KeyOpen2', 0);
KeyStrafe2 := ReadInt('Player2', 'KeyStrafe2', 0);
+ for i := 0 to High(KeyWeapon2) do
+ KeyWeapon2[i] := ReadInt('Player2', 'KeyWeapon2' + IntToStr(i), 0);
end;
with gPlayer2Settings, config do
WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon);
WriteInt('Player1', 'KeyOpen', KeyOpen);
WriteInt('Player1', 'KeyStrafe', KeyStrafe);
+ for i := 0 to High(KeyWeapon) do
+ WriteInt('Player1', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]);
WriteInt('Player1', 'KeyRight2', KeyRight2);
WriteInt('Player1', 'KeyLeft2', KeyLeft2);
WriteInt('Player1', 'KeyPrevWeapon2', KeyPrevWeapon2);
WriteInt('Player1', 'KeyOpen2', KeyOpen2);
WriteInt('Player1', 'KeyStrafe2', KeyStrafe2);
+ for i := 0 to High(KeyWeapon2) do
+ WriteInt('Player1', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]);
WriteStr('Player1', 'Name', Name);
WriteStr('Player1', 'model', Model);
WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon);
WriteInt('Player2', 'KeyOpen', KeyOpen);
WriteInt('Player2', 'KeyStrafe', KeyStrafe);
+ for i := 0 to High(KeyWeapon) do
+ WriteInt('Player2', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]);
WriteInt('Player2', 'KeyRight2', KeyRight2);
WriteInt('Player2', 'KeyLeft2', KeyLeft2);
WriteInt('Player2', 'KeyPrevWeapon2', KeyPrevWeapon2);
WriteInt('Player2', 'KeyOpen2', KeyOpen2);
WriteInt('Player2', 'KeyStrafe2', KeyStrafe2);
+ for i := 0 to High(KeyWeapon2) do
+ WriteInt('Player2', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]);
WriteStr('Player2', 'Name', Name);
WriteStr('Player2', 'model', Model);
diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index f2a98ff8aedc6f6f86c10b39ed904677955781fc..caddc0d9e7612dfa230b9676b010a95373bb6cbb 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
procedure NetFire(Wpn: Byte; X, Y, AX, AY: Integer; WID: Integer = -1);
procedure DoLerp(Level: Integer = 2);
procedure SetLerp(XTo, YTo: Integer);
+ procedure ForceWeapon(Weapon: Byte);
procedure JetpackOn;
procedure JetpackOff;
150, 0, 0);
end;
+procedure TPlayer.ForceWeapon(Weapon: Byte);
+var
+ i: Byte;
+begin
+ if g_Game_IsClient then Exit;
+ if Weapon > High(FWeapon) then Exit;
+ if FBFGFireCounter <> -1 then Exit;
+
+ if FTime[T_SWITCH] > gTime then Exit;
+
+ for i := WEAPON_KASTET to WEAPON_SUPERPULEMET do
+ if FReloading[i] > 0 then Exit;
+
+ if FWeapon[Weapon] then
+ begin
+ FCurrWeap := Weapon;
+ FTime[T_SWITCH] := gTime+156;
+ if FCurrWeap = WEAPON_SAW then
+ FSawSoundSelect.PlayAt(FObj.X, FObj.Y);
+ FModel.SetWeapon(FCurrWeap);
+ if g_Game_IsNet then MH_SEND_PlayerStats(FUID);
+ end;
+end;
+
procedure TPlayer.NextWeapon();
var
i: Byte;