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       

Multiple moving pushwalls!
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
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 6:14 ago.

Topics: 38
Posts: 2458
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Mon Dec 07, 2009 1:13 am
   Subject: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

Here's my Christmas present to you all (even though it is two and a half weeks early). It's a little something I cooked up while playing around with the MMC a while back, but only really had the knowledge of how to make it happen about a month ago. But here we go:

MULTIPLE MOVING PUSHWALLS!!!1!

This could open the doors (or rather, walls Very Happy) to having rooms that redefine their own shape when the player moves over a trigger, or uses a switch on the wall, or on a timer, or just when the player tries to move one pushwall while another is moving. It's up to your imagination to decide how to use this functionality. Smile

In WL_ACT1.CPP, replace everything from the line:

::: CODE :::
word pwallstate;


down to the bottom of the file (i.e. the end of the MovePWalls function) with the following code:

::: CODE :::
pwall_t pwall[MAXPWALLS];
int dirs[4][2]={{0,-1},{1,0},{0,1},{-1,0}};
/*
===============
=
= PushWall
=
===============
*/

int GetFreePush(void)
{
   for (int i = 0; i < MAXPWALLS; i++)
      if (!pwall[i].active)
         return i;
   return -1;
}

void PushWall (int checkx, int checky, int dir)
{
    int oldtile, dx, dy;

   int index = GetFreePush();
   if (index == -1)
      return;

    oldtile = tilemap[checkx][checky];
    if (!oldtile)
        return;

    dx = dirs[dir][0];
    dy = dirs[dir][1];

    if (actorat[checkx+dx][checky+dy])
    {
        SD_PlaySound (NOWAYSND);
        return;
    }
    actorat[checkx+dx][checky+dy] = (objtype *)(uintptr_t) (tilemap[checkx+dx][checky+dy] = oldtile);

    gamestate.secretcount++;
    pwall[index].x = checkx;
    pwall[index].y = checky;
    pwall[index].dir = dir;
    pwall[index].state = 1;
    pwall[index].pos = 0;
    pwall[index].tile = tilemap[checkx][checky];
   pwall[index].active = true;
    tilemap[checkx][checky] = 64;
    tilemap[checkx+dx][checky+dy] = 64;
    *(mapsegs[1]+(checky<<mapshift)+checkx) = 0;   // remove P tile info
    *(mapsegs[0]+(checky<<mapshift)+checkx) = *(mapsegs[0]+(player->tiley<<mapshift)+player->tilex); // set correct floorcode (BrotherTank's fix)

    PlaySoundLocTile (PUSHWALLSND, checkx, checky);
}

/*
=================
=
= MovePWalls
=
=================
*/

void MovePWalls (void)
{
   for (int i = 0; i < MAXPWALLS; i++)
   {
       int oldblock,oldtile;

       if (!pwall[i].state || !pwall[i].active)
           continue;

       oldblock = pwall[i].state/128;

       pwall[i].state += (word)tics;

       if (pwall[i].state/128 != oldblock)
       {
           // block crossed into a new block
           oldtile = pwall[i].tile;

           //
           // the tile can now be walked into
           //
           tilemap[pwall[i].x][pwall[i].y] = 0;
           actorat[pwall[i].x][pwall[i].y] = 0;
           *(mapsegs[0]+(pwall[i].y<<mapshift)+pwall[i].x) = player->areanumber+AREATILE;

           int dx=dirs[pwall[i].dir][0], dy=dirs[pwall[i].dir][1];
           //
           // see if it should be pushed farther
           //
           if (pwall[i].state>=256)
           {
               //
               // the block has been pushed two tiles
               //
               pwall[i].state = 0;
            pwall[i].active = false;
               tilemap[pwall[i].x+dx][pwall[i].y+dy] = oldtile;
               return;
           }
           else
           {
               int xl,yl,xh,yh;
               xl = (player->x-PLAYERSIZE) >> TILESHIFT;
               yl = (player->y-PLAYERSIZE) >> TILESHIFT;
               xh = (player->x+PLAYERSIZE) >> TILESHIFT;
               yh = (player->y+PLAYERSIZE) >> TILESHIFT;

               pwall[i].x += dx;
               pwall[i].y += dy;

               if (actorat[pwall[i].x+dx][pwall[i].y+dy]
                   || xl<=pwall[i].x+dx && pwall[i].x+dx<=xh && yl<=pwall[i].y+dy && pwall[i].y+dy<=yh)
               {
                   pwall[i].state = 0;
               pwall[i].active = false;
                   tilemap[pwall[i].x][pwall[i].y] = oldtile;
                   return;
               }
               actorat[pwall[i].x+dx][pwall[i].y+dy] = (objtype *)(uintptr_t) (tilemap[pwall[i].x+dx][pwall[i].y+dy] = oldtile);
               tilemap[pwall[i].x+dx][pwall[i].y+dy] = 64;
           }
       }

       pwall[i].pos = (pwall[i].state/2)&63;
   }
}


