Page 1 of 1

Make Enemy Explode On Death

Posted: Sun May 06, 2012 11:28 pm
by Baker
How can I make an enemy explode on death, like an explobox?

Re: Make Enemy Explode On Death

Posted: Sun May 06, 2012 11:57 pm
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;

Re: Make Enemy Explode On Death

Posted: Mon May 07, 2012 12:20 am
by Baker
Thanks!

Re: Make Enemy Explode On Death

Posted: Mon May 07, 2012 2:23 am
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.

Re: Make Enemy Explode On Death

Posted: Mon May 07, 2012 4:56 am
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 ();
};

Re: Make Enemy Explode On Death

Posted: Mon May 07, 2012 7:05 am
by Baker
Obviously I didn't think of spawns :D

Baker -1

Thanks for the QuakeC thoughts / example code.

Re: Make Enemy Explode On Death

Posted: Mon May 07, 2012 11:19 am
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

Re: Make Enemy Explode On Death

Posted: Tue May 08, 2012 4:50 am
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.

Re: Make Enemy Explode On Death

Posted: Tue May 08, 2012 6:13 pm
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

Re: Make Enemy Explode On Death

Posted: Tue May 08, 2012 9:16 pm
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?

Re: Make Enemy Explode On Death

Posted: Tue May 08, 2012 11:26 pm
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.

Re: Make Enemy Explode On Death

Posted: Wed May 09, 2012 6:02 am
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.

Re: Make Enemy Explode On Death

Posted: Wed May 09, 2012 4:40 pm
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.

Re: Make Enemy Explode On Death

Posted: Thu May 10, 2012 3:54 am
by r00k
SELF.HEALTH -= 500;

instant gib!


TE_ ... edit: nvm players should explode like a frog in a blender not like a fireball...

Re: Make Enemy Explode On Death

Posted: Thu May 10, 2012 9:52 pm
by toneddu2000
thanks Seven for the hint, I'll try it!