Coder Social home page Coder Social logo

cs2-import-scripts's Introduction

Import Scripts for Importing CSGO maps into CS2

Full credit to valve for the script, i merely adapted it to python3 and made sure it finds all necessary binaries without requiring edits to the PATH environment variable

Prerequisites

Precompiled Content

Precompiled content (such as any custom vmt, vtf, mdl, etc.) must be located in the \steam\steamapps\common\Counter-Strike Global Offensive\csgo folder. For example:

\steam\steamapps\common\Counter-Strike Global Offensive\csgo\materials\ \steam\steamapps\common\Counter-Strike Global Offensive\csgo\models\

Notes: Any custom content archived in a .bsp will need to be extracted into the appropriate folders before importing. The import tool also requires a vmf, so if you only have a bsp for your map, you will need to decompile it to a .vmf. Finally, '''do not copy .vmf files to the above folder''' as it will confuse the import tool.

Source Map Files

Your map files (.vmfs) can live anywhere outside of Counter-Strike Global Offensive as long as they are in a maps folder. Any prefab or instance vmfs referenced by your map must be in whatever subfolder structure is expected by the map. For example:

c:\mymapfolder\maps\mymap.vmf c:\mymapfolder\maps\prefabs\mymapprefab.vmf c:\mymapfolder\maps\instances\mymapinsstance.vmf

Personally, I recommend having set up your vmfs as follows.

  • Create a new folder somewhere, make sure there are no spaces in the path to the folder.
    • C:\csgomapproject\ and C:\mymaps\de_defusalmap\ work
    • C:\csgo map projects\ and C:\my maps\de_defusalmap\ will NOT WORK
  • create a folder named maps and copy your vmf, as well as all instances into that folder, keep any subfolders you have for instances, e.g. instances/ and instances_lights/
    • The resulting folder structure should be C:\csgomapproject\maps\de_defusalmap.vmf or C:\mymaps\de_defusalmap\maps\de_defusalmap.vmf for the above examples
  • Make sure your all instances in your vmf file have .vmf in their file property, i.e. instances/building.vmf is GOOD, instances/building will NOT WORK

Source Texture Files

If you have uncompressed source files for textures, (tga, psd, etc.) the import tool will try to use those when importing materials, otherwise it will fall back to converting and recompressing vtf files (which can decrease texture quality). For this to be successful, make sure your source files are in a mirrored location of the vtfs in \steam\steamapps\common\Counter-Strike Global Offensive\csgo\materials\ For example:

c:\steam\steamapps\common\Counter-Strike Global Offensive\csgo\materials\mymaterial\mytexture.vtf c:\mymapfolder\materials\mymaterial\mytexture.tga

Getting Started

1. Installing Python 3

To run the import script you will need to install Python 3 Easiest way to install is by opening powershell and typing "winget install python" and then following the steps through the installation process If this does not work, simply install python through the microsoft store: https://www.microsoft.com/store/productId/9PJPW5LDXLZ5

2. Installing the Colorama Extension

Next you will need a Python extension called colorama. To install this, simply open up a command prompt (search for cmd in Windows Start Menu) and type

python -m pip install colorama

3. Creating a new Addon with the Workshop Tools

Before running an import, you will need to create a Workshop Tools addon so that the imported content has a valid destination. To make a new addon, simply launch the game with Workshop Tools, and from the UI click "Create New Addon" and take note of the name for later.

4. Locating the Import Script

First up is locating the python import script, which can be found wherever you checked out this git repository.

Once you have located the folder, you will want to open up the windows terminal or powershell. This can be done by simply right clicking in the folder and hitting "Open in Terminal" for Windows 11 or typing "powershell" in the windows explorer address bar (any version of windows)

5. Running the Script + Parameters

Now you are ready to run the script by entering the following:

python import_map_community.py <s1gameinfopath> <s1contentpath> <s2gameinfopath> <s2addon> <mapname> -usebsp

Script Parameters

s1gameinfopath :Path to folder containing CSGO's gameinfo.txt, this MUST be the path that contains the compiled CSGO model and material content you want to import (e.g. .mdl, .vmt).

s1contentpath :Path to folder containing source content, (.vmf .psd .tga etc.). As mentioned above, for the importer to successfully find and use source texture files, make sure they are in a mirrored location to that of the .vtfs (see example above)

