Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Boom sight bug

Recommended Posts

I would be surprised that this would not have been noticed before, but it looks like a bug to me.

I cannot convince myself that is right to add the height of monster t2, to the z position of monster t1, in this sight check.

Can anyone give a convincing argument as why the orig code would be correct.


boolean P_CheckSight( mobj_t* t1, mobj_t* t2 )

    const sector_t * s1p = t1->subsector->sector;
    const sector_t * s2p = t2->subsector->sector;
    int   result;

    // First check for trivial rejection.

    // Determine subsector entries in REJECT table.
    int s1 = (s1p - sectors);
    int s2 = (s2p - sectors);
    unsigned int pnum = s1*numsectors + s2;
    unsigned int bytenum = pnum>>3;
    unsigned int bitnum = 1 << (pnum&7);

    // Check in REJECT table.
    if (rejectmatrix[bytenum]&bitnum)

        // can't possibly be connected
        return false;


    // [WDJ] From PrBoom
    // Uses model and modelsec, instead of the PrBoom heightsec.
    // killough 4/19/98: make fake floors and ceilings block monster view
    if( s1p->model > SM_fluid )
        s1p = &sectors[s1p->modelsec];
        if( (t1->z + t1->height <= s1p->floorheight
             && t2->z >= s1p->floorheight )
           || (t1->z >= s1p->ceilingheight
               // [WDJ] entire t2 is below ceiling
               && t2->z + t2->height <= s1p->ceilingheight) )
               // PrBoom orig        
               && t2->z + t1->height <= s1p->ceilingheight) )
            return false;
    if( s2p->model > SM_fluid )
        s2p = &sectors[s2p->modelsec];

        if( (t2->z + t2->height <= s2p->floorheight
             && t1->z >= s2p->floorheight )
           || (t2->z >= s2p->ceilingheight
           // [WDJ] entire t1 is below ceiling
               && t1->z + t1->height <= s2p->ceilingheight) )
               // PrBoom orig        
               && t1->z + t2->height <= s2p->ceilingheight) )
            return false;


    // [WDJ] MBF, From MBF, PrBoom.
    // killough 11/98: shortcut for melee situations.
    // same subsector? obviously visible
    // cph - compatibility optioned for demo sync, cf HR06-UV.LMP
    if( EN_mbf && (t1->subsector == t2->subsector) )
        return true;

    // An unobstructed LOS is possible.
    // Now look from eyes of t1 to any part of t2.


    cs_startz = t1->z + t1->height - (t1->height>>2);  // eyes at 3/4
    // Slope is (height / horz.), where horz. is measured such that the
    // the distance from eyes to target = 1.  Slope here is (height/1).
    see_bottomslope = t2->z - cs_startz;           // feet of target
    see_topslope = see_bottomslope + t2->height;   // head of target

    cs_trace.x = t1->x;
    cs_trace.y = t1->y;
    cs_t2x = t2->x;
    cs_t2y = t2->y;
    cs_trace.dx = t2->x - t1->x;
    cs_trace.dy = t2->y - t1->y;
    cs_t2_subsector = t2->subsector;  // location of t2
    // Setup for 3dfloor sight tests
    prev_frac = 0;

    // the head node is the last node output
    return   P_CrossBSPNode (numnodes-1);



Share this post

Link to post

I have created a test wad.




With the latest DoomLegacy code in the SVN (SVN 1396), I can walk the player around without any of the monsters

detecting the player.


I have tested it with eternity-engine 3.40 (which uses the same CheckSight as Boom, PrBoom, etc.) and it fails in

the back room with the spider-demon.


With most of the monsters, the monster height is the same as the player height, so adding the wrong height

in the calculation does not make a difference.  When you make the monster a spider-demon, it makes a difference.


Please try this wad out.  You should be able to walk around most rooms without being seen by any monsters.

Each room has a way to expose the player, and verify that the monsters can actually see.


Sight tests where the player is under the slime (monsters above the slime) are to the right.

