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       

[help] Adding teleporters in wolf4sdl
Page 1 of 2 Goto page 1, 2  Next
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
Mortimer
Don't Hurt Me
Don't Hurt Me


Joined: 25 Oct 2007
Last Visit: 05 Dec 2017

Topics: 14
Posts: 51

poland.gif

PostPosted: Tue May 06, 2008 7:24 am
   Subject: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

Hi again. Sorry by disturbing that much but I still must get used with this new engine.
I tried to make MCS's tutorial for teleporters. Compiling with Dev-C++, I got some linker errors of "undeclared" functions about "warpex, warpey, warpwy and warpwx. I believe the problem may be in wl_agent.cpp's main routine. I had to change it a little to stop the errors.

This is the original code from MCS:
::: CODE :::
void WarpPlayer (int facedir)
{
objtype  *check;
int  x,y;

buttonstate[bt_attack] = false;
buttonheld[bt_attack] = false;
gamestate.attackframe = 0;
gamestate.weaponframe = 0;
DrawPlayerWeapon();
ThreeDRefresh();
switch (facedir)
  {
  case EAST:
   check = actorat[warpex][warpey];
   if (check > objlist && (check->flags & FL_SHOOTABLE))
    KillActor(check);
   SpawnPlayer(warpex,warpey,facedir);
   break;
  case WEST:
   check = actorat[warpwx][warpwy];
   if (check > objlist && (check->flags & FL_SHOOTABLE))
    KillActor(check);
   SpawnPlayer(warpwx,warpwy,facedir);
   break;
  }

SD_PlaySound (BOSSACTIVESND);
if (DigiMode != sds_Off)
  {
  long lasttimecount = TimeCount;
  while(TimeCount < lasttimecount+35) //adjust warp duration here
   SD_Poll();
  }
else
  VW_WaitVBL(1*50);

buttonstate[bt_attack] = false;
buttonheld[bt_attack] = false;
gamestate.attackframe = 0;
gamestate.weaponframe = 0;
DrawPlayerWeapon();
ThreeDRefresh();
}




This is what I did
::: CODE :::
void WarpPlayer (int facedir)
{
objtype  *check;
int  x,y;
int32_t    TimeCount;

buttonstate[bt_attack] = false;
buttonheld[bt_attack] = false;
gamestate.attackframe = 0;
gamestate.weaponframe = 0;
DrawPlayerWeapon();
ThreeDRefresh();
switch (facedir)
  {
  case EAST:
   check = actorat[warpex][warpey];
   if (check > objlist && (check->flags & FL_SHOOTABLE))
    KillActor(check);
   SpawnPlayer(warpex,warpey,facedir);
   break;
  case WEST:
   check = actorat[warpwx][warpwy];
   if (check > objlist && (check->flags & FL_SHOOTABLE))
    KillActor(check);
   SpawnPlayer(warpwx,warpwy,facedir);
   break;
  }

SD_PlaySound (BOSSACTIVESND);
if (DigiMode != sds_Off)
  {
int32_t lasttimecount = TimeCount;
  while(TimeCount < lasttimecount+35); //adjust warp duration here
  // SD_Poll();
  }
else
  VW_WaitVBL(1*50);

buttonstate[bt_attack] = false;
buttonheld[bt_attack] = false;
gamestate.attackframe = 0;
gamestate.weaponframe = 0;
DrawPlayerWeapon();
ThreeDRefresh();
}


I had to add ""int32_t TimeCount;"" to stop the TimeCount's undeclared function. I also changed the "long" statement to "int32_t" (don't know if it's necessary) as Ripper defined it like that in wl_def.h.
The ""SD_Poll ();"" had to be commented out as I didn't find another way to stop the errors. After all this, the code compiled without problems, but now the game crashes when I try to enter in any teleport. Can anyone help me with this?
Haasboy
DieHard Officer
DieHard Officer


Joined: 23 Jul 2003
Last Visit: 04 Dec 2017

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

PostPosted: Tue May 06, 2008 8:04 am
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

A solution is simple, and need not be asked.

simply create declaration for the those problems, such as:
::: CODE :::

int warpex, warpey, warpwy, warpwx;

_________________
Haasboy Engine - Currently under construction (To be used with future mods - F.A.D.E.D. - Mansion X - Rising Evil Series)
Ripper
Code Master - Developer
Code Master - Developer


Joined: 15 Mar 2003
Last Visit: 30 Sep 2008

Topics: 21
Posts: 527
Location: Germany
blank.gif

PostPosted: Tue May 06, 2008 1:28 pm
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

The TimeCount variable does not exist anymore, as Wolf4SDL does not have a timer which is periodically called.
Please replace all references to TimeCount by a call to GetTimeCount().
If you stumble over any assignments to TimeCount you have to rewrite the code to first save the current GetTimeCount() value and then subtract this value from further GetTimeCount() calls (sounds complicated but it's just an equivalent way like it's done in the code above).

The reason why your game crashes, when you enter a teleporter is, that TimeCount is never updated, so you produced an endless loop.

Oh, another important thing: Don't use waiting loops without a call to SDL_Delay(5) (this waits 5 ms). Otherwise your CPU usage will raise to 100%.
If you are waiting for any user input in a loop, you have to call IN_ProcessEvents(). Otherwise no input will be handled (especially the Keyboard array would never be updated).

To wait for a given number of tics (35 in the above example) you can also replace
::: CODE :::
int32_t lasttimecount = TimeCount;
  while(TimeCount < lasttimecount+35);
by
::: CODE :::
Delay(35);


SD_Poll() does not exist anymore, as the sound playback does not use DMA and such things anymore. It just says play and there is nothing more to worry about Wink

_________________
Life is an awful game, but the graphics resolution rocks ;D
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 0:31 ago.

Topics: 37
Posts: 2401
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Tue May 06, 2008 6:30 pm
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Haasboy wrote:
A solution is simple, and need not be asked.

simply create declaration for the those problems, such as:
::: CODE :::

int warpex, warpey, warpwy, warpwx;


Try int32_t rather than int. Smile
TexZK
DieHard SS
DieHard SS


Joined: 07 Feb 2004
Last Visit: 17 Oct 2016

Topics: 19
Posts: 370
Location: Northern Italy
italy.gif

PostPosted: Wed May 07, 2008 5:34 am
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

"int32_t" and "int" are the same thing under a 32-bit environment compiler such as Dev-C++, or 64-bit under a 64-bit one.
Mortimer
Don't Hurt Me
Don't Hurt Me


Joined: 25 Oct 2007
Last Visit: 05 Dec 2017

Topics: 14
Posts: 51

poland.gif

PostPosted: Wed May 07, 2008 1:44 pm
   Subject: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Thanks for helping me understand this, Ripper. I also noticed that you used the Delay function in the spearflag code. It seems to be easier to use actually. Anyway the code is working fine now.
I just have one more doubt about this engine. Is it possible to add new sounds to the game? Tricob told me I should use them with unused defined names at audiowl6.h. It even works well, but I'll only be able to add like 10 new sounds, using all the unused names.
When I try to define a new digitized sound name, all musics and some sounds gets screwed, that if the game doesn't crash at the main menu. How I can add these sounds properly? Pizza
Metalor
DieHard Mutant
DieHard Mutant


Joined: 24 Aug 2005
Last Visit: 7:41 ago.

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

