Working on all.spawn with SOC level editor

This tutorial will cover an alternative method to work on all.spawn, with the using of level editor. It works mostly with vanilla or vanilla-like (ZRP) all.spawns, but doesn't work with complex mod gamedata, because the mods config folder somehow ruin the SDK spawn element part - 98% of the spawn elements will be missing, and adding new spawn in level editor will be impossible.

 Installing the SDK

1. Get the official SDK 0.4 here: [1]

- install ONLY to "Program Files" folder. If you are running Vista or Windows 7 x64, make sure you NOT install SDK in "Program Files (x86)" folder.

In this tutorial, I made exactly the following steps on a Windows 7 x64 system, and my installation path is C:\Program Files\X-Ray SDK.

2. Get the unofficial update here: [2] - update your install, when the patch asking, overwrite the C:\Program Files\X-Ray SDK\ folder.

3. Get the Microsoft Visual C++ 2005 runtime libraries - vcredist from microsoft download center and install. There are x86 and x64 versions of vcredist and you have to install as your operating system requires.

I installed on my Windows 7 x64 the Microsoft Visual C++ 2005 Redistributable Package (x64) and the Microsoft Visual C++ 2005 SP1 Redistributable Package (x64).

4. Sometimes you need some Borland runtime libraries - check if C:\Program Files\X-Ray SDK\level_editor\bins\ folder have these files:

bcbsmp60.bpl

elpackB6.BPL

rtl60.bpl

vcl60.bpl

vclx60.bpl

borlndmm.dll

If not - find them on the net and put there.

5. Unpack all original game archives (1.0004 or 1.0005 gamedata are recommended) contents to C:\Program Files\X-Ray SDK\level_editor\gamedata\ folder, overwriting all files.

Copying a mods gamedata into SDK gamedata – not recommended, because in the Level Editor the spawn object part will be ruined, and 98% of the spawn objects will be missing, so you can’t add spawn objects to the maps.

If you want spawn on the maps non-vanilla monsters, npc, weapon etc., you have to insert them into SDK gamedata step-by-step.

One spawn object, one config ltx, the necessary meshes and textures. Then open level editor, try to add the new spawn to the scene, and check, if your spawn object are 100% there. If you don’t see fatal error or duplicate section messages, or red log messages, and you can gather the new all.spawn with xrAI - you won. Continue with adding the next non-vanilla spawn to SDK gamedata.

6. This step is only needed, if you use the SOC SDK on Windows 7:

Install this Microsoft Application Compatibility Toolkit 5.6:

Create new database by clicking on New. Right-click on new database and select Create New -> Application Fix...

Enter application name - Level Editor - then browse for LevelEditor.exe in C:\Program Files\X-Ray SDK\level_editor\bins folder. Click Next...

Select Run this program in compatibility mode for Windows XP SP2. Click Next...

Scroll all the way to the bottom and select XPFileDialog. Then let the wizard finish.

Save your new database - File -> Save as – into C:\Program Files\X-Ray SDK\level_editor\bins folder, near LevelEditor.exe. Make sure that the new fix is selected. Then click File -> Install. (The same thing should also work on ActorEditor, ParticleEditor and ShaderEditor)

7. Create the X: virtual drive: search for createDiskX.bat in C:\Program Files\X-Ray SDK\scripts_plugins folder.

Look into the batch file, and correct the path for your Windows\System32 folder and your SDK installation folder. by default on my Windows 7 it looks like this:

```"C:\Windows\System32\subst.exe" X: /D
"C:\Windows\System32\subst.exe" X: "C:\Program Files\X-Ray SDK\level_editor"
```

Run createDiskX.bat, and check if you have a new X: drive. Now the content of the C:\Program Files\X-Ray SDK\level_editor folder is on the X: drive.

8. Now you can start the Level Editor with C:\Program Files\X-Ray SDK\level_editor\LevelEditor.bat file. If the Level Editor crashes at startup with missing dll errors - find needed dll and put in the C:\Program Files\X-Ray SDK\level_editor\bins folder.

 Tools for this tutorial

Get Bardak’s x-ray asset tools (now only for the sake of aiwrapper and converter): http://www.stalkerin.gameru.net/downloads/SDK/ai_compiler/xray_re-tools-10sep2008.rar

We will use the aiwrapper only for splitting the all.spawn to level.spawn and level.game files, and after that, we will convert the maps with the splitted, new files to level editor scene with the converter.

!!!Don’t use aiwrapper to gather a new all.spawn, because this tool has problems with level changers –

all new level changer will be missing from the game, what you added in the level editor and compiled your new spawn with aiwrapper.

Also, the aiwrapper lets you to make graph from invalid ai maps, and therefore online and offline ai will not work properly!!!

Instead of Bardak’s acdc, use the most universal acdc tool to work with all.spawn (it’s still needed to check our new all.spawn): [5]

Some more advanced x-ray asset converter, they are better, then Bardak’s first version:

Converter revision 6447: [6]

Converter revision 10192: [7]

Converter revision 13105 and 13172 (here you can expect maybe future revisions too): [8]

 Installing aiwrapper

Copy from the \xray_re-tools-10sep2008 folder the \2215 folder into C:\Program Files\X-Ray SDK\level_editor folder. The aiwrapper uses an xrAI from build 2215, and the tool will use this 2215 folder as a temporary working folder.

Make an \aiwrapper folder in C:\Program Files\X-Ray SDK\ folder. Copy the aiwrapper.exe and the fsaiwrapper.ltx from the \xray_re-tools-10sep2008 folder into C:\Program Files\X-Ray SDK\aiwrapper\ folder. Alter the \$sdk_root\$ in fsaiwrapper.ltx, according to the level_editor folder. So our path will be:

```\$sdk_root\$ = false|false|C:\Program Files\X-Ray SDK\level_editor\
```

Put aiwrapper.ini into C:\Program Files\X-Ray SDK\level_editor\ folder.

Make two batch file in C:\Program Files\X-Ray SDK\aiwrapper\ folder.

The first with split_spawns.bat name, and with this command:

`@start aiwrapper.exe -split_spawns`

The second with split_paths.bat name, and write this command:

`@start aiwrapper.exe -split_paths`

Now the aiwrapper is ready to split the all.spawn. Why we need it? Because if we convert a map to level editor scene, it will produce the scene spawn part from the level.spawn file (NOT from the all.spawn!). None of the game patches updated the level.spawn files, but the all.spawn changed in 1.0001, in 1.0003 and in 1.0004 patch too. So if you converted back the 18 vanilla levels even with 1.0004 and 1.0005 SDK gamedata, basically you get back the spawn setup of game version 1.000 in the level editor. I recommended to use the clear 1.0004 or 1.0005 gamedata for the SDK. The all.spawn remain unchanged since the 1.0004 patch, so if you create a new all.spawn from the splitted files, it will work with all commonly used game versions - 1.0004, 1.0005 and 1.0006.

Run both batch files. If it works, it lists a bunch of lines in a console, and quits after some second.

Now check your map folders in C:\Program Files\X-Ray SDK\level_editor\gamedata\levels\ folder. In each map folder you should have updated level.spawn (spawn setup of the map) and level.game (waypoint setup for the map) files with the current time – the vanilla all.spawn is splitted, and ready for converting.

You can do the same with vanilla-like spawns, for example ZRP all.spawn is possible to split, and you can open in level editor, and you can work with all the spawn and way fixes, what ZRP provided.

Sometimes for non-vanilla spawns split you have to copy the mod's config folder into SDK gamedata.

 Installing the x-ray asset converter

Create a \converter folder in C:\Program Files\X-Ray SDK\ folder.

Copy converter.exe and fsconverter.ltx files from Bardaks \xray_re-tools-src-10sep2008 into C:\Program Files\X-Ray SDK\converter\ folder.

!!!I used for this tutorial an updated converter.exe (rev.13172, size: 999032), which handles the SOC maps much better:!!! [9]

Alter the \$sdk_root\$ in fsconverter.ltx, according to the level_editor folder. So my path will be:

`\$sdk_root\$ = false|false|C:\Program Files\X-Ray SDK\level_editor\`

Place the converter.ini file to theC:\Program Files\X-Ray SDK \level_editor\ folder, search for these lines in converter.ini and correct them according to your SDK gamedata:

```; 2945
[2945_config]
\$game_data\$	= C:\Program Files\X-Ray SDK\level_editor\gamedata\
\$game_levels\$ = C:\Program Files\X-Ray SDK\level_editor\gamedata\levels\
fake_mu_gamemtls = 2xxx_fake_mu_gamemtls
fake_gamemtls = 29xx_fake_gamemtls
[29xx_fake_gamemtls]:2xxx_fake_gamemtls
materials\earth_death

; 2947 + (final version including updatings)
[2947_config]:2945_config
\$game_data \$ = C:\Program Files\X-Ray SDK\level_editor\gamedata\
\$game_levels \$ = C:\Program Files\X-Ray SDK\level_editor\gamedata\levels\

[aitest_config]:2947_config
\$game_data \$ = C:\Program Files\X-Ray SDK\level_editor\gamedata\
\$game_levels \$ = C:\Program Files\X-Ray SDK\level_editor\gamedata\levels\

[3120_config]:2947_config
\$game_data \$ = C:\Program Files\X-Ray SDK\level_editor\gamedata\
\$game_levels \$ = C:\Program Files\X-Ray SDK\level_editor\gamedata\levels\
```

(You may give the C:\Program Files\X-Ray SDK\level_editor\gamedata\ path for every \$game_data\$ and C:\Program Files\X-Ray SDK\level_editor\gamedata\levels\ path for every \$game_levels\$ line, so you can convert older build maps, if you copy into C:\Program Files\X-Ray SDK\level_editor\gamedata\levels\ folder the map folder from old builds)

Create a batch file in C:\Program Files\X-Ray SDK\converter\ folder with level_converter.bat name, with this command:

`@start converter.exe -level l01_escape -out l01_escape_vanilla -mode raw -with_lods`

Command explanation:

-level l01_escape : input folder, the converter seeks for the l01_escape map folder in C:\Program Files\X-Ray SDK\level_editor\gamedata\levels\ folder

-out l01_escape_vanilla : output folder of scene part files in C:\Program Files\X-Ray SDK\level_editor\maps\l01_escape_vanilla\ folder, and it creates a l01_escape_vanilla.level file too with this name, which can be opened in level editor. Also creates a folder in C:\Program Files\X-Ray SDK\level_editor\rawdata\objects\levels\l01_escape_vanilla\ folder for scene object files.

-mode raw : it’s best to convert the map to a scene in raw mode, it’s a safe debug mode, but the -le mode is good too

-with_lods:it creates lod textures for the map in C:\Program Files\X-Ray SDK\level_editor\gamedata\textures\lod\ folder with dds textures, so we don’t have to generate lods in level editor. The lod textures for the MU (multiple usage) objects on the map is a must have to get a valid scene!

Warning! There is a limit with lod textures, if you have in the C:\Program Files\X-Ray SDK\level_editor\gamedata\textures\lod\ folder more than 3000-4000 textures, you can't use xrLC, xrAI and xrDO_light, somehow these tools  simply quit with unknown error. Don't ask, why.
Temporary remove lod textures from this folder into another folder, keep in SDK gamedata only the lods what you need for the current scene.

!!!This is a spawn editing tutorial, therefore we don’t use the le2 command mode.

The le2 command mode creates more thousand object files for each map, and this will cause, that the Level Editor startup will take ages,

or it seems frozen at start. Only use the le2 converting mode, when you want to edit or rip the level geometry,

or you want to edit or rip the static objects from the map. In this case, temporary remove your map folders from

C:\Program Files\X-Ray SDK\level_editor\rawdata\objects\levels\ folder, to somewhere in your partition,

and re-copy them into rawdata after you opened the Level Editor.

The le mode creates few hundred larger objects per map, and the raw mode breaks a map only to few, bigger object files.

Both raw and le mode make possible a much faster Level Editor starting.!!!

Now the converter is ready to convert back maps to level editor scene. If you want to modify just some maps spawn, convert back only those maps.

If you want to work on all maps in Level Editor, here is the most convenient batch.

Create a batch file in C:\Program Files\X-Ray SDK\converter\ folder with convert_all18.bat name, and run this converter command from the batch file, so you can convert all 18 vanilla single player maps (on my rig it took 40 minutes):

```@start /wait converter.exe -level l01_escape -out l01_escape_vanilla -mode raw -with_lods
@start /wait converter.exe -level l02_garbage -out l02_garbage_vanilla -mode raw -with_lods
@start /wait converter.exe -level l03_agroprom -out l03_agroprom_vanilla -mode raw -with_lods
@start /wait converter.exe -level l03u_agr_underground -out l03u_agr_underground_vanilla -mode raw -with_lods
@start /wait converter.exe -level l04_darkvalley -out l04_darkvalley_vanilla -mode raw -with_lods
@start /wait converter.exe -level l04u_labx18 -out l04u_labx18_vanilla -mode raw -with_lods
@start /wait converter.exe -level l05_bar -out l05_bar_vanilla -mode raw -with_lods
@start /wait converter.exe -level l06_rostok -out l06_rostok_vanilla -mode raw -with_lods
@start /wait converter.exe -level l07_military -out l07_military_vanilla -mode raw -with_lods
@start /wait converter.exe -level l08_yantar -out l08_yantar_vanilla -mode raw -with_lods
@start /wait converter.exe -level l08u_brainlab -out l08u_brainlab_vanilla -mode raw -with_lods
@start /wait converter.exe -level l10u_bunker -out l10u_bunker_vanilla -mode raw -with_lods
@start /wait converter.exe -level l11_pripyat -out l11_pripyat_vanilla -mode raw -with_lods
@start /wait converter.exe -level l12_stancia -out l12_stancia_vanilla -mode raw -with_lods
@start /wait converter.exe -level l12_stancia_2 -out l12_stancia_2_vanilla -mode raw -with_lods
@start /wait converter.exe -level l12u_control_monolith -out l12u_control_monolith_vanilla -mode raw -with_lods
@start /wait converter.exe -level l12u_sarcofag -out l12u_sarcofag_vanilla -mode raw -with_lods
```

Now all the maps are ready to open in the Level Editor.

 Installing the xrAI tool

Copy the \bins folder with all the content to the C:\Program Files\X-Ray SDK\level_editor\ folder.

This creates a C:\Program Files\X-Ray SDK\level_editor\bins\compiler_ai\ folder with xrAI.exe and the needed dll files.

Copy the fsgame.ltx from C:\Program Files\X-Ray SDK\level_editor\ into C:\Program Files\X-Ray SDK\level_editor\bins\compiler_ai\ folder, the xrAI will ask for it.

The xrAI.bat is not needed from the xrAI pack, we create our own batch files, to make the workflow much easier to survey.

This is a spawn editing tutorial, but this xrAI tool needs level.gct.raw (level graph cross table raw file) files for each level,

which missing from vanilla gamedata, so we have to make level.graph for each map and finally we have to make a new game.graph.

Let’s create these batch files in the C:\Program Files\X-Ray SDK\level_editor\ folder, but don’t run these batch files yet:

make_level_graphs.bat:

```@start /wait bins\compiler_ai\xrAI.exe -g l01_escape
@start /wait bins\compiler_ai\xrAI.exe -g l02_garbage
@start /wait bins\compiler_ai\xrAI.exe -g l03_agroprom
@start /wait bins\compiler_ai\xrAI.exe -g l03u_agr_underground
@start /wait bins\compiler_ai\xrAI.exe -g l04_darkvalley
@start /wait bins\compiler_ai\xrAI.exe -g l04u_labx18
@start /wait bins\compiler_ai\xrAI.exe -g l05_bar
@start /wait bins\compiler_ai\xrAI.exe -g l06_rostok
@start /wait bins\compiler_ai\xrAI.exe -g l07_military
@start /wait bins\compiler_ai\xrAI.exe -g l08_yantar
@start /wait bins\compiler_ai\xrAI.exe -g l08u_brainlab
@start /wait bins\compiler_ai\xrAI.exe -g l10u_bunker
@start /wait bins\compiler_ai\xrAI.exe -g l11_pripyat
@start /wait bins\compiler_ai\xrAI.exe -g l12_stancia
@start /wait bins\compiler_ai\xrAI.exe -g l12_stancia_2
@start /wait bins\compiler_ai\xrAI.exe -g l12u_control_monolith
@start /wait bins\compiler_ai\xrAI.exe -g l12u_sarcofag
```

make_game_graph.bat:

`@start bins\compiler_ai\xrAI.exe -m`

make_all_spawn.bat:

`@start bins\compiler_ai\xrAI.exe -no_separator_check -noverbose -s`

Now we need to edit the C:\Program Files\X-Ray SDK\level_editor\gamedata\config\game_levels.ltx file to get the exact same map sequence, what we can reverse engineer from the vanilla game.graph and from the vanilla all.spawn.

Delete everything from game_levels.ltx (many test and cutout maps), and paste only these lines:

```[levels]
level01
level02
level03
level04
level05
level06
level07
level08
level09
level10
level11
level12
level13
level14
level15
level16
level17
level18

