Forum

Player death post effects

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Player death post effects

Postby Chip » Wed Jun 30, 2010 11:55 am

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.
User avatar
Chip
 
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland

Postby frag.machine » Wed Jun 30, 2010 12:11 pm

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)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Postby Spike » Wed Jun 30, 2010 1:03 pm

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).
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby Chip » Wed Jun 30, 2010 1:54 pm

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.
User avatar
Chip
 
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland

Postby skite2001 » Wed Jun 30, 2010 4:48 pm

nice, please keep me informed if you add/improve this thing^^ i really would like to add this to my mod ^_-
User avatar
skite2001
 
Posts: 17
Joined: Mon Nov 17, 2008 5:40 pm

Postby frag.machine » Wed Jun 30, 2010 5:41 pm

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)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Postby Chip » Wed Jun 30, 2010 8:24 pm

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.
User avatar
Chip
 
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland

Postby skite2001 » Wed Jun 30, 2010 8:58 pm

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?
User avatar
skite2001
 
Posts: 17
Joined: Mon Nov 17, 2008 5:40 pm

Postby Arkage » Wed Jun 30, 2010 9:10 pm

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.
User avatar
Arkage
 
Posts: 66
Joined: Thu Nov 19, 2009 4:17 pm

Postby Chip » Thu Jul 01, 2010 10:12 am

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.
User avatar
Chip
 
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland

Postby Spike » Thu Jul 01, 2010 10:16 am

What Arkage said - \n.
Nothing will happen without it.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby skite2001 » Sat Jul 03, 2010 4:28 pm

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 ^^
User avatar
skite2001
 
Posts: 17
Joined: Mon Nov 17, 2008 5:40 pm

Postby Chip » Sun Jul 04, 2010 10:04 am

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.
User avatar
Chip
 
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland

Postby GiffE » Fri Jul 09, 2010 2:17 am

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.
GiffE
 
Posts: 170
Joined: Sun Oct 08, 2006 3:39 pm
Location: USA, CT

Postby Chip » Fri Jul 09, 2010 9:23 am

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.
User avatar
Chip
 
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland

Next

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest