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       

[Code] Double Doors - Blake Stone style open from middle
Page 1 of 1
DieHard Wolfers Forum Index -> Code Tutorials 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
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 12 Dec 2017

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

PostPosted: Sun Dec 12, 2004 2:52 pm
   Subject: [Code] Double Doors - Blake Stone style open from middle
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

These changes will allow you to make doors open in the middle instead of the normal action.
Be sure to that your code is currently working before starting and make a backup of your code.

I will use color text to show changes that need to be made.
Green = comment the line
Red = add the line

Take a deep breath and begin...
First, open WL_DEF.H and find
::: CODE :::
extern   unsigned   doorposition[MAXDOORS],pwallstate;

Change this to:
::: CODE :::
extern   unsigned   ldoorposition[MAXDOORS],rdoorposition[MAXDOORS],pwallstate;


Now find the doorstruct definition in the same file and make the following changes.
::: CODE :::
typedef struct doorstruct
{
   byte   tilex,tiley;
   boolean   vertical;
   byte   lock;
   enum   {dr_open,dr_closed,dr_opening,dr_closing}   action;
   int      ticcount;
   boolean doubledoor;
} doorobj_t;


Close that file and open WL_MAIN.C.
find:
::: CODE :::
         sizeof(doorposition) +

change to:
::: CODE :::
         sizeof(ldoorposition) +
         sizeof(rdoorposition) +

find:
::: CODE :::
   DiskFlopAnim(x,y);
   CA_FarWrite (file,(void far *)doorposition,sizeof(doorposition));
   checksum = DoChecksum((byte far *)doorposition,sizeof(doorposition),checksum);

change to:
::: CODE :::
   DiskFlopAnim(x,y);
   CA_FarWrite (file,(void far *)ldoorposition,sizeof(ldoorposition));
   checksum = DoChecksum((byte far *)ldoorposition,sizeof(ldoorposition),checksum);
   DiskFlopAnim(x,y);
   CA_FarWrite (file,(void far *)rdoorposition,sizeof(rdoorposition));
   checksum = DoChecksum((byte far *)rdoorposition,sizeof(rdoorposition),checksum);

Find:
::: CODE :::
   DiskFlopAnim(x,y);
   CA_FarRead (file,(void far *)doorposition,sizeof(doorposition));
   checksum = DoChecksum((byte far *)doorposition,sizeof(doorposition),checksum);

change to:
::: CODE :::
   DiskFlopAnim(x,y);
   CA_FarRead (file,(void far *)ldoorposition,sizeof(ldoorposition));
   checksum = DoChecksum((byte far *)ldoorposition,sizeof(ldoorposition),checksum);
   DiskFlopAnim(x,y);
   CA_FarRead (file,(void far *)rdoorposition,sizeof(rdoorposition));
   checksum = DoChecksum((byte far *)rdoorposition,sizeof(rdoorposition),checksum);


Now open up WL_ACT1.C:
find:
::: CODE :::
   unsigned   doorposition[MAXDOORS];      // leading edge of door 0=closed

change to:
::: CODE :::
   unsigned   ldoorposition[MAXDOORS],rdoorposition[MAXDOORS];      // leading edge of door 0=closed