PostPosted: Mon Dec 08, 2008 7:25 pm
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I've been coming up with the game crash errors, even after taking the advice listed above. I have everything set up like it should be, but it just keeps crashing whenever I try to use one of the teleporters. (I've made the arrangements for 4 of them, a North, South, East and West respectively) I could post up the code (what I've added and where) if necessary.

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

...But I'll be back, you can count on it!
Metalor
DieHard Mutant
DieHard Mutant


Joined: 24 Aug 2005
Last Visit: 7:41 ago.

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

PostPosted: Sun Feb 01, 2009 4:17 pm
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Mortimer wrote:
Anyway the code is working fine now.


Mind posting a quick snippet of the WL_AGENT stuff?

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

...But I'll be back, you can count on it!
Metalor
DieHard Mutant
DieHard Mutant


Joined: 24 Aug 2005
Last Visit: 7:41 ago.

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

PostPosted: Tue Feb 03, 2009 8:01 am
   Subject: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

So, yeah, still have'n problems tryin' to get the teleporter code to work.

Here's my snippet: (I know you guys are probably expecting for me to do it myself, but I've been messin' around with this for three days without ANY kinds of results)

::: CODE :::

void WarpPlayer (int facedir)
{
objtype *check;
int x,y;

buttonstate[bt_attack] = false;
buttonheld[bt_attack] = false;
gamestate.attackframe = 0;
gamestate.weaponframe = 0;
DrawPlayerWeapon();
ThreeDRefresh();
switch (facedir)
{
case EAST:
check = actorat[warpex][warpey];
if (check > objlist && (check->flags & FL_SHOOTABLE))
KillActor(check);
SpawnPlayer(warpex,warpey,facedir);
break;
case WEST:
check = actorat[warpwx][warpwy];
if (check > objlist && (check->flags & FL_SHOOTABLE))
KillActor(check);
SpawnPlayer(warpwx,warpwy,facedir);
break;
case NORTH:
check = actorat[warpnx][warpny];
if (check > objlist && (check->flags & FL_SHOOTABLE))
KillActor(check);
SpawnPlayer(warpnx,warpny,facedir);
break;
case SOUTH:
check = actorat[warpsx][warpsy];
if (check > objlist && (check->flags & FL_SHOOTABLE))
KillActor(check);
SpawnPlayer(warpsx,warpsy,facedir);
break;
}
            if (DigiMode != sds_Off)
            {
                SDL_Delay(150);
            }
            else
            SD_PlaySound (BOSSACTIVESND);
                SD_WaitSoundDone();

buttonstate[bt_attack] = false;
buttonheld[bt_attack] = false;
gamestate.attackframe = 0;
gamestate.weaponframe = 0;
DrawPlayerWeapon();
ThreeDRefresh();
}


I've tried everything:
Applying tics like for the godmode sphere,
trying the above mentioned suggestions,
tried foregoeing the time stuff altogether,
I even tried using the spearflag code with no avail.

I'm not time-code literate, I'm good with guards and items, but not time stuff.

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

...But I'll be back, you can count on it!
MCS
Site Administrator
<B>Site Administrator</B>


Joined: 01 Mar 2003
Last Visit: 15 Jul 2013

Topics: 20
Posts: 243
Location: Amsterdam, the Netherlands
netherlands.gif

PostPosted: Tue Feb 03, 2009 8:34 am
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Try to comment out DrawPlayerWeapon(); twice and see what happens?

_________________
-= Fortune awaits those who search =-
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

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

PostPosted: Tue Feb 03, 2009 1:01 pm
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

The problem is actually in the timing section for the sound card... If you follow the original tutorial:

::: CODE :::

SD_PlaySound (BOSSACTIVESND);
if (DigiMode != sds_Off)
  {
  long lasttimecount = TimeCount;
  while(TimeCount < lasttimecount+35) //adjust warp duration here
   SD_Poll();
  }
else
  VW_WaitVBL(1*50);


The loop can never reach it's ending.... and thus the game hangs... This is because Ripper changed the way it handles the TimeCount.... So many people come up with a solution like yours where you use the WaitSoundDone:

::: CODE :::

  if (DigiMode != sds_Off)
  {
     SDL_Delay(150);
  }
  else SD_PlaySound (BOSSACTIVESND);
  SD_WaitSoundDone();


But the problem with that is that the sound is actually done playing (in the codes eyes because of the multi-channel sound in the SDL code) before it calls the WaitSoundDone... thus the code sits waiting for a sound to finish that isn't there....

So I just used this solution.. and it works just fine:

::: CODE :::

  SD_PlaySound (BOSSACTIVESND);
  VW_WaitVBL(100);


Make everyone wait, sound or no sound.. and it works just fine.. That is the code right out of the Map of the Month Source... I had the same problems and this was the fix.

Greg
BrotherTank
Metalor
DieHard Mutant
DieHard Mutant


Joined: 24 Aug 2005
Last Visit: 7:41 ago.

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

PostPosted: Tue Feb 03, 2009 3:08 pm
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Success!

The code finally works! MCS, your code finally did the trick, and BT, I wouldn't rule out your answer either. You guys, it's all you!

I say thanks to you both, and bow to your grateness!

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

...But I'll be back, you can count on it!
Metalor
DieHard Mutant
DieHard Mutant


Joined: 24 Aug 2005
Last Visit: 7:41 ago.

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

PostPosted: Tue Feb 03, 2009 5:50 pm
   Subject: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

One last thing about teleporters.

When I try to add in the CheckEnemyTile code about guards using teleporters, the code includes a term called: "farmapylookup" but this doesn't seem to be used anymore by the code, and I tried replacing it several times, but to no avail.

How can I fix this?

ie.
::: CODE :::

if (*(mapsegs[1]+farmapylookup[ob->tiley]+ob->tilex) == WARPEASTTILE)
{
PlaySoundLocTile (WARPSND,ob->tilex,ob->tiley);
ob->tilex = warpex;
ob->tiley = warpey;
return;
}

(code provided as example)

_________________
- 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: 1:19 ago.

Topics: 160
Posts: 8008
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Tue Feb 03, 2009 7:02 pm
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

You might use this code post as a guide.

::: CODE :::
// BJ "picks up" Guard Blocks
    if (*(mapsegs[1]+((player->tiley<<mapshift))+(player->tilex)) == BLOCKGUARD1)
       *(mapsegs[1]+((player->tiley<<mapshift))+(player->tilex)) = 0;
// End code for BJ getting Guard Blocks
The coordinates used are "player->tiley" and "player->tilex".
Metalor
DieHard Mutant
DieHard Mutant


Joined: 24 Aug 2005
Last Visit: 7:41 ago.

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

PostPosted: Tue Feb 03, 2009 7:25 pm
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Hmmm. Nothing seems to be going bonanza on me code-wise, and it works just fine in-game too.

Thanks a bunch!

_________________
- 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: 1:19 ago.

Topics: 160
Posts: 8008
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Tue Feb 03, 2009 7:35 pm
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

You're welcome. You might also look over the MAPSPOT function (in WL_ACT1.CPP, IIRC). You'll find it's much easier to use than "mapsegs". Smile
Metalor
DieHard Mutant
DieHard Mutant


Joined: 24 Aug 2005
Last Visit: 7:41 ago.

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

PostPosted: Wed Feb 04, 2009 8:16 am
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Nah, I got somethin' that works now, I don't feel like getting myself into another pickle. (of which I still have three, but those are unrelated to this topic)

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

...But I'll be back, you can count on it!
Metalor
DieHard Mutant
DieHard Mutant


Joined: 24 Aug 2005
Last Visit: 7:41 ago.

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

PostPosted: Wed Feb 11, 2009 4:48 pm
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

This isn't as big an issue as the other problems, but since it's on the subject:

How do you get a "teleporting" graphic to appear when using teleporters? (kinda like in doom, when you teleport in from one, there's all that green blurry stuff)

_________________
- 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: 1:19 ago.

Topics: 160
Posts: 8008
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Wed Feb 11, 2009 7:33 pm
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I'd say have it spawn a new Actor which displays such sprites.
Metalor
DieHard Mutant
DieHard Mutant


Joined: 24 Aug 2005
Last Visit: 7:41 ago.

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

PostPosted: Wed Feb 11, 2009 7:57 pm
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I thought a bit about that, but there's quite a few things to take in when doing so, I just wanted to know a somewhat effiecient way, rather than going through the trouble of add literally 4 different declarations for the same actor in over 10 separate instances. (and then there's the offchance that if it's an actor, that it could cause the player to get stuck in place)

But hey, I'll give it a shot just to see.

_________________
- 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: 1:19 ago.

Topics: 160
Posts: 8008
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Wed Feb 11, 2009 8:10 pm
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

It'll only get the player "stuck" if it's shootable. If you leave that flag out, it shouldn't be a problem. Smile
Metalor
DieHard Mutant
DieHard Mutant


Joined: 24 Aug 2005
Last Visit: 7:41 ago.

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

PostPosted: Wed Feb 11, 2009 8:39 pm
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Yes, well I tried adding somewhat of a variable to the teleporter array for the player, and it didn't work so sound (heck it wouldn't even compile) What I wouldn't give to be able to pick around the source codes of games like Orb of Dilaaria. Oh well. Still this problem is open to suggestions still.

_________________
- 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: 1:19 ago.

Topics: 160
Posts: 8008
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Thu Feb 12, 2009 6:17 pm
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

We might be able to help *if* you say what messages it gives you when you try to compile it. Please provide also what code you did that spawns this teleport-based actor. Thank you.
Metalor
DieHard Mutant
DieHard Mutant


Joined: 24 Aug 2005
Last Visit: 7:41 ago.

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

PostPosted: Thu Feb 12, 2009 8:08 pm
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Oh I took the code of the "blood splatz" tutorial and used that as a basis (basically did a few rearranging things, but I removed the code after it failed to compile, so I don't have a strait-forward answer after that)

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

...But I'll be back, you can count on it!
Codetech84
Code Master
Code Master


Joined: 12 Mar 2003
Last Visit: 15 Oct 2017

Topics: 22
Posts: 1281
Location: Rauma - Finland
finland.gif

PostPosted: Thu Feb 12, 2009 11:38 pm
   Subject: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I had this in Klooni, yeah it could've been done with only one state, but I wasn't short on memory. Just use the "SpawnTeleport (teleportx, teleporty);" to spawn it in the same tile with the player (it takes tile coordinates) I used it to spawn the effect to both ends of the teleporter.

Here it is (I converted it to SDL for your convinience) :

::: CODE :::
//
// Actor teleportation
//

extern statetype s_teleport1;
extern statetype s_teleport2;
extern statetype s_teleport3;
extern statetype s_teleport4;
extern statetype s_teleport5;
extern statetype s_teleport6;
extern statetype s_teleport7;
extern statetype s_teleport8;
extern statetype s_teleport9;
extern statetype s_teleport10;

statetype s_teleport1  = {false,SPR_TELEPORT_1,30,NULL,NULL,&s_teleport2};
statetype s_teleport2  = {false,SPR_TELEPORT_2,30,NULL,NULL,&s_teleport3};
statetype s_teleport3  = {false,SPR_TELEPORT_3,30,NULL,NULL,&s_teleport4};
statetype s_teleport4  = {false,SPR_TELEPORT_4,30,NULL,NULL,&s_teleport5};
statetype s_teleport5  = {false,SPR_TELEPORT_5,30,NULL,NULL,&s_teleport6};
statetype s_teleport6  = {false,SPR_TELEPORT_6,30,NULL,NULL,&s_teleport7};
statetype s_teleport7  = {false,SPR_TELEPORT_7,30,NULL,NULL,&s_teleport8};
statetype s_teleport8  = {false,SPR_TELEPORT_8,30,NULL,NULL,&s_teleport9};
statetype s_teleport9  = {false,SPR_TELEPORT_9,30,NULL,NULL,&s_teleport10};
statetype s_teleport10 = {false,SPR_TELEPORT_10,30,NULL,NULL,NULL};


/*
===================
=
=  SpawnTeleport
=
===================
*/
void SpawnTeleport (int32_t teleportx, int32_t teleporty)
{
     // Spawn the teleportation special effect
     GetNewActor ();
     if (!newobj) return;

     newobj->x = (int32_t)teleportx<<TILESHIFT)+TILEGLOBAL/2;
     newobj->y = (int32_t)teleporty<<TILESHIFT)+TILEGLOBAL/2;
     newobj->tilex = teleportx;
     newobj->tiley = teleporty;

     newobj->flags = FL_NONMARK;

     // Change state
     NewState (newobj, &s_teleport1);
}

