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] Door/Pushwall Control
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
Dugtrio17
Code Master
Code Master


Joined: 11 Mar 2003
Last Visit: 03 Oct 2013

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

PostPosted: Tue May 27, 2003 4:24 pm
   Subject: [Code] Door/Pushwall Control
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

Fire up Wl_act1.c, and take a look at around line 714. You should see "PUSHABLE WALLS". Well, have you ever wanted them to go further? Or faster? Well, wonder no more! For further, check out around line 835. You should see:
::: CODE :::

      //
      // see if it should be pushed farther
     //

     if (pwallstate>256)


See that 256? The divided by 128 is how far the pushwall should go. However, you'll notice that pushwalls normally go 3 spaces anyway, when it's obvious that they're only supposed to go 2. If you want it to always go 3, then your best bet is to change that 256 to a 384. This won't make it go 4 spaces; apparently, the game just doesn't like moving the pushwall 2 spaces (there's probably a technical reason for it, but that's not why I'm here. Maybe later Smile ). Why is it the number of tiles times 128? look up a little: you see this:
::: CODE :::
    oldblock = pwallstate/128;

I think that question's been answered now Smile
What about faster? VERY simple. Look here:
::: CODE :::
    pwallstate += tics;

All you have to do is do some sort of arithmetic with that tics. You could put it in parenthesis if you want, but my experiments worked fine without it (but if you do, don't put that semicolon in the parenthesis!). If you add, add very small numbers; adding 1 makes it go faster than multiplying by 2, though multiplication will give you more exact results. Something I noticed was that adding 1 gives it an almost Blake Stone speed (the pushwalls in Blake Stone, I mean). Don't worry about it going farther or shorter doing this; this won't have any effects on that.
OK, so you can make your pushwalls cruise 8 tiles faster than you can or creep slowly and go just one tile, but what about the doors? After all, the topic is "Pushwalls and Doors". No problem. Take a ride to around lines 593 and 639. You should look for these two:
593:
::: CODE :::
       position += tics<<10;

639:
::: CODE :::
       position -= tics<<10;

Simply make those 10's larger for faster doors, or smaller for slooooower doors. Heck, you can make 'em open like lighting and close like a turtle if you want, since 593 is the door opening speed and 639 is the door closing speed, and you can make them different if you want.
As for how far they open, check around lines 593 and 599. Those FFFF's are how far the door will open, in hexidecimal form. For fun, you can halve that (7FFF), and watch all the doors be only half open but still walk-throughable! While this can seem trivial, using this method and a few modifications, you can whip up Blake Stone style doors!
Last, but not least, is a simple method of there being more or less waiting time for a door to close. Look around line 270 for:
::: CODE :::
#define OPENTICS            300

Change that 300 to more or less, depending on how long you want them to stay open or closed.
But maybe you don't want doors to close on their own (like in Haunted House). That's easy; look at around 538 for the DoorOpen function. You should get this:
::: CODE :::
void DoorOpen (int door)
{
  if ( (doorobjlist[door].ticcount += tics) >= OPENTICS)
        CloseDoor (door);
}

This isn't the code for the door opening; this is the code for the door closing (as is senn in the comment above the function). There are a couple of ways to do this. The best way would be to completely remove the DoorOpen function and every last trace of it, including calls and such. But if you're in a hurry, there are two quicker (and safer, if you're less experienced with the code) ways. One is to comment out the two lines with the actual function (between the brackets), but this will give you a little warning message every time you compile. If you really don't mind that in the least bit, then that solution's for you. But an equally easy, yet warning-free, solution is to change that if statement to something impossible, like:
::: CODE :::
if (gamestate.health == 12.621 && gamestate.health != 12.621)

Cheap, but it's the lazy man's solution, and it works! Laughing

Happy to help,
-DAD

_________________
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 30 Oct 2017

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

PostPosted: Wed May 28, 2003 5:05 am
   Subject: The Pushwall that would become President!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

You have some very interesting Source Code techniques there Dugtrio17. It's nice to see someone just experimenting with all the numbers and codes and seeing what happends. That's pretty much what hex editing is all about! I've had many similar experiences with the Pushwalls/Doors, they're pretty fun to play around with. Smile

It'd be interesting to have pushwalls that move forever until they hit a wall, than have turning points - where they can just go around in a huge pattern throughout the level... and can crush your health like pac-men (and the enemies) if you run into them. Maybe have it so they can go faster on different floorcodes and transform into a boss or come to life and start running after you if they hit a certain banner on a wall. Or have it so that certain types of enemies can detect ammo and health and go into secret passages and grab em before you can. Ahhh, there's endless variations; but it sure is fun to imagine...

The bug on your 'newsize 20' thing that makes gray lines on the ends of the vertical display is pretty interesting. I'm guessing that the screen is so long that it just thinks you're IN the wall. If you play around with the focallength / viewglobal variables and CalcProjection function in WL_Main.C though - it makes the shapes of your persepction really funky in all sorts of ways (sometimes eliminating the bug, and causing other weird phenomina in the process). That would be a fun little challenge for an addon, having a place on a certain level where you have to play from a totally different kind of angle/distance outlook. Wink

Hey, glad you're enjoying my midi files. If you ever make a song, I'd love to hear it (and maybe even do a remix of it)! Here's something I just made this morning for fun; the voices/keyboard/guitar playing are included in a separate file if you can't deceifer them inside the original:

http://groups.yahoo.com/group/yetanotherwolf3dclub/files/Choksta_-_Demo_Melody.mp3
http://groups.yahoo.com/group/yetanotherwolf3dclub/files/ambience.mp3

Let me know if you ever have any more interesting Source Code Adventures in the future dude; they're really entertaining to read (and talk about with you). Mr Green
TheTalentedMrLeo
Forum Administrator
<B>Forum Administrator</B>


Joined: 14 Mar 2003
Last Visit: 09 Dec 2017

Topics: 35
Posts: 676
Location: Sometimes in Canada
usa.gif

PostPosted: Wed May 28, 2003 11:42 am
   Subject: Re: Pushwalls and Doors
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I would love to find out how I can make the doors open vertically instead of horizontally ( such as thos in doom ).
Dugtrio17
Code Master
Code Master


Joined: 11 Mar 2003
Last Visit: 03 Oct 2013

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

PostPosted: Wed May 28, 2003 1:31 pm
   Subject: Re: Pushwalls and Doors
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Thanks Chris Smile Making it go forever's easily done by commenting out lines 835 to 843. I was experimenting a little more, and made it so that a pushwall could crush the player by just adding a check that if the pushwall's x and y are the same as the player's tilex and tiley (for those out there reading this: make sure it's tilex and tiley, not just x and y, or it won't work. it would read "player->tilex" and "player->tiley"), then the player dies (any way you want it to happen; take a bazillion damage, playstate = ex_died, etc.). It would be interesting to modify this to crush enemies as well and to go back and forth (like in ROTT), or, more interestingly, in a pattern, as you described. A better way to do the crushing would probably be to do PacMan style, as you described. Hmm... this could all make for some interesting gameplay Smile
I was also thinking that maybe you could make the player have to push a fast-moving player/enemy crushing pushwall to open up a necessary passage, but the pushwall will also block your passage if you don't make it in time, then race to the end through some twisty passages, or maybe make it a bit slower and have a normal-style level, where you have to get a key to open a door to a narrow passage that the wall will block off if you're not fast enough. Of course, it would probably be best if the player saved before the start of each level, in case they don't make it Smile I can imagine a player just barely about to make it, and they dash across where the pushwall will block, but then they get crushed! ARGH! Mr Green
Different things with the doors could be used to create interesting effects, too; for example, having some doors opening at different speeds than others, like maybe a rusty door would creak open, but a new door would slide on smoothly. By the way MrLeo, making doors slide vertically would (I think) require rewriting the entire door opening and closing scheme, because that's more of a height thing. But it could be done. What would also be neat would a certain door that crushes non-boss enemies (and you!) when it closes.
Well, I'd type more, but I've got an angry brother who's pissed for me bumping him off the internet to go on my computer! Laughing

-DAD

_________________
Anonymous
Guest



Last Visit:





PostPosted: Sun Jun 06, 2004 8:59 pm
   Subject: Forcing pushwalls to move ONLY 2 tiles
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I've been playing with the pushwall movement code on-and-off for a while now, trying to get the pushwalls to stop after two tiles like they were originally designed to do. I realized, however, that the movement is based on tics, which are affected by the speed of the computer's processor. On the old 386s of Wolfenstein's day, the ticcount escalated slowly enough that the pushwalls usually stopped after two tiles. But on faster machines -- even on my 486 -- they commonly move three tiles instead.

I notice that the code in WL_ACT1.C checks to see if the pwall has moved a distance greater than 256 tics. Upon changing this value to 128, I got the pwalls to stop after two tiles. But upon simulating a slower computer by adding extra VBLs (Tab+V), I caused the pushwalls to stop moving after one tile! I want a solution that is two tile independent of processor speed.

I'm not really a coder -- just a tinkerer -- so does anybody have any thoughts on another way to check the distance a pwall has moved? I know games like Blake Stone and Corridor 7 have pushwalls that always move only two tiles. What would be a better way to accomplish this, rather than checking distance based on tics?

This is really just a "on principle" question since we've all obviously been designing our maps to account for three-tile pushwalls for years now, but it's an interesting bug I always wanted to solve. Any thoughts from the experts?
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 30 Oct 2017

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

PostPosted: Sun Jun 06, 2004 11:44 pm
   Subject: Re: Forcing pushwalls to move ONLY 2 tiles
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

B.J. Blaze wrote:
since we've all obviously been designing our maps to account for three-tile pushwalls for years now

Actually, I've always based my maps on the idea that a pushwall can go 2 OR 3 tiles; and I usually just put a block of wall three tiles away from the pushwall like in the original levels. Wink

I've always thought about this too Brian. I believe that 192 seems to work alright on modern machines. I'm sure that you could just save the pushwalls tilex and tiley values before they've moved, and then stop the pushwall when either the x or y value has increased / decreased by 2 from that original value. I think it would be alot funner just to remove that part of the code totally though, so you could have an 'infinity' pushwall that could move 64 sqaures (should there not be a wall to stop it) - lol.

Anothing thing that would be fun to change is the drawing routine in WL_DRAW.C. You know, when you look at the pushwall from the side, it doesn't move left/right... it moves backwards and than 'appears' to the left or right once it's passed that block? haha. It looks kind of unrealistic, doesn't it? I've always wanted to play around with that stuff, maybe I'll give it a shot tomorrow after work (unless someone else manages to post a solution before then).
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 30 Oct 2017

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

PostPosted: Mon Jun 07, 2004 12:40 am
   Subject: just need to be in the right frame of mind, I guess
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Oh my god, I can't believe how easy this was! To make a block always move 2 spaces, all you have to do is use a counter in WL_ACT1.C that adds up everytime the block itself has been moved (the point in which you can walk through that tile). Laughing

::: CODE :::
unsigned   pwallstate;
unsigned   pwallpos;         // amount a pushable wall has been moved (0-63)
unsigned   pwallx,pwally;
int      pwalldir;
int      count;


::: CODE :::
//
// the tile can now be walked into
//
tilemap[pwallx][pwally] = 0;
(unsigned)actorat[pwallx][pwally] = 0;
*(mapsegs[0]+farmapylookup[pwally]+pwallx) = player->areanumber+AREATILE;
count++;

//
// see if it should be pushed farther
//
if (count == 2) //this used to be "if (pwallstate>256)"
{
//
// the block has been pushed two tiles
//
   pwallstate = count = 0;
   return;

Just add/replace everything in red. Changing the number in "count == 2" will change the amount of spaces the block moves. Wink

----------------
EDIT: It would probably be a good idea to add the count into all the "pwallstate = count = 0;" lines in the MovePWalls() function (there's 4 others, below the one posted), so that the pushwalls which only move 1 space (though rare) will also be reset.


Last edited by Chris on Mon Jun 07, 2004 4:00 am; edited 3 times in total
TheTalentedMrLeo
Forum Administrator
<B>Forum Administrator</B>


Joined: 14 Mar 2003
Last Visit: 09 Dec 2017

Topics: 35
Posts: 676
Location: Sometimes in Canada
usa.gif

PostPosted: Mon Jun 07, 2004 12:45 am
   Subject: Re: Forcing pushwalls to move ONLY 2 tiles
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Ha ha, funny you should mention pushwalls! I'll share a little story of an experience I had a few years back. ( *Grabs chair. )

I happened to be playing through one of the levels one night in Wolf3d that had the multiple pushwall puzzle. As I activated one of the pushwalls, I somehow managed to walk "through" this wall as it was moving, only to get stuck in the wall itself. Too bad I hadn't saved before that point....boy was I pissed.

Great "feature", yes? Would make a great trap for the courageous BJ. Mr Green

On another note:

I've had an idea where I'd like to see a pushwall that could be activated multiple times - I.E. Activate pushwall, moves three tiles, then stops over another "pushwall" tile which then could be moved again, etc, etc. Pizza
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 30 Oct 2017

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

PostPosted: Mon Jun 07, 2004 1:19 am
   Subject: Re: Forcing pushwalls to move ONLY 2 tiles
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Man, what a cool story (sits by the campfire, roasting marshmellows and listening to the wise Leo share his tale). I remember the same thing happening when I was younger! Do you remember what level that was in? For me, I think it was in Spear Level 12. I ran behind the moving passage like a fool (trying to make a dive for the secret elevator!) and just got stuck, but I did save at the start of the level... so it wasn't a total loss. Would be funny if the secret passages actually caused damage (like a pacman ghost) when they run you over. That would probably also work well for when you "walk through walls" in some addons. Twisted Evil

Funny idea Leo. You're not the only one who's done some of those "super pushwalls that you can keep spinning around to 20 different areas" before. Most of the ones I've done were on graph paper before I even had editors (one I remember requiring you to push the block in 15 or 16 different specific directions with dead guards and objects everywhere to block the ghost and get 100% secret ratio... all I remember was that the first 6 directions were NWNESW - lol).

If you guys were looking for some interesting reading material, Dugtrio17 also started a thread about pushwalls a long time ago (although it didn't get that many replies). Here's the thread:

http://diehardwolfers.areyep.com/viewtopic.php?t=371
Anonymous
Guest



Last Visit:





PostPosted: Mon Jun 07, 2004 6:05 am
   Subject: Re: Forcing pushwalls to move ONLY 2 tiles
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Chris! You're the man! Look at that, you solved it already. I knew you'd read this thread. Smile Excellent idea on implementing a counter. I should have figured on something like that. I originally thought maybe I should locate the tilex/tiley position where the wall started and then calculate how far it's moved based on its current coordinates, but I was much too lazy to try coding that, LOL. Your solution is great. I'm going to try it out later tonight.

Actually, when I said "designing our maps to take 3-tile pushwalls into account", I actually meant "2 or 3 tile pushwalls", since I too always consider the possibility that the wall will move only two tiles. All of my secret areas (unless I made a mistake, heh) are designed to allow access whether the wall moves 2 or 3 tiles, and not move over anything.

I actually did try changing the value to 192 and had great results (even adding 8 VBLs couldn't get it to move only 1 tile), but it was still bugging me because I knew using tics could never be exact. Your method is much more precise. Just what I wanted.

Thanks also for linking me to that old thread; I've been wanting to speed up the pushwalls for a while now and this will help me there. But I agree, that pushwall draw routine REALLY needs help. I always hated how weird it looked if you got beside a pushwall and saw it moving sideways; it looked like the two outermost vertices were collapsing in on themselves as the wall continued to move away from you. That kind of codefixing is likely out of my realm of ability (well...more like out of my realm of time, since just about anything can be learned with enough time and patience), but if you come up with anything, I'd love to see how it's done.

Leo: Awesome story! I had the same thing happen to me once! I think it was a level in Episode Six; I was low on health and searching for secret healing caches, and found one. I ran in there, all excited, scooping up the health, and promptly got stuck in the pushwall as it moved three tiles! (It was one of those pwalls that slid out into the middle of the room.) Man, was I ever confused. Had to load my game back (don't remember how much time I lost). But yeah, it would be cool if the pushwalls could crush you if you got behind them...doesn't that happen in ROTT?

Also, as to the pushwall that can be pushed multiple times, that's easily done -- just place pushwall object codes over blank floor space, in the path your pushwall will take when it opens. Thus, when you push the wall the first time, it moves back and stops on another pushwall tile. Now that Chris has figured out an exact method for getting the wall to stop after two tiles, I'll feel more comfortable using tricks like this...I never wanted to do that before, since I couldn't be sure of where a wall would stop moving (unless I added blockable objects or something behind it, which I didn't always want to do). Using this idea, you can probably do stuff like make walls that the player can push until they're in front of doors or hallways, so that you can block enemies from getting out, or other stuff like that.

Thanks again for the help -- another age-old question answered!
Ringman
DieHard Wolfer
DieHard Wolfer


Joined: 31 Jul 2003
Last Visit: 14 Dec 2016

Topics: 54
Posts: 1165
Location: up my nose
usa.gif

PostPosted: Wed Jul 14, 2004 8:58 pm
   Subject: Re: [Code] Door/Pushwall Control
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

What about the problem that pushwalls have about not being a solid block? If you ever made a pushwall out in the middle of a level without an wall surrounding it, and pushed it and looked at it from other sides, you'll notice a bizarre glitch. The wall surfaces moves away from the all directions, so if you are on another side it looks like that side is sliding away. If you watch it from corner you'll see two wall surfaces converging into a point. It is really bizarre. Is there any way to fix this?

_________________
One day I saw upon a stair a little man who wasn't there. He wasn't there again today. My gosh I'd wish he'd go away.
Crane
Registered User
Registered User


Joined: 31 Aug 2008
Last Visit: 14 Sep 2008

Topics: 2
Posts: 15
Location: United Kingdom
uk.gif

PostPosted: Sun Aug 31, 2008 9:22 am
   Subject: Re: [Code] Door/Pushwall Control
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Trust me to post on four-year-old topics!

My solution to stop pushwalls from moving 3 spaces was the following: find this line of code in the MovePWalls routine...
::: CODE :::
if (pwallstate>256)

Change to...
::: CODE :::
if (pwallstate>=256)

That fixed all of my problems.

As for the issue of the appearance of a moving wall from the side, you might be able to borrow some code from the standard door opening procedures, but it doesn't sound like an easy job.
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 15:19 ago.

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

PostPosted: Sun Aug 31, 2008 6:15 pm
   Subject: Re: [Code] Door/Pushwall Control
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

To fix the Pushwall problem you mention, check out Ripper's "Free Pushwalls" code. IIRC, it's in the Feature Fanatics section.
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] Add Text to Screen at Skill Level select - Chris
Author: Chris
3 2437 Tue Sep 28, 2010 6:59 pm
Tricob 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] 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
No new posts [Help] Different Enemy Dying Frames/Views
Author: Guest
7 607 Tue Jul 29, 2003 3:00 pm
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