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       

Translating moving objects code to 4SDL
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
ronwolf1705
Moderator
<B>Moderator</B>


Joined: 31 Jul 2006
Last Visit: 0:05 ago.

Topics: 72
Posts: 3751

blank.gif

PostPosted: Sun Nov 25, 2012 11:52 am
   Subject: Translating moving objects code to 4SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

The moving object code:

http://diehardwolfers.areyep.com/viewtopic.php?t=4388

BT posted an excellent piece of code in there (#ifdef PUSHOBJECT) that allowed you to push objects. Being a total code noob, I can't get this to work in the 4SDL code. I was wondering if someone could 'translate' this for me. Any help is appreciated. 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: Wed Nov 28, 2012 7:15 am
   Subject: Re: Translating moving objects code to 4SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Hi Ron... I'll expand on this so that you define the pushable item by a tile placed on the floor code and post an update to the code..

Give me a few days...

Greg
BrotherTank
ronwolf1705
Moderator
<B>Moderator</B>


Joined: 31 Jul 2006
Last Visit: 0:05 ago.

Topics: 72
Posts: 3751

blank.gif

PostPosted: Wed Nov 28, 2012 7:24 am
   Subject: Re: Translating moving objects code to 4SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Thanks Greg, I appreciate it a lot! 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: Sat Dec 01, 2012 2:16 am
   Subject: Translating moving objects code to 4SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Ok Ronwolf... Here you go... The nice text in the Blue is what you will be adding to the different files.

In the version.h file add the following:

::: CODE :::

#define PUSHOBJECT   // Adds pushable sprite/static object code to the game


In wl_def.h

Make the static object structure look likke this:

::: CODE :::

//---------------------
//
// trivial actor structure
//
//---------------------

typedef struct statstruct
{
    byte      tilex,tiley;
    short     shapenum;           // if shapenum == -1 the obj has been removed
    byte      *visspot;
    uint32_t  flags;
    byte      itemnumber;

#ifdef PUSHOBJECT // Objects that can be pushed
    byte      pushable;
#endif   

} statobj_t;


#ifdef PUSHOBJECT // Objects that can be pushed
  // Place this value on the floor below an item that you want to be pushable
  #define PUSHITEMMARKER    145   // Add this value to your mapdata defines - change value if required
#endif

extern  void ResetFloorCode (int tilex,int tiley);   
// Arrays for quick checking locations on the map
extern  char            dx4dir[4];
extern  char            dy4dir[4];



In wl_game.cpp at the top of the file, add these lines to the Global Constants definitions:

::: CODE :::


// Arrays for quick checking cardinal direction locations on the map
char dx4dir[4]= { 0, 1, 0, -1 };  // dx & dy based on direction
char dy4dir[4]= {-1, 0, 1,  0 };



In the wl_agent.cpp file, down in the CMD_Use routine, add these lines before the last ending bracket of the routine:

::: CODE :::


// Static Object/Items manipulation routines
  for(statptr = statobjlist; statptr != laststatobj; statptr++)
  {
    if(statptr->tilex == checkx && statptr->tiley == checky && !buttonheld[bt_use])
    {
      buttonheld[bt_use] = true;        // that must react to spacebar
   
    #ifdef PUSHOBJECT // Pushable Items or Objects that can be pushed

      if (statptr->pushable) // Is the item Pushable
      {
        if (actorat[checkx][checky])
        {
          if(actorat[checkx + dx4dir[dir]][checky + dy4dir[dir]] > 0) { return; } // Is Tile to move to Free?
          SD_PlaySound (TAKEDAMAGESND);                                 // Make a Ugh pushing sound
          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
          actorat[checkx][checky] = (objtype *)(uintptr_t) 0;
          actorat[statptr->tilex][statptr->tiley] = (objtype *)(uintptr_t) 64;
        }
      }
    #endif
    // Other routines for static objects can be inserted here

    // End of static object check loop
    }
  }



And at the top of the routine, you will see the defines for checkx and so on... Make that section look like this:

::: CODE :::

    int     checkx,checky,doornum,dir;
    boolean elevatorok;
    statobj_t* statptr;


In the wl_act1.cpp file, add the following code above the SpawnStatic routine:

::: CODE :::


  /* ============ Reset Floor Code ================ */
  // Replace Any Map Modifier Code with a valid Floor Code Value
void ResetFloorCode (int tilex,int tiley)
{
  int x,y;
  for (x = di_north; x <= di_west; x++)
  {
    y = MAPSPOT (tilex+dx4dir[x], tiley+dy4dir[x], 0);
    if ( y >= AREATILE && y <= (AREATILE+NUMAREAS-1) )
      { MAPSPOT (tilex,tiley,0) = y; return; }
  }
}



In the SpawnStatic routine, add the following, to make the end of the routine look like this:

::: CODE :::


#ifdef PUSHOBJECT // Pushable Static Object Item
  if (MAPSPOT(tilex,tiley,0) == PUSHITEMMARKER)
  {
    laststatobj->pushable = 1;     // Make Item Pushable or True
    ResetFloorCode (tilex,tiley);  // Reset the Floor code to a valid Floor code value
  }
#endif

  laststatobj->flags |= statinfo[type].specialFlags;
  laststatobj++;
  if (laststatobj == &statobjlist[MAXSTATS]) Quit ("Too many static objects!\n");


And that should be it. Now you add the floor value of 145 to you mapedit defines... and put that tile down underneath the static objects that you want to be pushable on any of your maps. When the maps are loaded, as the static items are spawned, the ResetFloorCode will set the object as pushable and change the floor code back to a proper value of that of one of the squares immediately next to the spot where the pushable item is now marked. This code is taken directly from the Community Map of the Month contest code... I've just extracted it and coloured it nicely to make it easier to re-install. It worked perfectly in that source (SDL) so it shouldn't be a problem in the latest SDL source from Ripper [version 1.7 I believe].

Let me know if you have any problems...

Enjoy!

Greg
BrotherTank


Last edited by BrotherTank on Sat Dec 01, 2012 12:08 pm; edited 1 time in total
ronwolf1705
Moderator
<B>Moderator</B>


Joined: 31 Jul 2006
Last Visit: 0:05 ago.

Topics: 72
Posts: 3751

blank.gif

PostPosted: Sat Dec 01, 2012 5:26 am
   Subject: Re: Translating moving objects code to 4SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Thanks Greg, this is perfect! I didn't want any object pushable by default (only one episode will revolve around this, for now I've dubbed it the 'Sokoban'-episode Laughing), so such a marker is exactly what I needed. Smile One thing not to forget is that statptr still needs to be defined, otherwise you'll get error messages. Simply add 'statobj_t* statptr;' to the beginning of the CMD_Use function.
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: Sat Dec 01, 2012 11:59 am
   Subject: Re: Translating moving objects code to 4SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Yep... It's in my code but I missed pulling that out of the code... lol... I knew that I'd miss something or mistype something when I was copying and pasting from the code files to a text file and then addding the formatting blocks so it would look nice in the forums .... I've updated the post to add the missing line of code...

