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] Interactive Wall Patches in Wolf4SDL
Page 1 of 1
DieHard Wolfers Forum Index -> SDL 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
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 5:47 ago.

Topics: 163
Posts: 8152
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Mon Nov 21, 2011 8:25 pm
   Subject: [tutorial] Interactive Wall Patches in Wolf4SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

In this tutorial, you'll be shown how to make your Wall Patches interactive in Wolf4SDL. The tutorial assumes you've enabled the Wall Patches using Haasboy's tutorial.

First off, for the Wall Patches marked as "used", you'll want them to stay "used" when you save a game and load it again. So, go into WL_MAIN.CPP. Do a search for "SaveTheGame". You should see this:
::: CODE :::
/*
==================
=
= SaveTheGame
=
==================
*/

Insert this just below it:
::: CODE :::
// originally coded by Adam Biser
#define objplanesize  MAPSIZE*MAPSIZE*2
extern word *mapsegs[MAPPLANES];

Next, do a search for "tilemap". You should see this code:
::: CODE :::
    DiskFlopAnim(x,y);
    fwrite(tilemap,sizeof(tilemap),1,file);
    checksum = DoChecksum((byte *)tilemap,sizeof(tilemap),checksum);
    DiskFlopAnim(x,y);

This should be inserted just above that code:
::: CODE :::
    DiskFlopAnim(x,y);
    fwrite(mapsegs[1],objplanesize,1,file);
    checksum = DoChecksum((byte *)mapsegs[1],objplanesize,checksum);

Now do a search for "SetupGameLevel". You should see this:
::: CODE :::
    DiskFlopAnim(x,y);
    SetupGameLevel ();

This should be inserted just below it:
::: CODE :::
    DiskFlopAnim(x,y);
    fread(mapsegs[1],objplanesize,1,file);
    checksum = DoChecksum((byte *)mapsegs[1],objplanesize,checksum);

You see, all the Wall Patches data is located in the 2nd Plane. What this added code does is tell the game to save and load that data with your saved game. So whenever the Wall Patches data is changed, any game you save will reflect those changes.

Okay, the way the Wolf4SDL code is written, if you change a square on the map in WL_AGENT or WL_PLAY, the game will "forget" the square is changed after it updates the screen. There's probably a better way to do this, but I do have a workaround. Go into WL_DEF.H, and do a search for "void PushWall". You should see this code:
::: CODE :::
void OpenDoor (int door);
void PlaceItemType (int itemtype, int tilex, int tiley);
void PushWall (int checkx, int checky, int dir);

Immediately below that, insert this line of code:
::: CODE :::
void MapSquareChange (int checkx, int checky, int32_t value, int PlaneNumber);


Okay, now go into WL_ACT1.CPP. Do a search for "PUSHWALLSND". You see this code:
::: CODE :::
    *(mapsegs[0]+(pwally<<mapshift)+pwallx) = *(mapsegs[0]+(player->tiley<<mapshift)+player->tilex); // set correct floorcode (BrotherTank's fix)

    SD_PlaySound (PUSHWALLSND);
}

Insert this code just below it:
::: CODE :::
// Map Square Change - change the specified square of the Objects Plane to the value you specify.
// Example:  MapSquareChange (31, 32, 255, 0) will turn square (31,32) of the map to value 255, located in Plane Zero.

void MapSquareChange (int checkx, int checky, int32_t value, int PlaneNumber)
{
     *(mapsegs[PlaneNumber]+(checky<<mapshift)+checkx) = value;
}

You now have "the power" to change any square on the map - in any map plane - to another value, and do so from *any* source CPP file in the game, without having to add "extern" commands all over the place.

Finally, go into WL_AGENT.CPP. We're about to put in the fun part of the code, where we make the Wall Patches interactive. Do a search for "pushable wall". You should see this:
::: CODE :::
        //
        // pushable wall
        //

        PushWall (checkx,checky,dir);
        return;
    }

Insert this just below that code:
::: CODE :::
    if (!buttonheld[bt_use])
       switch (*(mapsegs[1]+(checky<<mapshift)+checkx))
              {
                case 256:
                        buttonheld[bt_use] = true;
                        GiveKey (0);
                        SD_PlaySound (GETKEYSND);
                        MapSquareChange(checkx,checky,255,1);
                        StartBonusFlash ();
                        break;
              }

Now, in this example, if the Wall Patch has the value 256, the code will regard it as a Gold Key, "pick it up", and mark the Wall Patch as "used", changing the square's value to 255, so the Wall Patch can't be used again unless you "die" or warp to that same level again.

I believe that covers everything. Hope the tutorial proves useful to someone. Smile
ThunderEnema
I am Death Incarnate
I am Death Incarnate


Joined: 05 Jul 2012
Last Visit: 26 Jun 2018

Topics: 4
Posts: 194
Location: Washington
usa.gif

PostPosted: Sun Jul 15, 2012 8:36 am
   Subject: Re: [tutorial] Interactive Wall Patches in Wolf4SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Sorry to resurrect an old topic, Tricob, but where can I find Haasboy's SDL Wallpatch tutorial? I can't seem to find it anywhere on here, and Haasboy's website is down apparently. I've tried implementing Adam's wallpatch code and I can't get it to work with SDL. I would appreciate the help. Thanks! Smile

_________________
"When I see someone wearing crocs in public, I have all the information I need to know that I will never get along with that person." -Me
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 5:47 ago.

Topics: 163
Posts: 8152
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Sun Jul 15, 2012 2:52 pm
   Subject: Re: [tutorial] Interactive Wall Patches in Wolf4SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

If I'm not mistaken, this is the topic you're looking for. Smile
ThunderEnema
I am Death Incarnate
I am Death Incarnate


Joined: 05 Jul 2012
Last Visit: 26 Jun 2018

Topics: 4
Posts: 194
Location: Washington
usa.gif

PostPosted: Sun Jul 15, 2012 5:27 pm
   Subject: Re: [tutorial] Interactive Wall Patches in Wolf4SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I can't believe I missed that... Thanks again! Smile

_________________
"When I see someone wearing crocs in public, I have all the information I need to know that I will never get along with that person." -Me
Officer-Michael John
Banned
Banned


Joined: 19 Dec 2014
Last Visit: 18 Feb 2017

Topics: 66
Posts: 280

blank.gif

Currently banned
PostPosted: Mon Jul 27, 2015 12:21 pm
   Subject: Re: [tutorial] Interactive Wall Patches in Wolf4SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

And how to adding interactive door in Wolf4SDL as in Batman No Man‘s Land?
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 5:47 ago.

Topics: 163
Posts: 8152
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Mon Jul 27, 2015 5:24 pm
   Subject: Re: [tutorial] Interactive Wall Patches in Wolf4SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

You'll have to ask the programmer for permission to post that.
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> SDL 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 Announcement: Wolf4SDL released
Author: Ripper
522 195621 Mon May 22, 2017 2:04 pm
Tricob View latest post
No new posts [help] Adding teleporters in wolf4sdl
Author: Mortimer
35 9988 Fri May 26, 2017 8:19 am
Military View latest post
No new posts [WOLF4SDL Help] Blake Stone Style doors
Author: Haasboy
3 2836 Sun Jul 20, 2008 7:56 am
Haasboy View latest post
No new posts [Help] Problem with Checkweaponchange function (wolf4sdl)
Author: Mortimer
4 3026 Sat May 17, 2008 11:26 am
Mortimer View latest post
No new posts [SDL] Apply 2nd ScaleFactor to selected (hi-res) vga gfx
Author: Andy_Nonymous
9 4247 Sun Apr 27, 2008 2:30 am
AlumiuN 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