Flashbang/stun grenades?

Discuss programming in the QuakeC language.
Post Reply
Nixtwiz
Posts: 2
Joined: Thu Feb 24, 2011 12:14 am

Flashbang/stun grenades?

Post by Nixtwiz »

I found a tutorial for screen flashes and was wondering what it would take to make a "flashbang" grenade with this.

After googling it, I found a tutorial to make flashbangs, but for Quake 2. Is there anyway to incorporate this into Quake 1 or would i need or would i need to start from scratch?
I'm very new to Quake coding (so don't comment on my signature) so any help is appreciated.

The screen flash tutorial:
http://inside3d.com/showtutorial.php?id=151

The Quake II tutorial:
http://webadvisor.aupr.edu/noc/Othertut ... es%20.html
<html><body bgcolor="black"><h1 style="color:white">THIS IS MY SIG</h1></body></html>
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Post by Baker »

Artifact-RJS mod has Flash grenades.

As far as I know, they work by playing with the gamma or the content blends of anyone judged to have been looking at flash grenade when it went off.

http://www.argon.org/artifact-rjs/

Yeah this probably isn't much help considering you likely don't have enough experience to pull the feature out of the source: http://www.argon.org/artifact-rjs/archi ... .2-src.zip

Still, making such an attempt is a good start to modding.

Look at things such as W_FireGrenade, GrenadeExplode, T_RadiusLight, etc.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Error
InsideQC Staff
Posts: 865
Joined: Fri Nov 05, 2004 5:15 am
Location: VA, USA
Contact:

Post by Error »

for my flashbang, I was thinking of using a white model, attached to the player's viewport (viewmodelforclient) and alpha it until it's invisible... :lol:
Junrall
Posts: 191
Joined: Mon Sep 21, 2009 12:27 am
Location: North West Oregon, USA
Contact:

Post by Junrall »

Error wrote:for my flashbang, I was thinking of using a white model, attached to the player's viewport (viewmodelforclient) and alpha it until it's invisible... :lol:
Nice! Simple and easy to do.
Good God! You shot my leg off!
OneManClan
Posts: 247
Joined: Sat Feb 28, 2009 2:38 pm
Contact:

Post by OneManClan »

Junrall wrote:
Error wrote:for my flashbang, I was thinking of using a white model, attached to the player's viewport (viewmodelforclient) and alpha it until it's invisible... :lol:
Nice! Simple and easy to do.
This sounds intriguing, though as a newb, I'm not sure how to implement it:

1. make a new .mdl which is just a flat white surface?

2. position it in front of the 'victims' face/eyes?

3. make it follow the victim so its always in front of their face?

4. use viewmodelforclient to make sure no-one else sees it?

5. "alpha it until it's invisible... " not sure how to do this, is there any example code of 'fading something in/out', using 'alpha channel' values (which I assume are a similar concept to the 'alpha values' in photoshop)

More info please

thanks,


OneManClan
Ranger366
Posts: 203
Joined: Thu Mar 18, 2010 5:51 pm

Post by Ranger366 »

OneManClan wrote: 1. make a new .mdl which is just a flat white surface?
2. position it in front of the 'victims' face/eyes?
3. make it follow the victim so its always in front of their face?
4. use viewmodelforclient to make sure no-one else sees it?
5. "alpha it until it's invisible... " not sure how to do this, is there any example code of 'fading something in/out', using 'alpha channel' values (which I assume are a similar concept to the 'alpha values' in photoshop)

OneManClan
1) makes sense, but i would use a different mesh.
2) i would do it as the weaponmodel. (self.weaponmodel =...)
3) weaponmodel solves that
4) weaponmodel does that
5) not possible in vanilla Quake to change the alpha of an mdl texture, i didnt saw this in any other engine before - i would simply disable the flashmodelhack.

But doing this feature with a model is a bad option, it can be simply deactivated by replacing it with another viewmodel, even worser in multiplayer, its simply dirty.
Mexicouger
Posts: 514
Joined: Sat May 01, 2010 10:12 pm
Contact:

Post by Mexicouger »

Ranger366 wrote:
OneManClan wrote: 1. make a new .mdl which is just a flat white surface?
2. position it in front of the 'victims' face/eyes?
3. make it follow the victim so its always in front of their face?
4. use viewmodelforclient to make sure no-one else sees it?
5. "alpha it until it's invisible... " not sure how to do this, is there any example code of 'fading something in/out', using 'alpha channel' values (which I assume are a similar concept to the 'alpha values' in photoshop)

