Page 1 of 1

Camera view after player death

Posted: November 13th, 2012, 10:19 pm
by flesk
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?

Re: Camera view after player death

Posted: November 13th, 2012, 11:05 pm
by Drofder2004
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.

Re: Camera view after player death

Posted: November 14th, 2012, 12:39 am
by flesk
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.

Re: Camera view after player death

Posted: November 14th, 2012, 8:28 am
by megazor
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".

Re: Camera view after player death

Posted: November 14th, 2012, 5:16 pm
by flesk
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());
	}
}

Re: Camera view after player death

Posted: November 15th, 2012, 12:40 am
by Drofder2004
Did CoD2 use setplayerangles, can't remember and dont have function list?
Have you tried just "self.angles"?

Re: Camera view after player death

Posted: November 20th, 2012, 10:38 pm
by flesk
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.

Re: Camera view after player death

Posted: November 21st, 2012, 11:50 pm
by Drofder2004
Have you been able to adjust the player angles at all, dead or alive?

Re: Camera view after player death

Posted: November 22nd, 2012, 9:58 pm
by flesk
No, I couldn't set player angles anyway.

Re: Camera view after player death

Posted: November 23rd, 2012, 1:35 am
by Drofder2004
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));
}

Re: Camera view after player death

Posted: November 23rd, 2012, 9:13 pm
by flesk
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));
}

Re: Camera view after player death

Posted: November 26th, 2012, 4:16 pm
by Drofder2004
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.

Re: Camera view after player death

Posted: November 30th, 2012, 12:52 pm
by flesk
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.

Re: Camera view after player death

Posted: December 1st, 2012, 9:08 pm
by flesk
Finally it works, without dodamage, the invulnerability time was due to player_deathInvulnerableTime cvar. Thanks to all.

Re: Camera view after player death

Posted: December 1st, 2012, 10:17 pm
by Drofder2004
Well done :)