Player death post effects

Discuss programming in the QuakeC language.
Chip
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland
Contact:

Player death post effects

Post by Chip »

I've been pondering some post-death effects, and, using Darkplaces, I decided to add black-and-white effect and slow motion when player gets killed.

Darkplaces has both effects as cvars, but I don't know how to implement them when player dies.

I've seen some examples but I couldn't replicate them, so I decided to ask.

It's something like when player's health reaches 0 or less, the cvars get changed in QuakeC. The slow motion cvar is slowmo 1 (and going 0.9, 0.8, 0.7 ... to 0 - deactivated).

I guess there's a general rule, and I can set what cvar I want, but I don't know how to set a cvar in QC.

Any help would be greatly appreciated.
QuakeWiki
getButterfly - WordPress Support Services
Roo Holidays

Fear not the dark, but what the dark hides.
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

Have you already tried something like this ?

Code: Select all

float slowmo_val = 0.9;
void () slowmo_change =
{
  stuffcmd ("slowmo ");
  stuffcmd (ftos (slowmo_val));
  stuffcmd ("\n");
  if (slowmo_val > 0.1)
  {
    slowmo_val = slowmo_val - 0.1;
  }
};

void () slowmo_reset =
{
  slowmo_val = 1.0;
  stuffcmd ("slowmo 1\n");
}

void()	player_diea1	=	[	$deatha1,	player_diea2	] {slowmo_change();};
void()	player_diea2	=	[	$deatha2,	player_diea3	] {slowmo_change();};
void()	player_diea3	=	[	$deatha3,	player_diea4	] {slowmo_change();};
void()	player_diea4	=	[	$deatha4,	player_diea5	] {slowmo_change();};
void()	player_diea5	=	[	$deatha5,	player_diea6	] {slowmo_change();};
void()	player_diea6	=	[	$deatha6,	player_diea7	] {slowmo_change();};
void()	player_diea7	=	[	$deatha7,	player_diea8	] {slowmo_change();};
void()	player_diea8	=	[	$deatha8,	player_diea9	] {slowmo_change();};
void()	player_diea9	=	[	$deatha9,	player_diea10	] {slowmo_change();};
void()	player_diea10	=	[	$deatha10,	player_diea11	] {};
void()	player_diea11	=	[	$deatha11,	player_diea11 ] {PlayerDead();slowmo_reset();};

BUT in a second thought, if you are using Darkplaces, I suspect this would be better handled by CSQC.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

By mentioning slowmo, I really really hope you're making a single-player mod.
In which case you can be lame and cvar_set it directly.
And if you're not, then you're probably breaking stuff anyway.

Regarding the black-and-white effect cvar, you should stuffcmd that (see frag.machine's post).
Chip
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland
Contact:

Post by Chip »

Thanks, I'll try that. Spike, yeah, it's for a single player mod.

If you ever played Jedi Knight II: Outcast you may know what I am talking about.

EDIT: Works like a charm! With some changes to stuffcmd. I'll look into CSQC to see how I can integrate this and come back.

Combined with a 3rd person switch, B/W, slow motion and (maybe) a bit of blur, it would make a hell of death effect.
QuakeWiki
getButterfly - WordPress Support Services
Roo Holidays

Fear not the dark, but what the dark hides.
skite2001
Posts: 17
Joined: Mon Nov 17, 2008 5:40 pm

Post by skite2001 »

nice, please keep me informed if you add/improve this thing^^ i really would like to add this to my mod ^_-
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

Chip wrote:Thanks, I'll try that. Spike, yeah, it's for a single player mod.

If you ever played Jedi Knight II: Outcast you may know what I am talking about.

EDIT: Works like a charm! With some changes to stuffcmd. I'll look into CSQC to see how I can integrate this and come back.

Combined with a 3rd person switch, B/W, slow motion and (maybe) a bit of blur, it would make a hell of death effect.
Found any problem ? Care to post your version ? I haven't actually tried this code, so I'd like to know what you changed.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Chip
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland
Contact:

Post by Chip »

No need for gradual motion change, so I'll just set it.

Right after PlayerDie() {

Code: Select all

local float ms;
ms = cvar("slowmo");
if(ms == 0) {
	stuffcmd(self, "slowmo 0.1");
}
That's it. And then reset it after PlayerDead().
QuakeWiki
getButterfly - WordPress Support Services
Roo Holidays

Fear not the dark, but what the dark hides.
skite2001
Posts: 17
Joined: Mon Nov 17, 2008 5:40 pm

Post by skite2001 »

hmm, added:

Code: Select all

void() PlayerDie =
{
	local float ms;
        ms = cvar("slowmo");
        if(ms == 0) {
        stuffcmd(self, "slowmo 0.1");
}
	
	local	float	i;
but its not working...whats my fault?
Arkage
Posts: 66
Joined: Thu Nov 19, 2009 4:17 pm

Post by Arkage »

You haven't added a new line ("\n" ) symbol after it.

Code: Select all

void() PlayerDie =
{
   local float ms;
        ms = cvar("slowmo");
        if(ms == 0) {
        stuffcmd(self, "slowmo 0.1\n");
} 
It acts the same as if the user pressed the enter button.
Chip
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland
Contact:

Post by Chip »

skite2001 wrote:hmm, added:

Code: Select all

void() PlayerDie =
{
	local float ms;
        ms = cvar("slowmo");
        if(ms == 0) {
        stuffcmd(self, "slowmo 0.1");
}
	
	local	float	i;
but its not working...whats my fault?
Try adding only stuffcmd(self, "slowmo 0.1"); right before local float i;

I suppose you're doing this in DP.
QuakeWiki
getButterfly - WordPress Support Services
Roo Holidays

Fear not the dark, but what the dark hides.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

What Arkage said - \n.
Nothing will happen without it.
skite2001
Posts: 17
Joined: Mon Nov 17, 2008 5:40 pm

Post by skite2001 »

right, only:
stuffcmd(self, "slowmo 0.1\n");
and resetting at PlayerDead Function via
stuffcmd(self, "slowmo 1\n");
worked like a charm in darkplaces

now looking which more effects could be added ^^
Chip
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland
Contact:

Post by Chip »

skite2001 wrote:right, only:
stuffcmd(self, "slowmo 0.1\n");
and resetting at PlayerDead Function via
stuffcmd(self, "slowmo 1\n");
worked like a charm in darkplaces

now looking which more effects could be added ^^
1. motion blur
2. excessive contrast
3. b/w (?)

That's what I'm adding anyway.

Oh, and by the way, my code works without adding "\n" after "slowmo". But then again, I'll code this directly into QuakeC using cvars not stuffcmd.
QuakeWiki
getButterfly - WordPress Support Services
Roo Holidays

Fear not the dark, but what the dark hides.
GiffE
Posts: 170
Joined: Sun Oct 08, 2006 3:39 pm
Location: USA, CT
Contact:

Post by GiffE »

black and white can be done using the same way, except with the cvar r_saturation. Fade it from 1 to 0, 0 being fully saturated/blacknwhite.
Chip
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland
Contact:

Post by Chip »

GiffE wrote:black and white can be done using the same way, except with the cvar r_saturation. Fade it from 1 to 0, 0 being fully saturated/blacknwhite.
I know that. Any idea for contrast? DP-only? Any idea for any screen effect like sepia, blue tint, green tint?

EDIT: It's actually r_glsl_saturation in DP.
QuakeWiki
getButterfly - WordPress Support Services
Roo Holidays

Fear not the dark, but what the dark hides.
Post Reply