DieHard Wolfers Forum Index DieHard Wolfers
A Wolfenstein 3d Fan Community


  Hosted by: MCS & Areyep.com - Designed by: BrotherTank

Original Yahoo Forum - Die Hard Archives

AReyeP HomepageAreyep Homepage DieHard Wolfenstein BunkerDieHard Wolfenstein Bunker Log inLog in RegisterRegister Banlist FAQFAQ Search ForumsSearch

  Username:    Password:      Remember me       

[Help] Deaf floor mechanism details needed
Page 1 of 1
DieHard Wolfers Forum Index -> Code Crackers View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page BottomView Next Topic
Post new topicReply to topic
Author Message
Andy_Nonymous
Moderator
<B>Moderator</B>


Joined: 02 Apr 2003
Last Visit: 17 Feb 2015

Topics: 99
Posts: 589
Location: New Jersey, USA
usa.gif

PostPosted: Sun Nov 27, 2011 7:12 am
   Subject: [Help] Deaf floor mechanism details needed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

In the SpawnStand function, there is a piece of code that checks if the spawned guard is on an AMBUSHTILE, and if so, assigns the FL_AMBUSH flag to him, making him "deaf".
Before that (in red) is some code that checks all the adjacent tiles, and if they are floors (ie. not walls or doors), does something to them.

- what is that code doing?
- why?
- what happens if it is left out?
- does this code cause the "deaf floor next to door" bug? (aka invisible barrier effect)

::: CODE :::
    if (tile == AMBUSHTILE)
    {
        tilemap[tilex][tiley] = 0;

        if (*(map+1) >= AREATILE)
            tile = *(map+1);
        if (*(map-mapwidth) >= AREATILE)
            tile = *(map-mapwidth);
        if (*(map+mapwidth) >= AREATILE)
            tile = *(map+mapwidth);
        if ( *(map-1) >= AREATILE)
            tile = *(map-1);

        *map = tile;
        newobj->areanumber = tile-AREATILE;

        newobj->flags |= FL_AMBUSH;
    }

Any light you can shed on this would be appreciated .. the more detailed, the better! Smile

Thanks,
Andy
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 13 Jan 2018

Topics: 55
Posts: 2118
Location: Canada
blank.gif

PostPosted: Sun Nov 27, 2011 12:06 pm
   Subject: Re: [Help] Deaf floor mechanism details needed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

When it assigns the FL_AMBUSH tag to the guard, it changes the deaf floorcode to a floorcode beside it (searching all directions left, right, up, and down for a floorcode tile to replace it with). This is so that if the player lands on that floorcode when a door is opening/closing (or stands on it while a guard is shooting them), they will still be in the correct "floorcode" area.

Try to imagine running through the map, with the floorcodes. When you open a door to a new "floorcode" area, all floors (even ones where the deaf guards are) will be the same floorcode, because of this code. Hope that makes more sense.

By the way, there's also a version of that red code at the bottom of SetupGameLevel() (which I'm guessing is there as an extra check for if you have a deaf floorcode without a guard on it - ie. You're on skill 1 and the deaf guard is skill 4 only).
Andy_Nonymous
Moderator
<B>Moderator</B>


Joined: 02 Apr 2003
Last Visit: 17 Feb 2015

Topics: 99
Posts: 589
Location: New Jersey, USA
usa.gif

PostPosted: Sun Nov 27, 2011 3:42 pm
   Subject: [Help] Deaf floor mechanism details needed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Chris,

OK, so once the spawned guards are flagged with FL_AMBUSH, the deaf floor code is not needed anymore and gets changed back to its surrounding/adjacent floor code. Otherwise the odd floor code causes "continuity" problems. I can now see what's happenin' Cool

Thanks again,
Andy
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 13 Jan 2018

Topics: 55
Posts: 2118
Location: Canada
blank.gif

PostPosted: Sun Nov 27, 2011 4:57 pm
   Subject: Re: [Help] Deaf floor mechanism details needed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Yup. Also, like the deaf floorcodes - once a DOOR get spawned, it gets it's floorcode changed to its surrounding/adjacent floor code too (in case you're standing in an open door with the scenarios mentioned above) Smile inside SpawnDoor():

