X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_player.pas;h=0522063cc24e07670a0c095dc391e2fadc56b3b8;hb=385f70688f69aba255d1cdb9b7f0717bfe1b6945;hp=14a2fdcd4d17d4fb9c3478ce9383303c7fe14986;hpb=d7d166dc3cd287276202e862746208892c4cc89f;p=d2df-sdl.git diff --git a/src/game/g_player.pas b/src/game/g_player.pas index 14a2fdc..0522063 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,15 @@ procedure g_Bot_RemoveAll(); implementation uses +{$IFDEF USE_NANOGL} + nanoGL, +{$ELSE} + GL, +{$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, g_holmes, utils, xstreams; const PLR_SAVE_VERSION = 0; @@ -987,7 +994,7 @@ end; procedure g_Bot_Add(Team, Difficult: Byte); var - m: SArray; + m: SSArray; _name, _model: String; a, tr, tb: Integer; begin @@ -1084,7 +1091,7 @@ end; procedure g_Bot_AddList(Team: Byte; lName: ShortString; num: Integer = -1); var - m: SArray; + m: SSArray; _name, _model: String; a: Integer; begin @@ -1221,7 +1228,7 @@ var s: String; a, b: Integer; config: TConfig; - sa: SArray; + sa: SSArray; begin BotNames := nil; @@ -2246,6 +2253,8 @@ begin FJetSoundOn.Free(); FJetSoundOff.Free(); FModel.Free(); + if FPunchAnim <> nil then + FPunchAnim.Free(); inherited; end; @@ -2336,9 +2345,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 @@ -2773,6 +2792,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 +2846,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]; @@ -4450,6 +4484,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 +4780,9 @@ begin FLoss := 0; end; + if FAlive and (FPunchAnim <> nil) then + FPunchAnim.Update(); + if FAlive and (gFly or FJetpack) then FlySmoke(); @@ -5266,6 +5308,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