[level01]
name = L01_Escape
caption = "L01_Escape"
offset = 3000.0, 1000.0, 0.0
id = 01

[level02]
name = L02_Garbage
caption = "L02_Garbage"
offset = 3000.0, 1000.0, 1000.0
id = 02

[level03]
name = L03_Agroprom
caption = "L03_Agroprom"
offset = 2000.0, 1000.0, 1000.0
id = 03

[level04]
name = l03u_agr_underground
caption = "l03u_agr_underground"
offset = 2000.0, 800.0, 1000.0
id = 04

[level05]
name = l04_darkvalley
caption = "l04_darkvalley"
offset = 4000.0, 1000.0, 1000.0
id = 05

[level06]
name = l04u_LabX18
caption = "l04u_LabX18"
offset = 4000.0, 800.0, 1000.0
id = 06

[level07]
name = L05_Bar
caption = "L05_Bar"
offset = 3000.0, 1000.0, 2000.0
id = 07

[level08]
name = L06_rostok
caption = "L06_rostok"
offset = 2000.0, 1000.0, 2000.0
id = 08

[level09]
name = l08_yantar
caption = "l08_yantar"
offset = 1000.0, 1000.0, 2000.0
id = 09

[level10]
name = l08u_brainlab
caption = "l08u_brainlab"
offset = 1000.0, 800.0, 2000.0
id = 10

[level11]
name = L07_Military
caption = "L07_Military"
offset = 3000.0, 1000.0, 3000.0
id = 11

[level12]
offset = 3000.0, 1000.0, 4000.0
id = 12

[level13]
name = L11_Pripyat
caption = "L11_Pripyat"
offset = 3000.0, 1000.0, 5000.0
id = 13

[level14]
name = L12_Stancia
caption = "L12_Stancia"
offset = 2000.0, 1000.0, 8000.0
id = 14

