diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index e90398276756262f8eb5272e2015fae609deae20..5430ba709c848c985c8d6c5ffedafe296143c09d 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
for i := 0 to High(gPlayers) do
if gPlayers[i] <> nil then
for i := 0 to High(gPlayers) do
if gPlayers[i] <> nil then
- if gPlayers[i] is TPlayer then gPlayers[i].Update()
- else TBot(gPlayers[i]).Update();
+ begin
+ if gPlayers[i] is TPlayer then
+ begin
+ gPlayers[i].Update();
+ gPlayers[i].RealizeCurrentWeapon(); // WARNING! DO NOT MOVE THIS INTO `Update()`!
+ end
+ else
+ begin
+ // bot updates weapons in `UpdateCombat()`
+ TBot(gPlayers[i]).Update();
+ end;
+ end;
end;
procedure g_Player_DrawAll();
end;
procedure g_Player_DrawAll();
result := 255; // default result: "no switch"
for i := 0 to High(wantThisWeapon) do wantThisWeapon[i] := false;
for i := 0 to High(FWeapon) do if (FNextWeap and (1 shl i)) <> 0 then begin wantThisWeapon[i] := true; Inc(wwc); end;
result := 255; // default result: "no switch"
for i := 0 to High(wantThisWeapon) do wantThisWeapon[i] := false;
for i := 0 to High(FWeapon) do if (FNextWeap and (1 shl i)) <> 0 then begin wantThisWeapon[i] := true; Inc(wwc); end;
- (*
- if wantThisWeapon[FCurrWeap] then
- begin
- // these hacks implements alternating between SG and SSG; sorry
- if FCurrWeap = WEAPON_SHOTGUN1 then begin wantThisWeapon[WEAPON_SHOTGUN2] := true; Inc(wwc); end;
- if FCurrWeap = WEAPON_SHOTGUN2 then begin wantThisWeapon[WEAPON_SHOTGUN1] := true; Inc(wwc); end;
- // these hacks implements alternating between knuckles and chainsaw; sorry
- if FCurrWeap = WEAPON_KASTET then begin wantThisWeapon[WEAPON_SAW] := true; Inc(wwc); end;
- if FCurrWeap = WEAPON_SAW then begin wantThisWeapon[WEAPON_KASTET] := true; Inc(wwc); end;
- end;
- *)
// exclude currently selected weapon from the set
wantThisWeapon[FCurrWeap] := false;
// slow down alterations a little
// exclude currently selected weapon from the set
wantThisWeapon[FCurrWeap] := false;
// slow down alterations a little
if FNextWeapDelay > 0 then begin FNextWeap := 0; exit; end; // yeah
end;
// do not reset weapon queue, it will be done in `RealizeCurrentWeapon()`
if FNextWeapDelay > 0 then begin FNextWeap := 0; exit; end; // yeah
end;
// do not reset weapon queue, it will be done in `RealizeCurrentWeapon()`
+ if wwc < 1 then begin resetWeaponQueue(); exit; end;
+ //e_WriteLog(Format('wwc=%d', [wwc]), MSG_WARNING);
// try weapons in descending order
for i := High(FWeapon) downto 0 do
begin
// try weapons in descending order
for i := High(FWeapon) downto 0 do
begin
exit;
end;
end;
exit;
end;
end;
+ // no suitable weapon found, so reset the queue, to avoid accidental "queuing" of weapon w/o ammo
+ resetWeaponQueue();
end;
procedure TPlayer.RealizeCurrentWeapon();
end;
procedure TPlayer.RealizeCurrentWeapon();
var
i, cwi: Integer;
begin
var
i, cwi: Integer;
begin
- if dir < 0 then dir := 1 else if dir > 0 then dir := 1 else exit;
+ if dir < 0 then dir := -1 else if dir > 0 then dir := 1 else exit;
cwi := FCurrWeap;
for i := 0 to High(FWeapon) do
begin
cwi := FCurrWeap;
for i := 0 to High(FWeapon) do
begin
- cwi := cwi+dir;
- if cwi < 0 then cwi += length(FWeapon)
- else if cwi > High(FWeapon) then cwi := cwi-length(FWeapon);
+ cwi := (cwi+length(FWeapon)+dir) mod length(FWeapon);
if FWeapon[cwi] then
begin
QueueWeaponSwitch(Byte(cwi));
if FWeapon[cwi] then
begin
QueueWeaponSwitch(Byte(cwi));
FJetFuel := JET_MAX;
end;
FJetFuel := JET_MAX;
end;
+ ITEM_MEDKIT_SMALL: if FHealth < PLAYER_HP_SOFT then IncMax(FHealth, 10, PLAYER_HP_SOFT);
+ ITEM_MEDKIT_LARGE: if FHealth < PLAYER_HP_SOFT then IncMax(FHealth, 25, PLAYER_HP_SOFT);
+
+ ITEM_ARMOR_GREEN: if FArmor < PLAYER_AP_SOFT then FArmor := PLAYER_AP_SOFT;
+ ITEM_ARMOR_BLUE: if FArmor < PLAYER_AP_LIMIT then FArmor := PLAYER_AP_LIMIT;
+
+ ITEM_SPHERE_BLUE: if FHealth < PLAYER_HP_LIMIT then IncMax(FHealth, 100, PLAYER_HP_LIMIT);
+ ITEM_SPHERE_WHITE:
+ if (FHealth < PLAYER_HP_LIMIT) or (FArmor < PLAYER_AP_LIMIT) then
+ begin
+ if FHealth < PLAYER_HP_LIMIT then FHealth := PLAYER_HP_LIMIT;
+ if FArmor < PLAYER_AP_LIMIT then FArmor := PLAYER_AP_LIMIT;
+ end;
+
ITEM_WEAPON_SAW: FWeapon[WEAPON_SAW] := True;
ITEM_WEAPON_SHOTGUN1: FWeapon[WEAPON_SHOTGUN1] := True;
ITEM_WEAPON_SHOTGUN2: FWeapon[WEAPON_SHOTGUN2] := True;
ITEM_WEAPON_SAW: FWeapon[WEAPON_SAW] := True;
ITEM_WEAPON_SHOTGUN1: FWeapon[WEAPON_SHOTGUN1] := True;
ITEM_WEAPON_SHOTGUN2: FWeapon[WEAPON_SHOTGUN2] := True;
begin
UpdateMove();
UpdateCombat();
begin
UpdateMove();
UpdateCombat();
+ end
+ else
+ begin
+ RealizeCurrentWeapon();
end;
end;
end;
end;