Walk down into the slime and turn the corner.

To be seen, step the player up onto the small pad near the wall, the top of your head will barely stick out.


Sight tests where the monster is under the slime are directly to the left.

The monsters are in the slime and cannot see you, until you step in the slime.


To the left, through the smallish opening, are the ceiling test rooms.


In the right ceiling-room, a spider-demon waits on a platform below the ceiling.

Go up the stairs and turn right again to get the player over the ceiling.

Do not step past the post, as there are stairs there leading down to the spider-demon.

You will be seen when stepping down into the green ceiling (you cannot see the steps because of the way deep water works, sorry).


In the left ceiling-room, a spider-demon waits on a platform above the ceiling.

Stay at the low level and just turn left, to stay under the ceiling.

If you go up the stairs, and turn left, you will be over the ceiling with the left-room spider-demon (which can then see you).



Edited by wesleyjohnson : clarify

Share this post

Link to post

Put it in a zip file and drag it onto the "Drag files here to attach" bar at the bottom of the text field (or browse for it manually).

Share this post

Link to post

Thanks, bonnie.  I did not notice that, perfect.  (I have edited the previous post).

Thanks, drfrag.  Fileconvy is the one I used before.  But since the system upgrade, I have lost all my bookmarks.

I was just about to get a box account, just to publish files for these forums.



Share this post

Link to post

Off-topic here: I can't help but notice that your typing style is kind of hard to read (Not sure if anyone has said this before.). Any explanation why? Or is it just a habit?

Share this post

Link to post

Probably damage due to years of writing reports for Defense Department contracts.


Or it could be that I write like I am coding a program.  You have to see the curly brackets....


Could be because I have been studying German, and Japanese.  They like to, at the end of the sentence, the verb, to put.




Edited by wesleyjohnson

Share this post

Link to post

Yep, looks like a cut/paste/modify bug, like P_DivlineSide.

Share this post

Link to post

Usually, by now, something like this would have attracted lots of attention by now.

I know KB1 is still alive.  What is going on, did a bunch of forum regulars and port maintainers die off or retire or something ?

Share this post

Link to post

I don't understand everything in the code. Can you please explain what I, as a mapper, should do to avoid this bug?

Share this post

Link to post

Well, first, I was trying to get someone else to verify that I am not seeing things.


Explanation for a mapper:

The sight code should not let a monster see a player that is on the other side of the deep water surface.  So a monster on the shore should not see a player under the water (or slime).

Likewise, a monster under the slime should not see a player on the shore.

This same logic applies to other uses of deep-water linedef where there is no part of the player in the same deep-water section as the monster, where the sections are

(above the ceiling, between ceiling and floor, and below the floor).

The code for doing this is in the CheckSIght function and does work, except for two mistakes.

 In some of the checks they are adding the wrong height.  Now, most of the monsters are the same height as the player, so effectively, for most monsters nothing bad will happen.

If the monster is big, like a spider demon, it makes a difference.  The sight check is going to determine whether the player's head sticks up into the ceiling area.

In doing this it adds the spider demon height to the player foot position, instead of the player height, thus calculating a player head position that is much too high.

Thus a spider demon over the ceiling will see a player below the ceiling, that it should not be able to see.


To avoid this bug, when you have a spider demon (or any other tall monster) over the ceiling, and the player is below the ceiling, you can lower the floor the player is on, using the spider demon height as a guide instead of the player height.

Not many maps have this situation, especially with something big such as a spider demon.  Probably explains why nobody noticed this before.


Check out the wad, walk around.  You will learn that the back room with the spider demon over the ceiling is where it fails.


It also fails in the reverse test, but that test makes the monster too short, so it does not have as much effect.


If you use DEH to make other tall monsters, then they will have the same problem.


If you use DEH to make monsters that are shorter than the player, then if they are placed over the ceiling, they will not see the player even when his head sticks into the ceiling area.  Flaming skulls should have that problem too.




Share this post

Link to post

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