Wolf3d Haven Forum

Please log in or register!
Today's Announcement:
Theres only 16 or less levels that you can contribute to! No need to sign up, just show up with a level! Again, up to 699 stactic objects are allowed. Don't be the only one who did not contribute!

Wolf3d Haven Forum

A Friendly Wolfenstein 3D Community, About Wolfenstein 3D, the game that gave birth to First Person Shooters...

  • Post new topic
  • Reply to topic

[code] movable objects...

Share

WLHack
Wolf3d Masters
Wolf3d Masters

Male
Number of posts: 446
Age: 20
Location: Finland
Registration date: 2007-03-26

[code] movable objects...

Post by WLHack on Mon Apr 09, 2007 2:58 am

Finally, here is the tutorial for it...
This might be a bit memorywasting, but it works...

Okay, lets start... First open WL_Agent.C and go to the
Cmd_Use function...

Now under "boolean elevatorok" add this line:
Code:

statobj_t      *statptr;


Then scroll few lines down and you should see
this:
Code:

 doornum = tilemap[checkx][checky];
 if (*(mapsegs[1]+farmapylookup[checky]+checkx) == PUSHABLETILE)
 {
 //
 // pushable wall
 //
  PushWall (checkx,checky,dir);
  return;
 }


Now just under it add this block:
Code:

 for(statptr = &statobjlist[0]; statptr != laststatobj; statptr++)
 {
    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);
    }
 }


And now you have a movable object...
Oh, change the SPR_STAT_1 to match the objects sprite
define, that you want to move...

And to avoid strange reactions, please select SPR_STAT
that is defined as blocking in WL_Act1.C

Dark_wizzie
Omega
Omega

Male
Number of posts: 2699
Age: 15
Location: USA or Tawain
Job: Student, forum admin
Hobbie: Game and game creation, eating, cooking, chess, music, computer hardware
Message: I made this forum when I was 13 =p
Registration date: 2007-03-25

Re: [code] movable objects...

Post by Dark_wizzie on Mon Apr 09, 2007 9:55 am

:shock:





EDIT:
MY GOD!!!!!!!!!!!!!!!!!!!!!!


_________________
Eric, Forum Admin~Fondator
Wolf3d Addon:Active!~~~~~MMORPG:Inactive-V1.11 7/7/09
15 years old. Iori idol. Emule USA Moderator. Lol CC1 Leader
--------------------------------------------------------------------------
Search for "Wolf3d Haven" (with quotes) and Dark_wizzie on google to track me!

drchainsaw
Wolf3d Masters
Wolf3d Masters

Male
Number of posts: 193
Age: 19
Location: England
Job: Busy
Hobbie: Wolf3D
Registration date: 2007-04-01

Re: [code] movable objects...

Post by drchainsaw on Tue Apr 10, 2007 1:38 pm

I just tried this and it works perfect. I might use this in my next mod :D

Good work WLHack!

Airslide
Subi
Subi

Male
Number of posts: 115
Age: 15
Location: Central Valley [Formerly Bay Area] (California USA)
Job: Student
Hobbie: Indie Game Development
Registration date: 2007-05-18

Re: [code] movable objects...

Post by Airslide on Fri May 25, 2007 7:09 pm

I haven't tried it yet, though it looks good and I may use it in my current mod. Could be useful for moving obstacles to block flamewalls in my game Smile


_________________

Dark_wizzie
Omega
Omega

Male
Number of posts: 2699
Age: 15
Location: USA or Tawain
Job: Student, forum admin
Hobbie: Game and game creation, eating, cooking, chess, music, computer hardware
Message: I made this forum when I was 13 =p
Registration date: 2007-03-25

Re: [code] movable objects...

Post by Dark_wizzie on Fri May 25, 2007 7:12 pm

and i suggested it >< =)


_________________
Eric, Forum Admin~Fondator
Wolf3d Addon:Active!~~~~~MMORPG:Inactive-V1.11 7/7/09
15 years old. Iori idol. Emule USA Moderator. Lol CC1 Leader
--------------------------------------------------------------------------
Search for "Wolf3d Haven" (with quotes) and Dark_wizzie on google to track me!

jayngo26
Green Tree
Green Tree

Male
Number of posts: 205
Age: 33
Location: Michigan, err, now South Carolina, USA
Hobbie: Gaming & Hockey
Message: Wolfenstein:Umbrella Beginnings Episode 2 in production!
Registration date: 2008-08-10

Re: [code] movable objects...

Post by jayngo26 on Thu Jun 25, 2009 8:46 am

Great code, but it appears this only works for 1 movable object. How would you code it to have multiple moving objects in your mod?


_________________
http://jayngoware.com/

Dark_wizzie
Omega
Omega

Male
Number of posts: 2699
Age: 15
Location: USA or Tawain
Job: Student, forum admin
Hobbie: Game and game creation, eating, cooking, chess, music, computer hardware
Message: I made this forum when I was 13 =p
Registration date: 2007-03-25

Re: [code] movable objects...

Post by Dark_wizzie on Sat Oct 24, 2009 10:04 am

Have 1 object be movable and others be nonmovable...Makes a perfect disguise. Just make both objects look the same to create a secret, secret area.


_________________
Eric, Forum Admin~Fondator
Wolf3d Addon:Active!~~~~~MMORPG:Inactive-V1.11 7/7/09
15 years old. Iori idol. Emule USA Moderator. Lol CC1 Leader
--------------------------------------------------------------------------
Search for "Wolf3d Haven" (with quotes) and Dark_wizzie on google to track me!
  • Post new topic
  • Reply to topic

Current date/time is Mon Nov 23, 2009 8:57 pm