Make Enemy Explode On Death

Discuss programming in the QuakeC language.
Post Reply
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Make Enemy Explode On Death

Post by Baker »

How can I make an enemy explode on death, like an explobox?
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 ..
gnounc
Posts: 428
Joined: Mon Apr 06, 2009 6:26 am

Re: Make Enemy Explode On Death

Post by gnounc »

replace the monsters death function with the death function of an explo box.

Looking in soldier.qc we see

Code: Select all

void() army_die =
{
// check for gib
	if (self.health < -35)
	{
		sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM);
		ThrowHead ("progs/h_guard.mdl", self.health);
		ThrowGib ("progs/gib1.mdl", self.health);
		ThrowGib ("progs/gib2.mdl", self.health);
		ThrowGib ("progs/gib3.mdl", self.health);
		return;
	}

// regular death
	sound (self, CHAN_VOICE, "soldier/death1.wav", 1, ATTN_NORM);
	if (random() < 0.5)
		army_die1 ();
	else
		army_cdie1 ();
};
you can replace its innards with the innards of the explo box death, or you can find where its called

Code: Select all

void() monster_army =
{	
....
...
	self.th_die = army_die;
..
..
}

and replace that with the explocode found in misc.qc

Code: Select all

void() barrel_explode =
{
	self.takedamage = DAMAGE_NO;
	self.classname = "explo_box";
	// did say self.owner
	T_RadiusDamage (self, self, 160, world);
	sound (self, CHAN_VOICE, "weapons/r_exp3.wav", 1, ATTN_NORM);
	particle (self.origin, '0 0 0', 75, 255);

	self.origin_z = self.origin_z + 32;
	BecomeExplosion ();
};
so
self.th_die = army_die;
is now
self.th_die = barrel_explode;
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Make Enemy Explode On Death

Post by Baker »

Thanks!
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 ..
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: Make Enemy Explode On Death

Post by frag.machine »

Be aware that doing so the enemies will have a blast damage like the exploding boxes, too.
Also, could be fun to keep the gib throwing part from the original death function.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
silverjoel
Posts: 52
Joined: Thu Sep 30, 2010 6:46 am

Re: Make Enemy Explode On Death

Post by silverjoel »

BecomeExplosion ();

This is what actually makes them explode.

Code: Select all

void()	army_die1	=[	$death1,	army_die2	] {};
void()	army_die2	=[	$death2,	army_die3	] {};
void()	army_die3	=[	$death3,	army_die4	]
{self.solid = SOLID_NOT;self.ammo_shells = 5;DropBackpack();};
void()	army_die4	=[	$death4,	army_die5	] {};
void()	army_die5	=[	$death5,	army_die6	] {};
void()	army_die6	=[	$death6,	army_die7	] {};
void()	army_die7	=[	$death7,	army_die8	] {};
void()	army_die8	=[	$death8,	army_die9	] {};
void()	army_die9	=[	$death9,	army_die10	] {};
void()	army_die10	=[	$death10,	army_die10	] {BecomeExplosion ();};
Will make the soldier explode. You could make your own exploding death function. Look at the tarbaby's.

Code: Select all

void()	tbaby_die1	=[	$exp,		tbaby_die2	] {
self.takedamage = DAMAGE_NO;
};
void()	tbaby_die2	=[	$exp,		tbaby_run1	] 
{
	T_RadiusDamage (self, self, 120, world);

	sound (self, CHAN_VOICE, "blob/death1.wav", 1, ATTN_NORM);
	self.origin = self.origin - 8*normalize(self.velocity);

	WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
	WriteByte (MSG_BROADCAST, TE_TAREXPLOSION);
	WriteCoord (MSG_BROADCAST, self.origin_x);
	WriteCoord (MSG_BROADCAST, self.origin_y);
	WriteCoord (MSG_BROADCAST, self.origin_z);
	
	BecomeExplosion ();
};
New function

Code: Select all

void() death_explode =
{
	self.takedamage = DAMAGE_NO;  //entity doesn't take any more damage
	T_RadiusDamage (self, self, 120, world);  //damage given by explosion
	sound (self, CHAN_VOICE, "weapons/r_exp3.wav", 1, ATTN_NORM);  //explosion sound

	WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);  //create a temp entity
	WriteByte (MSG_BROADCAST, TE_EXPLOSION);  //create the explosion effect
	WriteCoord (MSG_BROADCAST, self.origin_x);  //where the explosion is
	WriteCoord (MSG_BROADCAST, self.origin_y);
	WriteCoord (MSG_BROADCAST, self.origin_z);

	BecomeExplosion ();
};
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Make Enemy Explode On Death

Post by Baker »

Obviously I didn't think of spawns :D

Baker -1

Thanks for the QuakeC thoughts / example code.
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 ..
Seven
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: Make Enemy Explode On Death

Post by Seven »

Hello Baker,

