Inside3D!
     

Player death post effects
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
Chip



Joined: 21 Jan 2009
Posts: 314
Location: Romania

PostPosted: Wed Jun 30, 2010 11:55 am    Post subject: Player death post effects Reply with quote

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.
_________________
My Projects: Quake 1 Mods | OpenQuartz 2 | ChipQuake
Back to top
View user's profile Send private message Visit poster's website
frag.machine



Joined: 25 Nov 2006
Posts: 728

PostPosted: Wed Jun 30, 2010 12:11 pm    Post subject: Reply with quote

Have you already tried something like this ?
Code:

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.
_________________
frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/
Back to top
View user's profile Send private message Visit poster's website
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Wed Jun 30, 2010 1:03 pm    Post subject: Reply with quote

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).
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
Chip



Joined: 21 Jan 2009
Posts: 314
Location: Romania

PostPosted: Wed Jun 30, 2010 1:54 pm    Post subject: Reply with quote

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.
_________________
My Projects: Quake 1 Mods | OpenQuartz 2 | ChipQuake
Back to top
View user's profile Send private message Visit poster's website
skite2001



Joined: 17 Nov 2008
Posts: 17

PostPosted: Wed Jun 30, 2010 4:48 pm    Post subject: Reply with quote

nice, please keep me informed if you add/improve this thing^^ i really would like to add this to my mod ^_-
Back to top
View user's profile Send private message
frag.machine



Joined: 25 Nov 2006
Posts: 728

PostPosted: Wed Jun 30, 2010 5:41 pm    Post subject: Reply with quote

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.
_________________
frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/
Back to top
View user's profile Send private message Visit poster's website
Chip



Joined: 21 Jan 2009
Posts: 314
Location: Romania

PostPosted: Wed Jun 30, 2010 8:24 pm    Post subject: Reply with quote

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

Right after PlayerDie() {

Code:
local float ms;
ms = cvar("slowmo");
if(ms == 0) {
   stuffcmd(self, "slowmo 0.1");
}


That's it. And then reset it after PlayerDead().
_________________
My Projects: Quake 1 Mods | OpenQuartz 2 | ChipQuake
Back to top
View user's profile Send private message Visit poster's website
skite2001



Joined: 17 Nov 2008
Posts: 17

PostPosted: Wed Jun 30, 2010 8:58 pm    Post subject: Reply with quote

hmm, added:

Code:
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?
Back to top
View user's profile Send private message
Arkage



Joined: 19 Nov 2009
Posts: 27

PostPosted: Wed Jun 30, 2010 9:10 pm    Post subject: Reply with quote

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

Code:

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.
Back to top
View user's profile Send private message
Chip



Joined: 21 Jan 2009
Posts: 314
Location: Romania

PostPosted: Thu Jul 01, 2010 10:12 am    Post subject: Reply with quote

skite2001 wrote:
hmm, added:

Code:
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.
_________________
My Projects: Quake 1 Mods | OpenQuartz 2 | ChipQuake
Back to top
View user's profile Send private message Visit poster's website
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Thu Jul 01, 2010 10:16 am    Post subject: Reply with quote

What Arkage said - \n.
Nothing will happen without it.
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
skite2001



Joined: 17 Nov 2008
Posts: 17

PostPosted: Sat Jul 03, 2010 4:28 pm    Post subject: Reply with quote

right, only:

Quote:
stuffcmd(self, "slowmo 0.1\n");

and resetting at PlayerDead Function via
Quote:
stuffcmd(self, "slowmo 1\n");


worked like a charm in darkplaces

now looking which more effects could be added ^^
Back to top
View user's profile Send private message
Chip



Joined: 21 Jan 2009
Posts: 314
Location: Romania

PostPosted: Sun Jul 04, 2010 10:04 am    Post subject: Reply with quote

skite2001 wrote:
right, only:

Quote:
stuffcmd(self, "slowmo 0.1\n");

and resetting at PlayerDead Function via
Quote:
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.
_________________
My Projects: Quake 1 Mods | OpenQuartz 2 | ChipQuake
Back to top
View user's profile Send private message Visit poster's website
GiffE



Joined: 08 Oct 2006
Posts: 141
Location: USA, CT

PostPosted: Fri Jul 09, 2010 2:17 am    Post subject: Reply with quote

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.
_________________
http://www.giffe-bin.net/
Back to top
View user's profile Send private message Visit poster's website
Chip



Joined: 21 Jan 2009
Posts: 314
Location: Romania

PostPosted: Fri Jul 09, 2010 9:23 am    Post subject: Reply with quote

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.
_________________
My Projects: Quake 1 Mods | OpenQuartz 2 | ChipQuake
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group