::: CODE :::
    if (vertical)
    {
        *map = *(map-1);
                        // set area number
        tilemap[tilex][tiley-1] |= 0x40;
        tilemap[tilex][tiley+1] |= 0x40;
    }
    else
    {
        *map = *(map-mapwidth);
                                 // set area number
        tilemap[tilex-1][tiley] |= 0x40;
        tilemap[tilex+1][tiley] |= 0x40;
    }

So... if your door is beside a deaf floorcode, it gets assigned the deaf floorcode.
Then... if you look at your red code above, you'll see that the "ambush tile" clears the tilemap to 0 (no tile).

::: CODE :::
    if (tile == AMBUSHTILE)
    {
        tilemap[tilex][tiley] = 0;

...

Making our deaf door an invisible barrier, or "half-functional door" (as some behavior like the drawing routines and space bar are linked to the tilemap, while others like actor movements and some door reference numbers are linked to the actorat).


Last edited by Chris on Sun Nov 27, 2011 8:45 pm; edited 1 time in total
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 0:59 ago.

Topics: 161
Posts: 8030
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Sun Nov 27, 2011 8:45 pm
   Subject: Re: [Help] Deaf floor mechanism details needed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I don't know how it would react in Wolf3D 16-bit, but I wonder what would happen if the Ambush markers were taken out *before* the doors were spawned? Would this make all the doors bug-free? I wonder ... Neutral
Andy_Nonymous
Moderator
<B>Moderator</B>


Joined: 02 Apr 2003
Last Visit: 17 Feb 2015

Topics: 99
Posts: 589
Location: New Jersey, USA
usa.gif

PostPosted: Sun Nov 27, 2011 9:58 pm
   Subject: [Help] Deaf floor mechanism details needed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Be careful you don't remove the markers before the guards spawn! Wink

I have tried the code below in SetupGameLevel (in WL_GAME.CPP) in Mac-enstein and it certainly fixes the invisible door problem. Doesn't look like anything else is broken, but I'll keep testing.

Code in red moved to blue:
::: CODE :::
//
// spawn doors
//
    InitActorList ();                       // start spawning things with a clean slate
    InitDoorList ();
    InitStaticList ();
/*
    map = mapsegs[0];
    for (y=0;y<mapheight;y++)
    {
        for (x=0;x<mapwidth;x++)
        {
            tile = *map++;
            if (tile >= 90 && tile <= 101)
            {
                // door
                switch (tile)
                {
                    case 90:
                    case 92:
                    case 94:
                    case 96:
                    case 98:
                    case 100:
                        SpawnDoor (x,y,1,(tile-90)/2);
                        break;
                    case 91:
                    case 93:
                    case 95:
                    case 97:
                    case 99:
                    case 101:
                        SpawnDoor (x,y,0,(tile-91)/2);
                        break;
                }
            }
        }
    }
*/

//
// spawn actors
//
    ScanInfoPlane ();


//
// take out the ambush markers
//
    map = mapsegs[0];
    for (y=0;y<mapheight;y++)
    {
        for (x=0;x<mapwidth;x++)
        {
            tile = *map++;
            if (tile == AMBUSHTILE)
            {
                tilemap[x][y] = 0;
                if ( (unsigned)(uintptr_t)actorat[x][y] == AMBUSHTILE)
                    actorat[x][y] = NULL;

                if (*map >= AREATILE)
                    tile = *map;
                if (*(map-1-mapwidth) >= AREATILE)
                    tile = *(map-1-mapwidth);
                if (*(map-1+mapwidth) >= AREATILE)
                    tile = *(map-1+mapwidth);
                if ( *(map-2) >= AREATILE)
                    tile = *(map-2);

                *(map-1) = tile;
            }
        }
    }

// MAC6 132: moved door spawning after AMBUSH marker removal to fix invisible barrier bug

    map = mapsegs[0];
    for (y=0;y<mapheight;y++)
    {
        for (x=0;x<mapwidth;x++)
        {
            tile = *map++;
            if (tile >= 90 && tile <= 101)
            {
                // door
                switch (tile)
                {
                    case 90:
                    case 92:
                    case 94:
                    case 96:
                    case 98:
                    case 100:
                        SpawnDoor (x,y,1,(tile-90)/2);
                        break;
                    case 91:
                    case 93:
                    case 95:
                    case 97:
                    case 99:
                    case 101:
                        SpawnDoor (x,y,0,(tile-91)/2);
                        break;
                }
            }
        }
    }


//
// have the caching manager load and purge stuff to make sure all marks
// are in memory
//
    CA_LoadAllSounds ();
}

