Author |
Message |
allthisandwolf3d
Bring 'em On

Joined: 14 Mar 2007
Last Visit: 01 Mar 2016
Topics: 13
Posts: 77
Location: USA

|
Posted: Sat Mar 31, 2007 7:45 pm
Subject: moving objects
[ IP : Logged ]
|

 
|
|
ok i seriously do not know if any of you have heard this before but..
what if you make an object a pushwall?
if this is a new idea, then that means if i do that in my wolf3d nobody can find the secret level
anyways the animation of the object would be like it sliding. like for example, i push a vase, and the vase slides back. or kaybe a bookshelf slides sideways.
i have another idea. what if you make it so a pushwall can only be pushed in 1 way? like a pushwall that can only be pushed from north to south. or west to east. this i think will make secrets harder to find. |
_________________ Don'cha wish your username was hot like mine?
|
|
 |
insurrectionman
DieHard Mutant


Joined: 07 May 2005
Last Visit: 04 Feb 2019
Topics: 87
Posts: 759
Location: Wisconsin

|
Posted: Sun Apr 01, 2007 6:26 am
Subject: Re: moving objects
[ IP : Logged ]
|

  
|
|
That seems very interesting, I would also imagine like a super-kick and kick objects towards enemies. If you look at the pushwall code, make a new function with that, and somehow add an object to that. I could look at something like that and see how far I get. Very interesting idea, though. |
_________________ I'm back! I missed this community!
Youtube Channel: TreeSapThief
New Site: http://www.treesapthief.com
Twitter: @treesapthief
|
|
 |
WLHack
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 18 Jan 2018
Topics: 66
Posts: 1241
Location: Loppi - Finland

|
Posted: Sun Apr 01, 2007 9:23 am
Subject: Re: moving objects
[ IP : Logged ]
|

  
|
|
Ehe, I made small test with this...
Result:
Barrel before pressing space:
And after that:
Though there is still few bugs:
*Barrel moves only to one direction,
*To the barrels original spot, invisible blocking tile is spawned,
*Barrel ain't visible in all directions,
*Barrel won't stop when it hits walls or other static object. |
_________________ False Spear download
False Spear SDL download
Wolfenstein-blog
|
|
 |
allthisandwolf3d
Bring 'em On

Joined: 14 Mar 2007
Last Visit: 01 Mar 2016
Topics: 13
Posts: 77
Location: USA

|
|
 |
WLHack
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 18 Jan 2018
Topics: 66
Posts: 1241
Location: Loppi - Finland

|
Posted: Sun Apr 08, 2007 11:35 am
Subject: Re: moving objects
[ IP : Logged ]
|

  
|
|
Corrected bugs:
*Barrel can now be moved in all directions
*Barrel is now visible in every direction...
*Barrel stops to a walls... Other objects causes still proplems. |
_________________ False Spear download
False Spear SDL download
Wolfenstein-blog
|
|
 |
Codetech84
Code Master

Joined: 12 Mar 2003
Last Visit: 27 Aug 2018
Topics: 22
Posts: 1284
Location: Rauma - Finland

|
|
 |
WLHack
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 18 Jan 2018
Topics: 66
Posts: 1241
Location: Loppi - Finland

|
|
 |
Codetech84
Code Master

Joined: 12 Mar 2003
Last Visit: 27 Aug 2018
Topics: 22
Posts: 1284
Location: Rauma - Finland

|
|
 |
BrotherTank
Forum Administrator

Joined: 01 Mar 2003
Last Visit: 13 Sep 2017
Topics: 153
Posts: 2255
Location: Ontario

|
Posted: Sun Apr 08, 2007 12:55 pm
Subject: Re: moving objects
[ IP : Logged ]
|

  
|
|
WL_Hack:
I've got an idea for you and I think most of the code could be done in the CMD_Use function in wl_agent.c.
And instead of having it slide until it reaches a wall... have it move 1 tile at a time - each time the player pushes it. That's more realistic.
When I was able to work at my last job, we constantly received these 45 gallon drums of either resin or isocyanate... and the weight on these things is around 500lbs+ (varied slightly as to the level of fill - usually within 496 to 503lbs. + the weight of the drum itself (drums varied by design and material) but were usually in the 10 to 20lbs range). I can tell you that a 180lbs man (me) could push and slide them at most an arms length at a time. (as a millwright I wasn't a superhero, but I wasn't weak either). Even when empty, the drums (aka barrels) wouldn't slide say more than 3 feet because of the design of them and the physics involved (friction).
So to be honest, the best thing that you could code to be realistic would be move 1 space at a time as pushed each time by the player - providing there is nothing else in the way - blocking the movement. Pushwalls in the game are something completely different in the sense that they are man-made to slide and created to hide something. I think of them more as like trap doors and hinged panels that you would see in the old horror type movies.
Just my thoughts...
Greg
BrotherTank |
|
|
 |
WLHack
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 18 Jan 2018
Topics: 66
Posts: 1241
Location: Loppi - Finland

|
Posted: Sun Apr 08, 2007 1:17 pm
Subject: Re: moving objects
[ IP : Logged ]
|

  
|
|
Heh... Strange that you mentioned it Greg...
Simce all of my code is infact in CMD_USE and it only moves 1 tile at time.
And player can keep pushing it until it hits wall or etc. |
_________________ False Spear download
False Spear SDL download
Wolfenstein-blog
|
|
 |
WLHack
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 18 Jan 2018
Topics: 66
Posts: 1241
Location: Loppi - Finland

|
Posted: Mon Apr 09, 2007 1:58 am
Subject: Re: moving objects
[ IP : Logged ]
|

  
|
|
Hmm... Update (thanks to Codetech for helping out with few things)...
Currently all bugs seem to be fixed (I need still to test it around).
Though I didn't add support for cardinal directions... But I think it will be easy to
add after you see the code...
I am hoping that (if nothing happens) I could post it here at evening. |
_________________ False Spear download
False Spear SDL download
Wolfenstein-blog
|
|
 |
WLHack
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 18 Jan 2018
Topics: 66
Posts: 1241
Location: Loppi - Finland

