[SUG][SKILL - SWIMMER] Exit transition from ceiling water

Started by WillLem, November 04, 2020, 07:20:07 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

IchoTolot

QuoteAs I pointed out earlier, the weird behaviour occurs with any water, not just upside-down water.

QuoteAs Proxima said, this isn't really about "upside-down water" either (although that is, admittedly, the situation where this physics bug is most likely to be noticed). The behaviour occurs in any water trigger area, whether upside-down or not.

Upside-down water = water. For the game there is no difference as only the trigger area matters.

So it doesn't really matter what description I use here, it's only as WillLem stated the most obvious case where this comes into play.

QuoteIt's not about the lem stepping out, it's more that I think the lem should fall out. At the moment it's as if some invisible force field is stopping the lem from falling out of the bottom of the water trigger.

I think you missed the point of my assumption then. In order to fall out the lemming needs to step outside the water's trigger area first. So it's no invisible force field in that situation, but rather his inability to step downwards outside of the trigger area as lems cannot step downwards.

QuoteIf this is fixed, it will make the Swimmer a far more useful skill.

So a behavior that went unnoticed/unused for several years shall elevate the swimmer skill to new heights. I highly doubt that! It's still one VERY niche situation. :8():


But again, I tend towards a change though when this can be fixed with a few special "exit water from the bottom" (maybe this sounds better ;)) checks if these don't affect other behaviors.

Otherwise I think it's just not worth the trouble. :P


WillLem

Quote from: IchoTolot on December 10, 2020, 02:55:05 PM
Upside-down water = water. For the game there is no difference as only the trigger area matters.

I know; that's what I'm saying as well. We don't disagree here! :D

Quote from: IchoTolot on December 10, 2020, 02:55:05 PM
it's no invisible force field in that situation, but rather his inability to step downwards outside of the trigger area as lems cannot step downwards.

As I said, it's not so much that the lem should step out, it's more that the lem should fall out.

Quote from: IchoTolot on December 10, 2020, 02:55:05 PM
I tend towards a change though when this can be fixed with a few special "exit water from the bottom" (maybe this sounds better ;)) checks if these don't affect other behaviors.

Please can you explain what you mean here. It sounds like a good idea, but I just want to make sure I understand :lemcat:

IchoTolot

QuoteAs I said, it's not so much that the lem should step out, it's more that the lem should fall out.

Yes, yes, again I know exactly what you mean. But it seems like the current physics implementation needs the lemming to step out first and therefore he will not transition to a faller as he can't step out at the bottom. That's what I'm trying to explain about my suspicion about the current physics.

I am not trying to state what should happen there. I am trying to analyse and state my take on what is currently happen physics wise.

QuotePlease can you explain what you mean here. It sounds like a good idea, but I just want to make sure I understand

I cannot do that. Here will be the part namida needs to state what's the exact situation.

Again, all that I'm doing is trying to analyse what is happening here, why it happens and state my opinion how it could be handled. ---> Point 1.) and 2.) in my first post here.

As I just "guessed" the inner workings here I have no input if this is possible and how exactly the check needs to be.

It will probably be something like: "if a downwards ramp is before me and the water area ends under my position I move further downwards instead of forward into the wall". But again how the exact checks need to be is not in my grasp.


namida

Looking at the code, it appears that the check for "does the wall continue" and "does the water end" is lumped into a single check, presumably intended for cases where a wall continues beyond the bottom of the water. So I would say this is indeed a bug.

However, this is Nepster's code, so I don't know if this check is meant to avoid some other bug situation or if it's just an oversight...
My projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)
Non-Lemmings: Commander Keen: Galaxy Reimagined (a Commander Keen fangame)

namida

Swimmer code as it currently stands. I have bolded the line I suspect is responsible for this.

IchoTolot has dug up an old related topic by Nepster, which leads me to think this might actually have been an intentional design decision (though this is based only on reading the topic - I cbf digging out an old NL version to examine the level).

