Camera view after player death

Have questions about CoD2 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
flesk
CJ Wannabe
CJ Wannabe
Posts: 8
Joined: November 13th, 2012, 12:07 am

Camera view after player death

Post by flesk » November 13th, 2012, 10:19 pm

Hi,

I'm doing a mod which would add a custom difficulty to SP missions. One of the first things I'm doing is killing player when he gets the first shot but it doesn't work at all, when player dies, camera always look at a point instead of enemy so most of the times you have no idea of who have killed you or where the shot came from. This is the code:

Code: Select all

fastDeath()
{
	for(;;)
	{
		self waittill("damage", damage, attacker, direction_vec, point, cause);	
		self dodamage(self.health, attacker getorigin());
	}
}
I've tried to change view angles before and after player dies but it doesn't work.
Is there a way to change weapons damage without editing each weapon file? Any ideas to fix this?

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Camera view after player death

Post by Drofder2004 » November 13th, 2012, 11:05 pm

Cant remember much about CoD2 let alone scripting it, but was single player "self" actually "level.player".

You may also need to do: "setCanDamage", but I doubt it.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

flesk
CJ Wannabe
CJ Wannabe
Posts: 8
Joined: November 13th, 2012, 12:07 am

Re: Camera view after player death

Post by flesk » November 14th, 2012, 12:39 am

Yes, self is level.player in this case because of

Code: Select all

level.player thread fastDeath();
I've tried setcandamage but it's only for script_model, script_origin or script_brushmodel entities.

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Camera view after player death

Post by megazor » November 14th, 2012, 8:28 am

To make the player look at who has killed them, you need to change the view angles before the code has turned their state to "dead".

flesk
CJ Wannabe
CJ Wannabe
Posts: 8
Joined: November 13th, 2012, 12:07 am

Re: Camera view after player death

Post by flesk » November 14th, 2012, 5:16 pm

I've tried to change view angles before player dies but it still doesn't work. I think dodamage always force view angles so also tried to change angles after dying but nothing happens. Do you have a script that does this or something like this?
Now the code is this:

Code: Select all

fastDeath()
{
	for(;;)
	{
		self waittill("damage", damage, attacker, direction_vec, point, cause);	
		self setplayerangles((45,0,0)); //test angles
		self dodamage(self.health, attacker getorigin());
	}
}
Last edited by flesk on November 14th, 2012, 5:21 pm, edited 1 time in total.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Camera view after player death

Post by Drofder2004 » November 15th, 2012, 12:40 am

Did CoD2 use setplayerangles, can't remember and dont have function list?
Have you tried just "self.angles"?
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

flesk
CJ Wannabe
CJ Wannabe
Posts: 8
Joined: November 13th, 2012, 12:07 am

Re: Camera view after player death

Post by flesk » November 20th, 2012, 10:38 pm

Since I cant fix this with dodamage I'm trying to do this another way, now I set player health to 5. I should die when I get hit but it doesn't happen, if health is lower than damage, health becames 1 and after that there's a invulnerability time, so I disabled everything related to invulnerability but it still doesnt work. All changes I've done are in _gameskill.gsc, mainly in setSkill and playerHealthRegen, and I've put comments like <<<---->>> to make easy find all changes. I've uploaded this file and a test map, I hope someone could help.
You do not have the required permissions to view the files attached to this post.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Camera view after player death

Post by Drofder2004 » November 21st, 2012, 11:50 pm

Have you been able to adjust the player angles at all, dead or alive?
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

flesk
CJ Wannabe
CJ Wannabe
Posts: 8
Joined: November 13th, 2012, 12:07 am

Re: Camera view after player death

Post by flesk » November 22nd, 2012, 9:58 pm

No, I couldn't set player angles anyway.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Camera view after player death

Post by Drofder2004 » November 23rd, 2012, 1:35 am

I quickly reviewed some CoD SP code and this should not be hard.
Try this:

Code: Select all

level.player thread fastDeath();
 
fastDeath()
{
        self waittill("death");
        self setplayerangles((45,0,0));
}
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

flesk
CJ Wannabe
CJ Wannabe
Posts: 8
Joined: November 13th, 2012, 12:07 am

Re: Camera view after player death

Post by flesk » November 23rd, 2012, 9:13 pm

Thank you but it still doesn't work. You're right, it should not be hard but it is, at least for me, and I would like to know if it's just me or what, because this is my first try to scripting and is quite frustrating.

Code: Select all

dodamage(<health>, <source position>)
I did some testing and I got this:
- dodamage always make you look at (0,0,0) when you die, even if <source position> is correct, the game just use this for damage arrows.
- I can't change player angles after dying, it's like they get locked, it doesn't matter if I died with dodamage or not.

Now the code is this:

Code: Select all

fastDeath()
{
	self waittill("damage", damage, attacker, direction_vec, point, cause);
	self dodamage(self.health, attacker getorigin());
        self waittill("death");
        self setplayerangles((45,0,0));
}

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Camera view after player death

Post by Drofder2004 » November 26th, 2012, 4:16 pm

You cannot "waittill" death after doing damage.

Using "waittill" is exactly what it says: it will pause that function until the entity is sent a "notify" message.
So when the player dies, a message is sent ("player notify("death");").

I will see if I can look into this a little more later.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

flesk
CJ Wannabe
CJ Wannabe
Posts: 8
Joined: November 13th, 2012, 12:07 am

Re: Camera view after player death

Post by flesk » November 30th, 2012, 12:52 pm

I tried this:

Code: Select all

fastDeath2() {
		self waittill("death");
        self setplayerangles((45,0,0));
}

fastDeath()
{
	for(;;) {
		self waittill("damage", damage, attacker, direction_vec, point, cause);
		self dodamage(self.health, (0,0,0));
	}
}
and called the functions this way:

Code: Select all

	level.player thread maps\mod::fastDeath();
	level.player thread maps\mod::fastDeath2();
But, as usual, didn't work. I'll try to avoid dodamage if I can.

flesk
CJ Wannabe
CJ Wannabe
Posts: 8
Joined: November 13th, 2012, 12:07 am

Re: Camera view after player death

Post by flesk » December 1st, 2012, 9:08 pm

Finally it works, without dodamage, the invulnerability time was due to player_deathInvulnerableTime cvar. Thanks to all.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Camera view after player death

Post by Drofder2004 » December 1st, 2012, 10:17 pm

Well done :)
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest