summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9721d91)
raw | patch | inline | side by side (parent: 9721d91)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 6 Aug 2017 03:39:03 +0000 (06:39 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 6 Aug 2017 04:08:10 +0000 (07:08 +0300) |
src/game/g_player.pas | patch | blob | history |
diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index 989f11a095e2055a116a8a9316742798ac7ff684..558edf291005ae96e782a5a526694dc9b57bb8b5 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
JetFuel: Integer;
CurrWeap: Byte;
NextWeap: WORD;
+ NextWeapDelay: Byte;
Ammo: Array [A_BULLETS..A_CELLS] of Word;
MaxAmmo: Array [A_BULLETS..A_CELLS] of Word;
Weapon: Array [WEAPON_KASTET..WEAPON_SUPERPULEMET] of Boolean;
FSecrets: Integer;
FCurrWeap: Byte;
FNextWeap: WORD;
+ FNextWeapDelay: Byte; // frames
FBFGFireCounter: SmallInt;
FLastSpawnerUID: Word;
FLastHit: Byte;
Mem.ReadByte(gPlayers[a].FCurrWeap);
// Ñëåäóþùåå æåëàåìîå îðóæèå:
Mem.ReadWord(gPlayers[a].FNextWeap);
+// ...è ïàóçà:
+ Mem.ReadByte(gPlayers[a].FNextWeapDelay);
// Âðåìÿ çàðÿäêè BFG:
Mem.ReadSmallInt(gPlayers[a].FBFGFireCounter);
// Áóôåð óðîíà:
FBFGFireCounter := -1;
FJustTeleported := False;
FNetTime := 0;
+
+ resetWeaponQueue();
end;
procedure TPlayer.Damage(value: Word; SpawnerUID: Word; vx, vy: Integer; t: Byte);
procedure TPlayer.resetWeaponQueue ();
begin
FNextWeap := 0;
+ FNextWeapDelay := 0;
end;
-// return 255 for "no switch"; resets `FNextWeap`
+// return 255 for "no switch"
function TPlayer.getNextWeaponIndex (): Byte;
var
i: Word;
wantThisWeapon: array[0..64] of Boolean;
+ wwc: Integer = 0; //HACK!
begin
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 wantThisWeapon[i] := true;
+ 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 wantThisWeapon[WEAPON_SHOTGUN2] := true;
- if FCurrWeap = WEAPON_SHOTGUN2 then wantThisWeapon[WEAPON_SHOTGUN1] := true;
+ 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 wantThisWeapon[WEAPON_SAW] := true;
- if FCurrWeap = WEAPON_SAW then wantThisWeapon[WEAPON_KASTET] := true;
+ 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;
- // now exclude currently selected weapon from the set
+ // exclude currently selected weapon from the set
wantThisWeapon[FCurrWeap] := false;
+ // slow down alterations a little
+ if wwc > 1 then
+ begin
+ // more than one weapon requested, assume "alteration" and check alteration delay
+ if FNextWeapDelay > 0 then begin FNextWeap := 0; exit; end; // yeah
+ end;
// no more hacks (yet)
// do not reset weapon queue, it will be done in `RealizeCurrentWeapon()`
- // now try weapons in descending order
+ // try weapons in descending order
for i := High(FWeapon) downto 0 do
begin
if wantThisWeapon[i] and FWeapon[i] then
i, nw: Byte;
begin
nw := getNextWeaponIndex();
+ if FNextWeapDelay > 0 then Dec(FNextWeapDelay); // "alteration delay"
+ if nw = 255 then exit; // don't reset anything here
if nw > High(FWeapon) then begin resetWeaponQueue(); exit; end; // don't forget to reset queue here!
if FBFGFireCounter <> -1 then exit;
end;
// reset weapon queue; `getNextWeaponIndex()` guarantees to not select a weapon player don't have
resetWeaponQueue();
+ FNextWeapDelay := 10; // anyway, 'cause why not
end;
procedure TPlayer.cycleWeapon (dir: Integer);
FSavedState.JetFuel := FJetFuel;
FSavedState.CurrWeap := FCurrWeap;
FSavedState.NextWeap := FNextWeap;
+ FSavedState.NextWeapDelay := FNextWeapDelay;
for i := 0 to 3 do
FSavedState.Ammo[i] := FAmmo[i];
FJetFuel := FSavedState.JetFuel;
FCurrWeap := FSavedState.CurrWeap;
FNextWeap := FSavedState.NextWeap;
+ FNextWeapDelay := FSavedState.NextWeapDelay;
for i := 0 to 3 do
FAmmo[i] := FSavedState.Ammo[i];
Mem.WriteByte(FCurrWeap);
// Æåëàåìîå îðóæèå:
Mem.WriteWord(FNextWeap);
+// ...è ïàóçà
+ Mem.WriteByte(FNextWeapDelay);
// Âðåìÿ çàðÿäêè BFG:
Mem.WriteSmallInt(FBFGFireCounter);
// Áóôåð óðîíà:
Mem.ReadByte(FCurrWeap);
// Æåëàåìîå îðóæèå:
Mem.ReadWord(FNextWeap);
+// ...è ïàóçà
+ Mem.ReadByte(FNextWeapDelay);
// Âðåìÿ çàðÿäêè BFG:
Mem.ReadSmallInt(FBFGFireCounter);
// Áóôåð óðîíà: