From: binarymaster Date: Sat, 23 Sep 2017 19:14:54 +0000 (+0300) Subject: Physics: Fix climb ladders on the fly X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=81c234975e457cd374fa9b4d20fecdd983ade60c;p=d2df-sdl.git Physics: Fix climb ladders on the fly http://doom2d.org/forum/viewtopic.php?f=36&t=2347 --- diff --git a/src/game/g_phys.pas b/src/game/g_phys.pas index e92e49b..dd4c07a 100644 --- a/src/game/g_phys.pas +++ b/src/game/g_phys.pas @@ -60,6 +60,7 @@ function g_Obj_CollideWater(Obj: PObj; XInc, YInc: Integer): Boolean; inline; function g_Obj_CollideLiquid(Obj: PObj; XInc, YInc: Integer): Boolean; inline; function g_Obj_CollidePanel(Obj: PObj; XInc, YInc: Integer; PanelType: Word): Boolean; inline; function g_Obj_StayOnStep(Obj: PObj): Boolean; inline; +function g_Obj_CanMoveY(Obj: PObj; YInc: Integer): Boolean; inline; procedure g_Obj_Push(Obj: PObj; VelX, VelY: Integer); inline; procedure g_Obj_PushA(Obj: PObj; Vel: Integer; Angle: SmallInt); inline; procedure g_Obj_SetSpeed(Obj: PObj; s: Integer); inline; @@ -90,6 +91,13 @@ begin PANEL_STEP, False); end; +function g_Obj_CanMoveY(Obj: PObj; YInc: Integer): Boolean; inline; +begin + // Åñëè øàãíóòü â ïî âåðòèêàëè, à òàì ñòåíà => øàãàòü íåëüçÿ + // Èëè åñëè øàãíóòü âíèç, à òàì ñòóïåíü => øàãàòü íåëüçÿ + Result := not(g_Obj_CollideLevel(Obj, 0, YInc) or ((YInc > 0) and g_Obj_StayOnStep(Obj))); +end; + function CollideLiquid(Obj: PObj; XInc, YInc: Integer): Boolean; inline; begin Result := g_Map_CollidePanel(Obj^.X+Obj^.Rect.X+XInc, Obj^.Y+Obj^.Rect.Y+YInc, @@ -257,7 +265,7 @@ var begin result := true; if (not g_Obj_CollideLevel(Obj, sx, -12)) and // çàáèðàåìñÿ íà 12 ïèêñåëåé âëåâî/âïðàâî - g_Obj_CollidePanel(Obj, 0, 1, PANEL_WALL or PANEL_STEP) then // òîëüêî åñëè åñòü çåìëÿ ïîä íîãàìè + (sy >= 0) and (not g_Obj_CanMoveY(Obj, sy)) then // òîëüêî åñëè åñòü çåìëÿ ïîä íîãàìè begin slope(-1); end @@ -299,9 +307,8 @@ var if Blocked(Obj, 0, sy) then st := st or MOVE_BLOCK; end; - // Åñëè øàãíóòü â ïî âåðòèêàëè, à òàì ñòåíà => øàãàòü íåëüçÿ - // Èëè åñëè øàãíóòü âíèç, à òàì ñòóïåíü => øàãàòü íåëüçÿ - if g_Obj_CollideLevel(Obj, 0, sy) or ((sy > 0) and g_Obj_StayOnStep(Obj)) then + // Åñëè øàãàòü íåëüçÿ + if not g_Obj_CanMoveY(Obj, sy) then begin if sy > 0 then st := st or MOVE_HITLAND