You may be wondering where all of the variables have gone. They have been shoved into the pwall_t structure (thanks to whoever took this move in the first place, I think it was BrotherTank, because it made it a hell of a lot easier Smile ), which we shall add now.

In WL_DEF.H, replace the section:

::: CODE :::
extern word     pwallstate;
extern word     pwallpos;
extern word     pwallx,pwally;
extern byte     pwalldir,pwalltile;


with the following:

::: CODE :::
typedef struct
{
    bool     active;
    word     state;
    word     pos;        // amount a pushable wall has been moved (0-63)
    word     x;
    word     y;
    byte     dir;
    byte     tile;
} pwall_t;

#define MAXPWALLS 32

extern pwall_t  pwall[MAXPWALLS];
extern int dirs[4][2];
extern short     pw;

// Defines for the purpose of simplifying the draw loop
#define pwallstate  (pwall[pw].state)
#define pwallpos    (pwall[pw].pos)
#define pwallx      (pwall[pw].x)
#define pwally      (pwall[pw].y)
#define pwalldir    (pwall[pw].dir)
#define pwalltile   (pwall[pw].tile)


Now, in WL_DRAW.CPP, below the line:

::: CODE :::
int texdelta;


add the line:

::: CODE :::
short pw = 0;


Above the AsmRefresh function, add:

::: CODE :::
short GetCurPush(int x, int y)
{
   for (int i = 0; i < MAXPWALLS; i++)
       if ((pwall[i].x == x && pwall[i].y == y) || (pwall[i].x + dirs[pwall[i].dir][0] == x && pwall[i].y + dirs[pwall[i].dir][1] == y))
            return i;
}


Below the lines:

