Making missiles hit the owner

Discussion for Level editing, modeling, programming, or any of the other technical aspects of Quake
Post Reply
corncobman
Posts: 304
Joined: Fri Aug 08, 2003 7:00 am

Making missiles hit the owner

Post by corncobman »

I'm having a bit of trouble getting missiles to hit the owner, in g_runmissile() in g_missile.c

Code: Select all

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

	
	if ( ent->target_ent ) {
		passent = ent->target_ent->s.number;
	}

	else if (ent->count) 
	{
		passent = ENTITYNUM_NONE;
	}

	else {
		passent = ent->r.ownerNum;
	}
	
	trap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, origin, passent, ent->clipmask | CONTENTS_TRIGGER);

	if ( tr.entityNum != ENTITYNUM_NONE )
	{
		
		traceEnt = &g_entities[ tr.entityNum ];

		if((strcmp(ent->classname, "hook")) && (strcmp(ent->classname, "althook")))
		if(g_telemissiles.integer)
		if ( traceEnt && traceEnt->s.eType == ET_TELEPORT_TRIGGER ) {
			trigger_teleporter_touch ( traceEnt, ent, &tr );
			return;
		}

		if((strcmp(ent->classname, "hook")) && (strcmp(ent->classname, "althook")))
		if(g_bouncepadmissiles.integer)
		if ( traceEnt && traceEnt->s.eType == ET_PUSH_TRIGGER ) {
			trigger_push_touch ( traceEnt, ent, &tr );
			return;
		}
	}

	
	if ( tr.startsolid || tr.allsolid ) {
	
		trap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, ent->r.currentOrigin, passent, ent->clipmask );
		tr.fraction = 0;
	}
	else {
		VectorCopy( tr.endpos, ent->r.currentOrigin );
	}

	trap_LinkEntity( ent );

	if ( tr.fraction != 1 ) {
		
		if ( tr.surfaceFlags & SURF_NOIMPACT ) {
			if (ent->parent && ent->parent->client && ent->parent->client->hook == ent) {
				ent->parent->client->hook = NULL;
			}
			G_FreeEntity( ent );
			return;
		}

		G_MissileImpact( ent, &tr );
		
		if ( ent->s.eType != ET_MISSILE ) {
			return;		
		} 
	}

	if (!ent->count) {
		trap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, ent->r.currentOrigin, ENTITYNUM_NONE, ent->clipmask );
		if (!tr.startsolid || tr.entityNum != ent->r.ownerNum) {
			ent->count = 1;
		}
	}

	if(trap_PointContents (origin , -1) & MASK_WATER)
	{
		if(ent->s.weapon == WP_PLASMAGUN)
		{
			G_ExplodeMissile(ent);
			return;
		}
	}

	G_RunThink( ent );
The code above works provided I don't make the missiles shootable in the actual fire function, I think it might have something to do with the r.maxs and r.mins. If I do make the missiles shootable, the missile explodes immediately after being fired.

Code: Select all

bolt->health = rocket.health;
		bolt->takedamage = qtrue; 
		bolt->die = G_MissileDie; 	
		bolt->r.contents = CONTENTS_SHOOTABLE;
		VectorSet(bolt->r.mins, -10, -3, 0); 
		VectorCopy(bolt->r.mins, bolt->r.absmin); 
		VectorSet(bolt->r.maxs, 10, 3, 6); 
		VectorCopy(bolt->r.maxs, bolt->r.absmax);
-It is not the fall that kills you. It's the sudden stop at the end. (Douglas Adams)-

[url=http://www.violationentertainment.com/misc/ccm]-An eyeful a day is bloody fantastic!-[/url]
4days
Posts: 5465
Joined: Tue Apr 16, 2002 7:00 am

Post by 4days »

not a coder so i'm probably talking bollocks, but wouldn't you need to let the missle fly for a second or two before it thinks about a target?
corncobman
Posts: 304
Joined: Fri Aug 08, 2003 7:00 am

Post by corncobman »

Probably. I tried incorporating a wait into the missile without much success, they just explode after the wait has expired.
-It is not the fall that kills you. It's the sudden stop at the end. (Douglas Adams)-

[url=http://www.violationentertainment.com/misc/ccm]-An eyeful a day is bloody fantastic!-[/url]
Post Reply