NightVision Tutorial
Jump to navigation
Jump to search
Adding Nightvision To your Source Single Player Mod
Here's something that is part of Nightfall nightfall, and many people have been stumpled on - Night Vision.
Summary
Before i start, this is only one, and a very early attempt (It works), of one way to get the Night Vision Mode to work with your mod.
Before i start, i would like to credit Gnolfo from www.hl2coding.com and user:ts2do
Seting up the convar, The Meat and The Spuds
Open the file src/cl_dll/view_scene.cpp, and jump to the end (ctrl+end)
//nightfall - amckern - amckern@yahoo.com //NightVision static void ScreenOver_f( void ) //rename ScreenOver to what ever you wish, maybe cl_nightvis { IMaterial *pMaterial = materials->FindMaterial( "HUDoverlays/nightvision", TEXTURE_GROUP_OTHER, true ); //This is the texture we are going to use for the 'effect' - never use an ext on material files { static bool bDisplayed = false; if( bDisplayed ) { // turn it off view->SetScreenOverlayMaterial( NULL ); engine->ClientCmd( "mat_fullbright 0\n" );//turn full bright off again CLocalPlayerFilter filter; C_BaseEntity::EmitSound( filter, 0, "Nightfall.NightVisOff" ); //play the off sound } else { // turn it on view->SetScreenOverlayMaterial( pMaterial ); //this is the HUDoverlays/nightvision texture we made a pointer to above engine->ClientCmd( "mat_fullbright 1\n" );//light up the world CLocalPlayerFilter filter; C_BaseEntity::EmitSound( filter, 0, "Nightfall.NightVisOn" ); //On we go - play a sound to let the player know that the NV is on } bDisplayed = !bDisplayed; } } static ConCommand r_screenover( "r_screenover", ScreenOver_f );
So what we have done here is set a bool cvar (on/off) that either enables, or disables the night vision effect. if you read the comments, you will under stand what each part is doing.
Nightfall.NightVisOn
is