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       

Player Blocking Code for SDL?
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
Metalor
DieHard Mutant
DieHard Mutant


Joined: 24 Aug 2005
Last Visit: 8:31 ago.

Topics: 95
Posts: 911
Location: California
usa.gif

PostPosted: Thu Aug 08, 2013 3:20 pm
   Subject: Player Blocking Code for SDL?
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

I'm currently trying to add a player blocking object into one of my projects, but the compiler doesn't like the code string I put into it, giving me the message: "error: ISO C++ forbids cast to non-reference type used as lvalue"

This is the code I've been trying to implement:

::: CODE :::
    statobj_t   *statptr;

...

    if (*(mapsegs[1] + offset) == BLOCKPLAYER)
    {
        (unsigned)actorat[statptr->tilex][statptr->tiley] = 1;
    }


I'm pretty certain the compiler doesn't like this code because it's specifically for old C compilers, and not C++. Any ideas?

_________________
- Taking a hiatus from Wolfenstein for a while...

...But I'll be back, you can count on it!
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 17 Sep 2018

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

PostPosted: Thu Aug 08, 2013 5:05 pm
   Subject: Re: Player Blocking Code for SDL?
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I'm pretty sure that changing the "actorat" structure isn't the right move. Instead, I'd use the ClipMove routine in WL_AGENT.CPP. Look for this code:
::: CODE :::
    if (TryMove (ob))
        return;

In this area, I'd expand the "if" statement so the Objects plane for the BLOCKPLAYER mark is detected.
Metalor
DieHard Mutant
DieHard Mutant


Joined: 24 Aug 2005
Last Visit: 8:31 ago.

Topics: 95
Posts: 911
Location: California
usa.gif

PostPosted: Thu Aug 08, 2013 5:34 pm
   Subject: Re: Player Blocking Code for SDL?
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Okay, so then, how do I do that?

