Model Effect

Hi.

I want to add the 3D model lightning bolt effect to the Q1 Lightning gun, but i dont know how would i make it move (since it has no anims) or make its reach beign dynamic.

It is 3 model (bolt.mdl;bolt2.mdl;bolt3.mdl) files that works like a trail, but moves randomly and has a dynamic reach (like a trail, but with a model).

Heres what im trying to do:

And this is some C code i have found on Quake’s Sourcecode (maybe porting it to LUA may solve my issue):


	// Lightning bolt effect
	TraceResult trace;
	Vector vecOrg = pev->origin + Vector(0,0,16);
	UTIL_MakeVectors( pev->v_angle + pev->punchangle );

	// adjust lightning origin
	Vector tmpSrc = EyePosition() + gpGlobals->v_forward * 20 + gpGlobals->v_up * -8;
	UTIL_TraceLine( vecOrg, vecOrg + (gpGlobals->v_forward * 600), ignore_monsters, ENT(pev), &trace );

	if (trace.fAllSolid == FALSE)
	{
		MESSAGE_BEGIN( MSG_BROADCAST, gmsgTempEntity );
			WRITE_BYTE( TE_LIGHTNING2 );
			WRITE_ENTITY( entindex() );
			WRITE_COORD( tmpSrc.x );
			WRITE_COORD( tmpSrc.y );
			WRITE_COORD( tmpSrc.z );
			WRITE_COORD( trace.vecEndPos.x );
			WRITE_COORD( trace.vecEndPos.y );
			WRITE_COORD( trace.vecEndPos.z );
		MESSAGE_END();
	}

	Vector vecDir = gpGlobals->v_forward + ( 0.001 * gpGlobals->v_right ) + ( 0.001 * gpGlobals->v_up );

Any help is appreciated.

That C code is nothing to do with the effect, all it does is send the start and end coordinates of the beam to client, and the effect index.

[editline]15th March 2014[/editline]

You should post screenshots of those 3 models.

Oh, sure, here they are (i still didnt port them):
http://prntscr.com/30u188 (bolt.mdl)
http://prntscr.com/30u1eg (bolt2.mdl)
http://prntscr.com/30u1m5 (bolt3.mdl)

What Quake does I believe is simply render the same model over and over again from the start point to the end point.

Honestly I think you should try to recreate the effect as a trail in gmod without the use of custom models.

How would i do that?
I mean, i know how to add a model to a effect, but i dont know how i would make it draw the bolts again and again till it reaches the wall (or NPC).

It is a trail already (Check Quake SWEPs), but i love the model thingy because its looks more like its old counterpart.

How “long” are the models then? Say, relative to a watermelon.

I dont know exactly, but its probably sized like a crossbow bolt.

Perfect, that’s a small and manageable size and having it clip through walls ever so slightly would be a non-issue.

Also, do you have a way to compensate the bolt lag like in QuakeWorld? In standalone Quake multiplayer it pissed me off big time.

Unfortunately, no. Since we use this more in Singleplayer. But if i have an base code, i may optimize it later.

Pretty sure ToolTracer is a lightning style effect which you could use. Make an “effect” file which zigzags that all the way to the target?

Quake SWEPS already has a sprite based lightning effect according to Mat, he wanted the 3D effect specifically