FAQ  •  Register  •  Login

Make Enemy Explode On Death

Moderator: Inside3D Admins

<<

Baker

User avatar

Posts: 3191

Joined: Tue Mar 14, 2006 5:15 am

Post Sun May 06, 2012 11:28 pm

Make Enemy Explode On Death

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

User avatar

Posts: 305

Joined: Mon Apr 06, 2009 6:26 am

Post Sun May 06, 2012 11:57 pm

Re: Make Enemy Explode On Death

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

Looking in soldier.qc we see

  Code:
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:
void() monster_army =
{   
....
...
   self.th_die = army_die;
..
..
}



and replace that with the explocode found in misc.qc

  Code:
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

User avatar

Posts: 3191

Joined: Tue Mar 14, 2006 5:15 am

Post Mon May 07, 2012 12:20 am

Re: Make Enemy Explode On Death

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

User avatar

Posts: 1486

Joined: Sat Nov 25, 2006 1:49 pm

Post Mon May 07, 2012 2:23 am

Re: Make Enemy Explode On Death

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: 38

Joined: Thu Sep 30, 2010 6:46 am

Post Mon May 07, 2012 4:56 am

Re: Make Enemy Explode On Death

BecomeExplosion ();

This is what actually makes them explode.

  Code:
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:
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:
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

User avatar

Posts: 3191

Joined: Tue Mar 14, 2006 5:15 am

Post Mon May 07, 2012 7:05 am

Re: Make Enemy Explode On Death

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: 238

Joined: Sat Oct 06, 2007 8:49 pm

Location: Germany

Post Mon May 07, 2012 11:19 am

Re: Make Enemy Explode On Death

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

User avatar

Posts: 305

Joined: Mon Apr 06, 2009 6:26 am

Post Tue May 08, 2012 4:50 am

Re: Make Enemy Explode On Death

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: 238

Joined: Sat Oct 06, 2007 8:49 pm

Location: Germany

Post Tue May 08, 2012 6:13 pm

Re: Make Enemy Explode On Death

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:
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: 321

Joined: Tue Feb 24, 2009 4:39 pm

Location: Italy

Post Tue May 08, 2012 9:16 pm

Re: Make Enemy Explode On Death

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?
<<

qbism

User avatar

Posts: 811

Joined: Thu Nov 04, 2004 5:51 am

Post Tue May 08, 2012 11:26 pm

Re: Make Enemy Explode On Death

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

User avatar

Posts: 305

Joined: Mon Apr 06, 2009 6:26 am

Post Wed May 09, 2012 6:02 am

Re: Make Enemy Explode On Death

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: 238

Joined: Sat Oct 06, 2007 8:49 pm

Location: Germany

Post Wed May 09, 2012 4:40 pm

Re: Make Enemy Explode On Death

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: 922

Joined: Sat Nov 13, 2004 10:39 pm

Post Thu May 10, 2012 3:54 am

Re: Make Enemy Explode On Death

SELF.HEALTH -= 500;

instant gib!


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

toneddu2000

Posts: 321

Joined: Tue Feb 24, 2009 4:39 pm

Location: Italy

Post Thu May 10, 2012 9:52 pm

Re: Make Enemy Explode On Death

thanks Seven for the hint, I'll try it!

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.
Icons provided by Aha Soft