Tremulous Forum

Mods => Modding Center => Topic started by: Piper802 on August 04, 2009, 07:42:19 am

Title: Spawning an entity when a missile explodes.
Post by: Piper802 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.
Title: Re: Spawning an entity when a missile explodes.
Post by: benmachine 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.
Title: Re: Spawning an entity when a missile explodes.
Post by: kevlarman 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.
Title: Re: Spawning an entity when a missile explodes.
Post by: Piper802 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.
Title: Re: Spawning an entity when a missile explodes.
Post by: Piper802 on August 05, 2009, 08:43:22 pm
Meh, sorry for the double post, accidently clicked quote when I meant modify /noob.
Title: Re: Spawning an entity when a missile explodes.
Post by: Repatition on August 07, 2009, 11:27:56 pm
this would make a cool mod!
Title: Re: Spawning an entity when a missile explodes.
Post by: Piper802 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.