Anyhow... hope it does you well... and look forward to seeing it used in your project....

Greg
BrotherTank

PS: For ALL -- For what it is worth... You can find the Map of the Month source code in the downloads section for both the SDL and Dos versions. The SDL version has many routines modified and converted (the dos tutorials) so you might want to download it and have a look around at the code and the changes that I've made. That version is the SDL version 1.6, so if you are using the newer source version 1.7, then you will have to extract the code that you want and move it over to your working source. Enjoy...

BT
Arielus
DieHard Mutant
DieHard Mutant


Joined: 13 Mar 2003
Last Visit: 11:51 ago.

Topics: 20
Posts: 752
Location: Buenos Aires, Argentina
argentina.gif

PostPosted: Sat Dec 01, 2012 1:57 pm
   Subject: Re: Translating moving objects code to 4SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

BrotherTank,

In reference to the Map of the Month bit of your post, all I want to say is that it was arguably the best/funnest propeller of community efforts this family has to this date seen. I miss it a lot. Thank you for it...

Ariel

_________________
Hot to Rock - Long Live Metal!
ronwolf1705
Moderator
<B>Moderator</B>


Joined: 31 Jul 2006
Last Visit: 0:05 ago.

Topics: 72
Posts: 3751

blank.gif

PostPosted: Sat Dec 01, 2012 2:33 pm
   Subject: Re: Translating moving objects code to 4SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I definitely agree with that, Ariel! 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: Sun Dec 02, 2012 12:18 am
   Subject: Translating moving objects code to 4SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Thanks for that guys... I really did enjoy that too...

For what it's worth, it's easy to do and works just great as people enjoy doing 1 map [as it's easy to do just one] for fun. The software has been sitting there for years now... And no-one wants to keep it going or start it back up again. It's not that hard to set up and run. I'd do it if it wasn't for the fact that right now I'm working on trying to fix the forums software and get the mail system back up and working again.

Start a new topic about it in the Wolfenstein section and see if people are interested in working on or participating in the Map of the Month thing again.
I'm sure people will be interested. That and with the Winter season hitting a great many of us, we might see a little more traffic for the forums once again. Smile
Cool

Greg
BrotherTank
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 18 Jul 2018

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

PostPosted: Sun Dec 02, 2012 4:13 am
   Subject: Re: Translating moving objects code to 4SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

BrotherTank wrote:
For what it's worth, it's easy to do and works just great as people enjoy doing 1 map [as it's easy to do just one] for fun. The software has been sitting there for years now... And no-one wants to keep it going or start it back up again. It's not that hard to set up and run. I'd do it if it wasn't for the fact that right now I'm working on trying to fix the forums software and get the mail system back up and working again.

Start a new topic about it in the Wolfenstein section and see if people are interested in working on or participating in the Map of the Month thing again.

It was suggested already, main problem was always coding. Here's a thread about it:

http://diehardwolfers.areyep.com/viewtopic.php?t=6301&start=40#81896

I think "Addons/Mods/TCs" is the right section for new levels, based on the sub-forum descriptions (?).
Dean
Moderator
<B>Moderator</B>


Joined: 10 Jan 2006
Last Visit: 18 Jan 2018

Topics: 52
Posts: 2189
Location: Australia
australia.gif

PostPosted: Sun Dec 02, 2012 1:55 pm
   Subject: Re: Translating moving objects code to 4SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Yeah, there's been repeated interest raised over the last few years about doing an SDL version but I seem to recall there being some minor things in the exe that weren't functioning correctly or something... Tricob will remember better than I do. Anyway, I'm sure we'd get participants if we were to start a competition again.

What's with this Winter rubbish of which you speak? Summer here, Beautiful sunny day of 22 degrees (Celcius of course!) and the crickets on, what more could you ask for?! Smile

_________________
The Wolfenstein 3d Blog
The Wolfenstein 3d Blog is now on Facebook!

"Strong minds discuss ideas, average minds discuss events, weak minds discuss people" - Socrates
Tricob
Moderator
<B>Moderator</B>


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

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

PostPosted: Mon Dec 03, 2012 5:30 pm
   Subject: Re: Translating moving objects code to 4SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

Dean wrote:
Yeah, there's been repeated interest raised over the last few years about doing an SDL version but I seem to recall there being some minor things in the exe that weren't functioning correctly or something... Tricob will remember better than I do.
My memory's kind of sketchy on the issue, but from what I've read in earlier posts, the enemies' Advanced AI feature had a bug that kept crashing the EXE. When I disabled the feature through an H file and Rebuilt the EXE, no crashes at all occurred. BrotherTank posted a bugfix to the problem sometime later, but I wasn't able to find what files the code changes related to. Neutral
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 [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 [Wolf4SDL Help] Inserting a second palette (like in SoD)
Author: Andy_Nonymous
10 3047 Mon Jun 02, 2008 3:59 pm
Adam Biser 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 [help] Wolf4sdl's implemented tutorials
Author: Mortimer
6 3073 Tue May 06, 2008 1:15 pm
Ripper 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