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] Vanishing Dogs Bug Fix
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
WSJ
DieHard Officer
DieHard Officer


Joined: 17 Apr 2004
Last Visit: 08 May 2017

Topics: 24
Posts: 521

blank.gif

PostPosted: Mon Jun 13, 2005 9:27 pm
   Subject: [Tutorial] Vanishing Dogs Bug Fix
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

There is a bug in the original Wolfenstein code which will sometimes cause Dogs and Fake Hitlers to "disappear" when they go through an open door. This fix will solve it...

Open WL_ACT2.C, and go down to the "T_DogChase" function. Add the lines marked in red:

::: CODE :::

void T_DogChase (objtype *ob)
{
   long    move;
   int      dist,chance;
   long   dx,dy;


   if (ob->dir == nodir)
   {
      SelectDodgeDir (ob);
      if (ob->dir == nodir)
         return;                     // object is blocked in
   }

   move = ob->speed*tics;

   while (move)
   {
   //
   // check for byte range
   //
      dx = player->x - ob->x;
      if (dx<0)
         dx = -dx;
      dx -= move;
      if (dx <= MINACTORDIST)
      {
         dy = player->y - ob->y;
         if (dy<0)
            dy = -dy;
         dy -= move;
         if (dy <= MINACTORDIST)
         {
            NewState (ob,&s_dogjump1);
            return;
         }
      }

      if (ob->distance < 0)
      {
      //
      // waiting for a door to open
      //
         if (doorobjlist[-ob->distance-1].action != dr_open)
            return;
         ob->distance = TILEGLOBAL;   // go ahead, the door is now opoen
      }

      if (move < ob->distance)
      {
         MoveObj (ob,move);
         break;
      }
   
   ( ... )


That should make the Dogs not disappear when they run through a door.

For Fake Hitlers, go to the "T_Fake" function and again add the lines in red:

::: CODE :::

void T_Fake (objtype *ob)
{
   long move;
   int   dx,dy,dist;
   boolean   dodge;

   if (CheckLine(ob))         // got a shot at player?
   {
      if ( US_RndT() < (tics<<1) )
      {
      //
      // go into attack frame
      //
         NewState (ob,&s_fakeshoot1);
         return;
      }
   }

   if (ob->dir == nodir)
   {
      SelectDodgeDir (ob);
      if (ob->dir == nodir)
         return;                     // object is blocked in
   }

   move = ob->speed*tics;

   while (move)
   {

      if (ob->distance < 0)
      {
      //
      // waiting for a door to open
      //
         if (doorobjlist[-ob->distance-1].action != dr_open)
            return;
         ob->distance = TILEGLOBAL;   // go ahead, the door is now opoen
      }

      if (move < ob->distance)
      {
         MoveObj (ob,move);
         break;
      }

   ( ... )


As you can see, I used the same block of code in both chase routines. This block was used in "T_Chase" and some of the boss chase routines, but it was left out for Dogs and Fake Hitlers. Its main purpose, I believe, was to prevent guards from walking through a door that hadn't fully opened.

I hope this tutorial was helpful.

-WSJ

EDIT: removed an unnecessary line... "OpenDoor (-ob->distance-1);" (no quotes). However, if you decide to give your Dogs the ability to open doors, I think you'll have to add this line right above the "if (doorobjlist[-ob->distance-1].action != dr_open)"


Last edited by WSJ on Tue Jun 14, 2005 7:06 pm; edited 1 time in total
Zombie_Plan
DieHard Wolfer
DieHard Wolfer


Joined: 12 Oct 2004
Last Visit: 07 Jun 2016

Topics: 101
Posts: 1614
Location: A hole in the wall
australia.gif

PostPosted: Tue Jun 14, 2005 2:39 am
   Subject: Re: [Tutorial] Vanishing Dogs Bug Fix
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Good one WSJ, hopefully people will use this. I'm glad to see you're still contributing to the community code-wise.
WSJ
DieHard Officer
DieHard Officer


Joined: 17 Apr 2004
Last Visit: 08 May 2017

Topics: 24
Posts: 521

blank.gif

PostPosted: Tue Jun 14, 2005 5:08 am
   Subject: Re: [Tutorial] Vanishing Dogs Bug Fix
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Yeah, Tricob reminded me about this bug because I had mentioned it in the "ReadThis" manual in Castle Totenkopf. Now that I've figured out how to fix it, I thought it would be good to post this tutorial.
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 17 Nov 2017

Topics: 46
Posts: 2291
Location: USA
usa.gif

PostPosted: Tue Jun 14, 2005 10:16 am
   Subject: Re: [Tutorial] Vanishing Dogs Bug Fix
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Why are the "OpenDoor (-ob->distance-1);" lines there since dogs and fake hitlers can't open doors? I assume that line can be left out, right?

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
Zombie_Plan
DieHard Wolfer
DieHard Wolfer


Joined: 12 Oct 2004
Last Visit: 07 Jun 2016

Topics: 101
Posts: 1614
Location: A hole in the wall
australia.gif

PostPosted: Tue Jun 14, 2005 5:25 pm
   Subject: Re: [Tutorial] Vanishing Dogs Bug Fix
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

You have to remember that WSJ doesn't use dogs that often, and his ghosts are usually flamers or minigunners, so they all need to be able to open doors for him. At least, i think that's wat waz planned...
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 7:41 ago.

Topics: 160
Posts: 7993
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Tue Jun 14, 2005 7:10 pm
   Subject: Re: [Tutorial] Vanishing Dogs Bug Fix
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

A major thanks for the bug fix tutorial, WSJ. I remember having major problems with the Dog-related bug in my own Level 6 of Episode 4, and had to remove the dogs in that room all together. Now I can put 'em back in! Cheesy Grin
WSJ
DieHard Officer
DieHard Officer


Joined: 17 Apr 2004
Last Visit: 08 May 2017

Topics: 24
Posts: 521

blank.gif

PostPosted: Tue Jun 14, 2005 7:14 pm
   Subject: Re: [Tutorial] Vanishing Dogs Bug Fix
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

@Adam: I believe you're right... Embarassed Thanks for pointing that out. You see, I copied and pasted that segment of code from "T_Chase" when I tried to fix the bug. Leaving that line there didn't cause any problems for me, so I guess I overlooked it.

@Deathshead: Yes, that has often been the case in my mods, though I don't think I came up with the bug fix until COTS, which had dogs in it.

@Tricob: You're welcome. Smile

The code has been updated.
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 30 Oct 2017

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

PostPosted: Tue Jun 14, 2005 7:52 pm
   Subject: Re: [Tutorial] Vanishing Dogs Bug Fix
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Interesting WSJ. I was going to impliment this, but apparently I already fixed this bug (without even knowing it). Surprised
After doing some testing, looks like this is the reason: http://diehardwolfers.areyep.com/viewtopic.php?p=34280&#34280

::: CODE :::
//
// follow the walls from there to the right, drawwing as we go
//
         spotvis[player->tilex][player->tiley] = 1;

So, I guess if you want to get rid of a bunch of "detect sprites over player" bugs at once; adding that one line to WL_DRAW.C might be easier. Wink
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 7:41 ago.

Topics: 160
Posts: 7993
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Tue Jun 14, 2005 8:50 pm
   Subject: Re: [Tutorial] Vanishing Dogs Bug Fix
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

It doesn't allow you to kill the dog or move forward, though. That's the whole problem with the "vanishing" in the first place.
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 17 Nov 2017

Topics: 46
Posts: 2291
Location: USA
usa.gif

PostPosted: Tue Jun 14, 2005 9:26 pm
   Subject: Re: [Tutorial] Vanishing Dogs Bug Fix
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

What surprises me is that "if (ob->distance < 0)" should never be true for the dog or fake hitler.
In TryWalk, ob->distance is set to the negative door number (-1 more). The doornum is set in CHECKSIDE, but dogobj and fakeobj never use CHECKSIDE. Strange. Maybe I'm missing something though...

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
Dugtrio17
Code Master
Code Master


Joined: 11 Mar 2003
Last Visit: 03 Oct 2013

Topics: 49
Posts: 903
Location: Seattle
usa.gif

PostPosted: Tue Jun 14, 2005 9:49 pm
   Subject: Re: [Tutorial] Vanishing Dogs Bug Fix
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Chris LIIIIIIIIIIIIVVVEESS... I can die a happy man Smile
Oh, and fine job fixing this annoying bug, WSJ.

_________________
WSJ
DieHard Officer
DieHard Officer


Joined: 17 Apr 2004
Last Visit: 08 May 2017

Topics: 24
Posts: 521

blank.gif

PostPosted: Wed Jun 15, 2005 5:14 am
   Subject: Re: [Tutorial] Vanishing Dogs Bug Fix
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Chris is AL-I-I-I-VE! HE'S AL-I-I-I-VE!! AL-I-I-I-VE!!!

Sorry, I love doing that Frankenstein voice. I remember years back when I was new to coding, I figured out how to create a new enemy for the first time, and I was yelling "It's AL-I-I-I-VE! IT'S AL-I-I-I-VE!!"

Cheesy Grin
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 7:41 ago.

Topics: 160
Posts: 7993
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Wed Jun 15, 2005 6:14 pm
   Subject: Re: [Tutorial] Vanishing Dogs Bug Fix
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Adam Biser wrote:
What surprises me is that "if (ob->distance < 0)" should never be true for the dog or fake hitler.
In TryWalk, ob->distance is set to the negative door number (-1 more). The doornum is set in CHECKSIDE, but dogobj and fakeobj never use CHECKSIDE. Strange. Maybe I'm missing something though...

The door-related code still has some bugs in it that Id never fixed. If you look through the code, you'll see that the code has a "safeguard" to prevent guards from walking through doors if they're not completely open. And yet anyone can walk through a door the instant anyone but the player signals it to open. I'd really like to fix that bug, as it causes the Officers in my Level One of Episode 4 to disappear if you're moving against a door when an Officer signals it to open.

Another "safeguard" that doesn't work: The code checks to see if the maximum length of a recorded demo has been reached, and the demo should end automatically when the maximum length *is* reached. Yet the maximum length can always be exceeded regardless of this so-called "safeguard".
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 17 Nov 2017

Topics: 46
Posts: 2291
Location: USA
usa.gif

PostPosted: Thu Jun 16, 2005 6:49 am
   Subject: Re: [Tutorial] Vanishing Dogs Bug Fix
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Tricob wrote:
If you look through the code, you'll see that the code has a "safeguard" to prevent guards from walking through doors if they're not completely open. And yet anyone can walk through a door the instant anyone but the player signals it to open.
That's a bug I've not seen. The only door-related bug I've seen, which is the one I think this is supposed to fix, is the dog (I think) appearing to jump through a door.
Maybe ob->distance is becoming 0 a different way. Maybe in MoveObj where we have "ob->distance -=move;" but it doesn't check to make sure that "ob->distance" stays 0 or greater.... just rambling.

EDIT: MoveObj isn't it because we check that move < ob->distance before calling it.

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 7:41 ago.

Topics: 160
Posts: 7993
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Thu Jun 16, 2005 6:18 pm
   Subject: Re: [Tutorial] Vanishing Dogs Bug Fix
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Adam Biser wrote:
Maybe ob->distance is becoming 0 a different way. Maybe in MoveObj where we have "ob->distance -=move;" but it doesn't check to make sure that "ob->distance" stays 0 or greater.... just rambling.

EDIT: MoveObj isn't it because we check that move < ob->distance before calling it.

I think this is connected with the fact that (BLOCK) objects and solid walls can be walked through with the "help" of a Moving Guard. It's possible that the "moving" routine - being it in or out of Attack mode - is restarted (perhaps just for a single cycle) from the beginning, compensating for the positional change. If that's the case, the problem could be fixed by adding a simple "IF" statement in the right part of the code. Just a hypothesis.
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 30 Oct 2017

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

PostPosted: Fri Jun 17, 2005 11:40 am
   Subject: Re: [Tutorial] Vanishing Dogs Bug Fix
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Tricob wrote:
It doesn't allow you to kill the dog or move forward, though. That's the whole problem with the "vanishing" in the first place.

How are you testing this Tricob? The first case I could find was in SOD level 3.

SPEAR1.EXE - Fresh spear code, no changes.
SPEAR2.EXE - Fresh spear code, WSJ's dog chase addition.
SPEAR3.EXE - Fresh spear code, with the spotvis = 1 line.
SAVEGAM0.* - A 1x1 floorcode by a door that makes the dog vanish

http://www.canadianphilatelics.com/choksta/dogtest.zip

Only the exe with the change I posted makes the dog appear (and behave correctly). I can assure you that these exes are 100% real. Feel free to test things out and see what you get though. Whatever the outcome, you're still great in my book WSJ. Pizza

Tricob wrote:
Another "safeguard" that doesn't work: The code checks to see if the maximum length of a recorded demo has been reached, and the demo should end automatically when the maximum length *is* reached. Yet the maximum length can always be exceeded regardless of this so-called "safeguard".

Yeah, I never really liked seeing that "Demo Buffer Overflowed" message either. I just made it so that the level would fade out, then return you to the menu when the limit has been reached. If you want to try that, here's what the end of my PollControls() funtion in WL_PLAY.C looks like:

::: CODE :::
      *demoptr++ = buttonbits;
      *demoptr++ = controlx;
      *demoptr++ = controly;

      if (demoptr >= lastdemoptr-8)
         playstate = ex_completed;
      else
      {

         controlx *= (int)tics;
         controly *= (int)tics;
      }

If you use it in combination with this idea, the game will prompt you with a display of the demo number screen once it's reached the limit too. Still not as fun as seeing the "neverending demo files" that you can achieve with that beta exe on the Demo Recording thread though. What?

Dugtrio17 wrote:
Chris LIIIIIIIIIIIIVVVEESS... I can die a happy man Smile

DATZ AW3ZOME!
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 7:41 ago.

Topics: 160
Posts: 7993
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Fri Jun 17, 2005 7:14 pm
   Subject: Re: [Tutorial] Vanishing Dogs Bug Fix
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Re: Dogtest.ZIP. Deal. I'll check it out.

I'm sceptical about the savegames part, though. They tend to behave irradically when you run them on anything but the EXE you saved them with. The SAVEGAMx's results would probably be misleading.

Edit: Testing all three EXEs, I warped to Floor 4, which let me get to dogs sooner than Floor 3 would have. I wasn't able to replicate the disappearing dogs bug in any three of the SPEARx.EXE files. *However*, the problem *did* recur when I loaded the saved game in SPEAR1 and SPEAR2. SPEAR3 did something really wacky ... It said the saved game was "Corrupted", than brought me to Floor 17, and hung on a black screen.

I don't really know why your code change works though, since the change is in WL_DRAW, not WL_ACT1 or WL_ACT2. It seems as though the dog bug doesn't exist in SOD at all. The code change mentioned below might say why.

Up until version 1.2 of Wolfenstein 3-D, Id had some maps they didn't release because it had Deaf Guards turn into "Statues", despite the fact that all Floor Codes were correct. This bug often occurs if you place a Deaf Guard in a tight hall, especially in a dead end.

Well, it turns out that the bug does *not* occur if you place a Difficulty 1 Moving Actor in the same room as the Deaf Guard! I imagine Id figured out the same thing, so they figured out what part of the code fixed the problem, placed Spear-exclusive code into the game, and got the maps working (There's still one map-related bug left; Floor 4 has a hidden hall with lots of twists and turns, then a pack of Deaf Guards; one SS in this room is a "living statue" still; a misplaced Floor Code in a single square between four Deaf Guards is the cause of this, and is easily fixable).

Anyway, maybe Id fixed the dog bug when they fixed the "Deaf Guard statue" bug using the same line(s) of code.

Whatever the case, thanks for the Dog fix and Demo fix. Smile
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 30 Oct 2017

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

PostPosted: Thu Sep 28, 2017 5:49 am
   Subject: Re: [Tutorial] Vanishing Dogs Bug Fix
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

It seems another way to fix the Dogs Disappearing in Doors is to get rid of the "tilespot" checks in DrawScaleds in WL_DRAW.C:

::: CODE :::
//
// place active objects
//
   for (obj = player->next;obj;obj=obj->next)
   {
      if (!(visptr->shapenum = obj->state->shapenum))
         continue;                  // no shape

      spotloc = (obj->tilex<<6)+obj->tiley;   // optimize: keep in struct?
      visspot = &spotvis[0][0]+spotloc;

      //
      // could be in any of the nine surrounding tiles
      //
      if (*visspot
      || *(visspot-1)
      || *(visspot+1)
      || *(visspot-65)
      || *(visspot-64)
      || *(visspot-63)
      || *(visspot+65)
      || *(visspot+64)
      || *(visspot+63) )

{
         obj->active = true;

Thanks to AryanWolf3D and AlumiuN for talking about "removing tilespot" so that I could notice this added bonus. Laughing
Aryan_Wolf3D
I am Death Incarnate
I am Death Incarnate


Joined: 21 Jul 2011
Last Visit: 20 Nov 2017

Topics: 6
Posts: 171

blank.gif

PostPosted: Thu Sep 28, 2017 6:33 am
   Subject: Re: [Tutorial] Vanishing Dogs Bug Fix
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

Haha, so you did test it! Glad to hear it worked! Thumbs Up

_________________
"Way too many #ifdefs in the code!" - John Carmack
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 7685 Sun Jan 10, 2010 12:26 pm
Fragstein3D View latest post
No new posts [Help] Setting RocketLauncher: Explosive Range...?
Author: KyleRTCW
17 4243 Thu Jun 03, 2004 3:21 am
Codetech84 View latest post
No new posts [Info] Tricks - Dogs that shoot - Modifying Behaviour
Author: Guest
19 284 Sat Mar 20, 2004 7:31 am
Dugtrio17 View latest post
No new posts [Info] Alarm Sounding in game?? WSJ...??
Author: Guest
7 308 Tue Jun 17, 2003 10:04 pm
Reivax44 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