Watching for player death

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Wierdo
Corporal
Posts: 47
Joined: Wed Jan 09, 2008 11:15 pm
Location: Winfield, KS

Watching for player death

Post by Wierdo »

I have been looking for a suitable means on knowing when a player dies. Cannot find this info. My goal is to make a map that does the old 95 C&C game in First Person. Just like Renegade, except with weapons that are more in line with the old game. I want it so EVA says "unit lost" when an allie - or even self dies.

Already have the old style barracks and powerplant made, will make them destroyable sometime. The old music plays mapwide as well. 8-)
User avatar
211476
Captain
Posts: 273
Joined: Fri Feb 29, 2008 2:20 am
Location: Arizona, USA
Contact:

Post by 211476 »

change death animation sound to UnitLost.wav? not very good at scripting :cry:
Image
Wierdo
Corporal
Posts: 47
Joined: Wed Jan 09, 2008 11:15 pm
Location: Winfield, KS

death animation/sound?

Post by Wierdo »

What you say could be possible, but would require altering original game files. I still want it to fit inside the pk3. Besides, if I did that, I would override pain sounds in the process.

What I have below actually works, but with issues:

Code: Select all

eva:
   if ($player[local.playtm].dmteam == "allies")
      {
      if ($player[local.playtm].health < 1)
         {
         $gdi_speaker playsound lost_snd
         wait 6.5
         }
      }
   wait .5
   goto eva
end
If the player lay dead for more than 6.9 seconds, the report of "Unit Lost" will occur twice. Also, I am uncertian as to how the script will handle multiple dead units.
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

I don't think that works I mean you have an undefined local variable local.playtm . This may work

Code: Select all

eva:
while(1)
{

	for(local.i=1;local.i <= $player.size;local.i++) 
	{
		if ($player[local.i].isdead == NIL && $player[local.i].dmteam == "allies" && $player[local.i].health < 1) 
		{ 
			$gdi_speaker playsound lost_snd
			$player[local.i].isdead = 1
		} 
		else
		{
			if ($player[local.i].isdead == 1 && $player[local.i].health >= 1)
			$player[local.i].isdead = NIL
		}
	}
	waitframe
}
end
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

I don't think that works I mean you have an undefined local variable local.playtm . This may work

Code: Select all

eva:
while(1)
{

	for(local.i=1;local.i <= $player.size;local.i++) 
	{
		if ($player[local.i].isdead == NIL && $player[local.i].dmteam == "allies" && $player[local.i].health < 1) 
		{ 
			$gdi_speaker playsound lost_snd
			$player[local.i].isdead = 1
		} 
		else
		{
			if ($player[local.i].isdead == 1 && $player[local.i].health >= 1)
			$player[local.i].isdead = NIL
		}
	}
	waitframe
}
end
Image
Wierdo
Corporal
Posts: 47
Joined: Wed Jan 09, 2008 11:15 pm
Location: Winfield, KS

Post by Wierdo »

I don't think that works I mean you have an undefined local variable local.playtm .
It did work, although it was flooding the console with error reports every 0.1 seconds. :? And the sound effect would repeat every 7 seconds unless I decided to respawn. I tried your method, and it is waaaay better. No errors. No repeats. 8-)
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Wierdo wrote:
I don't think that works I mean you have an undefined local variable local.playtm .
It did work, although it was flooding the console with error reports every 0.1 seconds. :? And the sound effect would repeat every 7 seconds unless I decided to respawn. I tried your method, and it is waaaay better. No errors. No repeats. 8-)
If the If statement failed then your old code would reapeat every .5 seconds if it succeded then there was a 6.5 second wait . If your playing alone then $player is you . If another player joins it forms an array so you have $player[1] and $player[2] so I assume you where playing alone . If you play from the maplist or by typing map mymap where mymap is the name of your map then your playing in single player not MP . Just some things to think about .
Image
Post Reply