MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_DLIGHT );
//WRITE_SHORT( entindex() ); // entity, attachment
WRITE_COORD( pev->origin.x ); // origin
WRITE_COORD( pev->origin.y );
WRITE_COORD( pev->origin.z );
WRITE_BYTE( 16 ); // radius
WRITE_BYTE( 128 ); // R
WRITE_BYTE( 0 ); // G
WRITE_BYTE( 128 ); // B
WRITE_BYTE( 10 ); // life * 10
WRITE_BYTE( 32 ); // decay
MESSAGE_END();
You may want to note that TE_DLIGHTs are always set up this way.// Teh_Freak: World Lighting!
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_DLIGHT );
WRITE_COORD( vecShootOrigin.x ); // origin
WRITE_COORD( vecShootOrigin.y );
WRITE_COORD( vecShootOrigin.z );
WRITE_BYTE( 16 ); // radius
WRITE_BYTE( 255 ); // R
WRITE_BYTE( 255 ); // G
WRITE_BYTE( 128 ); // B
WRITE_BYTE( 5 ); // life * 10
WRITE_BYTE( 32 ); // decay
MESSAGE_END();
// Teh_Freak: World Lighting!
Most of this setup should be self-explanitory, except for the WRITE_COORDs. you'll notice that they are vectors. The vector vecShootOrigin was initialized at the top of the function, so I decided to use it.// Teh_Freak: World Lighting!
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_DLIGHT );
WRITE_COORD( vecArmPos.x ); // origin
WRITE_COORD( vecArmPos.y );
WRITE_COORD( vecArmPos.z );
WRITE_BYTE( 16 ); // radius
WRITE_BYTE( 128 ); // R
WRITE_BYTE( 0 ); // G
WRITE_BYTE( 128 ); // B
WRITE_BYTE( 10 ); // life * 10
WRITE_BYTE( 32 ); // decay
MESSAGE_END();
// Teh_Freak: World Lighting!
Notice the vectors. If you look at the vectors in the TE_SPRITE, they match up with the vectors here. In case you wanted to know, the TE_SPRITE creates the muzzleflash for the Alien Grunt, so it was a good choice to use the same vectors.// Teh_Freak: World Lighting!
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_DLIGHT );
WRITE_COORD( vecStart.x ); // origin
WRITE_COORD( vecStart.y );
WRITE_COORD( vecStart.z );
WRITE_BYTE( 10 ); // radius
WRITE_BYTE( 255 ); // R
WRITE_BYTE( 192 ); // G
WRITE_BYTE( 64 ); // B
WRITE_BYTE( 20 ); // life * 10
WRITE_BYTE( -32 ); // decay
MESSAGE_END();
// Teh_Freak: World Lighting!
If you look at the ELIGHT and DLIGHT, they are set up pretty much the same. Now scroll down till you see the CONTROLLER_AE_BALL_SHOOT event, and add this after the ELIGHT:
// Teh_Freak: World Lighting!
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_DLIGHT );
WRITE_COORD( vecStart.x ); // origin
WRITE_COORD( vecStart.y );
WRITE_COORD( vecStart.z );
WRITE_BYTE( 32 ); // radius
WRITE_BYTE( 255 ); // R
WRITE_BYTE( 192 ); // G
WRITE_BYTE( 64 ); // B
WRITE_BYTE( 10 ); // life * 10
WRITE_BYTE( 32 ); // decay
MESSAGE_END();
// Teh_Freak: World Lighting!
You should know what does what here. Now scroll down to void CControllerHeadBall :: HuntThink(void).// Teh_Freak: World Lighting!
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_DLIGHT );
WRITE_COORD( pev->origin.x ); // origin
WRITE_COORD( pev->origin.y );
WRITE_COORD( pev->origin.z );
WRITE_BYTE( pev->renderamt / 16 );// radius
WRITE_BYTE( 255 ); // R
WRITE_BYTE( 192 ); // G
WRITE_BYTE( 255 ); // B
WRITE_BYTE( 2 ); // life * 10
WRITE_BYTE( 0 ); // decay
MESSAGE_END();
// Teh_Freak: World Lighting!
You may notice the pev->origin.x-z. If there were vectors, I'd still use this, because it is in the center of the ball. You should also not the pev->renderamt / 16. This makes the light slowly fade out with the render amount of the head ball (you will notice that the head ball fades away if you've ever had a controller head ball not hit you).// Teh_Freak: World Lighting!
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_DLIGHT );
WRITE_COORD( pev->origin.x ); // origin
WRITE_COORD( pev->origin.y );
WRITE_COORD( pev->origin.z );
WRITE_BYTE( 8 ); // radius
WRITE_BYTE( 255 ); // R
WRITE_BYTE( 192 ); // G
WRITE_BYTE( 64 ); // B
WRITE_BYTE( 2 ); // life * 10
WRITE_BYTE( 0 ); // decay
MESSAGE_END();
// Teh_Freak: World Lighting!
What this will do is make a dynamic light follow the zap ball, lighting up world brushes as it passes them, but entities won't get light up! So for the first (and last) time in this tutorial, we'll add an ELIGHT. Put it after the DLIGHT:
// Teh_Freak: Entity Lighting!
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_ELIGHT );
WRITE_SHORT( entindex( ) ); // entity, attachment
WRITE_COORD( pev->origin.x ); // origin
WRITE_COORD( pev->origin.y );
WRITE_COORD( pev->origin.z );
WRITE_COORD( 8 ); // radius
WRITE_BYTE( 255 ); // R
WRITE_BYTE( 192 ); // G
WRITE_BYTE( 64 ); // B
WRITE_BYTE( 2 ); // life * 10
WRITE_COORD( 0 ); // decay
MESSAGE_END();
// Teh_Freak: Entity Lighting!
You will notice that the ELIGHT and DLIGHT are almost the same, so using it shouldn't be that hard. Well, now compile your DLL, make a cube room with one very faint light (ZHLT will make the room full bright if you have no lights) and start up a map with the three monsters we just edited.You must log in to post a comment. You can login or register a new account.
Please post your question in the forums, not here.