Interesting to see that you also have some of those ideas...
That is how I started with the additional death animations in the "small mod compilation",
which should scare/suprise/entertain the player.
I like frag.machine´s idea too.
In the meantime I went over to "burn" the corpses to ashes after some time.
Crazy ideas needs crazy minds :)

All the best for your project,
Seven
gnounc
Posts: 428
Joined: Mon Apr 06, 2009 6:26 am

Re: Make Enemy Explode On Death

Post by gnounc »

BecomeExplosion ();

This is what actually makes them explode.
BecomeExplosion just changes the model to the explosion sprite.
If you intend the explosion to do any damage, you'll need the call to t_radiusDamage() that you see in the tarbabies code as well.

The way I show includes the damage, which I assume was the desired effect.

The way I outlined has the added benefit of having exactly 1 line of code changed.
Its dead simple.
Seven
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: Make Enemy Explode On Death

Post by Seven »

Please excuse me Baker.

But your death animation thread here and the new game "Legend of Grimrock", which is an amazing game and everybody should try/buy it,
made me try to bring the death animations into Quake.

It was a fun experience to fiddeling with qc and particle effects to get what Legend of Grimrock has.
Just to show you my actual progress:

These are the death animations of Legend of Grimrock
http://www.youtube.com/watch?v=G_-GjV1g ... ature=plcp

This is my trial to bring them into Quake:
http://www.youtube.com/watch?v=8KYbcURe ... ature=plcp

This is the very simple code I used:

Code: Select all

void()	army_die1	=[	$death1,	army_die2	] {
self.traileffectnum = particleeffectnum("grimrock_soldier");};
void()	army_die2	=[	$death2,	army_die3	] {
self.alpha = 0.7;};
void()	army_die3	=[	$death3,	army_die4	]
{self.solid = SOLID_NOT;self.ammo_shells = 5;DropBackpack();
self.alpha = 0.6;};
void()	army_die4	=[	$death4,	army_die5	] {
self.alpha = 0.5;};
void()	army_die5	=[	$death5,	army_die6	] {
self.alpha = 0.4;};
void()	army_die6	=[	$death6,	army_die7	] {
self.alpha = 0.3;};
void()	army_die7	=[	$death7,	army_die8	] {
self.alpha = 0.2;};
void()	army_die8	=[	$death8,	army_die9	] {
self.alpha = 0.1;};
void()	army_die9	=[	$death9,	army_die10	] {
self.alpha = -1;};
void()	army_die10	=[	$death10,	army_die10	] {
remove(self);
};
It maybe inspires you to make your (of course much better) death animation.

Best wishes,
Seven
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: Make Enemy Explode On Death

Post by toneddu2000 »

very nice effect in general, Seven! For this purpose I found it a little "weak", comparing it to the "original" I think you made a great job, but as an explosion effect per se imo it would be better to add some radius explosion
How do you create the particle? Did you use DP?
Meadow Fun!! - my first commercial game, made with FTEQW game engine
qbism
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am
Contact:

Re: Make Enemy Explode On Death

Post by qbism »

Seven wrote:This is my trial to bring them into Quake:
http://www.youtube.com/watch?v=8KYbcURe ... ature=plcp
I liked your effect because it looked like disintegration while still in motion rather than dropping straight down. Would be more like the original effect for the particles to stay on the ground a bit longer before fading.
gnounc
Posts: 428
Joined: Mon Apr 06, 2009 6:26 am

Re: Make Enemy Explode On Death

Post by gnounc »

Since you cant outline the model with particles as tightly as grimrock can, you could cheat a little and add a skin frame to your models
that has the red particles interspersed along its defining edges. That would probably help make the effect look much tighter.

Your current version looks very good though.
Good work.
Seven
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: Make Enemy Explode On Death

Post by Seven »

Thank you for your feedback.

toneddu2000,
yes, i use DP (please see the qc code with dpextensions i used to achieve it).
If you want to try it yourself, I added a download (with QC source and effectinfo) over at quakeone.com:
http://quakeone.com/forums/quake-mod-re ... post111594
The effect has no explosion, because I only wanted to "copy" the Legend of Grimrock effect.
I am sorry for the offtopic in Bakers thread.

qbism,
Yes you are right. The particles should stay a little longer on ground before they vanish.
Thank you for the tip.

gnounc,
I am not sure how to do that (adding a skinframe to a model with particles interspersed).
To be honest, I even dont fully understand your english meaning (my motzher tounge is german) :)
I will try to modify the spawning position of the particles a little more via effectinfo params.

Again, I am sorry for the offtopic talk Baker.
r00k
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Re: Make Enemy Explode On Death

Post by r00k »

SELF.HEALTH -= 500;

instant gib!


TE_ ... edit: nvm players should explode like a frog in a blender not like a fireball...
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: Make Enemy Explode On Death

Post by toneddu2000 »

thanks Seven for the hint, I'll try it!
Meadow Fun!! - my first commercial game, made with FTEQW game engine
Post Reply