Spoiler
function TLemmingGame.HandleSwimming(L: TLemming): Boolean;
var
  LemDy: Integer;

  function LemDive(L: TLemming): Integer;
    // Returns 0 if the lem may not dive down
    // Otherwise return the amount of pixels the lem dives
  var
    DiveDepth: Integer;
  begin
    if L.LemIsClimber then DiveDepth := 3
    else DiveDepth := 4;

    Result := 1;
    while HasPixelAt(L.LemX, L.LemY + Result) and (Result <= DiveDepth) do
    begin
      Inc(Result);
      if L.LemY + Result >= PhysicsMap.Height then Result := DiveDepth + 1; // End while loop!
    end;

    // do not dive, when there is no more water
    if not HasTriggerAt(L.LemX, L.LemY + Result, trWater) then Result := 0;


    if Result > DiveDepth then Result := 0; // too much terrain to dive
  end;

begin
  Result := True;

  Inc(L.LemX, L.LemDx);

  if HasTriggerAt(L.LemX, L.LemY, trWater) or HasPixelAt(L.LemX, L.LemY) then
  begin
    LemDy := FindGroundPixel(L.LemX, L.LemY);

    // Rise if there is water above the lemming
    if (LemDy >= -1) and HasTriggerAt(L.LemX, L.LemY -1, trWater)
                     and not HasPixelAt(L.LemX, L.LemY - 1) then
      Dec(L.LemY)

    else if LemDy < -6 then
    begin
      if LemDive(L) > 0 then
        Inc(L.LemY, LemDive(L)) // Dive below the terrain
      // Only transition to climber, if the lemming is not under water
      else if L.LemIsClimber and not HasTriggerAt(L.LemX, L.LemY - 1, trWater) then
        Transition(L, baClimbing)
      else
      begin
        TurnAround(L);
        Inc(L.LemX, L.LemDx); // Move lemming back
      end
    end

    else if LemDy <= -3 then
    begin
      Transition(L, baAscending);
      Dec(L.LemY, 2);
    end

    // see http://www.lemmingsforums.net/index.php?topic=3380.0
    // And the swimmer should not yet stop if the water and terrain overlaps
    else if (LemDy <= -1)
         or ((LemDy = 0) and not HasTriggerAt(L.LemX, L.LemY, trWater)) then
    begin
      Transition(L, baWalking);
      Inc(L.LemY, LemDy);
    end;
  end

  else // if no water or terrain on current position
  begin
    LemDy := FindGroundPixel(L.LemX, L.LemY);
    If LemDy > 1 then
    begin
      Inc(L.LemY);
      Transition(L, baFalling);
    end
    else // if LemDy = 0 or 1
    begin
      Inc(L.LemY, LemDy);
      Transition(L, baWalking);
    end;
  end;

end;
My projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)
Non-Lemmings: Commander Keen: Galaxy Reimagined (a Commander Keen fangame)

WillLem

So... what's the ruling on this?

My thoughts, simplified as much as possible:

1) The Swimmer is a very under-powered Skill as it stands. The ability to exit water from underneath would double its possible use-cases (no, a Shimmier is not comparable because a Shimmier can only exit terrain from underneath; whereas if what I'm proposing gets passed, Swimmers will be able to exit the water in both directions).

2) It would make physical sense. Water is a soft obstacle, and if the body of water were in a zero-gravity environment, things would be able to exit it from any direction.

Swimmers need a good boost. If you pass this one, I promise I'll never mention Splat/Anti-Splat Fields again! ;P

namida

My thought is basically that I would like to make the change, but I need to be confident that nothing is going to break as a side effect. For this, I need to spend some time reviewing the code to firstly understand why it's written the way it is, and secondly see if/how I can adjust it to have logical behavior in this situation, without undesirable side effects.

To be clear, by "nothing is going to break", I am primarily thinking in the sense of "will it introduce other bugs". Although if there are levels that would be broken by this, that is absolutely a factor to take into account too.
My projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)
Non-Lemmings: Commander Keen: Galaxy Reimagined (a Commander Keen fangame)

namida

Implemented the suggested behavior in commit c552b4c.
My projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)
Non-Lemmings: Commander Keen: Galaxy Reimagined (a Commander Keen fangame)