I've heard the objects plane thingy mentioned elsewhere, but I'd need an example to understand exactly what you mean (I'm sorry, I've been working on this stuff all day, so my brain's fried).

_________________
- Taking a hiatus from Wolfenstein for a while...

...But I'll be back, you can count on it!
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 17 Sep 2018

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

PostPosted: Thu Aug 08, 2013 5:42 pm
   Subject: Re: Player Blocking Code for SDL?
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I believe the code in WL_AGENT.CPP is this:
::: CODE :::
    if (TryMove (ob) || (*(mapsegs[1] + offset) == BLOCKPLAYER) )
        return;

As for WL_ACT1.CPP and WL_GAME.CPP, there should be no code referring to this "object" at all. The blocker I'm using is not an "Object" of any type. It's an invisible "checkmark" placed on the map, and it bars the player's way, should he try to cross it. MCS's "enemy-blocker code" works much the same way, so it isn't really my own original idea. Embarassed

Please let me know if the code works. Thanks. Smile
Metalor
DieHard Mutant
DieHard Mutant


Joined: 24 Aug 2005
Last Visit: 8:31 ago.

Topics: 95
Posts: 911
Location: California
usa.gif

PostPosted: Thu Aug 08, 2013 6:07 pm
   Subject: Re: Player Blocking Code for SDL?
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Alright, I placed it at the bottom of TryMove(), and got these two errors:

error: `offset' was not declared in this scope
error: return-statement with no value, in function returning 'int'

Also, I knew that the "thing" being spawned was not an object, I'm just not familiar with creating things that refer to the objects plane.

_________________
- Taking a hiatus from Wolfenstein for a while...

...But I'll be back, you can count on it!
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 17 Sep 2018

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

PostPosted: Thu Aug 08, 2013 9:08 pm
   Subject: Re: Player Blocking Code for SDL?
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Metalor wrote:
Alright, I placed it at the bottom of TryMove(), and got these two errors:
Ah ... it should be in the ClipMove routine, and it should *replace* the TryMove lines of code, not just be inserted below it.

Regarding the "offset" error, try placing this line of code just above the TryMove line of code:
::: CODE :::
    offset = (player->tiley<<mapshift)+(player->tilex);

I believe that will cover it. Smile
Metalor
DieHard Mutant
DieHard Mutant


Joined: 24 Aug 2005
Last Visit: 8:31 ago.

Topics: 95
Posts: 911
Location: California
usa.gif

PostPosted: Thu Aug 08, 2013 10:07 pm
   Subject: Re: Player Blocking Code for SDL?
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I replaced all three instances of TryMove in ClipMove, and I added the "offset" code. The game didn't initially like that code, so I added:
::: CODE :::
unsigned    offset;

to make up for it.

However, the code doesn't seem to function properly, as I can still move over the space marked by the blocker in an editor, however it seems to have an odd effect when placed near walls as it makes it possible to enter into the nearby wall and get stuck inside.

To elaborate, I placed the strings under these three sets of code:
::: CODE :::
    ob->x = basex+xmove;
    ob->y = basey+ymove;

...

    ob->x = basex+xmove;
    ob->y = basey;

...

    ob->x = basex;
    ob->y = basey+ymove;

_________________
- Taking a hiatus from Wolfenstein for a while...

...But I'll be back, you can count on it!
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 17 Sep 2018

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

PostPosted: Fri Aug 09, 2013 6:33 pm
   Subject: Re: Player Blocking Code for SDL?
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

The ClipMove routine should look like this:

::: CODE :::
void ClipMove (objtype *ob, int32_t xmove, int32_t ymove)
{
    int32_t    basex,basey;

    basex = ob->x;
    basey = ob->y;

    ob->x = basex+xmove;
    ob->y = basey+ymove;
    offset = (player->tiley<<mapshift)+(player->tilex);
    if (TryMove (ob) || (*(mapsegs[1] + offset) == BLOCKPLAYER) )
        return;

#ifndef REMDEBUG
    if (noclip && ob->x > 2*TILEGLOBAL && ob->y > 2*TILEGLOBAL
        && ob->x < (((int32_t)(mapwidth-1))<<TILESHIFT)
        && ob->y < (((int32_t)(mapheight-1))<<TILESHIFT) )
        return;         // walk through walls
#endif

    if (!SD_SoundPlaying() ) SD_PlaySound (HITWALLSND);

    ob->x = basex+xmove;
    ob->y = basey;
    if (TryMove (ob))
        return;

    ob->x = basex;
    ob->y = basey+ymove;
    if (TryMove (ob))
        return;

    ob->x = basex;
    ob->y = basey;
}
Metalor
DieHard Mutant
DieHard Mutant


Joined: 24 Aug 2005
Last Visit: 8:31 ago.

Topics: 95
Posts: 911
Location: California
usa.gif

PostPosted: Fri Aug 09, 2013 6:54 pm
   Subject: Re: Player Blocking Code for SDL?
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Well, I made the changes above and it still seems to do the same thing. In fact, the only thing the spaces seem to do is the opposite of what I'm trying to program them to do (I've gotten stuck inside of both walls and enemies now).

I'm not real keen on how this code works, but I'd assume it'd have something with playerobj in it or something to prevent the player entering inside. At least, that's what I'd guess off the top of my head.

_________________
- Taking a hiatus from Wolfenstein for a while...

...But I'll be back, you can count on it!
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 13 Sep 2018

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

PostPosted: Fri Aug 09, 2013 10:12 pm
   Subject: Re: Player Blocking Code for SDL?
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I think Tricob's idea might work if you arrange it something like this...

::: CODE :::
boolean TryMove (objtype *ob)
{
    int         xl,yl,xh,yh,x,y;
    objtype    *check;
    int32_t     deltax,deltay;

    if (MAPSPOT(ob->x>>TILESHIFT, ob->y>>TILESHIFT, 1) == BLOCKPLAYER)
        return false;


    xl = (ob->x-PLAYERSIZE) >>TILESHIFT;
    yl = (ob->y-PLAYERSIZE) >>TILESHIFT;
Metalor
DieHard Mutant
DieHard Mutant


Joined: 24 Aug 2005
Last Visit: 8:31 ago.

Topics: 95
Posts: 911
Location: California
usa.gif

PostPosted: Fri Aug 09, 2013 10:47 pm
   Subject: Re: Player Blocking Code for SDL?
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Tried Chris' code and it worked perfectly. Thanks for both of your help!

_________________
- Taking a hiatus from Wolfenstein for a while...

...But I'll be back, you can count on it!
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 17 Sep 2018

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

PostPosted: Sat Aug 10, 2013 3:46 pm
   Subject: Re: Player Blocking Code for SDL?
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

Thanks for the helping hand, Chris. Smile
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: Wolf3d & Spear of Destiny Shareware SDL Downloads
Author: BrotherTank
10 15112 Tue Aug 24, 2010 10:18 am
dcbasic View latest post
No new posts Sticky: [Tutorial] Compiling Wolf4SDL with Code::Blocks
Author: dcbasic
90 24553 Wed May 24, 2017 7:53 pm
Falcon*93 View latest post
No new posts Remaking released mod into SDL
Author: Dean
14 4074 Thu Aug 14, 2008 4:58 pm
Dean View latest post
No new posts [Help] Gun Bobbing in SDL
Author: RichterBelmont12
8 2861 Wed Jul 23, 2008 6:37 pm
Tricob View latest post
No new posts [SDL] Apply 2nd ScaleFactor to selected (hi-res) vga gfx
Author: Andy_Nonymous
9 4477 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