Decompiling Maps: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
 
(191 intermediate revisions by 68 users not shown)
Line 1: Line 1:
[[Category:Level Design]] [[Category:Tutorials]]
{{LanguageBar}}
[[Category:Level Design]]
[[Category:Tutorials]]


Before you read on make sure you know that decompiling maps can be a very sticky business.  It is widly frowned upon by the majority of professional level designers.  For good reason, when you decompile a map you are taking their hard work and using it for yourself. So before you get the idea to go around decompiling every map and throwing the vmf's up on the internet, please take the time and think about something you have dedicated a small portion of your life to, and then imagine someone breaking it into a million pieces.
Decompiling is the process of taking a compiled map file and generating a file that Hammer can open. Decompiled maps are not perfect recreations, because of format differences{{clarify}}, loss of data (such as missing [[Func viscluster]], tools textures such as NPC Clip or Player Clip all replaced with either Nodraw or entirely replaced with NPC Clip/Player Clip which cause lighting issues or NPCs/players to get stuck in some area, and imprecise vertex position on complex brushes). This makes them useful for learning, measurement, and inspection, but not direct recompilation. The original source is ideal for reproductions or modifications.


When you decompile a map you should be thinking one of two things:
Releasing reproductions, modifications, or approximations of another's work without permission nor credit may be considered rude to the author, is largely frowned upon, and is in fact copyright infringement, which may have legal consequences depending on the source of the map. There are methods of preventing maps from being fully decompiled (obfuscating textures, keeping entities or VScript server-side, etc.), but these are rarely used because most people who decompile maps are doing so to learn from them rather than to steal.
* You are curious how a certain part of his/her map works
* You are going to greatly change the map and only use the skeleton, and of course give the author full rights to your work.


==Decompilers==
==={{source2|4}}===
*{{vrf|4}} (used to view the entities and other lumps on a map, decompiling to vmap, and exporting to glTF)
==={{src|4}}===
*[[EntSpy]] (used to view and edit the entities of a BSP without recompiling)
*[[BSPSource]] (open source map decompiler for Source engine maps, based on VMEX)
*[[VMEX]] (decompiler for Source engine maps)
*[[MapFool]] (helps porting HL1 maps to Source)
*[[xwad]] (command-line tool to convert texture formats)
==={{gldsrc|4}}===
* {{bspviewer|4}} requires .NET Framework v1.1. (not recommended)
:{{Warning|In {{crafty|4}} the function of bsp decompilation was cut out.}}
*{{hlusmd|4}} requires .NET Desktop Runtime 6
*{{mbspc|4}} (not recommended)
*{{b2m|4}} (not recommended)
*{{winbspc|4}} (not recommended)
{{warning|[[BSP2MAP]], [[MBSPC]], [[005]] and [[WinBSPC]] are unstable and may not compile correctly in the end; {{hlusmd|1}} instead. It will still require manual cleanup, but is significantly more accurate.}}
*{{005|4}} ({{hl}} not recommended; {{nightfire}} recommended)


