If "Life = 0" Teleport (not working, testmap included, help)

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
User avatar
Tormentor667
Posts: 13556
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Re: If "Life = 0" deactivate "Respawn"

Post by Tormentor667 »

*push*

I am Mr. Impatience :( :roll:
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: If "Life = 0" deactivate "Respawn"

Post by HotWax »

*pop*

Code: Select all

//Respawn > Take one Life
script 803 RESPAWN
{
   Thing_ChangeTID(0, PLAYER_TID + PlayerNumber());

   if (CheckInventory("LifeItem") > 0)
      {

   // ...etc...
User avatar
Tormentor667
Posts: 13556
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Re: If "Life = 0" deactivate "Respawn"

Post by Tormentor667 »

That actually works... but... for some reason, I always get telefragged by myself?!
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: If "Life = 0" deactivate "Respawn"

Post by HotWax »

That can probably be solved by removing the teleport line in the DEATH script. If you're teleporting there on respawn, you don't need to also teleport there on death, right?

If for some reason you do need to do that, you can try removing the corpse's TID after the teleport, preventing the corpse from teleporting again during the RESPAWN script.

Like so:

Code: Select all

//Death - Continue?
script 802 DEATH
{

 // Stuff

   }
else
   TeleportOther(ActivatorTID(), PRISONSPOT + PlayerNumber(), 1);
   Thing_ChangeTID(0, 0);
}
User avatar
Tormentor667
Posts: 13556
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Re: If "Life = 0" deactivate "Respawn"

Post by Tormentor667 »

Thx Hotti, but I am still trying as it doesn't work. Here is my script as it looks now (mainy the DEATH and RESPAWN ones, as the ENTER script's important line is this one "Thing_ChangeTID(0, PLAYER_TID + PlayerNumber());"):

Code: Select all

/**************************       Death       *****************************/
	
//Death - Continue?
script 801 DEATH
{

	int counter = 10;

	if (CheckInventory("LifeItem") > 0)
	{
		while(GetActorProperty(0, APROP_HEALTH) <= 0 && counter > 0)
		{
			SetFont("BigFont");
			SetHUDSize(640, 480, 1);
			HUDMessage(s: "Continue?"; HUDMSG_PLAIN, 202, CR_WHITE, 320.0, 220.0, 1.0);
			HUDMessage(d: counter; HUDMSG_PLAIN, 203, CR_WHITE, 320.0, 240.0, 1.0);
			delay(35);
			counter--;
		}
		if (counter == 0)
		{
			TeleportOther(ActivatorTID(), PRISONSPOT + PlayerNumber(), 1);
		}
	}
	else
	{
		delay(1);
	}

}

/*********************		Respawn		************************/

	//Static actions executed when the player respawns.

script 670 RESPAWN
{

	Thing_ChangeTID(0, PLAYER_TID + PlayerNumber());

	if (CheckInventory("LifeItem") > 0)
		{
			TakeInventory("LifeItem", 1);
		}
	else
		{
			TeleportOther(ActivatorTID(), PRISONSPOT + PlayerNumber(), 1);
			Thing_ChangeTID(0, 0);
		}


    		// clear messages
		HUDMessage(s: ""; HUDMSG_PLAIN, 202, CR_WHITE, 0.0, 0.0, 0.0);
		HUDMessage(s: ""; HUDMSG_PLAIN, 203, CR_WHITE, 0.0, 0.0, 0.0);
}
The problem remains: I get telefragged when respawning to the mapspot.
User avatar
Tormentor667
Posts: 13556
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Re: If "Life = 0" Teleport (not working, testmap included, help)

Post by Tormentor667 »

Testmap
http://home.arcor.de/tormentor667/M_STR00.zip

Just play it, STR00 is the map lump name. You are still getting telefragged by yourself or something else, no idea what though. The "LifeItem" isn't included so you will directly go to the jail area.
User avatar
Tormentor667
Posts: 13556
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Re: If "Life = 0" Teleport (not working, testmap included, help)

Post by Tormentor667 »

Noone?! :(
User avatar
Lumpy
Posts: 256
Joined: Tue Jul 15, 2003 5:29 pm
Location: Pa,USA
Contact:

Re: If "Life = 0" Teleport (not working, testmap included, help)

Post by Lumpy »

It seems as though your old corpse is retaining the tid. I commited rocketcide, and tried to respawn. When I did so I teleported, and watched my old dead corpse do the same, and telefrag me.

I believe you will also need this in your mix of scripts somewhere.

Code: Select all

Script 257 Death 
{ 
    Thing_ChangeTID(0, 0); 
}
Not sure if that will help, I'm pressed for time, and cannot test it right now. But that should clear the players tid when he dies, and hopefully will clear it from the corpse.
User avatar
solarsnowfall
Posts: 1581
Joined: Thu Jun 30, 2005 1:44 am

Re: If "Life = 0" Teleport (not working, testmap included, help)

Post by solarsnowfall »

I've found that as more and more ACS functions take a tid of 0 as the activator I really don't need to give the player a tid anymore. There are only two circumstances in which I think you would need to give the player a tid. 1)If the function does not take a tid of 0 as the activator. In which case you should probably submit a feature request so that this functionality can be extended. 2)You need to get information about the player from a script that isn't activated by the player, such as an open script. That said, the second scenario is easily avoided with the many ways we have to get the player to activate the script: by using the enter, respawn, return, and death types, direct activation of a void type, or indirect activation of a void type through the enter, respawn, etc types.