s2gameinfopath :Path to folder containing CS2's gameinfo.gi

s2addon :The name of CS2 Workshop addon that you created earlier. This is where your assets will be imported to.

mapname :This is the map name (.vmf) without extension, e.g. de_examplemap that you wish to import. If your map sits under a subdirectory of the /maps/ folder in <s1contentpath>. Be sure to add this path before your map name. For example: my_maps/de_examplemap

-usebsp :This runs the map through a special vbsp process to generate clean map geometry from brushes, removing hidden faces and stitching up edges, making the CS2 version easier to work with in Hammer. It preserves world (vis) brushes and func_detail brushes for compatibility with S2. This parameter will also merge all func_instances in your map. Note that the final geometry will be triangulated, but cleaning it up is a fairly simple process, which will be explained in another guide.

-usebsp_nomergeinstances :Use this instead of -usebsp if you wish to both generate clean geo and also preserve func_instances. Note that this takes a little longer as it has to run through the import process twice. The final geometry will also be triangulated.

-skipdeps :Optional: skips importing all dependencies/content and only generates the vmap file(s). This provides a 'quick' import when iterating entities for example. Do not run with this if you are importing for the first time.

Example:

python import_map_community.py "C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\csgo" "c:\map_sources\" "C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\game\csgo" de_example_cs2 de_examplemap -usebsp

Explanation for this example:

  • Your CSGO installation should be at C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\csgo
  • Your vmf should be in C:\map_sources\maps
  • Your vmf should be called de_examplemap.vmf
  • Your CS2 addon should be called de_example_cs2

KNOWN PITFALLS

Avoid all of these, and your import should work:

  • Do NOT have a .vmf of your map in your csgo folder, i.e. not a single vmf here C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\csgo!!! Not doing so WILL cause the import to fail
  • Do NOT have a space in the path to your vmf file, see Source Map Files for details
  • Move ALL custom content you use into your C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\csgo folder, referencing files from the gameinfo.txt WILL NOT WORK
  • If a single model is missing, the import WILL FAIL
  • If a texture vmt is broken, the importer WILL FAIL
  • If you use an hdr skybox texture in your map, the import WILL FAIL -> replace this with any other skybox, cs2 will use a different type of skybox anyways
  • Custom clip textures will not be imported, you either have to replace them in s1 hammer with the normal clip or you will need to reassign textures in cs2 (cs2 does not rely on custom clips for footstep sounds, just use the normal clip)
  • On some machines, windows defender will quarantine vbsp.exe in \Counter-Strike Global Offensive\game\csgo\import_scripts\bin -> if you run into weird vbsp errors make sure the exe is still in that folder, if not then add an exception for the file to your anti virus
  • Naming your <s1contentpath> folder csgo seems to break the importer, so choose a different folder name to be safe

cs2-import-scripts's People

Contributors

andreaskeller96 avatar zer0k-z avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cs2-import-scripts's Issues

VBSP FAILED, using vmf only for S2 geo.

I got this error while trying to port old Inferno to CS2. Here is the log:


  • Running Command: source1import -retail -nop4 -nop4sync -usebsp -src1gameinfodir "E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\csgo" -src1contentdir "E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\sdk_content" -s2addon "de_inferno_csgo" -game csgo maps\de_inferno_csgo\de_inferno.vmf