Now find SpawnDoor():
::: CODE :::
void SpawnDoor (int tilex, int tiley, boolean vertical, int lock)
{
   int   areanumber;
   unsigned   far *map;

   if (doornum==64)
      Quit ("64+ doors on level!");

//   doorposition[doornum] = 0;      // doors start out fully closed
   switch (MAPSPOT(tilex,tiley,0))
   {
      case 90:
      case 91:
         lastdoorobj->doubledoor = true;
         break;
      default:
         lastdoorobj->doubledoor = false;
   }
   if (lastdoorobj->doubledoor)
   {
      ldoorposition[doornum] = 0x7fff;      // doors start out fully closed
      rdoorposition[doornum] = 0x8000;
   }
   else
   {
      ldoorposition[doornum] = 0;      // doors start out fully closed
      rdoorposition[doornum] = 0; // this will function like the original doorposition[]
   }

   lastdoorobj->tilex = tilex;
   lastdoorobj->tiley = tiley;


Now in DoorOpening():
::: CODE :::
//   position = doorposition[door];
   if (doorobjlist[door].doubledoor)
      position = 0x7fff-ldoorposition[door];
   else
      position = rdoorposition[door];

And:
::: CODE :::

   if (doorobjlist[door].doubledoor)
   {
      position += (tics<<10)/2;
      if (position >= 0x7fff)
      {
      //
      // door is all the way open
      //
         position = 0x7fff;
         doorobjlist[door].ticcount = 0;
         doorobjlist[door].action = dr_open;
         actorat[doorobjlist[door].tilex][doorobjlist[door].tiley] = 0;
      }
      ldoorposition[door] = 0x7fff-position;
      rdoorposition[door] = 0x8000+position;
   }
   else
   {

      position += (tics<<10);
      if (position >= 0xffff)
      {
      //
      // door is all the way open
      //
         position = 0xffff;
         doorobjlist[door].ticcount = 0;
         doorobjlist[door].action = dr_open;
         actorat[doorobjlist[door].tilex][doorobjlist[door].tiley] = 0;
      }
//   doorposition[door] = position;
      ldoorposition[door] = 0;
      rdoorposition[door] = position;
   }

And in DoorClosing(), find:
::: CODE :::
   position = doorposition[door];
//
// slide the door by an adaptive amount
//
   position -= tics<<10;

And change it to:
::: CODE :::
   if (doorobjlist[door].doubledoor)
   {
      position = 0x7fff-ldoorposition[door];
      // slide the door by an adaptive amount
      position -= (tics<<10)/2;
   }
   else
   {
      position = rdoorposition[door];
      // slide the door by an adaptive amount
      position -= (tics<<10);
   }

While still in DoorClosing, find:
::: CODE :::
   doorposition[door] = 0;

and change to:
::: CODE :::
   if (doorobjlist[door].doubledoor)
   {
      ldoorposition[door] = 0x7fff-position;
      rdoorposition[door] = 0x8000+position;
   }
   else
   {
      ldoorposition[door] = 0;
      rdoorposition[door] = position;
   }


Now go to WL_STATE.C:
In CheckLine(), find:
::: CODE :::
         if (intercept>doorposition[value] )
            return false;

and change it to:
::: CODE :::
         if (doorobjlist[value].doubledoor)
         {
            if (intercept<ldoorposition[value] || intercept>rdoorposition[value] )
               return false;
         }
         else
         {
            if (intercept>rdoorposition[value] )
               return false;
         }

You will find that if statement twice, so replace both of them.

Open WL_DRAW.C and add these lines right before HitHorizDoor():
::: CODE :::
boolean   leftside;

void SetLeftDoorSide (void)
{
   leftside=true;
}
void SetRightDoorSide (void)
{
   leftside=false;
}


Now inside of HitHorizDoor:
::: CODE :::
   texture = ( (xintercept-doorposition[doornum]) >> 4) &0xfc0;

becomes:
::: CODE :::
   if (doorobjlist[doornum].doubledoor)
   {
      if (leftside)//left
         texture = ( (xintercept+0x7fff-ldoorposition[doornum]) >> 4) &0xfc0;
      else
         texture = ( (xintercept+0x8000+ldoorposition[doornum]) >> 4) &0xfc0;
   }
   else
      texture = ( (xintercept-rdoorposition[doornum]) >> 4) &0xfc0;

And in HitVertDoor():
::: CODE :::
   texture = ( (yintercept-doorposition[doornum]) >> 4) &0xfc0;

becomes:
::: CODE :::
   if (doorobjlist[doornum].doubledoor)
   {
      if (leftside)//left
         texture = ( (yintercept+0x7fff-ldoorposition[doornum]) >> 4) &0xfc0;
      else
         texture = ( (yintercept+0x8000+ldoorposition[doornum]) >> 4) &0xfc0;
   }
   else
      texture = ( (yintercept-rdoorposition[doornum]) >> 4) &0xfc0;


And FINALLY, open WL_DR_A.ASM and find:
::: CODE :::
   EXTRN   HitVertPWall:FAR

add these lines after it:
::: CODE :::
   EXTRN   SetLeftDoorSide:FAR
   EXTRN   SetRightDoorSide:FAR


Find:
::: CODE :::
EXTRN   doorposition:WORD      ; table of door position values

Change to:
::: CODE :::
EXTRN   ldoorposition:WORD      ; table of door position values
EXTRN   rdoorposition:WORD



then find and make changes to:
::: CODE :::
hithmid:
;   cmp   ax,[doorposition+bx]      ; position of leading edge of door
;   jb   continuehoriz

   call FAR SetLeftDoorSide
   cmp ax, [ldoorposition+bx]         ; ax is yintercept.
   jb   drawhdoor
   call FAR SetRightDoorSide
   cmp ax, [rdoorposition+bx]
   jb   continuehoriz

;
; draw the door
;
drawhdoor:
   mov   [WORD xintercept],ax      ; save pixel intercept position


now find and make changes to:
::: CODE :::
hitvmid:
;   cmp   ax,[doorposition+bx]      ; position of leading edge of door
;   jb   continuevert

   call FAR SetLeftDoorSide
   cmp ax, [ldoorposition+bx]         ; ax is yintercept.
   jb   drawvdoor
   call FAR SetRightDoorSide
   cmp ax, [rdoorposition+bx]
   jb   continuevert

;
; draw the door
;
drawvdoor:
   mov   [WORD yintercept],ax      ; save pixel intercept position


That's it... hopefully there aren't any typos in here.
Just make changes to SpawnDoor() to suit your project.

NOTE: This will cause your current SaveGames to no longer work.

EDIT: Fixed a bug in the CheckLine change.

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


Last edited by Adam Biser on Tue Jun 07, 2005 7:55 pm; edited 1 time in total
andy3012
DieHard Guard
DieHard Guard


Joined: 02 Jul 2004
Last Visit: 15 Feb 2008

Topics: 29
Posts: 292
Location: England
uk.gif

PostPosted: Mon Dec 13, 2004 12:09 pm
   Subject: Re: [Tutorial] Double Doors
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

kool, this is a great tutorial... Though ive decided not to make games no longer...
TexZK
DieHard SS
DieHard SS


Joined: 07 Feb 2004
Last Visit: 17 Oct 2016

Topics: 19
Posts: 370
Location: Northern Italy
italy.gif

PostPosted: Mon Dec 13, 2004 12:09 pm
   Subject: Re: [Tutorial] Double Doors
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

::: CODE :::
position += (tics<<10)/2;


equals:

::: CODE :::
position += tics << UNSIGNEDSHIFT+1;
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 12 Dec 2017

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

PostPosted: Mon Dec 13, 2004 12:18 pm
   Subject: Re: [Tutorial] Double Doors
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Or even just
::: CODE :::
position += (tics << 9);

Would this be faster, or will the compiler optimize UNSIGNEDSHIFT+1 for you?

I'm not saying that the code is the most optimized. I'm sure you can tweak it in quite a few places.
The part I hate is the need for SetLeftDoorSide and SetRightDoorSide, but I couldn't find a value to test to see which side of the door the ray tracer hit.

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
ZuljinRaynor
DieHard Officer
DieHard Officer


Joined: 17 Jan 2004
Last Visit: 30 Apr 2011

Topics: 19
Posts: 559
Location: New Jersey, USA
usa.gif

PostPosted: Mon Dec 13, 2004 12:45 pm
   Subject: Re: [Tutorial] Double Doors
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I'm sorta lost in how you add these doors. Do you add them the same way as the regular ones? Also, I have added the max amount of doors in the one area meaning 85 is the Elevator Wall and I don'y know how to make new doors then from 64 to 84 in the cases. I'd add the double doors as new doors in the 64 to 84 range.
::: CODE :::
tile = *map++;
                        if (tile >= 86 && tile <= 105)
         {
         // door
            switch (tile)
            {
            case 86:
            case 88:
            case 90:
            case 92:
            case 94:
            case 96:
            case 98:
            case 100:
            case 102:
            case 104:
               SpawnDoor (x,y,1,(tile-86)/2);
               break;
            case 87:
            case 89:
            case 91:
            case 93:
            case 95:
            case 97:
            case 99:
            case 101:
            case 103:
            case 105:
               SpawnDoor (x,y,0,(tile-87)/2);
               break;
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 12 Dec 2017

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

PostPosted: Mon Dec 13, 2004 12:48 pm
   Subject: Re: [Tutorial] Double Doors
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Yes, you add them just like regular doors.
The only part you need to change to fit your project is in SpawnDoor() itself:
::: CODE :::
switch (MAPSPOT(tilex,tiley,0))
   {
      case 90:  // These doors will be double doors
      case 91:
         lastdoorobj->doubledoor = true;
         break;
      default:
         lastdoorobj->doubledoor = false;
   }

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
ZuljinRaynor
DieHard Officer
DieHard Officer


Joined: 17 Jan 2004
Last Visit: 30 Apr 2011

Topics: 19
Posts: 559
Location: New Jersey, USA
usa.gif

PostPosted: Mon Dec 13, 2004 12:51 pm
   Subject: Re: [Tutorial] Double Doors
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Okay... but my other problem is, that my doors are filled up. 86-105 are my doors. 85 is the elevator wall and 106 is the deaf guard. How would I make it that lets say... 83 and 84 are double doors and how would I make it even a regular door? My problem is that I'm out of contiguous spots for doors.
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 12 Dec 2017

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

PostPosted: Tue Jun 07, 2005 8:06 pm
   Subject: Re: [Code] Double Doors - Blake Stone style open from middle
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Bug fix!
For the CheckLine code... add the red lines
::: CODE :::
         if (doorobjlist[value].doubledoor)
         {
            if (intercept<ldoorposition[value] || intercept>rdoorposition[value] )
               return false;
         }
         else
         {
            if (intercept>rdoorposition[value] )
               return false;
         }

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

Topics: 153
Posts: 2256
Location: Ontario
canada.gif

PostPosted: Sat Dec 03, 2005 8:46 am
   Subject: Re: [Code] Double Doors - Blake Stone style open from middle
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Hey Adam,

Any chance of getting a version that will work with the "Raycastor" tutorial. The only reason that I ask is that with Ripper's new DOS4GW modified raycastor and Darkone's that I stripped from NewWolf Classic, the asm file is no longer required. As such, I haven't been able to make this tutorial work other than with the original Wolf3d source code.

I could really use it for the "Raycastor" tutorial... Smile

Greg
BrotherTank
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 12 Dec 2017

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

PostPosted: Sat Dec 03, 2005 8:51 am
   Subject: Re: [Code] Double Doors - Blake Stone style open from middle
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Actually, I haven't even tried the new raycaster tutorial yet. Sorry.
I'll take a look at the tutorial and see if anything jumps out at me.

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
Ripper
Code Master - Developer
Code Master - Developer


Joined: 15 Mar 2003
Last Visit: 30 Sep 2008

Topics: 21
Posts: 527
Location: Germany
blank.gif

PostPosted: Sun Jul 20, 2008 4:35 am
   Subject: Re: [Code] Double Doors - Blake Stone style open from middle
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

A small bug fix to avoid ghosty hole in the middle of the door when looking at it from very specific perspectives:
Replace
::: CODE :::
jb   drawhdoor
by
::: CODE :::
jbe   drawhdoor

and
::: CODE :::
jb   drawvdoor
by
::: CODE :::
jbe   drawvdoor


This way there won't be a hole at 0x7fff anymore.

_________________
Life is an awful game, but the graphics resolution rocks ;D
Lingyan203
Bring 'em On
Bring 'em On


Joined: 05 Dec 2009
Last Visit: 05 Dec 2017

Topics: 16
Posts: 104
Location: Ottawa, Ontario
canada.gif

PostPosted: Wed Jan 12, 2011 4:39 pm
   Subject: Re: [Code] Double Doors - Blake Stone style open from middle
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

What if you want a specific door to open like the Blake Stone style one? Let's say if I added a new door, and want that one to open from the middle, but the others to open like original Wolf. What do I do?
Tragos2d
Don't Hurt Me
Don't Hurt Me


Joined: 05 Jul 2011
Last Visit: 14 Sep 2011

Topics: 8
Posts: 55

usa.gif

PostPosted: Tue Jul 05, 2011 12:46 pm
   Subject: Re: [Code] Double Doors - Blake Stone style open from middle
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

I apologize if this has already been addressed. But can a door also be set to open vertically up or down?
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> Code Tutorials 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 [Code] Blood Splatz Tutorial - Blood Splatters
Author: Dugtrio17
45 11219 Tue Mar 11, 2008 12:02 am
AlumiuN View latest post
No new posts [Code] Display Different Ammo Types on Statusbar-BrotherTank
Author: BrotherTank
1 2381 Fri Feb 11, 2005 9:18 pm
Zombie_Plan View latest post
No new posts [Code] Adding a Frames per Second Counter - Darkone
Author: BrotherTank
0 1703 Sat Mar 13, 2004 2:07 pm
BrotherTank View latest post
No new posts [Code] Changing an Enemies Attack Strength - BrotherTank
Author: BrotherTank
0 1969 Tue Jan 27, 2004 10:29 am
BrotherTank View latest post
No new posts [Code] Changing Weapons -CheckWeaponChange- BrotherTank
Author: BrotherTank
2 2700 Sun Oct 26, 2003 1:21 am
Guest 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