News:

Come Chat with us live! Learn how HERE!

Main Menu

Spawning an entity when a missile explodes.

Started by Piper802, August 04, 2009, 07:42:19 AM

Piper802

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

/*
================
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:
 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.

benmachine

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

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#msg169333Ok 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

#3
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.

Piper802

#4
Meh, sorry for the double post, accidently clicked quote when I meant modify /noob.

Repatition


Piper802

Thanks :D. It'll hopefully be hosted on [TFF]The Final Frontier as the Grangers on Ice minigame.