== The Hackers Toolbox ==
==Files==
To decompile maps I suggest the following tools:
Most maps do not need to be extracted, as they are located in the file system rather than VPK. The map files are normally located in a ''maps'' folder, for example <code>common\Team Fortress 2\tf\maps\</code> holds all the official Team Fortress 2 maps.
* [http://www.geocities.com/cofrdrbob/entspy.html EntSpy]
{{note|A few games may have extra maps sectioned into other mod folders, for example <code>Portal 2\portal2_dlc1\maps\</code>.}}
* [http://www.geocities.com/cofrdrbob/vmex.html VMEX]
{{note|A few games use [[Patching_levels_with_lump_files|lump file edits]] to edit existing entities,  and [[Commentary_System|comment files]] to add new entities without recompiling maps. for example: {{l4d2}} adds [[info_remarkable]] entities and [[env_player_blocker]] entities this way.<br>
BSPSource is capable of reading the .lmp files and incorporate its data, but it will not load entities from the commentary files. Luckily you can convert commentary files back to VMF files by following [[Commentary_System#Converting_Commentary_back_to_VMF|these steps]]. and merging those entities into the decompiled map.}}


'''Optional'''
==Before you go==
* [http://www.fileaholic.com/cgi-sql/file-info.sql/11109 BSP2MAP]
Before you take this jump to run off and decompile a map take a second or two to think, "What am I trying to learn/do?".
* [http://www.peppyfool.com/page6.htm MapFool]
Read the included TXT files, you may just find the creator's e-mail, and that could be more helpful than you imagine.


'''EntSpy''' is a program that will let you edit almost all the entities in a specified map.
Some mappers will offer help and advice, they may even go so far as to provide examples of what you wanted to borrow from the map.


'''[[Vmex]]''' will decompile source maps for you with almost perfect accuracy. It gets a little shady when it comes to decompiling HL1 maps. VMEX is also built with a protection system that any map maker can use to stop VMEX from decompiling his/her map.  More on this later.
==Porting newer maps to older Source games==
Decompiled maps from [[Left 4 Dead 2]], [[Portal 2]], [[Counter-Strike: Global Offensive]], and [[Alien Swarm]] will crash when loaded in the Hammer for [[Half-Life 2]], [[Team Fortress 2]], [[Counter-Strike: Source]], [[Day of Defeat: Source]] and other games based on {{src13|1}}, [[Orange_Box_(engine_branch)|Orange Box branches]] ({{src07}} - {{src09}}/{{srcmp}}) or earlier. Opening the map in [[Left 4 Dead]] Hammer and re-saving it will automatically convert it to be compatible.
{{Note|This VMF incompatibility issue does not affect {{gmod|1}}, as it ran on heavily modified version of {{src13|1}} that support assets from {{l4dbranch|1}} and later. Garry's Mod ships with modified version of Hammer which fixed the issue, allowing you to load VMFs (or decompiled maps) from Left 4 Dead 2 and later branches.}}


'''BSP2MAP''' This program will decompile some HL1 maps. Unfortunetly, HL1 maps do not store as much information about the geometry of a map, so the geometry has to be recreated using the polygons.
{{todo|Document how to fix this manually. It's caused by L4D2 changing the character used to separate output values, but I'm not sure what character it changed to.}}


'''MapFool''' This is a niffty program that will help you with porting HL1 maps to Source, it lets you open the wads and even save them as new materials and textures for use in your new source map.
==See also==
 
*[[Porting GoldSrc content (maps, models, etc.) to Source]]
'''[[xwad]]''' is a tool that can convert bmp, wad, & spr to tga, vtf, and vmt.
[[Category:Source]]
 
== Getting Dirty ==
To start off, you are required to have installed the JRE, which can be downloaded from [http://java.sun.com/j2se/1.5.0/download.jsp http://java.sun.com/j2se/1.5.0/download.jsp].  Once that is installed you are ready to decompile your first map.  Download VMEX and copy it to a folder that is close to a drive letter (eg, "C:\VMex") the reason will soon be clear.  You'll motice VMEX comes with two bat files, these, unfortunetly, have to be run from the command prompt, so goto Start->Run and type in "cmd"
 
When the screen pops up, navigate to the folder you installed VMex to by use of the cd command. Example, to get to the drive I mentioned earlier, type "cd C:\VMex" (without the quotes).  Good thing you installed it close to a root directory!
 
When I go to decompile maps I usually copy the map I am decompiling to the VMEX directory, but this step is optional, its just a matter of avoiding a lot of typeing.  On the command prompt type in "vmex my_mapname" with your map file substitued for my_mapname.  After a few seconds and a bunch of .'s you should be all set with a genuine VMF file.

Latest revision as of 04:59, 9 July 2025

English (en)한국어 (ko)Русский (ru)中文 (zh)Translate (Translate)

Decompiling is the process of taking a compiled map file and generating a file that Hammer can open. Decompiled maps are not perfect recreations, because of format differences[Clarify], loss of data (such as missing Func viscluster, tools textures such as NPC Clip or Player Clip all replaced with either Nodraw or entirely replaced with NPC Clip/Player Clip which cause lighting issues or NPCs/players to get stuck in some area, and imprecise vertex position on complex brushes). This makes them useful for learning, measurement, and inspection, but not direct recompilation. The original source is ideal for reproductions or modifications.

Releasing reproductions, modifications, or approximations of another's work without permission nor credit may be considered rude to the author, is largely frowned upon, and is in fact copyright infringement, which may have legal consequences depending on the source of the map. There are methods of preventing maps from being fully decompiled (obfuscating textures, keeping entities or VScript server-side, etc.), but these are rarely used because most people who decompile maps are doing so to learn from them rather than to steal.

Decompilers

Source 2 Source 2

  • Source 2 Viewer Source 2 Viewer (used to view the entities and other lumps on a map, decompiling to vmap, and exporting to glTF)

Source Source

  • EntSpy (used to view and edit the entities of a BSP without recompiling)
  • BSPSource (open source map decompiler for Source engine maps, based on VMEX)
  • VMEX (decompiler for Source engine maps)
  • MapFool (helps porting HL1 maps to Source)
  • xwad (command-line tool to convert texture formats)

GoldSrc GoldSrc

  • BSP Viewer BSP Viewer requires .NET Framework v1.1. (not recommended)
Warning.pngWarning:In Crafty Crafty the function of bsp decompilation was cut out.
Warning.pngWarning:BSP2MAP, MBSPC, 005 and WinBSPC are unstable and may not compile correctly in the end; Half-Life Unified SDK Map Decompiler instead. It will still require manual cleanup, but is significantly more accurate.

Files

Most maps do not need to be extracted, as they are located in the file system rather than VPK. The map files are normally located in a maps folder, for example common\Team Fortress 2\tf\maps\ holds all the official Team Fortress 2 maps.

Note.pngNote:A few games may have extra maps sectioned into other mod folders, for example Portal 2\portal2_dlc1\maps\.
Note.pngNote:A few games use lump file edits to edit existing entities, and comment files to add new entities without recompiling maps. for example: Left 4 Dead 2 adds info_remarkable entities and env_player_blocker entities this way.
BSPSource is capable of reading the .lmp files and incorporate its data, but it will not load entities from the commentary files. Luckily you can convert commentary files back to VMF files by following these steps. and merging those entities into the decompiled map.

Before you go

Before you take this jump to run off and decompile a map take a second or two to think, "What am I trying to learn/do?". Read the included TXT files, you may just find the creator's e-mail, and that could be more helpful than you imagine.

Some mappers will offer help and advice, they may even go so far as to provide examples of what you wanted to borrow from the map.

Porting newer maps to older Source games

Decompiled maps from Left 4 Dead 2, Portal 2, Counter-Strike: Global Offensive, and Alien Swarm will crash when loaded in the Hammer for Half-Life 2, Team Fortress 2, Counter-Strike: Source, Day of Defeat: Source and other games based on Source 2013, Orange Box branches (Source 2007 - Source 2009/Source Multiplayer) or earlier. Opening the map in Left 4 Dead Hammer and re-saving it will automatically convert it to be compatible.

Note.pngNote:This VMF incompatibility issue does not affect Garry's Mod, as it ran on heavily modified version of Source 2013 that support assets from Left 4 Dead engine branch and later. Garry's Mod ships with modified version of Hammer which fixed the issue, allowing you to load VMFs (or decompiled maps) from Left 4 Dead 2 and later branches.
Todo: Document how to fix this manually. It's caused by L4D2 changing the character used to separate output values, but I'm not sure what character it changed to.

See also