[level15]
name = L12U_Sarcofag
caption = "L12U_Sarcofag"
offset = 2000.0, 1200.0, 8000.0
id = 15

[level16]
name = l12u_control_monolith
caption = "l12u_control_monolith"
offset = 2000.0, 1400.0, 8000.0
id = 16

[level17]
name = L12_Stancia_2
caption = "L12_Stancia_2"
offset = 2000.0, 1000.0, 9000.0
id = 17

[level18]
name = l10u_bunker
caption = "l10u_bunker"
offset = 3000.0, 800.0, 4000.0
id = 18
```

Now all your tools are ready to work with the vanilla all.spawn in the Level Editor.

 Working on Level Editor spawn

This tutorial will not cover, how to add the spawn objects, and how to set up the dozens of options,

but maybe later I (or someone else) will expand this part.

You can open any converted map in the Level Editor (File -> Open,

search C:\Program Files\X-Ray SDK\level_editor\maps\ folder, for example our converted map,

the l01_escape_vanilla.level file), and experiment with adding or editing the spawn objects.

After you finished, save your scene in Level Editor, and choose Compile -> Make Game.

This command will output a new level.spawn and a new level.game file, with all of your modifications

(and some other things, if the map has any, sound environments, static sound sources, static particles, environment modificator areas, but now these are unimportant).

It’s always good to save your work as a separate level file, so the vanilla maps will be untouched.

!!!When you want to save your map under Windows 7, sometimes you get this fatal:

```!Can't write file: 'c:\program files\x-ray sdk\level_editor\maps\l01_escape_mod.*.level'. Error: 'No such file or directory'.

FATAL ERROR
[error]Expression    : assertion failed
[error]Function      : I:\xray-svn\editors\LevelEditor\Edit\SceneIO.cpp
[error]File          : I:\xray-svn\editors\LevelEditor\Edit\SceneIO.cpp
[error]Line          : 254
[error]Description   : F

stack trace:
```

!!!Pay attention to always save your map with .level extension in the end, so in this case I saved the map succesfully as: l01_escape_mod.level, but I failed with just: l01_escape_mod.

Now just comes some xrAI work, and we are ready.

 Working with xrAI

1.) For the first time, run all the 3 batches, exclusively in this order (later, you don’t need to run the make_level_graphs.bat and make_game_graph.bat, because after the first run, all the necessary graph files will be there):

1. make_level_graphs.bat: updates in each SDK vanilla SP map folder the level.graph and level.gct.raw files

2. make_game_graph.bat: merges level.graph files, according to the game_levels.ltx, creates level.gct files and produces a new game.graph

3. make_all_spawn.bat: merges level.spawn files, according to the game_levels.ltx, and creates a new all.spawn, according to the new game.graph (1 minute, and it’s ready)

The new game.graph will be smaller, then vanilla, but it’s natural. I have after this process a 6.518.845 sized game.graph.

The vanilla game.graph is 8.128.486 sized, but GSC included many level.graphs for test and cutout maps (as you can see them in vanilla game_levels.ltx), which graphs will be missing from game.graph after the process - our game.graph will be smaller.

You get an l01_escape.spawn – because the actor is in this level -, so just rename it to all.spawn and copy to the gamedata. Use the universal acdc, check your new spawn, is it really there.

These files you will need to copy from C:\Program Files\X-Ray SDK\level_editor\gamedata to the mods gamedata:

```gamedata\spawns\all.spawn
gamedata\game.graph
Because of the new game.graph, from gamedata\levels\ we need from all 18 SP map folder:
level.graph
level.gct.raw
level.gct
```

Start a new game, and enjoy your spawn.

2.) After the first testing, you can jump back to level editor, and add new spawn objects, and after Compile -> Make Game, you need just run the spawn maker command, make_all_spawn.bat, and start a new game to test again.

Have fun!

Credits

written by: Bangalore

X-ray SDK install tutorials used from Kamikazze and mnn