X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_player.pas;h=8c626569dfe2dd1e25476321c64567ea7333f5ff;hb=3a2594735abd86e583b35da46526b9d16a9cd0ed;hp=b4d00c9923a6f8e4a63d15795fe00d42e9d112c5;hpb=cd1ca85acc0740e0f307782e2af54e5ba0a59507;p=d2df-sdl.git diff --git a/src/game/g_player.pas b/src/game/g_player.pas index b4d00c9..8c62656 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -1,4 +1,4 @@ -(* Copyright (C) DooM 2D:Forever Developers +(* Copyright (C) Doom 2D: Forever Developers * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,7 +21,7 @@ interface uses SysUtils, Classes, - mempool, + {$IFDEF USE_MEMPOOL}mempool,{$ENDIF} e_graphics, g_playermodel, g_basic, g_textures, g_weapons, g_phys, g_sound, g_saveload, MAPDEF, g_panel; @@ -135,7 +135,7 @@ type Time: Word; end; - TPlayer = class(TPoolObject) + TPlayer = class{$IFDEF USE_MEMPOOL}(TPoolObject){$ENDIF} private FIamBot: Boolean; FUID: Word; @@ -176,6 +176,7 @@ type FSavedState: TPlayerSavedState; FModel: TPlayerModel; + FPunchAnim: TAnimation; FActionPrior: Byte; FActionAnim: Byte; FActionForce: Boolean; @@ -213,6 +214,7 @@ type procedure SetAction(Action: Byte; Force: Boolean = False); procedure OnDamage(Angle: SmallInt); virtual; function firediry(): Integer; + procedure DoPunch(); procedure Run(Direction: TDirection); procedure NextWeapon(); @@ -491,7 +493,7 @@ type procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right! end; - TCorpse = class(TPoolObject) + TCorpse = class{$IFDEF USE_MEMPOOL}(TPoolObject){$ENDIF} private FModelName: String; FMess: Boolean; @@ -586,10 +588,18 @@ procedure g_Bot_RemoveAll(); implementation uses +{$IFDEF USE_NANOGL} + nanoGL, +{$ELSE} + GL, +{$ENDIF} +{$IFDEF ENABLE_HOLMES} + g_holmes, +{$ENDIF} e_log, g_map, g_items, g_console, g_gfx, Math, g_options, g_triggers, g_menu, g_game, g_grid, wadreader, g_main, g_monsters, CONFIG, g_language, - g_net, g_netmsg, g_window, GL, g_holmes, + g_net, g_netmsg, g_window, utils, xstreams; const PLR_SAVE_VERSION = 0; @@ -2246,6 +2256,8 @@ begin FJetSoundOn.Free(); FJetSoundOff.Free(); FModel.Free(); + if FPunchAnim <> nil then + FPunchAnim.Free(); inherited; end; @@ -2336,9 +2348,19 @@ var ID: DWORD; w, h: Word; dr: Boolean; + Mirror: TMirrorType; begin if FAlive then begin + if Direction = TDirection.D_RIGHT then + Mirror := TMirrorType.None + else + Mirror := TMirrorType.Horizontal; + + if FPunchAnim <> nil then + FPunchAnim.Draw(FObj.X+IfThen(Direction = TDirection.D_LEFT, 15-FObj.Rect.X, FObj.Rect.X-15), + FObj.Y+FObj.Rect.Y-11, Mirror); + if (FMegaRulez[MR_INVUL] > gTime) and (gPlayerDrawn <> Self) then if g_Texture_Get('TEXTURE_PLAYER_INVULPENTA', ID) then begin @@ -2395,10 +2417,13 @@ procedure TPlayer.DrawAim(); var ex, ey: Integer; begin + +{$IFDEF ENABLE_HOLMES} if isValidViewPort and (self = gPlayer1) then begin g_Holmes_plrLaser(ax0, ay0, ax1, ay1); end; +{$ENDIF} e_DrawLine(sz, ax0, ay0, ax1, ay1, 255, 0, 0, 96); if (g_Map_traceToNearestWall(ax0, ay0, ax1, ay1, @ex, @ey) <> nil) then @@ -2773,6 +2798,17 @@ begin e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 150, 200, 150, 255-h*50); end; +procedure TPlayer.DoPunch(); +var + id: DWORD; +begin + if FPunchAnim = nil then begin + g_Frames_Get(id, 'FRAMES_PUNCH'); + FPunchAnim := TAnimation.Create(id, False, 1); + end else + FPunchAnim.reset(); +end; + procedure TPlayer.Fire(); var f, DidFire: Boolean; @@ -2816,15 +2852,19 @@ begin locobj.Accel.X := xd-wx; locobj.Accel.y := yd-wy; + DoPunch(); + 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); - if gFlash = 1 then - if FPain < 50 then - FPain := min(FPain + 25, 50); - end else g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 3, FUID); + if (gFlash = 1) and (FPain < 50) then FPain := min(FPain + 25, 50); + end + else + begin + g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 3, FUID); + end; DidFire := True; FReloading[FCurrWeap] := WEAPON_RELOAD[FCurrWeap]; @@ -4308,6 +4348,12 @@ var Anim: TAnimation; ID: DWORD; begin + FIncCam := 0; + FBFGFireCounter := -1; + FShellTimer := -1; + FPain := 0; + FLastHit := 0; + if not g_Game_IsServer then Exit; if FDummy then @@ -4412,12 +4458,6 @@ begin else FAngle := 0; - FIncCam := 0; - FBFGFireCounter := -1; - FShellTimer := -1; - FPain := 0; - FLastHit := 0; - SetAction(A_STAND, True); FModel.Direction := FDirection; @@ -4450,6 +4490,11 @@ begin FSpectatePlayer := -1; FSpawned := True; + if (gPlayer1 = nil) and (gLMSPID1 = FUID) then + gPlayer1 := self; + if (gPlayer2 = nil) and (gLMSPID2 = FUID) then + gPlayer2 := self; + if g_Game_IsNet then begin MH_SEND_PlayerPos(True, FUID, NET_EVERYONE); @@ -4741,6 +4786,9 @@ begin FLoss := 0; end; + if FAlive and (FPunchAnim <> nil) then + FPunchAnim.Update(); + if FAlive and (gFly or FJetpack) then FlySmoke(); @@ -5266,6 +5314,8 @@ begin locobj.Accel.X := xd-wx; locobj.Accel.y := yd-wy; + DoPunch(); + if g_Weapon_Hit(@locobj, 50, FUID, HIT_SOME) <> 0 then g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj.X, FObj.Y) else