|
Posted: Mon Apr 09, 2007 3:15 am
Subject: Re: moving objects
[ IP : Logged ]
|

  
|
|
Okay... Here is the working code (based on Dugtrios tutorial)...
Its a bit memory wasting and I bet there is many ways to optimize it
but here it is anyway...
Okay... Now lets start (I used SPR_STAT_1 aka. Green barrel as an
example).
Open WL_Agent.C and go to the Cmd_Use - function...
There under "boolean elevatorok" add this line:
::: CODE :::
statobj_t *statptr;
Now scroll down a bit more until you see these lines:
::: CODE :::
doornum = tilemap[checkx][checky];
if (*(mapsegs[1]+farmapylookup[checky]+checkx) == PUSHABLETILE)
{
//
// pushable wall
//
PushWall (checkx,checky,dir);
return;
}
Now directly under them add these lines:
::: CODE :::
for(statptr = &statobjlist[0]; statptr != laststatobj; statptr++)
{
//Check the sprite:
if(statptr->tilex == checkx && statptr->tiley == checky &&
statptr->shapenum == SPR_STAT_1 && !buttonheld[bt_use])
{
buttonheld[bt_use] = true;
//Check direction of movement (corrected directions)
switch(dir)
{
case di_north:
if((unsigned)actorat[checkx][checky-1] == 1) // Check if new tile is free
return;
check = actorat[checkx][checky-1]; // Check for walls
if (check && check<objlist)
return;
statptr->tiley = checky-1; //Move object north
statptr->visspot = &spotvis[checkx][checky-1];
(unsigned)actorat[checkx][checky] = 0; //Make old tile unblocking...
(unsigned)actorat[checkx][checky-1] = 1; //...And new one blocking
break;
case di_east:
if((unsigned)actorat[checkx+1][checky] == 1)
return;
check = actorat[checkx+1][checky];
if (check && check<objlist)
return;
statptr->tilex = checkx+1; //Move object east
statptr->visspot = &spotvis[checkx+1][checky];
(unsigned)actorat[checkx][checky] = 0;
(unsigned)actorat[checkx+1][checky] = 1;
break;
case di_south:
if((unsigned)actorat[checkx][checky+1] == 1)
return;
check = actorat[checkx][checky+1];
if (check && check<objlist)
return;
statptr->tiley = checky+1; //Move object south
statptr->visspot = &spotvis[checkx][checky+1];
(unsigned)actorat[checkx][checky] = 0;
(unsigned)actorat[checkx][checky+1] = 1;
break;
case di_west:
if((unsigned)actorat[checkx-1][checky] == 1)
return;
check = actorat[checkx-1][checky];
if (check && check<objlist)
return;
statptr->tilex = checkx-1; //Move object west
statptr->visspot = &spotvis[checkx-1][checky];
(unsigned)actorat[checkx][checky] = 0;
(unsigned)actorat[checkx-1][checky] = 1;
break;
case nodir:
return;
}
// This is optional:
// gamestate.secretcount++;
// SD_PlaySound (PUSHWALLSND);
}
}
Now... Thats is the all code you need (or atleast I don't remember adding any extra code)...
BTW: When you select the object you want to be movable, make sure that it isn't defined
as a "bo_" in WL_Act1.C...
And if you are going to use non-blocking objects, remember to comment out the lines defining
that the new tile is blocking (also the line defining that the old tile is unblocking is useless in
that case an can be commented out)... |
_________________ False Spear download
False Spear SDL download
Wolfenstein-blog
Last edited by WLHack on Tue Apr 10, 2007 2:30 am; edited 1 time in total
|
|
 |
ronwolf1705
Moderator

Joined: 31 Jul 2006
Last Visit: 7:05 ago.
Topics: 74
Posts: 3812

|
Posted: Mon Apr 09, 2007 5:12 am
Subject: Re: moving objects
[ IP : Logged ]
|

  
|
|
This is great! Everything works fine, I haven't encountered any bugs so far. This could be used for some interesting level design. |
|
|
 |
ronwolf1705
Moderator

Joined: 31 Jul 2006
Last Visit: 7:05 ago.
Topics: 74
Posts: 3812

|
Posted: Mon Apr 09, 2007 7:15 am
Subject: Re: moving objects
[ IP : Logged ]
|

  
|
|
Can this also be used for guards, so that you can push guards away? |
|
|
 |
WLHack
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 18 Jan 2018
Topics: 66
Posts: 1241
Location: Loppi - Finland

|
|
 |
BrotherTank
Forum Administrator

Joined: 01 Mar 2003
Last Visit: 13 Sep 2017
Topics: 153
Posts: 2255
Location: Ontario

|
Posted: Mon Apr 09, 2007 8:49 pm
Subject: moving objects
[ IP : Logged ]
|

  
|
|
Actually WL_Hack.. Here's what I was using..
::: CODE :::
char dx4dir[4]={ 0, 1, 0, -1 }; // dx & dy based on direction
char dy4dir[4]={-1, 0, 1, 0 };
/* ================= Cmd_Use ================ */
void Cmd_Use (void)
{
objtype *check;
int checkx,checky,doornum,dir;
#ifndef ELEVFIX
boolean elevatorok;
#endif
#ifdef GAMEMSGSOBJECT
statobj_t *statptr;
#endif
#ifdef TREASURECHEST
byte chestresult;
#endif
// find which cardinal direction the player is facing
if (player->angle < ANGLES/8 || player->angle > 7*ANGLES/8)
{
dir = di_east;
#ifndef ELEVFIX
elevatorok = true;
#endif
}
else if (player->angle < 3*ANGLES/8)
{
dir = di_north;
#ifndef ELEVFIX
elevatorok = false;
#endif
}
else if (player->angle < 5*ANGLES/8)
{
dir = di_west;
#ifndef ELEVFIX
elevatorok = true;
#endif
}
else
{
dir = di_south;
#ifndef ELEVFIX
elevatorok = false;
#endif
}
checkx = player->tilex + dx4dir[dir];
checky = player->tiley + dy4dir[dir];
doornum = tilemap[checkx][checky];
if (*(mapsegs[1]+MAPSIZE*checky+checkx) == PUSHABLETILE) // pushable wall
{
PushWall (checkx,checky,dir);
return;
}
for(statptr = &statobjlist[0]; statptr != laststatobj; statptr++)
{
if(statptr->tilex == checkx && statptr->tiley == checky && !buttonheld[bt_use])
{
buttonheld[bt_use] = true; // that must react spacebar
switch (statptr->shapenum)
{
#ifdef GAMEMSGSOBJECT // Trying to use this object - give in-game message
case SPR_STAT_35: SetMessage("You won't fit in there!"); break; // Wooden Barrel
// If you want sprites to have messages for touching them - add the sprite here
// as a case, and then the message you want. ie:
case SPR_STAT_18: SetMessage ("You were expecting a Parrot?"); break; // Skeleton cage
case SPR_STAT_17: SetMessage ("You don't have time to get in the cage!"); break; // empty cage
case SPR_STAT_13: SetMessage ("Who are you? An interior decorator?"); break; // empty table
case SPR_STAT_5: SetMessage ("What? Can't I just hang around?"); break; // hanging skeleton
case SPR_STAT_37: SetMessage ("Is there anyone in there?"); break; // empty well
#endif
#ifdef PUSHOBJECT // Objects that can be pushed
case SPR_STAT_1: // Green Barrel
// Add additional pushable sprite cases here
{
check = (unsigned)actorat[statptr->tilex + dx4dir[dir]][statptr->tiley + dy4dir[dir]];
if(check) return; // Is Tile Free? Yes?No?
if (MAPSPOT(statptr->tilex + dx4dir[dir],statptr->tiley + dy4dir[dir],0) >= 1
&& MAPSPOT(statptr->tilex + dx4dir[dir],statptr->tiley + dy4dir[dir],0) <= MAXWALLTILES)
return; // Hit a wall
if (check && check<objlist) return; // Bad or Removed Item
(unsigned)actorat[statptr->tilex][statptr->tiley] = 0; // Free original Tile
statptr->tilex = statptr->tilex + dx4dir[dir]; // Free to move object
statptr->tiley = statptr->tiley + dy4dir[dir]; // to it's new location
statptr->visspot = &spotvis[statptr->tilex][statptr->tiley]; // Make it visible
(unsigned)actorat[statptr->tilex][statptr->tiley] = 1; // Block New Position
SetMessage ("Item Moved");
}
#endif
#ifdef TREASURECHEST // Dugtrio's idea on a Treasure Chest - BT Modified
case SPR_TRESCHEST:
{
statptr->shapenum = SPR_TRESCHESTOPEN;
switch (US_RndT ()%10)
{
case 0: // surprise - ammo
case 5:
GiveAmmo (20,wp_pistol);
SD_PlaySound (GETAMMOSND);
break;
case 1: // surprise - health bonus
case 6:
HealSelf (50);
SD_PlaySound (HEALTH2SND);
break;
case 2: // Ouch! - It exploded.. and hurt the player
case 7:
SD_PlaySound (MISSILEFIRESND);
TakeDamage (30,NULL);
break;
case 3: // Points Bonus
case 8:
SD_PlaySound (BONUS4SND);
GivePoints (5000);
break;
case 4: // Chest is empty
case 9:
SD_PlaySound (SELECTITEMSND);
break;
}
StartBonusFlash ();
break;
}
#endif
default: break;
}
}
}
if (!buttonheld[bt_use] && doornum & 0x80)
{
OperateDoor (doornum & ~0x80);
}
else if (!buttonheld[bt_use] && doornum)
{
buttonheld[bt_use] = true;
switch (doornum)
{
case ELEVATORTILE: // use elevator
#ifndef ELEVFIX
if (elevatorok)
#endif
{
tilemap[checkx][checky]++; // flip switch
if (*(mapsegs[0]+MAPSIZE*player->tiley+player->tilex) == ALTELEVATORTILE)
playstate = ex_secretlevel;
else
playstate = ex_completed;
SD_StopSound();
SD_PlaySound (LEVELDONESND);
while (SD_SoundPlaying()) SD_Poll(); // Allow for longer switch sounds
SD_WaitSoundDone();
break;
}
#ifdef PUSHSWITCH
case SWITCHTILE:
case SWITCHTILE+1:
SD_PlaySound (LEVELDONESND);
if (doornum == SWITCHTILE)
{
#ifdef GAMEMSGS
SetMessage ("Do you hear something moving?");
#endif
tilemap[checkx][checky]++;
}
else
{
#ifdef GAMEMSGS
SetMessage ("Did you hear something move this time?");
#endif
tilemap[checkx][checky]--;
}
switch (MAPSPOT(checkx,checky,1))
{
case 700: // Pushwall North
PushWall (pwx,pwy,di_north);
break;
case 701: // Pushwall South
PushWall (pwx,pwy,di_south);
break;
case 702: // Pushwall East
PushWall (pwx,pwy,di_east);
break;
case 703: // Pushwall West
PushWall (pwx,pwy,di_west);
break;
case 708: // Pushwall2 North
PushWall (pw2x,pw2y,di_north);
break;
case 709: // Pushwall2 South
PushWall (pw2x,pw2y,di_south);
break;
case 710: // Pushwall2 East
PushWall (pw2x,pw2y,di_east);
break;
case 711: // Pushwall2 West
PushWall (pw2x,pw2y,di_west);
break;
case 716: // Pushwall3 North
PushWall (pw3x,pw3y,di_north);
break;
case 717: // Pushwall3 South
PushWall (pw3x,pw3y,di_south);
break;
case 718: // Pushwall3 East
PushWall (pw3x,pw3y,di_east);
break;
case 719: // Pushwall3 West
PushWall (pw3x,pw3y,di_west);
break;
case 724: // Pushwall4 North
PushWall (pw4x,pw4y,di_north);
break;
case 725: // Pushwall4 South
PushWall (pw4x,pw4y,di_south);
break;
case 726: // Pushwall4 East
PushWall (pw4x,pw4y,di_east);
break;
case 727: // Pushwall4 West
PushWall (pw4x,pw4y,di_west);
break;
}
break;
#endif
#ifdef AMMOWALLS // Ammo Rack
case AMMOWALLTILE:
if(gamestate.ammo >= MAXAMMO) return;
tilemap[checkx][checky]++;
#ifdef GAMEMSGS
SetMessage (AMMOWALLMSG);
#endif
SD_PlaySound(GETAMMOSND);
GiveAmmo (AMMOWALLAMMO,wp_pistol);
StartBonusFlash();
break;
#endif
#ifdef HEALTHWALLS
case HEALTHWALLTILE:
if(gamestate.health >= MAXHEALTH) return;
tilemap[checkx][checky]++;
#ifdef GAMEMSGS
SetMessage (HEALTHWALLMSG);
#endif
SD_PlaySound(HEALTH2SND);
HealSelf (HEALTHWALLHEALTH);
StartBonusFlash();
break;
#endif
default:
break;
}
}
else SD_PlaySound (DONOTHINGSND);
}
Yep.. there's a lot there, including my Switch Activated Pushwall Code (idea from MSC and Areyep - via EoD). Also included is my elevator fix... What that is is this:
Wall Pic 21 is the elevator switch down... the dark pick for it is the elevator rails... then pic 22 is the switch up and the dark image for it is a black image... What I do for elevatorfix (ELEVFIX) is I export the switch up, the switch down and the elevator rails... and in my favorite graphic editor, I reduce the brightness by an amount to match how the rest of the walls are (light/dark) in the vswap... so now I have switch down light & dark... switch up, light & dark, and elevator rails - also light & dark... Now... I insert the dark switch down over the 21 dark image (original elevator rails)... I insert the dark switch up into the "black" image... and then I insert the elevator rails into a new graphic slot (the first one open after the regular or original walls) and reset the defines in my Mapediting program and fix all the maps so that they conform to my new graphic values/location in the vswap....
What this does is this... Normally, you can only have elevators that work in the North/South directions... Well.. if you've done everything properly.. You now have the ability to put elevators in the East/West directions as well... It's not much of a change, but will really mess up someone as they usually look for elevators in the original North/South position..
Want to have even more fun with the elevators... use this graphic (making light and dark images) into the next free open graphic and I can now also create proper dead elevators as well...
And the other stuff... well.. that's Dugtrio's code for say a treasure chest... and the possible bonus items that you can get from it... (just add two sprites into the vswap - there is no need to do anything else like the bo_?? stuff... ) And then there is the same idea with the Health and Ammo Walls...
But yeah... lol... My code is much smaller as I set the checkx and checky directions using the trick from Darkone's NewWolf code... You can also use those dx4dir & dy4dir defines for pushwalls (and save some space as well... ).
Anyhow... enjoy...
Greg
BrotherTank
PS: the messages for those items are due to medications and lack of sleep... it's over 36 hours now and counting... lol... man I need some sleep... I look like a Racoon... really.. lol... I've got complete black circles around both eyes... .. anyhow... play with that and see what you think??
BT  |
Last edited by BrotherTank on Tue Apr 10, 2007 10:46 am; edited 1 time in total
|
|
 |
WLHack
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 18 Jan 2018
Topics: 66
Posts: 1241
Location: Loppi - Finland

|
|
 |
doomjedi
DieHard Wolfer


Joined: 21 Jul 2006
Last Visit: 1:31 ago.
Topics: 120
Posts: 2959
Location: Israel

|
Posted: Tue Apr 10, 2007 2:46 am
Subject: Re: moving objects
[ IP : Logged ]
|

  
|
|
Wow, now we can make cool wolf3d version of "Sokoban" game
...anyone to make such a project? it could be soooo cool |
_________________ https://boa.realm667.com/
|
|
 |
BrotherTank
Forum Administrator

Joined: 01 Mar 2003
Last Visit: 13 Sep 2017
Topics: 153
Posts: 2255
Location: Ontario

|
|
 |
TexZK
DieHard SS


Joined: 07 Feb 2004
Last Visit: 19 Oct 2016
Topics: 19
Posts: 370
Location: Northern Italy

|
Posted: Fri Apr 27, 2007 7:25 am
Subject: Re: moving objects
[ IP : Logged ]
|

  
|
|
You could also hit their neck if the displayed guard picture is the back one (or by computing the viewing angle to check if it's backward). This way you can make add bit more "stealth" features. |
|
|
 |
AlumiuN
DieHard Wolfer

Joined: 29 Nov 2007
Last Visit: 3:41 ago.
Topics: 38
Posts: 2537
Location: Christchurch, New Zealand

|
Posted: Sun Dec 09, 2007 4:52 pm
Subject: Re: moving objects
[ IP : Logged ]
|

 
|
|
One way of doing this might be to remove the static object and temporarily turn it into a projectile, spawning another static object on the tile where it was pushed once it reaches the centre of that tile and removing the temporary object. This would show a sliding image using the actor list. This could also lead on to things like having the direction of the object being a full 360 degrees based on player->angle rather than four directions. |
|
|
 |
|