NightVision Tutorial: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
[[Category:Programming]] | [[Category:Programming]] | ||
[[Category:Tutorials]] | [[Category:Tutorials]] | ||
== Adding Nightvision To your Source Single Player Mod == | == 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. | Here's something that is part of Nightfall [[nightfall]], and many people have been stumpled on - Night Vision. | ||
Line 9: | Line 8: | ||
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, 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 hl2coding.com and [[user:ts2do]] | Before i start, i would like to credit Gnolfo from www.hl2coding.com and [[user:ts2do]] | ||
== Seting up the convar, | == 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) | Open the file '''src/cl_dll/view_scene.cpp''', and jump to the end (ctrl+end) | ||
Line 19: | Line 18: | ||
//NightVision | //NightVision | ||
static void ScreenOver_f( void ) | 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 ); | 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 | |||
{ | { | ||
Line 28: | Line 29: | ||
{ | { | ||
// turn it off | // turn it off | ||
view->SetScreenOverlayMaterial( NULL ); | |||
engine->ClientCmd( "mat_fullbright 0\n" );//turn full bright off again | engine->ClientCmd( "mat_fullbright 0\n" );//turn full bright off again | ||
CLocalPlayerFilter filter; | CLocalPlayerFilter filter; | ||
C_BaseEntity::EmitSound( filter, 0, "Nightfall.NightVisOff" ); | C_BaseEntity::EmitSound( filter, 0, "Nightfall.NightVisOff" ); | ||
//play the off sound | |||
} | } | ||
else | else | ||
Line 37: | Line 39: | ||
// turn it on | // turn it on | ||
view->SetScreenOverlayMaterial( pMaterial ); | 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 | engine->ClientCmd( "mat_fullbright 1\n" );//light up the world | ||
CLocalPlayerFilter filter; | CLocalPlayerFilter filter; | ||
C_BaseEntity::EmitSound( filter, 0, "Nightfall.NightVisOn" ); | C_BaseEntity::EmitSound( filter, 0, "Nightfall.NightVisOn" ); | ||
//On we go - play a sound to let the player know that the NV is on | |||
} | } | ||
Line 49: | Line 53: | ||
</pre> | </pre> | ||
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. | |||
<pre>Nightfall.NightVisOn</pre> is | |||
<pre> | |||
</pre> | |||
Revision as of 07:56, 9 November 2005
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