Adding Search Path e:/steamlibrary/steamapps/common/counter-strike global offensive/csgo/ IMPORT_LEAFIEST_GAME
Adding Search Path e:/steamlibrary/steamapps/common/counter-strike global offensive/sdk_content/ IMPORT_LEAFIEST_CONTENT
Adding Search Path e:/steamlibrary/steamapps/common/counter-strike global offensive/csgo/ IMPORT_GAME
Adding Search Path e:/steamlibrary/steamapps/common/counter-strike global offensive/sdk_content/ IMPORT_CONTENT
Adding Search Path e:/steamlibrary/steamapps/common/counter-strike global offensive/csgo IMPORT_GAME
Adding Search Path e:/steamlibrary/steamapps/common/counter-strike global offensive/csgo IMPORT_CONTENT
Adding Search Path E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\game\csgo_addons\de_inferno_csgo EXPORT_GAME
Adding Search Path E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\content\csgo_addons\de_inferno_csgo EXPORT_CONTENT
Adding Search Path E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\game\csgo_addons\de_inferno_csgo GAME
Adding Search Path E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\content\csgo_addons\de_inferno_csgo CONTENT
Adding Search Path E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\game\csgo_addons\de_inferno_csgo EXPORT_LEAFIEST_GAME
Adding Search Path E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\content\csgo_addons\de_inferno_csgo EXPORT_LEAFIEST_CONTENT
Adding Search Path E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\game\core\ SOURCE2_CORE_GAME
Adding Search Path E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\content\core\ SOURCE2_CORE_CONTENT
Adding Search Path E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\game\csgo_imported BASE_MOD_EXPORT_GAME
Adding Search Path E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\content\csgo_imported BASE_MOD_EXPORT_CONTENT
Removing Search Path E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\game\csgo_imported BASE_MOD_EXPORT_GAME
Removing Search Path E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\content\csgo_imported BASE_MOD_EXPORT_CONTENT
Building file list...
File spec: maps\de_inferno_csgo\de_inferno.vmf
Found file to import e:\steamlibrary\steamapps\common\counter-strike global offensive\sdk_content\maps\de_inferno_csgo\de_inferno.vmf

Command Line: source1import -retail -nop4 -nop4sync -usebsp -src1gameinfodir E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\csgo -src1contentdir E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\sdk_content -s2addon de_inferno_csgo -game csgo maps\de_inferno_csgo\de_inferno.vmf
Blacklisting files...

Final import list order:
e:\steamlibrary\steamapps\common\counter-strike global offensive\sdk_content\maps\de_inferno_csgo\de_inferno.vmf

Importing 1 resources...

  • (1/1) e:\steamlibrary\steamapps\common\counter-strike global offensive\sdk_content\maps\de_inferno_csgo\de_inferno.vmf

Running modified s1 VBSP.exe to help clean up geo:
./bin/vbsp.exe -game "E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\csgo" -prepfors2 e:/steamlibrary/steamapps/common/counter-strike global offensive/sdk_content/maps/de_inferno_csgo/de_inferno.vmf

Begin VBSP:

Valve Software - vbsp.exe (Jun 13 2023)
Prepping bsp for s2 import!
Command line: "./bin/vbsp.exe" "-game" "E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\csgo" "-prepfors2" "e:/steamlibrary/steamapps/common/counter-strike" "global" "offensive/sdk_content/maps/de_inferno_csgo/de_inferno.vmf"

usage : vbsp [options...] mapfile
example: vbsp -onlyents c:\hl2\hl2\maps\test

Common options (use -v to see all options):

-v (or -verbose): Turn on verbose output (also shows more command
line options).

-onlyents : This option causes vbsp only import the entities from the .vmf
file. -onlyents won't reimport brush models.
-onlyprops : Only update the static props and detail props.
-glview : Writes .gl files in the current directory that can be viewed
with glview.exe. If you use -tmpout, it will write the files
into the \tmp folder.
-nodetail : Get rid of all detail geometry. The geometry left over is
what affects visibility.
-nowater : Get rid of water brushes.
-staticpropcombine : Cluster specially supported static prop models.
-keepsources : Don't clean up cluster models after bspzip.
-staticpropcombine_considervis : Cluster static prop models only within
vis clusters.
-staticpropcombine_autocombine : Automatically combine simple static props
without an explicit combine rule.
-staticpropcombine_suggestrules: Suggest rules to add to spcombinerules.txt
-prepfors2 : Prep bsp geo for import to S2 (import workflow improvement).
-nofuncinstance : Only valid if prepping for s2, skip all func_instance entities (top level map only).
-isfuncinstance : Only valid when using -nofuncinstance, describes if vmf is itself a func_instance map.
-low : Run as an idle-priority process.

-vproject : Override the VPROJECT environment variable.
-game :

END VBSP

VBSP FAILED, using vmf only for S2 geo.
+- Wrote file e:\steamlibrary\steamapps\common\counter-strike global offensive\content\csgo_addons\de_inferno_csgo\maps\de_inferno_csgo\de_inferno_prefab.vmap (Copied from e:\steamlibrary\steamapps\common\counter-strike global offensive\sdk_content\maps\de_inferno_csgo\de_inferno.vmf)
CVMFtoVMAP: Missing a required top-level key.
Failed to construct map document from provided vmf data.
source1import - Encountered an error importing file "e:\steamlibrary\steamapps\common\counter-strike global offensive\sdk_content\maps\de_inferno_csgo\de_inferno.vmf"!
*** Error Importing e:\steamlibrary\steamapps\common\counter-strike global offensive\sdk_content\maps\de_inferno_csgo\de_inferno.vmf


