X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_gfx.pas;h=e49a72cdaf286758c9a048d96a40b7e26259f3bd;hb=66d9ad247935e99fe7161849b71ed952cbb85508;hp=0ec78f65b68a6a44be558efeda92d61685a565d3;hpb=58722c153faad833472ba181784dcde8cf65152e;p=d2df-sdl.git diff --git a/src/game/g_gfx.pas b/src/game/g_gfx.pas index 0ec78f6..e49a72c 100644 --- a/src/game/g_gfx.pas +++ b/src/game/g_gfx.pas @@ -121,6 +121,8 @@ type procedure freeze (); inline; // remove velocities and acceleration procedure sleep (); inline; // switch to sleep mode + function checkAirStreams (): Boolean; // `true`: affected by air stream + function alive (): Boolean; inline; procedure die (); inline; procedure think (); inline; @@ -228,11 +230,50 @@ begin end; +// `true`: affected by air stream +function TParticle.checkAirStreams (): Boolean; +var + pan: TPanel; +begin + pan := g_Map_PanelAtPoint(x, y, GridTagLift); + result := (pan <> nil); + if result then + begin + if ((pan.PanelType and PANEL_LIFTUP) <> 0) then + begin + if (velY > -4-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_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; + end; + // awake + if result and (state = TPartState.Sleeping) then state := TPartState.Normal; + end; +end; + + // switch to sleep mode procedure TParticle.sleep (); inline; begin - state := TPartState.Sleeping; - freeze(); + if not checkAirStreams() then + begin + state := TPartState.Sleeping; + freeze(); + end; end; @@ -383,41 +424,6 @@ procedure TParticle.thinkerBloodAndWater (); if result then begin velY := 0.5; accelY := 0.15; end; end; - // `true`: affected by air stream - function checkAirStreams (): Boolean; - var - pan: TPanel; - begin - pan := g_Map_PanelAtPoint(x, y, GridTagLift); - result := (pan <> nil); - if result then - begin - if ((pan.PanelType and PANEL_LIFTUP) <> 0) then - begin - if (velY > -4-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_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; - end; - // awake - if result and (state = TPartState.Sleeping) then state := TPartState.Normal; - end; - end; - // switch to freefall mode procedure freefall (); begin @@ -453,8 +459,8 @@ begin if gAdvBlood then begin - // still check for air streams when sleeping - if (state = TPartState.Sleeping) then begin checkAirStreams(); goto _done; end; // so blood will dissolve + // still check for air streams when sleeping (no) + if (state = TPartState.Sleeping) then begin {checkAirStreams();} goto _done; end; // so blood will dissolve // process stuck particles if (state = TPartState.Stuck) then @@ -525,6 +531,8 @@ begin dX := round(velX); dY := round(velY); + if (state = TPartState.Normal) then checkAirStreams(); + // gravity, if not stuck if (state <> TPartState.Stuck) and (abs(velX) < 0.1) and (abs(velY) < 0.1) then begin @@ -849,19 +857,19 @@ begin // check for level bounds 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)); - if (pan <> nil) then + // this hack will allow water spawned in water to fly out + // it can happen when player fell from a huge height (see "DOOM2D.WAD:\MAP03", for example) + if (fVelY >= 0) then begin - // either in a wall, or in a liquid - //if ((pan.tag and GridTagObstacle) <> 0) then continue; // don't spawn in walls - //env := TEnvType.ELiquid; - continue; + // in what environment we are starting in? + pan := g_Map_PanelAtPoint(x, y, (GridTagObstacle or GridTagLiquid)); end else begin - env := TEnvType.EAir; + pan := g_Map_PanelAtPoint(x, y, GridTagObstacle); end; + if (pan <> nil) then continue; + env := TEnvType.EAir; // color case color of @@ -1059,12 +1067,13 @@ begin if (dX <> 0) then begin // has some horizontal velocity - pan := g_Map_traceToNearest(x, y, x+dX, y+dY, GridTagObstacle, @ex, @ey); + pan := g_Map_traceToNearest(x, y, x+dX, y+dY, (GridTagObstacle or GridTagLiquid), @ex, @ey); if (x <> ex) then begin floorY := Unknown; ceilingY := Unknown; end; // dunno yet x := ex; y := ey; if (pan <> nil) then begin + if ((pan.tag and GridTagLiquid) <> 0) then begin die(); exit; end; // die in liquid // hit the wall; falling down vertically velX := 0; accelX := 0;