_________________
Click here to visit KFH Games website!
*UPDATED* Spear of Destiny Reloaded
KFH Games on Facebook
Metalor
DieHard Mutant
DieHard Mutant


Joined: 24 Aug 2005
Last Visit: 7:41 ago.

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

PostPosted: Fri Feb 13, 2009 8:42 am
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

One question, where do I place it exactly? (inside the part in the WL_AGENT function or in WL_ACT2) And does it also apply to the guard version of the code?

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

...But I'll be back, you can count on it!
Codetech84
Code Master
Code Master


Joined: 12 Mar 2003
Last Visit: 15 Oct 2017

Topics: 22
Posts: 1281
Location: Rauma - Finland
finland.gif

PostPosted: Fri Feb 13, 2009 10:25 am
   Subject: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

You can use it for both, like this for example (player code):

::: CODE :::
SpawnPlayer(warpwx,warpwy,facedir);
SpawnTeleport(warpwx,warpwy);


::: CODE :::
SpawnPlayer(warpex,warpey,facedir);
SpawnTeleport(warpex,warpey);

_________________
Click here to visit KFH Games website!
*UPDATED* Spear of Destiny Reloaded
KFH Games on Facebook
Metalor
DieHard Mutant
DieHard Mutant


Joined: 24 Aug 2005
Last Visit: 7:41 ago.

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

