Author Topic: Spawning an entity when a missile explodes.  (Read 5298 times)

Piper802

  • Posts: 56
  • Turrets: +2/-2
Spawning an entity when a missile explodes.
« on: August 04, 2009, 07:42:19 am »
Hey, recently I've been getting started on modding Tremulous's source and have made some pretty fun stuff. Like I modified the lucifer cannon so it shot more like a missile launcher (5 shots per clip, fast bolt travels fast, higher damage, and it plays the EV_human_buildable_explosion effect when it explodes). Now, I wanted to do something similar to that using the same technique but with "acid bombs" (like in TremX). Though I've noticed that the way I had been coding it, alien bolts won't spawn any type of entity. Human bolts will.. (I've spawned hives, explosion effects etc). But alien bolts still spawn nothing. As you probably know, when a bolt reaches it's "next think" it explodes and calls the function "g_explodeMissile". Then in g_missile you can manipulate how a specific bolt explodes (like this):

Code: [Select]
/*
================
G_ExplodeMissile

Explode a missile without an impact
================
*/
void G_ExplodeMissile( gentity_t *ent )
{
  gentity_t *vic, *tent, *other;
  vec3_t    dir;
  vec3_t    origin;

  if( ent->parent && ent->parent->client && !strcmp( ent->classname, "grenade" ) )
    --ent->parent->client->pers.grenadeCount;

  BG_EvaluateTrajectory( &ent->s.pos, level.time, origin );
  SnapVector( origin );
  G_SetOrigin( ent, origin );

  // we don't have a valid direction, so just point straight up
  dir[ 0 ] = dir[ 1 ] = 0;
  dir[ 2 ] = 1;

  ent->s.eType = ET_GENERAL;

  if( ent->s.weapon != WP_LOCKBLOB_LAUNCHER &&
      ent->s.weapon != WP_FLAMER )
    G_AddEvent( ent, EV_MISSILE_MISS, DirToByte( dir ) );

  ent->freeAfterEvent = qtrue;
  
  switch( ent->s.weapon )
  {
case WP_LUCIFER_CANNON:
 tent = G_TempEntity( ent->r.currentOrigin, EV_HUMAN_BUILDABLE_EXPLOSION );
 break;
default:
break;
}
 switch( ent->s.weapon )
  {
case WP_ALEVEL3_UPG:
 tent = G_TempEntity( ent->r.currentOrigin, EV_ALIEN_BUILDABLE_EXPLOSION );
 hiveFire( ent );
 break;
default:
break;
}


  // splash damage
  if( ent->splashDamage )
    G_RadiusDamage( ent->r.currentOrigin, ent->parent, ent->splashDamage,
                    ent->splashRadius, ent, ent->splashMethodOfDeath );

  trap_LinkEntity( ent );
}
More specifically, these are the lines which manipulate how the lucifer cannon/dragoon barb explode:
Code: [Select]
 switch( ent->s.weapon )
  {
case WP_LUCIFER_CANNON:
 tent = G_TempEntity( ent->r.currentOrigin, EV_HUMAN_BUILDABLE_EXPLOSION );
 break;
default:
break;
}
 switch( ent->s.weapon )
  {
case WP_ALEVEL3_UPG:
 tent = G_TempEntity( ent->r.currentOrigin, EV_ALIEN_BUILDABLE_EXPLOSION );
 hiveFire( ent );
 break;
default:
break;
}
They're pretty much the same code, just for different weapons. Though for some reason, the lucifer cannon will spawn the ev_human_buildable_explosion without any problems, but the dragoon barb won't spawn either the ev_alien_buildable_explosion or the hive.

Does anyone know what's wrong? Thanks in advance.
« Last Edit: August 04, 2009, 07:49:39 am by Piper802 »

benmachine

  • Posts: 915
  • Turrets: +99/-76
    • ben's machinery
Re: Spawning an entity when a missile explodes.
« Reply #1 on: August 04, 2009, 11:13:56 pm »
Looks to me like G_ExplodeMissile is only called when a missile expires having not hit anything. Normally, G_MissileImpact is used.

That doesn't explain why it works for lcannon so I'm not too confident of that answer, but it definitely looks like that.
benmachine

kevlarman

  • Posts: 2737
  • Turrets: +291/-295
Re: Spawning an entity when a missile explodes.
« Reply #2 on: August 05, 2009, 12:17:07 am »
it's not a particularly good idea to call hiveFire() on an entity that isn't a hive.
Quote from: Asvarox link=topic=8622.msg169333#msg169333
Ok let's plan it out. Asva, you are nub, go sit on rets, I will build, you two go feed like hell, you go pwn their asses, and everyone else camp in the hallway, roger?
the dretch bites.
-----
|..d| #
|.@.-##
-----

Piper802

  • Posts: 56
  • Turrets: +2/-2
Re: Spawning an entity when a missile explodes.
« Reply #3 on: August 05, 2009, 08:42:38 pm »
Thanks benmachine! It worked :D. Apparently the reason why the luci would play an effect when impacts is because theres some more lines in g_missileImpact which tell tell the it to call g_explodeMissile when the luci impacts D:. And the reason why it worked with pulse rifle was because in the mod I'm making the pulse speed was set to 0 lol... So it expired naturally. Anyways, thanks for the help :D.
Edit:
The only problem is that the hives don't do any damage :[. It's probably easy to fix, but while I have you guys here I'd like some input lol.
« Last Edit: August 05, 2009, 09:29:17 pm by Piper802 »

Piper802

  • Posts: 56
  • Turrets: +2/-2
Re: Spawning an entity when a missile explodes.
« Reply #4 on: August 05, 2009, 08:43:22 pm »
Meh, sorry for the double post, accidently clicked quote when I meant modify /noob.
« Last Edit: August 05, 2009, 08:49:12 pm by Piper802 »

Repatition

  • Posts: 332
  • Turrets: +11/-196
    • http://jbjarts.blogspot.com/
Re: Spawning an entity when a missile explodes.
« Reply #5 on: August 07, 2009, 11:27:56 pm »
this would make a cool mod!

Piper802

  • Posts: 56
  • Turrets: +2/-2
Re: Spawning an entity when a missile explodes.
« Reply #6 on: August 09, 2009, 04:40:22 am »
Thanks :D. It'll hopefully be hosted on [TFF]The Final Frontier as the Grangers on Ice minigame.