Jump to content

[41.78.16] [SP/MP] Multiple issues in IsoZombie.spotted


Solution Improbable

Recommended Posts

It seems that the `spotted` method has a few quirks. I found most of these with a decompiler and careful reading, but I've done my best to verify the behaviour in-game. I can't really say if many of these quirks are outright bugs, but they're at least weird enough to raise my eyebrows. Apologies in advance for the verbosity... its hard to be both precise and concise when describing code without referring to the source.
 

I'll refer to the first argument of the method (with type `IsoMovingObject`) as the`player`, and `this` as the`zombie`.
 

1.  Increasing the light level of the player's current square reduces the likelihood of being spotted. There's a scaling factor that is applied which looks like `1 - (playerLightLevel - zombieLightLevel^3)`.
 

2.  Separately, there is a scaling factor derived from `RenderSettings.getInstance().getAmbientForPlayer`, which can increase the likelihood of the player being spotted if *they* can see better in the dark. This doesn't do much in normal gameplay since the adjustment for Cat's Eyes is equal to the floor used for the ambient factor (`0.2`), but it does matter if `Night Vision Goggles` are activated (??), or if `bLastStand` is true.
 

3.  Movement speed (`getMovementLastFrame().getLength()`) is used in two places to determine a scaling factor, but I believe the breakpoints used are no longer valid. For example:
 

    -   speed < 0.01 scales spot chance by 0.5
    -   speed < 0.06 scales spot chance by 0.8
    -   speed >= 0.06 scales spot chance by 2.4
 

    Movement is generally either 0, or greater or equal to .5 (walking speed), so the central branch looks like dead code. `getMovementLastFrame()` is correctly normalized for different framerates, so perhaps these breakpoints are from an era when the speed was actually returned per frame.
 

4.  Walls (and other near wall sneak bonus squares) provide the bonus regardless of zombie direction (ie. whether the wall is between the zombie and the player or not). This may be intended behavior, but there seems to be some attempt to use the zombie direction in this section, so I thought I should mention.

5.  Walls are bizarrely asymmetric as to which directions they provide a near wall sneak bonus. Here is some ascii art of the 6 squares around a wall segment ("+" means bonus, "." no bonus, and "X" is the tile with the wall segment, which also receives a bonus).
 

         N

        .+.
        +X+

   
    The same tiles provide a bonus regardless of whether the wall segment is oriented to the north or to the west. In the case of a western facing wall, this means that a player receives the bonus if they stand (visually) two tiles east of the wall, but do not receive it standing less than one tile to the southeast.
 

    AFAICT, this is due to asymmetric handling of the N direction in `checkIsNearWall`: the square north of the player is not checked for a non-solidtrans sneak modifier. Instead, the players current square is checked. I could see this being the start of a valid workaround for the asymmetry in the `collideN/collideW` flags, but it doesn't work. Even if it did, the western direction is completely analogous, and it's not currently being special cased.
 

6.  Less bizarrely, but still worth mentioning, `solidtrans` objects only provide their bonus in the four cardinal directions. This seems like intended behavior, but it's unfortunate that a player cannot sneak around an object without popping in and out of near wall sneak.
 

7.  Vehicles provide a near wall sneak bonus based on `isNearVehicle`. `isNearVehicle` checks if the player is within a fixed-size circle centered on the vehicle model. This circular region ignores vehicle size and orientation. Thankfully, there are no vehicles in vanilla that are large enough for the vehicle model to actually extend outside of the region. However, it does mean that:
 

    -   smaller vehicles are easier to hide behind than larger vehicles;
    -   vehicles have a noticeably smaller sneak area off the front and back than to the sides;
    -   vehicles typically provide a sneak bonus from much farther away than walls and solidtrans objects.
 

I'm happy to provide snippets of psuedocode or disassembled bytecode to clarify.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...