PostPosted: Fri Feb 13, 2009 12:22 pm
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

There was a bit of modifying required (ie. adding a " ( " to both of the TILESHIFT variables) But otherwise, it works like a charm!

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

...But I'll be back, you can count on it!
Codetech84
Code Master
Code Master


Joined: 12 Mar 2003
Last Visit: 15 Oct 2017

Topics: 22
Posts: 1281
Location: Rauma - Finland
finland.gif

PostPosted: Fri Feb 13, 2009 12:55 pm
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Yes you are right, sorry, I didn't take the time to test it after converting it over.

_________________
Click here to visit KFH Games website!
*UPDATED* Spear of Destiny Reloaded
KFH Games on Facebook
Military
DieHard Guard
DieHard Guard


Joined: 10 Oct 2015
Last Visit: 26 Oct 2017

Topics: 20
Posts: 297

blank.gif

PostPosted: Wed May 24, 2017 10:06 am
   Subject: Re: [help] Adding teleporters in wolf4sdl
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

At one point, I had a serious problem and wrote a lengthy forum post asking for help, but ended up figuring it out on my own halfway through. Talk about rubber duck programming!

There's still one issue I'm having, though. The teleporters work right, but after the delay, a twitchy mess of stretched textures (the ones at the teleporter's location and destination, I think) appears for a while before the proper landing location shows up. Here's my code for the main function:

::: CODE :::

void WarpPlayer (int warp_id)
{
objtype *check;
int x,y,warpangle;

buttonstate[bt_attack] = false;
buttonheld[bt_attack] = false;
gamestate.attackframe = 0;
gamestate.weaponframe = 0;
//DrawPlayerWeapon();
ThreeDRefresh();

check = actorat[warpx[warp_id]][warpy[warp_id]];
if (check > objlist && (check->flags & FL_SHOOTABLE)) //if you land on someone, kill them
   KillActor(check);

if(warp_id > 16)
   warpangle = warp_id*90; //teleporters from 16 to 23 are diagonal
else
   warpangle = warp_id*90 + 135; //teleporters from 0 to 15 are orthogonal

if (warpangle>360)
   warpangle = warpangle%360; //angles for teleporters from 5 to 24

SpawnPlayer(warpx[warp_id],warpy[warp_id],warpangle);

SD_PlaySound(BOSSACTIVESND);
VW_WaitVBL(100); //play a cool sound and pause everything for a moment

buttonstate[bt_attack] = false;
buttonheld[bt_attack] = false;
gamestate.attackframe = 0;
gamestate.weaponframe = 0;
//DrawPlayerWeapon();
ThreeDRefresh();

}


Yeah, I made quite a number of changes to sate my ravenous hunger for more teleporters. But I got it all to work, and now there's only this visual error remaining (though I think it might have caused the game to crash on one occasion)

And while I'm at it, is there any tutorial / source for making enemies use teleports?
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 2 Goto page 1, 2  Next
Jump to:  

Related topics
 Topics   Replies   Views   Last Post 
No new posts Announcement: Wolf4SDL released
Author: Ripper
522 154809 Mon May 22, 2017 2:04 pm
Tricob View latest post
No new posts [WOLF4SDL Help] Blake Stone Style doors
Author: Haasboy
3 2192 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 2392 Mon Jun 02, 2008 3:59 pm
Adam Biser View latest post
No new posts [Help] Problem with Checkweaponchange function (wolf4sdl)
Author: Mortimer
4 2328 Sat May 17, 2008 11:26 am
Mortimer View latest post
No new posts [help] Wolf4sdl's implemented tutorials
Author: Mortimer
6 2474 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