diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index 050e0e650950b20e5e51a65d23f40564b87d3638..f4c54db99b1deaa191ea23dd9a5bb92c650ae7bc 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*)
-{$MODE DELPHI}
+{$INCLUDE ../shared/a_modes.inc}
unit g_player;
interface
procedure SetWeapon(W: Byte);
function IsKeyPressed(K: Byte): Boolean;
function GetKeys(): Byte;
- function PickItem(ItemType: Byte; respawn: Boolean; var remove: Boolean): Boolean; virtual;
+ function PickItem(ItemType: Byte; arespawn: Boolean; var remove: Boolean): Boolean; virtual;
function Collide(X, Y: Integer; Width, Height: Word): Boolean; overload;
function Collide(Panel: TPanel): Boolean; overload;
function Collide(X, Y: Integer): Boolean; overload;
function FullInStep(XInc, YInc: Integer): Boolean;
//function NeedItem(Item: Byte): Byte;
procedure SelectWeapon(Dist: Integer);
- procedure SetAIFlag(fName, fValue: String20);
- function GetAIFlag(fName: String20): String20;
- procedure RemoveAIFlag(fName: String20);
+ procedure SetAIFlag(aName, fValue: String20);
+ function GetAIFlag(aName: String20): String20;
+ procedure RemoveAIFlag(aName: String20);
function Healthy(): Byte;
procedure UpdateMove();
procedure UpdateCombat();
procedure TPlayer.ChangeModel(ModelName: string);
var
- Model: TPlayerModel;
+ locModel: TPlayerModel;
begin
- Model := g_PlayerModel_Get(ModelName);
- if Model = nil then Exit;
+ locModel := g_PlayerModel_Get(ModelName);
+ if locModel = nil then Exit;
FModel.Free();
- FModel := Model;
+ FModel := locModel;
end;
procedure TPlayer.SetModel(ModelName: string);
var
f, DidFire: Boolean;
wx, wy, xd, yd: Integer;
- obj: TObj;
+ locobj: TObj;
begin
if g_Game_IsClient then Exit;
// FBFGFireCounter - âðåìÿ ïåðåä âûñòðåëîì (äëÿ BFG)
if R_BERSERK in FRulez then
begin
//g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
- obj.X := FObj.X+FObj.Rect.X;
- obj.Y := FObj.Y+FObj.Rect.Y;
- obj.rect.X := 0;
- obj.rect.Y := 0;
- obj.rect.Width := 39;
- obj.rect.Height := 52;
- obj.Vel.X := (xd-wx) div 2;
- obj.Vel.Y := (yd-wy) div 2;
- obj.Accel.X := xd-wx;
- obj.Accel.y := yd-wy;
-
- if g_Weapon_Hit(@obj, 50, FUID, HIT_SOME) <> 0 then
+ locobj.X := FObj.X+FObj.Rect.X;
+ locobj.Y := FObj.Y+FObj.Rect.Y;
+ locobj.rect.X := 0;
+ locobj.rect.Y := 0;
+ locobj.rect.Width := 39;
+ locobj.rect.Height := 52;
+ locobj.Vel.X := (xd-wx) div 2;
+ locobj.Vel.Y := (yd-wy) div 2;
+ locobj.Accel.X := xd-wx;
+ locobj.Accel.y := yd-wy;
+
+ if g_Weapon_Hit(@locobj, 50, FUID, HIT_SOME) <> 0 then
g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj.X, FObj.Y)
else
g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj.X, FObj.Y);
begin
result := 255; // default result: "no switch"
// had weapon cycling on previous frame? remove that flag
- if (FNextWeap and $2000) <> 0 then begin FNextWeap := FNextWeap and $1FFF; FNextWeapDelay := 0; end;
+ if (FNextWeap and $2000) <> 0 then
+ begin
+ FNextWeap := FNextWeap and $1FFF;
+ FNextWeapDelay := 0;
+ end;
// cycling has priority
if (FNextWeap and $C000) <> 0 then
begin
- if (FNextWeap and $8000) <> 0 then dir := 1 else dir := -1;
+ if (FNextWeap and $8000) <> 0 then
+ dir := 1
+ else
+ dir := -1;
FNextWeap := FNextWeap or $2000; // we need this
- if FNextWeapDelay > 0 then exit; // cooldown time
+ if FNextWeapDelay > 0 then
+ exit; // cooldown time
cwi := FCurrWeap;
for i := 0 to High(FWeapon) do
begin
exit;
end;
// no cycling
- 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;
+ 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;
// exclude currently selected weapon from the set
wantThisWeapon[FCurrWeap] := false;
// slow down alterations a little
begin
//e_WriteLog(Format(' FNextWeap=%x; delay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
// more than one weapon requested, assume "alteration" and check alteration delay
- if FNextWeapDelay > 0 then begin FNextWeap := 0; exit; end; // yeah
+ if FNextWeapDelay > 0 then
+ begin
+ FNextWeap := 0;
+ exit;
+ end; // yeah
end;
// do not reset weapon queue, it will be done in `RealizeCurrentWeapon()`
// but clear all counters if no weapon should be switched
- if wwc < 1 then begin resetWeaponQueue(); exit; end;
+ 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
resetWeaponQueue();
end;
-function TPlayer.PickItem(ItemType: Byte; respawn: Boolean; var remove: Boolean): Boolean;
+function TPlayer.PickItem(ItemType: Byte; arespawn: Boolean; var remove: Boolean): Boolean;
var
a: Boolean;
begin
if g_Game_IsClient then Exit;
// a = true - ìåñòî ñïàâíà ïðåäìåòà:
- a := LongBool(gGameSettings.Options and GAME_OPTION_WEAPONSTAY) and respawn;
+ a := LongBool(gGameSettings.Options and GAME_OPTION_WEAPONSTAY) and arespawn;
remove := not a;
case ItemType of
IncMax(FHealth, 10, PLAYER_HP_SOFT);
Result := True;
remove := True;
+ FFireTime := 0;
if gFlash = 2 then Inc(FPickup, 5);
end;
IncMax(FHealth, 25, PLAYER_HP_SOFT);
Result := True;
remove := True;
+ FFireTime := 0;
if gFlash = 2 then Inc(FPickup, 5);
end;
IncMax(FHealth, 100, PLAYER_HP_LIMIT);
Result := True;
remove := True;
+ FFireTime := 0;
if gFlash = 2 then Inc(FPickup, 5);
end;
FArmor := PLAYER_AP_LIMIT;
Result := True;
remove := True;
+ FFireTime := 0;
if gFlash = 2 then Inc(FPickup, 5);
end;
ITEM_WEAPON_SAW:
- if (not FWeapon[WEAPON_SAW]) or ((not respawn) and (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF])) then
+ if (not FWeapon[WEAPON_SAW]) or ((not arespawn) and (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF])) then
begin
FWeapon[WEAPON_SAW] := True;
Result := True;
FMegaRulez[MR_SUIT] := gTime+PLAYER_SUIT_TIME;
Result := True;
remove := True;
+ FFireTime := 0;
if gFlash = 2 then Inc(FPickup, 5);
end;
FBerserk := gTime+30000;
Result := True;
remove := True;
+ FFireTime := 0;
end;
if FHealth < PLAYER_HP_SOFT then
begin
FBerserk := gTime+30000;
Result := True;
remove := True;
+ FFireTime := 0;
end;
end;
IncMax(FHealth, 4, PLAYER_HP_LIMIT);
Result := True;
remove := True;
+ FFireTime := 0;
if gFlash = 2 then Inc(FPickup, 5);
end;
FFireTime := 0;
FFirePainTime := 0;
end
+ else if FMegaRulez[MR_SUIT] >= gTime then
+ begin
+ if FMegaRulez[MR_SUIT] = gTime then
+ FFireTime := 1;
+ FFirePainTime := 0;
+ end
else
begin
OnFireFlame(1);
procedure TPlayer.NetFire(Wpn: Byte; X, Y, AX, AY: Integer; WID: Integer = -1);
var
- Obj: TObj;
+ locObj: TObj;
F: Boolean;
WX, WY, XD, YD: Integer;
begin
if R_BERSERK in FRulez then
begin
//g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
- obj.X := FObj.X+FObj.Rect.X;
- obj.Y := FObj.Y+FObj.Rect.Y;
- obj.rect.X := 0;
- obj.rect.Y := 0;
- obj.rect.Width := 39;
- obj.rect.Height := 52;
- obj.Vel.X := (xd-wx) div 2;
- obj.Vel.Y := (yd-wy) div 2;
- obj.Accel.X := xd-wx;
- obj.Accel.y := yd-wy;
-
- if g_Weapon_Hit(@obj, 50, FUID, HIT_SOME) <> 0 then
+ locobj.X := FObj.X+FObj.Rect.X;
+ locobj.Y := FObj.Y+FObj.Rect.Y;
+ locobj.rect.X := 0;
+ locobj.rect.Y := 0;
+ locobj.rect.Width := 39;
+ locobj.rect.Height := 52;
+ locobj.Vel.X := (xd-wx) div 2;
+ locobj.Vel.Y := (yd-wy) div 2;
+ locobj.Accel.X := xd-wx;
+ locobj.Accel.y := yd-wy;
+
+ if g_Weapon_Hit(@locobj, 50, FUID, HIT_SOME) <> 0 then
g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj.X, FObj.Y)
else
g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj.X, FObj.Y);
firew, fireh: Integer;
angle: SmallInt;
mon: TMonster;
- pla: TPlayer;
+ pla, tpla: TPlayer;
vsPlayer, vsMonster, ok: Boolean;
begin
vsPlayer := LongBool(gGameSettings.Options and GAME_OPTION_BOTVSPLAYER);
if (g_GetUIDType(Target.UID) = UID_PLAYER) and
vsPlayer then
begin // Èãðîê
- with g_Player_Get(Target.UID) do
- begin
- if (@FObj) <> nil then
+ tpla := g_Player_Get(Target.UID);
+ if tpla <> nil then
+ with tpla do
begin
- Target.X := FObj.X;
- Target.Y := FObj.Y;
+ if (@FObj) <> nil then
+ begin
+ Target.X := FObj.X;
+ Target.Y := FObj.Y;
+ end;
end;
- end;
Target.cX := Target.X + PLAYER_RECT_CX;
Target.cY := Target.Y + PLAYER_RECT_CY;
Result := FKeys[Key].Pressed;
end;
-function TBot.GetAIFlag(fName: String20): String20;
+function TBot.GetAIFlag(aName: String20): String20;
var
a: Integer;
begin
Result := '';
- fName := LowerCase(fName);
+ aName := LowerCase(aName);
if FAIFlags <> nil then
for a := 0 to High(FAIFlags) do
- if LowerCase(FAIFlags[a].Name) = fName then
+ if LowerCase(FAIFlags[a].Name) = aName then
begin
Result := FAIFlags[a].Value;
Break;
end;
end;
-procedure TBot.RemoveAIFlag(fName: String20);
+procedure TBot.RemoveAIFlag(aName: String20);
var
a, b: Integer;
begin
if FAIFlags = nil then Exit;
- fName := LowerCase(fName);
+ aName := LowerCase(aName);
for a := 0 to High(FAIFlags) do
- if LowerCase(FAIFlags[a].Name) = fName then
+ if LowerCase(FAIFlags[a].Name) = aName then
begin
if a <> High(FAIFlags) then
for b := a to High(FAIFlags)-1 do
end;
end;
-procedure TBot.SetAIFlag(fName, fValue: String20);
+procedure TBot.SetAIFlag(aName, fValue: String20);
var
a: Integer;
ok: Boolean;
a := 0;
ok := False;
- fName := LowerCase(fName);
+ aName := LowerCase(aName);
if FAIFlags <> nil then
for a := 0 to High(FAIFlags) do
- if LowerCase(FAIFlags[a].Name) = fName then
+ if LowerCase(FAIFlags[a].Name) = aName then
begin
ok := True;
Break;
SetLength(FAIFlags, Length(FAIFlags)+1);
with FAIFlags[High(FAIFlags)] do
begin
- Name := fName;
+ Name := aName;
Value := fValue;
end;
end;