X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_gfx.pas;h=476f658d15175b28e911ee8b60e2dca69b6bcd0a;hb=227dcd4daa2ac6aa576859da6af85370594f9d96;hp=52c885692f6a5b61f994ce3f4942a954c0718043;hpb=ee042fbd9cc188c3f0547d51f8012ef73447dfc7;p=d2df-sdl.git diff --git a/src/game/g_gfx.pas b/src/game/g_gfx.pas index 52c8856..476f658 100644 --- a/src/game/g_gfx.pas +++ b/src/game/g_gfx.pas @@ -334,36 +334,38 @@ end; function TParticle.checkAirStreams (): Boolean; var pan: TPanel; + r: Integer; begin pan := g_Map_PanelAtPoint(x, y, GridTagLift); - result := (pan <> nil); + result := (pan <> nil) and WordBool(pan.PanelType and (PANEL_LIFTUP or PANEL_LIFTDOWN or PANEL_LIFTLEFT or PANEL_LIFTRIGHT)); + r := Random(3); if result then begin - if ((pan.PanelType and PANEL_LIFTUP) <> 0) then - begin - if (velY > -1-Random(3)) then velY -= 0.8; - if (abs(velX) > 0.1) then velX -= velX/10.0; - velX += (Random-Random)*0.2; - accelY := 0.15; - end - else if ((pan.PanelType and PANEL_LIFTDOWN) <> 0) then - begin - if (velY < 1+Random(3)) then velY += 0.8; - accelY := 0.15; - end - else if ((pan.PanelType and PANEL_LIFTLEFT) <> 0) then - begin - if (velX > -8-Random(3)) then velX -= 0.8; - accelY := 0.15; - end - else if ((pan.PanelType and PANEL_LIFTRIGHT) <> 0) then - begin - if (velX < 8+Random(3)) then velX += 0.8; - accelY := 0.15; - end - else - begin - result := false; + case pan.LiftType of + LIFTTYPE_UP: + begin + if (velY > -1-r) then velY -= 0.8; + if (abs(velX) > 0.1) then velX -= velX/10.0; + velX += (Random-Random)*0.2; + accelY := 0.15; + end; + LIFTTYPE_DOWN: + begin + if (velY < 1+r) then velY += 0.8; + accelY := 0.15; + end; + LIFTTYPE_LEFT: + begin + if (velX > -8-r) then velX -= (8+r) div 2; + accelY := 0.15; + end; + LIFTTYPE_RIGHT: + begin + if (velX < 8+r) then velX += (8+r) div 2; + accelY := 0.15; + end; + else + result := false; end; // awake if result and (state = TPartState.Sleeping) then state := TPartState.Normal; @@ -455,7 +457,7 @@ var ex: Integer; begin if (not force) and (ceilingY <> Unknown) then exit; - if (nil = g_Map_traceToNearest(x, y, x, g_Map_MinY, GridTagObstacle, @ex, @ceilingY)) then + if (nil = g_Map_traceToNearest(x, y, x, g_Map_MinY, GridTagSolid, @ex, @ceilingY)) then begin ceilingY := g_Map_MinY-2; end; @@ -597,7 +599,7 @@ var pan: TPanel; dx, dy: SmallInt; ex, ey: Integer; - checkEnv: Boolean; + checkEnv, inAir, inStep: Boolean; floorJustTraced: Boolean; {$IF DEFINED(D2F_DEBUG_FALL_MPLAT)} oldFloorY: Integer; @@ -693,7 +695,7 @@ begin dx := round(velX); dy := round(velY); - if (state = TPartState.Normal) then checkAirStreams(); + inAir := checkAirStreams(); // gravity, if not stuck if (state <> TPartState.Stuck) and (abs(velX) < 0.1) and (abs(velY) < 0.1) then @@ -741,7 +743,24 @@ begin if (dx <> 0) then begin // has some horizontal velocity - pan := g_Map_traceToNearest(x, y, x+dx, y+dy, GridTagObstacle, @ex, @ey); + inStep := False; + pan := g_Map_traceToNearest(x, y, x+dx, y+dy, GridTagSolid, @ex, @ey); + if (pan = nil) and (dy >= 0) then + begin + // do not stuck inside step + if g_Map_traceToNearest(x, y, x, y, GridTagStep, nil, nil) = nil then + // check for step panel below + pan := g_Map_traceToNearest(x, y, x, y+dy, GridTagStep, nil, @ey); + inStep := pan <> nil; + if inStep then + begin + // stick to panel edges + if ex < pan.X then + ex := pan.X + else if ex > pan.X + pan.Width - 1 then + ex := pan.X + pan.Width - 1; + end; + end; checkEnv := (x <> ex); x := ex; y := ey; @@ -755,19 +774,24 @@ begin end; if (pan <> nil) then begin - // we stuck - // the only case when we can have both ceiling and wall is corner; stick to wall in this case - // check if we stuck to a wall - if (dx < 0) then dx := -1 else dx := 1; - if (g_Map_PanelAtPoint(x+dx, y, GridTagObstacle) <> nil) then - begin - // stuck to a wall - stickToWall(dx); - end + if inStep then + stickToWall(dx) else begin - // stuck to a ceiling - stickToCeiling(); + // we stuck + // the only case when we can have both ceiling and wall is corner; stick to wall in this case + // check if we stuck to a wall + if (dx < 0) then dx := -1 else dx := 1; + if (g_Map_PanelAtPoint(x+dx, y, GridTagSolid) <> nil) then + begin + // stuck to a wall + stickToWall(dx); + end + else + begin + // stuck to a ceiling + stickToCeiling(); + end; end; end; end @@ -818,7 +842,7 @@ begin if (y <> floorY) then continue; end; // environment didn't changed - hitAFloor(); + if not inAir then hitAFloor(); break; // done with vertical movement end; TFloorType.LiquidIn: // entering the liquid @@ -836,7 +860,7 @@ begin findFloor(true); // force rescan if (floorType = TFloorType.Wall) and (floorY = y) then begin - hitAFloor(); + if not inAir then hitAFloor(); break; // done with vertical movement end; end; @@ -961,11 +985,11 @@ begin if (x < g_Map_MinX) or (y < g_Map_MinY) or (x > g_Map_MaxX) or (y > g_Map_MaxY) then continue; // in what environment we are starting in? - pan := g_Map_PanelAtPoint(x, y, (GridTagObstacle or GridTagLiquid)); + pan := g_Map_PanelAtPoint(x, y, (GridTagSolid or GridTagLiquid)); if (pan <> nil) then begin // either in a wall, or in a liquid - if ((pan.tag and GridTagObstacle) <> 0) then continue; // don't spawn in walls + if ((pan.tag and GridTagSolid) <> 0) then continue; // don't spawn in walls env := TEnvType.ELiquid; end else @@ -1274,7 +1298,7 @@ begin if (dx <> 0) then begin // has some horizontal velocity - pan := g_Map_traceToNearest(x, y, x+dx, y+dy, (GridTagObstacle or GridTagLiquid), @ex, @ey); + pan := g_Map_traceToNearest(x, y, x+dx, y+dy, (GridTagSolid or GridTagLiquid), @ex, @ey); if (x <> ex) then begin floorY := Unknown; ceilingY := Unknown; end; // dunno yet x := ex; y := ey; @@ -1370,11 +1394,11 @@ begin if (x < g_Map_MinX) or (y < g_Map_MinY) or (x > g_Map_MaxX) or (y > g_Map_MaxY) then continue; // in what environment we are starting in? - pan := g_Map_PanelAtPoint(x, y, (GridTagObstacle or GridTagLiquid)); + pan := g_Map_PanelAtPoint(x, y, (GridTagSolid or GridTagLiquid)); if (pan <> nil) then begin // either in a wall, or in a liquid - //if ((pan.tag and GridTagObstacle) <> 0) then continue; // don't spawn in walls + //if ((pan.tag and GridTagSolid) <> 0) then continue; // don't spawn in walls //env := TEnvType.ELiquid; continue; end @@ -1452,11 +1476,11 @@ begin if (x < g_Map_MinX) or (y < g_Map_MinY) or (x > g_Map_MaxX) or (y > g_Map_MaxY) then continue; // in what environment we are starting in? - pan := g_Map_PanelAtPoint(x, y, (GridTagObstacle or GridTagLiquid)); + pan := g_Map_PanelAtPoint(x, y, (GridTagSolid or GridTagLiquid)); if (pan <> nil) then begin // either in a wall, or in a liquid - //if ((pan.tag and GridTagObstacle) <> 0) then continue; // don't spawn in walls + //if ((pan.tag and GridTagSolid) <> 0) then continue; // don't spawn in walls //env := TEnvType.ELiquid; continue; end