Page 1 of 1

Custom grappling hook (trail)?!

Posted: Tue Dec 30, 2008 10:26 am
by Herr W
Hi everyone!

I've just replaced the grappling hook by a sticky, Monkeys-of-Doom style chameleon. :D Problem is that it still fires with the lightning-gun trail, which unfortunately doesn't look like a chameleon-tongue at all :cry:

What I found in cg_weapons.c is this:

Code: Select all

/*
==========================
CG_GrappleTrail
==========================
*/
void CG_GrappleTrail( centity_t *ent, const weaponInfo_t *wi ) {
	vec3_t	origin;
	entityState_t	*es;
	vec3_t			forward, up;
	refEntity_t		beam;

	es = &ent->currentState;

	BG_EvaluateTrajectory( &es->pos, cg.time, origin );
	ent->trailTime = cg.time;

	memset( &beam, 0, sizeof( beam ) );
	//FIXME adjust for muzzle position
	VectorCopy ( cg_entities[ ent->currentState.otherEntityNum ].lerpOrigin, beam.origin );
	beam.origin[2] += 26;
	AngleVectors( cg_entities[ ent->currentState.otherEntityNum ].lerpAngles, forward, NULL, up );
	VectorMA( beam.origin, -6, up, beam.origin );
	VectorCopy( origin, beam.oldorigin );

	if (Distance( beam.origin, beam.oldorigin ) < 64 )
		return; // Don't draw if close

	beam.reType = RT_LIGHTNING;
	beam.customShader = cgs.media.lightningShader;

	AxisClear( beam.axis );
	beam.shaderRGBA[0] = 0xff;
	beam.shaderRGBA[1] = 0xff;
	beam.shaderRGBA[2] = 0xff;
	beam.shaderRGBA[3] = 0xff;
	trap_R_AddRefEntityToScene( &beam );
}
... Where

Code: Select all

	beam.reType = RT_LIGHTNING;
	beam.customShader = cgs.media.lightningShader;
... seems to tell the game to use the lightning-gun beam and it's shader for the grappling hook. - Question is, if there is a (not too tricky) way to create a custom texture or shader to replace it... :confused:

Re: Custom grappling hook (trail)?!

Posted: Tue Dec 30, 2008 11:06 am
by ^misantropia^
Yep. Add a field 'qhandle_t grapplingHookShader' to the cgMedia_t struct in cgame/cg_local.h and initialize it in cgame/cg_weapons.c, function CG_RegisterWeapon(). Add a 'case WP_GRAPPLING_HOOK:' to the switch and load your shader with:

Code: Select all

cgs.media.grapplingHookShader = trap_R_RegisterShader("yourShader");

Re: Custom grappling hook (trail)?!

Posted: Tue Dec 30, 2008 3:33 pm
by Herr W
Cool, works!!! Thanks a lot, ^misantropia^! :)