OneManClan
1) makes sense, but i would use a different mesh.
2) i would do it as the weaponmodel. (self.weaponmodel =...)
3) weaponmodel solves that
4) weaponmodel does that
5) not possible in vanilla Quake to change the alpha of an mdl texture, i didnt saw this in any other engine before - i would simply disable the flashmodelhack.

But doing this feature with a model is a bad option, it can be simply deactivated by replacing it with another viewmodel, even worser in multiplayer, its simply dirty.
I don't like that method at all. Why not just take an image, overlay it on the screen, and then just set its alpha lower and lower as time goes on, until it disapears. That requires some engine coding, but can be done fairly easily
Ranger366
Posts: 203
Joined: Thu Mar 18, 2010 5:51 pm

Post by Ranger366 »

Mexicouger wrote:That requires some engine coding, but can be done fairly easily
Indeed, im not very familar with displaying images at Engine coding (i just worked with view.cpp, sbar.cpp for the HUD postioning)
but i thought that (because this here is the QuakeC section) it should be done over a QC only way. Which is a bad idea because QC is >serverside< code.
Error
InsideQC Staff
Posts: 865
Joined: Fri Nov 05, 2004 5:15 am
Location: VA, USA
Contact:

Post by Error »

My mod is using dark places only in mind. Viewmodelforclient is useful as you can still have a weapon model. Anyone hit will spawn the model attached to the players view which will gradually disappear using model alpha. Using csqc would make it nicer but I try to not use csqc as I'm not that comfortable with it yet. My solution is simple, effective, and requires a whole lot less coding than the csqc/engine alternative.
Nahuel
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: Flashbang/stun grenades?

Post by Nahuel »

Nixtwiz wrote:I found a tutorial for screen flashes and was wondering what it would take to make a "flashbang" grenade with this.

After googling it, I found a tutorial to make flashbangs, but for Quake 2. Is there anyway to incorporate this into Quake 1 or would i need or would i need to start from scratch?
I'm very new to Quake coding (so don't comment on my signature) so any help is appreciated.

The screen flash tutorial:
http://inside3d.com/showtutorial.php?id=151

The Quake II tutorial:
http://webadvisor.aupr.edu/noc/Othertut ... es%20.html



if you use the code for that tutorial, you should open weapons.qc
find the code
void() GrenadeExplode =
{
T_RadiusDamage (self, self.owner, 120, world);

WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_EXPLOSION);
WriteCoord (MSG_BROADCAST, self.origin_x);
WriteCoord (MSG_BROADCAST, self.origin_y);
WriteCoord (MSG_BROADCAST, self.origin_z);

BecomeExplosion ();
};

and change with
void() GrenadeExplode =
{

BecomeExplosion ();
Palfrom(700, 350, self.origin, world, 250, 250, 250, 1, FALSE);
sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 0.3, ATTN_NORM);

};



grettings
hi, I am nahuel, I love quake and qc.
Nixtwiz
Posts: 2
Joined: Thu Feb 24, 2011 12:14 am

Post by Nixtwiz »

If i replaced the code it would get rid of the normal grenade too. I need to have both an explosive grenade and a flashbang grenade.
<html><body bgcolor="black"><h1 style="color:white">THIS IS MY SIG</h1></body></html>
Ranger366
Posts: 203
Joined: Thu Mar 18, 2010 5:51 pm

Post by Ranger366 »

Nixtwiz wrote:If i replaced the code it would get rid of the normal grenade too. I need to have both an explosive grenade and a flashbang grenade.
Logically, make a copy of GrenadeExplode and modify it, then make that the grenade uses the copy instead of the original.
Nahuel
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Post by Nahuel »

Nixtwiz wrote:If i replaced the code it would get rid of the normal grenade too. I need to have both an explosive grenade and a flashbang grenade.
I recommend then have the flash-grenade as a secondary fire of the grenade launcher (if you do not want to create a new item).
It is easy to do with this tutorial
http://www.inside3d.com/showtutorial.php?id=19
so you can have the two grenade explosions
hi, I am nahuel, I love quake and qc.
MauveBib
Posts: 634
Joined: Thu Nov 04, 2004 1:22 am

Post by MauveBib »

I use the floating fading model idea in My Squad AI Thing, albeit in reverse, in order to make the screen fade to black on death.
Apathy Now!
Post Reply