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       

[Tutorial] Tweaking the deaf floor code
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: Mon Dec 05, 2011 1:26 pm
   Subject: [Tutorial] Tweaking the deaf floor code
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

In another thread, I pointed out a limitation of the wolf3d engine in how deaf floor codes can be placed on a map.

If you have a narrow channel with consecutive deaf floor codes, the ones behind the front one may not get converted, resulting in dummy guards that won't react until you knife or shoot them. This depends on the orientaion:



Coming from the west, only the easternmost guard will react and shoot when the player passes the channel. The rest will stay still until you shoot them, one at a time. From the east side, all will react and start shooting. This is due to the order in which the tiles are examined for guard spawning and tile conversion: top to bottom, left to right. Those leftmost spots on the west side never see adjacent "normal" floorcodes to covert to. In my testing, channels coming from the north also have the bug, and those from the south are ok.

This is the code that converts the deaf floor tiles (aka ambush markers) to a normal floor code (from SpawnStand in WL_ACT2.CPP):

::: CODE :::
    map = mapsegs[0]+(tiley<<mapshift)+tilex;
    tile = *map;
    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;

The four ifs look at adjacent tiles: east, north, south, and west, respectively. Frankly, it's not necessary to always look at all four adjacent tiles; one successful find, and you should stop looking, so I would change the last 3 ifs to else ifs.

To allow a three-deep line of deaf guards, this code would do the trick:

::: CODE :::
    map = mapsegs[0]+(tiley<<mapshift)+tilex;
    tile = *map;
    if (tile == AMBUSHTILE)
    {
        tilemap[tilex][tiley] = 0;

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

        *map = tile;

The last four else ifs are:

Look 2 tiles east, look 3 tiles east, look 2 tiles south, look 3 tiles south, respectively.

I don't consider this a valid fix for the wolf3d engine, but rather a quick and dirty customization for a particular mapping situation. I think it should work in the DOS version too.


Andy
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 23 Sep 2018

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

PostPosted: Mon Dec 05, 2011 3:37 pm
   Subject: Re: [Tutorial] Tweaking the deaf floor code
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I suppose you could also just create 48 new objects for Standing Deaf Guards (4 directions * 3 skills * 4 enemy types) which automatically get assigned the FL_AMBUSH flag, and then you could get rid of the deaf floorcode altogether. The way you have it, I think it could be possible (though unlikely) for a deaf guard to grab a different floorcode from an adjacent room, where they still wouldn't work correctly. I noticed that your code only looks 3 tiles away also, whereas your guards are in rows of 3-7.

(yes, I know... this is just a cheap hack - lol. It's cool that you're playing around with this though...)
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 2:38 ago.

Topics: 164
Posts: 8229
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Mon Dec 05, 2011 6:29 pm
   Subject: Re: [Tutorial] Tweaking the deaf floor code
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I'd been thinking about a solution to the problem myself. My plan was to give the tiles a "second go-round", approaching the Deaf guards from the south and east to find the correct floorcode.

If I'm not mistaken, the Wolf4SDL Deaf Guard code has another problem: If a Deaf guard is placed next to another Deaf guard, and it's one particular tight spot, he'll actually have a *wall* assigned to the square he's on! What?
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: Tue Dec 06, 2011 11:02 am
   Subject: Re: [Tutorial] Tweaking the deaf floor code
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Chris wrote:
The way you have it, I think it could be possible (though unlikely) for a deaf guard to grab a different floorcode from an adjacent room, where they still wouldn't work correctly.

Heh, actually it's quite likely, and I ran into that problem almost immediately. All you need is another room right next to the channel.

To prevent that, I would only venture beyond an adjacent tile if it's an ambush tile:

::: CODE :::
    map = mapsegs[0]+(tiley<<mapshift)+tilex;
    tile = *map;
    if (tile == AMBUSHTILE)
    {
        tilemap[tilex][tiley] = 0;

        if (*(map+1) >= AREATILE)
            tile = *(map+1);
        else if (*(map-mapwidth) >= AREATILE)
            tile = *(map-mapwidth);
        else if (*(map+mapwidth) >= AREATILE)
            tile = *(map+mapwidth);
        else if ( *(map-1) >= AREATILE)
            tile = *(map-1);
        else if ((*(map+1)==AMBUSHTILE) && (*(map+2) >= AREATILE))
            tile = *(map+2);
        else if (
(*(map+2)==AMBUSHTILE) && (*(map+3) >= AREATILE))
            tile = *(map+3);
        else if (
(*(map+mapwidth)==AMBUSHTILE) && (*(map+mapwidth*2) >= AREATILE))
            tile = *(map+mapwidth*2);
        else if (
(*(map+mapwidth*2)==AMBUSHTILE) && (*(map+mapwidth*3) >= AREATILE))
            tile = *(map+mapwidth*3);

        *map = tile;



Tricob wrote:
I'd been thinking about a solution to the problem myself. My plan was to give the tiles a "second go-round", approaching the Deaf guards from the south and east to find the correct floorcode.

That was my first instinct too, but I found out that the WL_GAME.CPP stuff doesn't seem to do anything. Perhaps it's just to catch the ambush tiles without actors on them? Anyway, the "working" code is part of the actor spawning process in WL_ACT2.CPP, which I assume could only be run once.

Tricob wrote:
If I'm not mistaken, the Wolf4SDL Deaf Guard code has another problem: If a Deaf guard is placed next to another Deaf guard, and it's one particular tight spot, he'll actually have a *wall* assigned to the square he's on! What?

I haven't experienced that - the guard just becomes a zombie.
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 2:38 ago.

Topics: 164
Posts: 8229
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Tue Dec 06, 2011 3:20 pm
   Subject: Re: [Tutorial] Tweaking the deaf floor code
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Andy_Nonymous wrote:
Tricob wrote:
I'd been thinking about a solution to the problem myself. My plan was to give the tiles a "second go-round", approaching the Deaf guards from the south and east to find the correct floorcode.

That was my first instinct too, but I found out that the WL_GAME.CPP stuff doesn't seem to do anything. Perhaps it's just to catch the ambush tiles without actors on them? Anyway, the "working" code is part of the actor spawning process in WL_ACT2.CPP, which I assume could only be run once.
If you install my MapSquareChange routine, you probably won't have that kind of problem anymore. I wish I'd had such a routine years back! Smile
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 23 Sep 2018

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

PostPosted: Mon Sep 02, 2013 3:07 pm
   Subject: Re: [Tutorial] Tweaking the deaf floor code
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

Tricob's approach works for me (for your map image). Here's what I added in SetupGameLevel() of wl_game.cpp:

::: CODE :::
//
// 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;

                if ( ISPOINTER(actorat[x][y]) )
                    actorat[x][y]->areanumber = tile-AREATILE;

            }
        }
    }

    // second backwards pass (for some user maps)

    for (y=mapheight-2;y>0;y--)
    {
        for (x=mapwidth-2;x>0;x--)
        {
            tile = MAPSPOT(x,y,0);

            if (tile == AMBUSHTILE)
            {
                if (MAPSPOT(x+1,y,0) >= AREATILE)
                    tile = MAPSPOT(x+1,y,0);
                else if (MAPSPOT(x,y-1,0) >= AREATILE)
                    tile = MAPSPOT(x,y-1,0);
                else if (MAPSPOT(x,y+1,0) >= AREATILE)
                    tile = MAPSPOT(x,y+1,0);
                else if (MAPSPOT(x-1,y,0) >= AREATILE)
                    tile = MAPSPOT(x-1,y,0);

                MAPSPOT(x,y,0) = tile;

                if ( ISPOINTER(actorat[x][y]) )
                    actorat[x][y]->areanumber = tile-AREATILE;
            }
        }
    }

This is for SDL and can probably be optimized though. Can you find a map that breaks it? 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 9605 Sun Jan 10, 2010 12:26 pm
Fragstein3D View latest post
No new posts [Info] Black & White Effect - Tutorial
Author: Guest
10 297 Thu Mar 17, 2005 6:24 pm
Dugtrio17 View latest post
No new posts [Info] Tricks - Dogs that shoot - Modifying Behaviour
Author: Guest
19 288 Sat Mar 20, 2004 7:31 am
Dugtrio17 View latest post
This topic is locked: you cannot edit posts or make replies. [Info] Source code for Darkone's NewWolf Classic
Author: Raistlin
1 1784 Tue Feb 10, 2004 10:18 am
BrotherTank View latest post
No new posts [Info] Making Guards Always Face You - Rotating guards
Author: CoolMario
3 88 Wed Jul 30, 2003 9:31 am
Codetech84 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