::: CODE :::
        if(playerInPushwallBackTile)
        {


Add the line:

::: CODE :::
            pw = GetCurPush(focaltx, focalty);


Now, within the AsmRefresh functions, there will be two instances of the lines:

::: CODE :::
                    if(tilehit==64)
                    {


If you're using Chris's lots and lots of walls tutorial, this line will look different (I think), but it will be followed by 'if(pwalldir==di_west || pwalldir==di_east)' or something to that effect.

Below the first one of these, add:

::: CODE :::
                        pw = GetCurPush(xspot>>mapshift, xspot&0x3F);


And below the second, add:

::: CODE :::
                        pw = GetCurPush(yspot>>mapshift, yspot&0x3F);


Now, in the WallRefresh function (it doesn't matter where), add the line:

::: CODE :::
pw = 0;


In WL_AGENT.CPP, just above the TryMove function, add the following line:

::: CODE :::
int pdirs[4][2]={{0,-1},{1,0},{0,1},{-1,0}};


Now, in the TryMove function, below the lines:

::: CODE :::
            if (check && !ISPOINTER(check))
            {


Add the lines:

::: CODE :::
                for (int i = 0; i < MAXPWALLS; i++)
                   if ((pwall[i].x == x && pwall[i].y == y) || (pwall[i].x + dirs[pwall[i].dir][0] == x && pwall[i].y + dirs[pwall[i].dir][1] == y))
                    {
                        pw = i;
                        break;
                    }


In WL_GAME.CPP, in the SetupGameLevel, replace the line:

::: CODE :::
            = pwallstate = pwallpos = facetimes = 0;


With the lines:

::: CODE :::
            = facetimes = 0;
            for (int i = 0; i < MAXPWALLS; i++)
            {
                pwall[i].active = false;
                pwall[i].state = 0;
                pwall[i].pos = 0;
            }


In the Died function, replace the line:

::: CODE :::
        pwallstate = pwallpos = 0;


With the lines:

::: CODE :::
        for (int i = 0; i < MAXPWALLS; i++)
        {
            pwall[i].active = false;
            pwall[i].state = 0;
            pwall[i].pos = 0;
        }


In WL_MAIN.CPP, in the SaveTheGame function, replace the lines:

::: CODE :::
    fwrite (&pwallstate,sizeof(pwallstate),1,file);
    checksum = DoChecksum((byte *)&pwallstate,sizeof(pwallstate),checksum);
    fwrite (&pwalltile,sizeof(pwalltile),1,file);
    checksum = DoChecksum((byte *)&pwalltile,sizeof(pwalltile),checksum);
    fwrite (&pwallx,sizeof(pwallx),1,file);
    checksum = DoChecksum((byte *)&pwallx,sizeof(pwallx),checksum);
    fwrite (&pwally,sizeof(pwally),1,file);
    checksum = DoChecksum((byte *)&pwally,sizeof(pwally),checksum);
    fwrite (&pwalldir,sizeof(pwalldir),1,file);
    checksum = DoChecksum((byte *)&pwalldir,sizeof(pwalldir),checksum);
    fwrite (&pwallpos,sizeof(pwallpos),1,file);
    checksum = DoChecksum((byte *)&pwallpos,sizeof(pwallpos),checksum);


With the lines:

::: CODE :::
    fwrite (&pwall,sizeof(pwall),1,file);
    checksum = DoChecksum((byte *)&pwall,sizeof(pwall),checksum);


And in the LoadTheGame function, replace the lines:

::: CODE :::
    fread (&pwallstate,sizeof(pwallstate),1,file);
    checksum = DoChecksum((byte *)&pwallstate,sizeof(pwallstate),checksum);
    fread (&pwalltile,sizeof(pwalltile),1,file);
    checksum = DoChecksum((byte *)&pwalltile,sizeof(pwalltile),checksum);
    fread (&pwallx,sizeof(pwallx),1,file);
    checksum = DoChecksum((byte *)&pwallx,sizeof(pwallx),checksum);
    fread (&pwally,sizeof(pwally),1,file);
    checksum = DoChecksum((byte *)&pwally,sizeof(pwally),checksum);
    fread (&pwalldir,sizeof(pwalldir),1,file);
    checksum = DoChecksum((byte *)&pwalldir,sizeof(pwalldir),checksum);
    fread (&pwallpos,sizeof(pwallpos),1,file);
    checksum = DoChecksum((byte *)&pwallpos,sizeof(pwallpos),checksum);


With the lines:

::: CODE :::
    fread (&pwall,sizeof(pwall),1,file);
    checksum = DoChecksum((byte *)&pwall,sizeof(pwall),checksum);


And there we go - you now have the ability to move 32 pushwalls at once. If you want to be able to move more at once, just change the MAXPWALLS define in WL_DEF.H. Note that moving a pushwall remains the same - just call PushWall with the x,y coordinate and the direction. Smile Also note that you will need to rebuild your whole project after this, or things may start going badly wrong. Razz


Last edited by AlumiuN on Sun Jun 22, 2014 6:18 pm; edited 4 times in total
ronwolf1705
Moderator
<B>Moderator</B>


Joined: 31 Jul 2006
Last Visit: 2:27 ago.

Topics: 72
Posts: 3750

blank.gif

PostPosted: Mon Dec 07, 2009 5:38 am
   Subject: Re: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Sounds like a pretty great idea! Smile And I imagine it would be cool to just walk over a trigger and suddenly the room takes another shape. Nice code. Smile
Haasboy
DieHard Officer
DieHard Officer


Joined: 23 Jul 2003
Last Visit: 16 Feb 2018

Topics: 58
Posts: 581
Location: South Africa, Johannesburg
southafrica.gif

PostPosted: Mon Dec 07, 2009 11:49 am
   Subject: My (early) Christmas present...
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

This is a great idea...and it adds a lot...

the only problem is I had to add "short pw = 0;" to WL_AGENT.CPP cos it gave the error regarding the one point of the code...but it still doesn't compile, cos it tells me that I then have multiple pw declared...

Take note that I'm using this code with Chris's MAXWALL code!!!



EDIT: This doesn't even compile on a clean source...
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 6:14 ago.

Topics: 38
Posts: 2458
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Mon Dec 07, 2009 1:53 pm
   Subject: Re: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Yeah, if you're using Chris's MAXWALL code it will need some other bits and pieces added to it. I'll take a look at it in the next couple of days. Smile You can try yourself if you want - all of the old pwallstate, etc. variables are now defined as pwall[pw].state, etc. I only did this to stop myself from having to rewrite the whole draw loop with the new table.

EDIT: Ok, Chris's code doesn't change anything that mine does - but you might want to change pwalltile in the pwall_t struct to a word. I might have missed something - what sort of compilation error do you get?
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

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

PostPosted: Mon Dec 07, 2009 4:17 pm
   Subject: Re: My (early) Christmas present...
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

AlumiuN wrote:
You may be wondering where all of the variables have gone. They have been shoved into the pwall_t structure (thanks to whoever took this move in the first place, I think it was BrotherTank, because it made it a hell of a lot easier Smile ), which we shall add now.


Yep.. it's one of the many things I did in the bunker source... lol.. Thanks for giving the shoutout... I wondered when someone would pickup on this and realize the potential... oh well.. there goes one of the secret ideas in my work with Areyep... lol....

Greg
BrotherTank
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

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

PostPosted: Mon Dec 07, 2009 4:18 pm
   Subject: Re: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Haasboy:

In the wl_def.h file... add the line:

extern short pw;

anywhere... and then you will have no problems compiling it..

Greg
BrotherTank
Haasboy
DieHard Officer
DieHard Officer


Joined: 23 Jul 2003
Last Visit: 16 Feb 2018

Topics: 58
Posts: 581
Location: South Africa, Johannesburg
southafrica.gif

PostPosted: Mon Dec 07, 2009 7:49 pm
   Subject: My (early) Christmas present...
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Thanks BT...it works now...

_________________
Haasboy Engine - Currently under construction (To be used with future mods - F.A.D.E.D. - Mansion X - Rising Evil Series)
Tricob
Moderator
<B>Moderator</B>


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

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

PostPosted: Mon Dec 07, 2009 8:54 pm
   Subject: Re: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Good work, AlumiuN. This definitely open the "walls" to new features for the game, not least of which are those "wall crushers" in Hexen. I probably won't use this tutorial in WolfDX, but putting it in its follow-up is always possible; not much of that is written in stone. Smile
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 6:14 ago.

Topics: 38
Posts: 2458
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Tue Dec 08, 2009 12:56 am
   Subject: Re: My (early) Christmas present...
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

BrotherTank wrote:
AlumiuN wrote:
You may be wondering where all of the variables have gone. They have been shoved into the pwall_t structure (thanks to whoever took this move in the first place, I think it was BrotherTank, because it made it a hell of a lot easier Smile ), which we shall add now.


Yep.. it's one of the many things I did in the bunker source... lol.. Thanks for giving the shoutout... I wondered when someone would pickup on this and realize the potential... oh well.. there goes one of the secret ideas in my work with Areyep... lol....

Greg
BrotherTank


Lol, sorry. I knew someone else would have come up with something like this by now. Very Happy Also, thanks for the fix. I originally had it just as a local variable in the TryMove function, but I forgot about it when writing the tutorial. I'll add it to the tutorial. Smile
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

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

PostPosted: Tue Dec 08, 2009 2:12 am
   Subject: Re: My (early) Christmas present...
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

AlumiuN wrote:
Lol, sorry. I knew someone else would have come up with something like this by now. Very Happy Also, thanks for the fix. I originally had it just as a local variable in the TryMove function, but I forgot about it when writing the tutorial. I'll add it to the tutorial. Smile


Hey No problem... There'll be other ideas and such when I give the engine to Steve...

I did a lot of little things in that source.... and I knew it was only time until someone caught onto them and saw the potential... Laughing.. I have a habit of reworking the source (even the SDL) to try and make it more compressed and more efficient. In doing so, I flip back and forth to working in ideas... but when I released the last version of it, I included many of the compressed routines and ideas, but dropped the functions that might call them.. lol.

So you might see some areas of code that aren't even used in the game... You might not.. it's been ages since I was tinkering with that directory on my HD... so I'm not 100% on what's in there, but I do remember some things specific and this was one of them.

Greg
BrotherTank
Haasboy
DieHard Officer
DieHard Officer


Joined: 23 Jul 2003
Last Visit: 16 Feb 2018

Topics: 58
Posts: 581
Location: South Africa, Johannesburg
southafrica.gif

PostPosted: Fri Dec 11, 2009 11:43 pm
   Subject: Re: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

How would I use this with BT switch Activated Pushwalls code, cos when I add it to the code, it only pushes one of the four walls that I'd have set to move once activated, and it's always the same wall - It doesn't move all the walls????

_________________
Haasboy Engine - Currently under construction (To be used with future mods - F.A.D.E.D. - Mansion X - Rising Evil Series)
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 6:14 ago.

Topics: 38
Posts: 2458
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Tue Dec 15, 2009 12:24 am
   Subject: Re: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

That'll require some large modifications to work. You'll probably have to traverse through the whole map checking for certain pushwall objects and moving them in the required direction. I plan to implement this one myself, so I'll have some code at some point. Smile
KyleRTCW
DieHard Officer
DieHard Officer


Joined: 30 Jul 2003
Last Visit: 30 May 2018

Topics: 45
Posts: 510
Location: Ohio
usa.gif

PostPosted: Sun May 22, 2011 11:39 am
   Subject: Re: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Does any know how to get this code to work so that pushwalls are viewable from all angles?
With only one pushwall, the push wall variables were global, but now pushwall information gathered on the fly with "pw= GetCurPushwall([x/y]spot<<mapshift,[x/y]spot&(MAPSIZE-1))"

I've been trying different things with it but most of the raycaster stuff is over my head at the moment.

_________________
Steam: http://steamcommunity.com/id/stormx312
KyleRTCW
DieHard Officer
DieHard Officer


Joined: 30 Jul 2003
Last Visit: 30 May 2018

Topics: 45
Posts: 510
Location: Ohio
usa.gif

PostPosted: Wed May 25, 2011 10:17 am
   Subject: My (early) Christmas present...
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Figured out how to make all pushwalls viewable from all angles, was a lot simpler than I thought at first. There is one very minor graphical glitch when standing in a BIT_WALL tile (players can stand in BIT_WALL tiles since they can tailgate pushwalls instead of waiting for the entire block to leave the tile like in the original wolf). When I get the time, I'll try and see if I can fix that.

Before you start: implement Chris's MAXWALLTILE/MAXDOOR limitation removal if you haven't already (though it's possible without doing so).

In WL_DEF.H:
::: CODE :::
#define WALLSHIFT       10

#define BIT_WALL        (1<<WALLSHIFT)
#define BIT_DOOR        (1<<(WALLSHIFT+1))
#define BIT_ALLTILES    (1<<(WALLSHIFT+2))
#define LAST_WALLNUM    BIT_WALL-5
#define LAST_DOORNUM    BIT_DOOR-1

// NOTE: these will take up "wall tiles"
#define MOVINGIN_N BIT_WALL-1
#define MOVINGIN_S BIT_WALL-2
#define MOVINGIN_E BIT_WALL-3
#define MOVINGIN_W BIT_WALL-4



In WL_ACT1.CPP:
::: CODE :::


void PushWall (int checkx, int checky, int dir)
{
    int oldtile, dx, dy;

   int index = GetFreePush();
   if (index == -1)
      return;

    oldtile = tilemap[checkx][checky];
    if (!oldtile)
        return;

    dx = dirs[dir][0];
    dy = dirs[dir][1];

    if (actorat[checkx+dx][checky+dy])
    {
        SD_PlaySound (NOWAYSND);
        return;
    }
    actorat[checkx+dx][checky+dy] = (objtype *)(uintptr_t) (tilemap[checkx+dx][checky+dy] = oldtile);

    gamestate.secretcount++;
    pwall[index].x = checkx;
    pwall[index].y = checky;
    pwall[index].dir = dir;
    pwall[index].state = 1;
    pwall[index].pos = 0;
    pwall[index].tile = tilemap[checkx][checky];
   pwall[index].active = true;
    tilemap[checkx][checky] = BIT_WALL;
    //tilemap[checkx+dx][checky+dy] = BIT_WALL;
    switch (dir) {
    case NORTH:
        tilemap[checkx+dx][checky+dy] = MOVINGIN_N;
        break;
    case EAST:
        tilemap[checkx+dx][checky+dy] = MOVINGIN_E;
        break;
    case SOUTH:
        tilemap[checkx+dx][checky+dy] = MOVINGIN_S;
        break;
    case WEST:
        tilemap[checkx+dx][checky+dy] = MOVINGIN_W;
        break;
    }


    *(mapsegs[1]+(checky<<mapshift)+checkx) = 0;   // remove P tile info
    *(mapsegs[0]+(checky<<mapshift)+checkx) = *(mapsegs[0]+(player->tiley<<mapshift)+player->tilex); // set correct floorcode (BrotherTank's fix)

    PlaySoundLocTile (PUSHWALLSND, checkx, checky);
}

/*
=================
=
= MovePWalls
=
=================
*/

void MovePWalls (void)
{
   for (int i = 0; i < MAXPWALLS; i++)
   {
       int oldblock,oldtile;

       if (!pwall[i].state || !pwall[i].active)
           continue;

       oldblock = pwall[i].state/128;

       pwall[i].state += (word)tics;

       if (pwall[i].state/128 != oldblock)
       {
           // block crossed into a new block
           oldtile = pwall[i].tile;

           //
           // the tile can now be walked into
           //
           tilemap[pwall[i].x][pwall[i].y] = 0;
           actorat[pwall[i].x][pwall[i].y] = 0;
           *(mapsegs[0]+(pwall[i].y<<mapshift)+pwall[i].x) = player->areanumber+AREATILE;

           int dx=dirs[pwall[i].dir][0], dy=dirs[pwall[i].dir][1];
           //
           // see if it should be pushed farther
           //
           if (pwall[i].state>=256) // 384 for 3 tiles
           {
               //
               // the block has been pushed two tiles
               //
               pwall[i].state = 0;
            pwall[i].active = false;
               tilemap[pwall[i].x+dx][pwall[i].y+dy] = oldtile;
               return;
           }
           else
           {
               int xl,yl,xh,yh;
               xl = (player->x-PLAYERSIZE) >> TILESHIFT;
               yl = (player->y-PLAYERSIZE) >> TILESHIFT;
               xh = (player->x+PLAYERSIZE) >> TILESHIFT;
               yh = (player->y+PLAYERSIZE) >> TILESHIFT;

               pwall[i].x += dx;
               pwall[i].y += dy;

               if (actorat[pwall[i].x+dx][pwall[i].y+dy]
                   || xl<=pwall[i].x+dx && pwall[i].x+dx<=xh && yl<=pwall[i].y+dy && pwall[i].y+dy<=yh)
               {
                   pwall[i].state = 0;
               pwall[i].active = false;
                   tilemap[pwall[i].x][pwall[i].y] = oldtile;
                   return;
               }
               tilemap[pwall[i].x][pwall[i].y] = BIT_WALL;
               actorat[pwall[i].x+dx][pwall[i].y+dy] = (objtype *)(uintptr_t) (tilemap[pwall[i].x+dx][pwall[i].y+dy] = oldtile);
               //tilemap[pwall[i].x+dx][pwall[i].y+dy] = BIT_WALL;
               
                switch(pwall[i].dir) {
                    case NORTH:
                        tilemap[pwall[i].x+dx][pwall[i].y+dy] = MOVINGIN_N;
                        break;
                    case EAST:
                        tilemap[pwall[i].x+dx][pwall[i].y+dy] = MOVINGIN_E;
                        break;
                    case SOUTH:
                        tilemap[pwall[i].x+dx][pwall[i].y+dy] = MOVINGIN_S;
                        break;
                    case WEST:
                        tilemap[pwall[i].x+dx][pwall[i].y+dy] = MOVINGIN_W;
                        break;
                }

           }
       }

       pwall[i].pos = (pwall[i].state/2)&63;
   }
}


In WL_DRAW.CPP:
In void Asm_Refresh()

Under the first instance of
  
if(tilehit == BIT_WALL)
you should have added
  
pw = GetCurPush(xspot >> mapshift, xspot & (MAPSIZE - 1));
Replace that line with this block of code:
::: CODE :::
                        switch (tilehit) {
                        case MOVINGIN_N:
                            pw = GetCurPush(xspot >> mapshift, (xspot & (MAPSIZE-1)) + 1);
                            break;
                        case MOVINGIN_S:
                            pw = GetCurPush(xspot >> mapshift, (xspot & (MAPSIZE-1)) - 1);
                            break;
                        case MOVINGIN_W:
                            pw = GetCurPush((xspot >> mapshift) + 1, xspot & (MAPSIZE-1));
                            break;
                        case MOVINGIN_E:
                            pw = GetCurPush((xspot >> mapshift) - 1, xspot & (MAPSIZE-1));
                            break;
                        case BIT_WALL:
                            pw = GetCurPush(xspot >> mapshift, xspot & (MAPSIZE-1));
                            break;
                        }


Under the second instance of
  
if(tilehit == BIT_WALL)
you should have added
  
pw = GetCurPush(yspot >> mapshift, yspot & (MAPSIZE - 1));
Replace that line with this block of code:
::: CODE :::
                        switch (tilehit) {
                            case MOVINGIN_N:
                                pw = GetCurPush(yspot >> mapshift, (yspot & (MAPSIZE-1)) + 1);
                                break;
                            case MOVINGIN_S:
                                pw = GetCurPush(yspot >> mapshift, (yspot & (MAPSIZE-1)) - 1);
                                break;
                            case MOVINGIN_W:
                                pw = GetCurPush((yspot >> mapshift) + 1, yspot & (MAPSIZE-1));
                                break;
                            case MOVINGIN_E:
                                pw = GetCurPush((yspot >> mapshift) - 1, yspot & (MAPSIZE-1));
                                break;
                            case BIT_WALL:
                                pw = GetCurPush(yspot >> mapshift, yspot & (MAPSIZE-1));
                                break;
                        }


Finally, find both instances of
  
if (tilehit == BIT_WALL)
in Asm_Refresh and replace them with
  
if (tilehit >= MOVINGIN_W && tilehit <= BIT_WALL)

All done Smile

_________________
Steam: http://steamcommunity.com/id/stormx312
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 6:14 ago.

Topics: 38
Posts: 2458
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Wed Dec 04, 2013 12:08 am
   Subject: Re: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I've just been looking at this again and noticed the issue with multiple pushwalls having issues if they're moving different directions (I don't know how I missed it, ffs), but thankfully there's a quick an easy fix. Replace the GetCurPush function in wl_draw.cpp with this:

::: CODE :::
short GetCurPush(int x, int y)
{
   for (int i = 0; i < MAXPWALLS; i++)
       if ((pwall[i].x == x && pwall[i].y == y) || (pwall[i].x + dirs[pwall[i].dir][0] == x && pwall[i].y + dirs[pwall[i].dir][1] == y))
            return i;
}


And add the line:

::: CODE :::
extern int dirs[4][2];


to wl_def.h, preferably just under the line 'extern pwall_t pwall[MAXPWALLS];'.

It's a little easier than Kyle's fix, and doesn't require a bunch of tilemap codes. Having said that, I haven't noticed the graphical glitch when the player is standing in a pushwall's back tile, I'll keep looking and see what I can find.
linuxwolf
I am Death Incarnate
I am Death Incarnate


Joined: 16 Oct 2012
Last Visit: 10 Jun 2018

Topics: 6
Posts: 171


PostPosted: Sun Dec 15, 2013 3:57 pm
   Subject: Re: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I would like to use this feature in a mod I'm working on. Can someone please upload full source zip for me? I want to download and look through the source without following the tutorial. Thanks!
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 6:14 ago.

Topics: 38
Posts: 2458
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Sun Dec 15, 2013 4:03 pm
   Subject: Re: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I'll go get a fresh copy of the source and stick it in. Smile

EDIT: Here you go Smile Everything I've changed has the #define ALUMULTIPUSH around it.
linuxwolf
I am Death Incarnate
I am Death Incarnate


Joined: 16 Oct 2012
Last Visit: 10 Jun 2018

Topics: 6
Posts: 171


PostPosted: Sun Dec 15, 2013 6:46 pm
   Subject: Re: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

The zip seems to be corrupted. Can you make another one? Thanks.

In the mean time I keep reading the tutorial. I have a question. In GetCurPush() you don't explicitly return a value if no push wall is found and you don't check the state of push walls before returning their index. Do you have any comment about that?
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 6:14 ago.

Topics: 38
Posts: 2458
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Sun Dec 15, 2013 7:29 pm
   Subject: Re: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

The zip opens fine for me. What are you using to open it?

As for the GetCurPush() function, it should always find a pushwall, if it doesn't then the tilemap is wrong (as pushwalls are always indicated on the tilemap) and you'll probably have bigger issues than it not finding a pushwall Razz
linuxwolf
I am Death Incarnate
I am Death Incarnate


Joined: 16 Oct 2012
Last Visit: 10 Jun 2018

Topics: 6
Posts: 171


PostPosted: Sun Dec 15, 2013 8:04 pm
   Subject: Re: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I added your code to my mod and it works! Thank you.
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 6:14 ago.

Topics: 38
Posts: 2458
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Sun Dec 15, 2013 8:17 pm
   Subject: Re: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

No problem. Smile
linuxwolf
I am Death Incarnate
I am Death Incarnate


Joined: 16 Oct 2012
Last Visit: 10 Jun 2018

Topics: 6
Posts: 171


PostPosted: Mon Dec 16, 2013 5:03 pm
   Subject: Re: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Hey. I haven't tried this yet but does the engine draw correctly when two push walls are moving together side-by-side and in the same direction? Thanks!

FYI you have been added to the programmer credits in one of our mods.
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 6:14 ago.

Topics: 38
Posts: 2458
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Mon Dec 16, 2013 5:19 pm
   Subject: Re: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Yeah, definitely. The only issue I've had in the past is looking at the front of a pushwall moving a different direction from the first, and the fix I posted not long ago (which is included in the code I gave you) should fix that issue too.
linuxwolf
I am Death Incarnate
I am Death Incarnate


Joined: 16 Oct 2012
Last Visit: 10 Jun 2018

Topics: 6
Posts: 171


PostPosted: Mon Dec 16, 2013 6:14 pm
   Subject: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

And those moving walls were one right next to each other? It isn't working for us.

We can live without this feature for now. I just thought I'd let you know in case you had time to work on it.
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 6:14 ago.

Topics: 38
Posts: 2458
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Mon Dec 16, 2013 6:15 pm
   Subject: Re: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Hmm, that's not good. Feel free to email your code if you want me to take a look, I have plenty of time Smile
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 6:14 ago.

Topics: 38
Posts: 2458
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Mon May 12, 2014 3:05 am
   Subject: Re: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

OK, sorry to bring this thread up again but I have a small fix. Find the line in WL_AGENT.CPP:

::: CODE :::
for (int i = 0; i < MAXPWALLS; i++)


And change it and the line below it to this:

::: CODE :::
if (((pwall[i].x == x && pwall[i].y == y) || (pwall[i].x + dirs[pwall[i].dir][0] == x && pwall[i].y + dirs[pwall[i].dir][1] == y))


I recently found this bug when turning on compiler optimization for the MMC, and I'm absolutely amazed that it didn't cause crashes when you moved against the front end of a moving pushwall.
Officer-Michael John
Banned
Banned


Joined: 19 Dec 2014
Last Visit: 18 Feb 2017

Topics: 66
Posts: 280

blank.gif

Currently banned
PostPosted: Tue Dec 30, 2014 1:17 pm
   Subject: Re: Multiple moving pushwalls!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

What good multiple pushwall code?
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 Sticky: [Tutorial] Compiling Wolf4SDL with Code::Blocks
Author: dcbasic
90 22249 Wed May 24, 2017 7:53 pm
Falcon*93 View latest post
No new posts [WOLF4SDL Help] Blake Stone Style doors
Author: Haasboy
3 2775 Sun Jul 20, 2008 7:56 am
Haasboy View latest post
No new posts [SDL-Help] Wall patches fix
Author: insurrectionman
0 1078 Tue Jul 15, 2008 11:12 am
insurrectionman View latest post
No new posts [Wolf4SDL Help] Inserting a second palette (like in SoD)
Author: Andy_Nonymous
10 2992 Mon Jun 02, 2008 3:59 pm
Adam Biser View latest post
No new posts [Help] Problem with Checkweaponchange function (wolf4sdl)
Author: Mortimer
4 2946 Sat May 17, 2008 11:26 am
Mortimer 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