Unless the player having a tid is vital to some other portion of the project, I'd suggest dropping the use of a tid. If you think it is vital, chances are it probably isn't. This script set seems to work as you would need it.

Code: Select all

#include "zcommon.acs"

script 669 enter
{
	SetFont("BIGFONT");
	SetHUDSize(640, 480, 1);
	while (TRUE)
	{
		HUDMessage(s:"\cG", i:CheckInventory("LifeItem"); HUDMSG_PLAIN, 201, 0, 614.0, 376.0, 0.05);
		delay(1);
	}
}

script 801 death
{
	int counter = 10;
	if (CheckInventory("LifeItem") > 0)
	{
		SetFont("BIGFONT");
		SetHUDSize(640, 480, 1);
		while (counter > 0)
		{
			counter--;
			HUDMessage(s:"\cG", i:CheckInventory("LifeItem"); HUDMSG_PLAIN, 201, 0, 614.0, 376.0, 0.05);
			delay(1);
		}
		Teleport_NoFog(900+PlayerNumber(), 0, 0);
	}
}

script 670 respawn
{
	if (CheckInventory("LifeItem") > 0)
	{
		TakeInventory("LifeItem", 1);
	}
	else
	{
		Teleport_NoFog(900+PlayerNumber(), 0, 0);
	}
	HUDMessage(s: ""; HUDMSG_PLAIN, 202, CR_WHITE, 0.0, 0.0, 0.0);
	HUDMessage(s: ""; HUDMSG_PLAIN, 203, CR_WHITE, 0.0, 0.0, 0.0);
}
User avatar
Tormentor667
Posts: 13556
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Re: If "Life = 0" Teleport (not working, testmap included, help)

Post by Tormentor667 »

Well, solar, thank you but you should know best if the players need a TID or not as you have worked with the Stronghold script yourself. So is there a way to get this working AND the TID for the player as well? I am not sure what's possible and / or needed with Stronghold. :?
User avatar
solarsnowfall
Posts: 1581
Joined: Thu Jun 30, 2005 1:44 am

Re: If "Life = 0" Teleport (not working, testmap included, help)

Post by solarsnowfall »

Most probably not. A lot of improvements have been made since then that would reduce or eliminate the need for the player to have a tid. See you over on the development forum.
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: If "Life = 0" Teleport (not working, testmap included, help)

Post by HotWax »

Even if you need to give the player a TID for other reasons, you may not have to actually use that TID in the teleport call. This would avoid teleporting your corpse since the teleport would then be guaranteed only to affect the activator.
Locked

Return to “Editing (Archive)”