NAV (file format): Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(mapname.nav, ExpandBox)
Line 1: Line 1:
{{stub}}
{{stub}}
A '''NAV''' file is a map specific [[Navigation Meshes|'''<u>Nav</u>'''igation Mesh]] file for [[bot]]s in {{game link|Counter-Strike: Source}}, {{game link|Counter-Strike: Global Offensive}}, and for [[NextBot]] entities from {{game link|Left 4 Dead}}, {{game link|Left 4 Dead 2}} and {{game link|Team Fortress 2}}.


A '''NAV''' file is a [[Navigation Meshes|'''Nav'''igation Mesh]] file for [[Counter-Strike: Source]] [[bots]], and [[NextBot]] entities from [[Left 4 Dead]], [[Left 4 Dead 2]] and [[Team Fortress 2]]. It defines, among other things the walkable space in a level. The file is not generated automatically when bots are played for the first time on a specific map, meaning that the bots will stand around helplessly. One can edit a Navigation Mesh manually by typing nav_edit 1 in the console with [[sv_cheats]] enabled. NAV creation is an open-source task available in the SDK. If one were to implement their bots, it would be easier because NAV creation is already supplied.
It defines the walkable space in a level among other things. Except in {{css}} and {{csgo}}, the file is '''not''' generated automatically when bots are played for the first time on a specific map, meaning that the bots will stand around helplessly.
One can edit a Navigation Mesh manually by typing {{ent|nav_edit|1}} in the console with {{ent|sv_cheats|1}}.
NAV creation is an open-source task available in the SDK. If one were to implement their bots, it would be easier because NAV creation is already supplied.
 
The .nav file of <code><game>/maps/<mapname>.[[bsp]]</code> is saved and loaded as <code><game>/maps/<mapname>.nav</code>.


The difference between an [[AIN]] and a '''NAV''' file is that an '''AIN''' file is mainly used for [[NPC]] navigation.
The difference between an [[AIN]] and a '''NAV''' file is that an '''AIN''' file is mainly used for [[NPC]] navigation.
Line 7: Line 12:
== File format ==
== File format ==


Note: This is reverse engineered data.
{{Note| This is reverse engineered data. Reverse engineered format code can also be found [https://github.com/mrazza/gonav/blob/master/parser.go here].}}
Reverse engineered format code can also be found [https://github.com/mrazza/gonav/blob/master/parser.go here].


{{ExpandBox|
<source lang="cpp">
<source lang="cpp">
unsigned int magicNumber; // Magic number to check if the file is a .nav file
unsigned int magicNumber; // Magic number to check if the file is a .nav file
Line 87: Line 92:
}
}
</source>
</source>
 
}}
==See also==
==See also==
* [[Navigation Meshes]]
* [[Navigation Meshes]]
Line 93: Line 98:
* [https://github.com/Blackfire62/TF2_NavFile_Reader Nav File parser in c++]
* [https://github.com/Blackfire62/TF2_NavFile_Reader Nav File parser in c++]


[[Category:Level Design]]
[[Category:Navigation Meshes]]
[[Category:Glossary]]
[[Category:Glossary]]
[[Category:Level Design]]
[[Category:AI]]
[[Category:AI]]
[[Category:File formats]]
[[Category:File formats]]

Revision as of 11:05, 22 August 2021

Stub

This article or section is a stub. You can help by expanding it.

A NAV file is a map specific Navigation Mesh file for bots in Counter-Strike: Source Counter-Strike: Source , Counter-Strike: Global Offensive Counter-Strike: Global Offensive , and for NextBot entities from Left 4 Dead Left 4 Dead , Left 4 Dead 2 Left 4 Dead 2 and Team Fortress 2 Team Fortress 2 .

It defines the walkable space in a level among other things. Except in Counter-Strike: Source and Counter-Strike: Global Offensive, the file is not generated automatically when bots are played for the first time on a specific map, meaning that the bots will stand around helplessly. One can edit a Navigation Mesh manually by typing nav_edit 1 in the console with sv_cheats 1. NAV creation is an open-source task available in the SDK. If one were to implement their bots, it would be easier because NAV creation is already supplied.

The .nav file of <game>/maps/<mapname>.bsp is saved and loaded as <game>/maps/<mapname>.nav.

The difference between an AIN and a NAV file is that an AIN file is mainly used for NPC navigation.

File format

Note.pngNote: This is reverse engineered data. Reverse engineered format code can also be found here.



unsigned int magicNumber; // Magic number to check if the file is a .nav file
unsigned int version; // Version of the .nav file, for example GMod and TF2 has 16

if ( version >= 10 ) {
	unsigned int subVersion; // Sub version of the .nav file, for example GMod has 0, TF2 has 2. This is usedt
}

if ( version >= 4 ) {
	unsigned int saveBspSize; // Size of source bsp file to verify that the bsp hasn't changed
}

if ( version >= 14 ) {
	unsigned char isAnalyzed;
}

if ( version >= 5 ) {
	// Places data. This is the "Mid", "Banana", etc stuff that is used in this nav mesh
	unsigned short count;

	for( int i = 0; i < count; ++i ) {
		unsigned short len; // length of the name
		char name[len]; // The name. Maximum len is 256
	}

	if ( version > 11 ) {
		unsigned char m_hasUnnamedAreas;
	}
}

{
	// Load custom data pre area
	// This is by default is completely unused, it is left for mods to store custom data
}

unsigned int count; // number of CNavAreas

{
	// PreLoadAreas( count )
	// This is by default is completely unused, it is left for mods to store custom data
	// Assuming that the data is per nav area
	//for( int i = 0; i < count; ++i ) {
	//}
}

for( i = 0; i < count; ++i ) {
	// Per CNavArea data
	unsigned int id; // ID of the CNavArea

	// Attribute flags
	if ( version <= 8 ) {
		unsigned char attributeFlags;
	} else if ( version < 13 ) {
		unsigned short attributeFlags;
	} else {
		int attributeFlags;
	}

	Vector m_nwCorner; // size is 3 * float(x,y,z), North-West corner of the area
	Vector m_seCorner; // size is 3 * float(x,y,z), South-East corner of the area
	
	// More data...
}

if ( version >= 6 ) {
	unsigned int count; // number of CNavAreas

	for( i = 0; i < count; ++i ) {
		// Ladder data
	}
}

{
	// Load Custom Data
	// Again, by default this is unused
}

See also