I also noticed that only the deaf guard floors placed north and west of doors had caused the bug; deaf guard codes south and east of doors had no effect.
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 0:59 ago.

Topics: 161
Posts: 8030
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Sun Nov 27, 2011 11:49 pm
   Subject: Re: [Help] Deaf floor mechanism details needed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Actually, it was the "take out the ambush markers" routine I would've relocated. And yes, I definitely had planned to spawn the guards before removing the Ambush markers. Smile
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 13 Jan 2018

Topics: 55
Posts: 2118
Location: Canada
blank.gif

PostPosted: Mon Nov 28, 2011 3:53 pm
   Subject: Re: [Help] Deaf floor mechanism details needed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

@Tricob: Well... there's two of them (the main one is in SpawnStand), as mentioned above.

I think the way Andy did it (moving the doors below the spawn actors and extra ambush check) makes the most sense. I don't see any issues with it from briefly skimming through the sequence of all the related code yet.
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 0:59 ago.

Topics: 161
Posts: 8030
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Mon Nov 28, 2011 4:04 pm
   Subject: Re: [Help] Deaf floor mechanism details needed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Chris wrote:
@Tricob: Well... there's two of them, as mentioned above.
Not that I can tell; in WL_ACT2.CPP, the variable "tile" is given a valid floor number, which is then used by the "deaf" guard. The ambush markers in the map remain until all the guards in the map are spawned in WL_GAME. Am I misreading something? Confused
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 13 Jan 2018

Topics: 55
Posts: 2118
Location: Canada
blank.gif

PostPosted: Mon Nov 28, 2011 7:22 pm
   Subject: Re: [Help] Deaf floor mechanism details needed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Tricob wrote:
Am I misreading something? Confused

Yes. The phrase you quoted "take out the ambush markers" (which I'm assuming you took from the code in Andy's last post), is not from WL_ACT2.CPP - it's from the SetupGameLevel() function of WL_GAME (as mentioned in his 2nd paragraph, and it's existence as a separate entity from the WL_ACT2.CPP code was already mentioned in the 3rd paragraph of my first post).

"as mentioned above" Wink
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 0:59 ago.

Topics: 161
Posts: 8030
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Tue Nov 29, 2011 4:05 pm
   Subject: Re: [Help] Deaf floor mechanism details needed
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

Looking back as it, that's one of a *lot* of things I either missed or misread. Embarassed I'll think I'll go back to working on Spacebar-related code for a bit. Smile
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> Code Crackers View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page TopView Next Topic
Page 1 of 1
Jump to:  

Related topics
 Topics   Replies   Views   Last Post 
No new posts Sticky: [Info] Help for newbie coders! C++ Tutorial
Author: Dugtrio17
20 7997 Sun Jan 10, 2010 12:26 pm
Fragstein3D View latest post
No new posts [Info] Black & White Effect - Tutorial
Author: Guest
10 296 Thu Mar 17, 2005 6:24 pm
Dugtrio17 View latest post
No new posts [Help] Setting RocketLauncher: Explosive Range...?
Author: KyleRTCW
17 4461 Thu Jun 03, 2004 3:21 am
Codetech84 View latest post
No new posts [Help] Berserk mode
Author: wolf3dbreaker
2 1733 Tue Feb 03, 2004 11:01 pm
Xarkon View latest post
No new posts [Info] Adding Locked Doors
Author: Guest
3 243 Thu Apr 17, 2003 6:30 am
Ripper View latest post
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
   You cannot delete your posts in this forum
You cannot vote in polls in this forum


Copyright ©2003-2008 DieHard Wolfers
A Modified subBunker Theme by BrotherTank
Powered by phpBB © 2001, 2005 phpBB Group