FAILED:
e:\steamlibrary\steamapps\common\counter-strike global offensive\sdk_content\maps\de_inferno_csgo\de_inferno.vmf


ERROR: 0 imported, 1 failed, 0 skipped, 0 unknown, 0m:00s

Error running:

source1import -retail -nop4 -nop4sync -usebsp -src1gameinfodir "E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\csgo" -src1contentdir "E:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\sdk_content" -s2addon "de_inferno_csgo" -game csgo maps\de_inferno_csgo\de_inferno.vmf
Aborting

CS2 MAP IMPORT ERROR

I'm trying to import CS:GO JB Map to CS2.
I've followed everysingle bit of the tutorial & still can't this to operate correctly.
Please any advice?

image

Failed to load file (invalid)! - pak01.vpk

Since latest update the script returns the following error:

c:\program files (x86)\steam\steamapps\common\counter-strike global offensive\csgo\pak01.vpk
Failed to load file (invalid)!
Error running:
>>>source1import -retail -nop4 -nop4sync -usebsp -src1gameinfodir "C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\csgo" -src1contentdir "C:\Users\user\Documents\css_cs2\map" -s2addon "map" -game csgo maps\map.vmf
Aborting

Ignore import model/texture failures?

A certain model of mine fails because I believe it has ö ä ü in bone names.

Error log:

[...]
Writing 4 Animations:0..1..2..3..Done
Failed to create bone 'k÷rper'Failed to create bone 'fl³gel_rehtz'Failed to create bone 'fl³gel_links'Failed to create bone 'k÷rper01'Failed to create bone 'fl³gel_rehtz01'Failed to create bone 'fl³gel_links01'Failed to create bone 'k÷rper02'Failed to create bone 'fl³gel_rehtz02'Failed to create bone 'fl³gel_links02'Failed to create bone 'k÷rper03'Failed to create bone 'fl³gel_rehtz03'Failed to create bone 'fl³gel_links03'Failed to create bone 'k÷rper04'Failed to create bone 'fl³gel_rehtz04'Failed to create bone 'fl³gel_links04'Failed to create bone 'k÷rper05'Failed to create bone 'fl³gel_rehtz05'Failed to create bone 'fl³gel_links05'

---------------------------------------------------------
Encountered accessviolation.
Wrote minidump to cs_mdl_import_2024_0525_143731_0_accessviolation.mdmp
---------------------------------------------------------

Error running:
>>>cs_mdl_import -nop4  -i "F:\Program Files\Steam\steamapps\common\Counter-Strike Global Offensive\csgo" -o "F:\Program Files\Steam\steamapps\common\Counter-Strike Global Offensive\content\csgo_addons\am_shoji" "models\pg_props\pg_park\pg_schmetterlinge.mdl"
Aborting

I have tried removing the model altogether but this results in the process just aborting (in hopes to just edit the erroring model out with the CS2 Editor.)

--------------------------------
- Running Command: cs_mdl_import -nop4  -i "F:\Program Files\Steam\steamapps\common\Counter-Strike Global Offensive\csgo" -o "F:\Program Files\Steam\steamapps\common\Counter-Strike Global Offensive\content\csgo_addons\am_shoji" "models\pg_props\pg_park\pg_schmetterlinge.mdl"
--------------------------------
Creating device for graphics adapter 0 
No Input files found
Error running:
>>>cs_mdl_import -nop4  -i "F:\Program Files\Steam\steamapps\common\Counter-Strike Global Offensive\csgo" -o "F:\Program Files\Steam\steamapps\common\Counter-Strike Global Offensive\content\csgo_addons\am_shoji" "models\pg_props\pg_park\pg_schmetterlinge.mdl"
Aborting

Is there any flag I can use to just ignore models which fail to import and continue with the rest? I do not have the original source files anymore (just the original *.vmf file). I could potentially edit the model out with the source 1 editor but I would like to avoid having to set it all up properly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.