Actions

SCHG How-to

Difference between revisions of "Creating Levels in Sonic Heroes"

From Sonic Retro

 
(14 intermediate revisions by 4 users not shown)
Line 2: Line 2:
 
{{GuideBy|igorseabra4}}
 
{{GuideBy|igorseabra4}}
  
This guide will show you how to create a custom level in Sonic Heroes.
+
'''WARNING''': the text on this page is obsolete. Please check the [https://github.com/igorseabra4/HeroesPowerPlant/wiki Heroes Power Plant wiki] for up-to-date modding information.
  
 
== Introduction ==
 
== Introduction ==
First of all, you should come [https://github.com/igorseabra4/HeroesCompiledBinaries here] and download pretty much everything in that page. It has every program this page mentions, except for [[HeroesONE]], [https://www.gtamodding.com/wiki/Magic.TXD Magic.TXD], 3ds Max and HeroesCollisionEditor, all of which you should get as well. Make sure you are using the latest version of each tool, they get updated frequently.
+
This guide will show you how to create a custom level in Sonic Heroes. We will mainly be using [[Heroes Power Plant]] and creating a [[Reloaded Mod Loader]] compatible level mod.
  
In the PC version of Sonic Heroes, level models are multiple .BSP files located inside .ONE archives, which are located in the dvdroot folder. We'll be using HeroesOBJ2BSP to convert .OBJ files (with a .MTL material library) exported from 3ds Max (you can try using other model editors, but I can't guarantee it'll work) into .BSPs. Then we'll use HeroesONE to put the .BSPs inside a .ONE archive and replace one of the originals. Then, we'll add the textures to the level's .TXD texture archive file with Magic.TXD and edit visibility data in the level's _blk.bin file with [[Heroes Visibility Editor]]. After that, we'll create a collision model and convert it to a .CL readable by Heroes using HeroesCL2OBJ or HeroesCollisionEditor.
+
First of all, you should come [[Heroes Power Plant|here]] and download the latest version of Heroes Power Plant (I'll just refer to it as HPP from now on). Get [https://www.gtamodding.com/wiki/Magic.TXD Magic.TXD] as well, as we're gonna need that to edit TXD texture archives. For model editing, we're gonna use 3ds Max, although it's possible to use other model editors as well, 3ds Max is reccomended due to being easy to export different parts of the model to separate files (which we're gonna need to do). [[Reloaded Mod Loader]] will be used to load the levels for testing and playing ingame, and [[HeroesONE]] is optional but necessary if you're porting objects between levels.
  
If this is your first time creating a level for this game, it's a good idea to first extract and take a look at the original levels, to see stuff like their size, shape, how they're laid out, what types of textures are in each .BSP etc. Use either HeroesBSP2OBJ or [[File:Bsp2objv021sonic.zip]] to rip the original .BSP models after extracting them from the original .ONE archives, Magic.TXD to rip the textures and HeroesCL2OBJ to rip the collision models. You can also play a bit with [[Heroes Layout Editor]], add a few random objects or teleport around the stage for a bit. Make sure to read the entire tutorial and as much of these wiki pages as you can, so you know what you're doing and you're not just throwing models at a wall to see what renders.
+
In the PC version of Sonic Heroes, level models are multiple BSP files located inside ONE archives; their visibility data in the level's s*_blk.bin file. Both are located in the dvdroot folder. The collision model is a CL file in the dvdroot/collisions folder. HPP can handle editing of those. Textures are located in a TXD archive, which we'll edit with Magic.TXD.
  
Since the console versions of Sonic Heroes use the same file types for most files and do accept .BSPs from the PC version, you can create custom levels for the PC or any of them, as long as you remember to save the .TXD in the correct version (Magic.TXD allows you to choose either PC, GameCube or PlayStation2). There's only start/ending position and spline editors for the PC EXE though.
+
If this is your first time creating a level for this game, it's a good idea to first extract and take a look at the original levels, to see stuff like their size, shape, how they're laid out etc. HPP can export level models and collision models in OBJ format. Magic.TXD can rip the textures.
 +
 
 +
Since the console versions of Sonic Heroes use the same file types for most files and do accept .BSPs from the PC version, you can create custom levels for the PC or any of them, as long as you remember to save the .TXD in the correct version (Magic.TXD allows you to choose either PC, GameCube, Xbox or PlayStation2). However, data located in the EXE such as start positions can't be modified in those as there's no mod loader for these versions.
 +
 
 +
== Setting Up a Mod ==
 +
First of all, we're going to set up a mod folder for your work. Your stage is going to use the Generic Stage Injection Mod to replace start positions and splines at runtime by the Mod Loader, without need to edit the game's EXE. None of the game's original files will be replaced during this.
 +
 
 +
Notice the HPP package has a folder called Generic Stage Injection Mod. In it, there's a small readme with steps on setting up your Reloaded mod. Follow them and come back to this once you have your mod set up.
 +
 
 +
Before using HPP, noticed the readme. It explains a bit about how to use the program and I really reccomend you to read it as I'm not gonna explain here.
 +
 
 +
Open the Mod Loader Config Editor window and create a new file. In the Level Flag box, choose which level you want your custom one to replace; this is an important step as some objects will only work in the level slots they originally belonged to (such as frogs) and pinball table and bingo slide collision also only works in slots which originally had them. So once you've picked a level that suits your desires, save the file as Stage.json in your mod stage folder.
 +
 
 +
If you try your mod now, since there are no new files, all you're gonna get ingame is the original level but you'll start at the 0, 0, 0 position and there will be no splines.
  
 
== Level Models ==
 
== Level Models ==
 
For more information, see [[SCHG:Sonic Heroes/Model Format|Model Format]].
 
For more information, see [[SCHG:Sonic Heroes/Model Format|Model Format]].
  
=== Filenames ===
+
I assume you already have a model of a level you want to import in 3ds Max right now.
First of all, you should choose a stage to replace. Choose based on the theme of the stage you plan to make and objects you want to use, as some only work in a few level slots. Also, pinball table/BINGO mode only works on levels which originally had them. The .ONE files for the levels are named s{{red|LL}}.one, where {{red|LL}} is the level number (some start with stg instead of s). For a complete list of level numbers, see the [[SCHG:Sonic_Heroes/Level_List#File Names and Data|File Names and Data]] level list.
 
  
If this is your first time creating a level for this game, first you should open one of the original .ONEs with HeroesONE and take a look at how the .BSPs inside it are named:
+
=== Chunks ===
 +
Chunks are the game's way of splitting a level into multiple parts, so only a some of them will show up at a time. Each chunk has a number and is made up of multiple BSP files, if your curiosity made you open one of the game's original ONEs you should have noticed that. This is how a BSP is named:
  
S{{red|LL}}_{{green|MM}}_{{blue|NN}}.BSP (or STG instead of S, accordingly with the .ONE name)
+
S{{red|LL}}_{{green|MM}}_{{blue|NN}}.BSP (or STG instead of S)
  
{{red|LL}} is the level number, {{green|MM}} is the material setting identifier and {{blue|NN}} is the chunk number.
+
{{red|LL}} is the level number, {{green|MM}} is the material setting identifier and {{blue|NN}} is the chunk number. Check the [[SCHG:Sonic Heroes/Level List#File Names and Data|Level List]] page to see your level's number (in the File Names and Data list). That will also tell you whether your files start with S or STG.
  
Levels in Sonic Heroes are divided into multiple {{blue|NN}} chunks. Each chunk has a number and can have a large number of BSPs set for it. All files with the same {{blue|NN}} number make up the same chunk. For the game to know which chunk to display at a given time, the camera must be inside boundaries set in the ''*_blk.bin file'', which we'll discuss soon; if the BSP has no number (S{{red|LL}}_{{green|MM}}.BSP) it'll be rendered all the time.
+
For the game to know which chunk to display at a given time, the camera must be inside boundaries set in the ''s*_blk.bin file'', which we'll discuss soon; if the last part of the name is ommited (S{{red|LL}}_{{green|MM}}.BSP) the file will always be displayed (this is used for some levels' skyboxes).
  
The files also have different {{green|MM}} material settings. They will set how the model is rendered. For a complete list of what you can use, see [[SCHG:Sonic_Heroes/EXE_Editing#Material_Flags|Material Flags]]. These are some of them:
+
The files also have different {{green|MM}} material settings. They will set how the model is rendered. They are the following:
  
*ON - Normal
+
{| class="prettytable"
*ONS - Normal, shadow casting
+
!Identifier||Description
*ONW - Normal, no culling
+
|-
*ONWS - Normal, no culling, shadow casting
+
| DN
*DN - Skybox
+
| Sky model material
*PN - Normal, alpha testing
+
|-
*PNS - Normal, alpha testing, shadow casting
+
| O
*PNW - Normal, alpha testing, no culling
+
| Reflective material
*PNWS - Normal, alpha testing, shadow casting, no culling
+
|-
*DA - Skybox, Alpha material
+
| OS
*AFN - Alpha material
+
| Reflective floor material
*AFNS - Alpha material, shadow casting
+
|-
*K - Additive alpha
+
| ON
*KW - Additive alpha, no culling
+
| Regular material
 +
|-
 +
| ONS
 +
| Regular floor material
 +
|-
 +
| ONW
 +
| Regular material without culling
 +
|-
 +
| ONWS
 +
| Regular floor material without culling
 +
|-
 +
| P
 +
| Alpha testing with reflective material
 +
|-
 +
| PS
 +
| Alpha testing with reflective floor material
 +
|-
 +
| PN
 +
| Alpha testing material
 +
|-
 +
| PNS
 +
| Alpha testing floor material
 +
|-
 +
| PNW
 +
| Alpha testing material without culling
 +
|-
 +
| PNWS
 +
| Alpha testing floor material without culling
 +
|-
 +
| DA
 +
| Alpha sky material
 +
|-
 +
| AF
 +
| Alpha reflective material
 +
|-
 +
| AFS
 +
| Alpha reflective floor material
 +
|-
 +
| AFN
 +
| Alpha material
 +
|-
 +
| AFNS
 +
| Alpha floor material
 +
|-
 +
| K
 +
| Additive alpha material
 +
|-
 +
| KW
 +
| Additive alpha material without culling
 +
|-
 +
| A
 +
| Alpha reflective material
 +
|-
 +
| AS
 +
| Alpha reflective floor material
 +
|-
 +
| AN
 +
| Alpha material
 +
|-
 +
| ANS
 +
| Alpha floor material
 +
|}
  
=== BSP Importing ===
+
=== Importing Your Models ===
In 3ds Max, you should split your models into groups so that each group will be converted into one .BSP file. So separate floors from walls and materials which use alpha from ones which don't. When splitting meshes, make each material its own object (so the number of materials and objects is 1:1; if you're too lazy to do that by hand, in 3ds Max just group everything into one mesh and use [http://www.scriptspot.com/3ds-max/scripts/detach-by-material-id this tool] to split it). There's a maximum of 65535 vertices and triangles per .BSP, but each one shouldn't be even close to that (as HeroesOBJ2BSP will add extra vertices to fix UV coordinates). Split the level into chunks; each resulting .BSP shouldn't be much bigger than around 500 kb or the game will crash.
+
In 3ds Max, you should split your models into meshes so that each mesh will be converted into one BSP file. You can first split the model into multiple by chunk, then split each chunk into the different components of it: floors should be in their own mesh (ONS) as they recieve shadows and walls (ON) don't. Parts of the model with textures with alpha testing should have the PN in their name, textures with normal alpha should have the AFN in their name, the skybox will be DN, effects such as water and glow will be K and so on. You can name your meshes the same name of their BSP so you won't have trouble renaming them later. A file name for the floor models of the third chunk in Seaside Hill would be S01_ONS_03.BSP, a name for a model with alpha textures for the fourth chunk in Casino Park would be STG05_AFN_04.BSP. Note that you can use the shaders from the original stages as well (such as animated water and blue roads from the city levels). Just take a look at the texture name in the original TXD and name your texture accordingly.
  
Export your .OBJs from 3ds Max (remember to use Y axis = up) and drag them into HeroesOBJ2BSP (or just double-click the program to convert every .OBJ in the folder). Remember your .OBJ must use dots (.), not commas (,) as floating point separators in case you're from a country which uses that. And don't drag the .MTL into the program, it'll load that automatically.
+
There's a maximum of 65535 vertices and triangles per BSP, but each one shouldn't be even close to that (as HPP will add extra vertices to fix UV coordinates and vertex colors). Each resulting BSP shouldn't be much bigger than around 400 kb or the game will crash in the game without the [https://github.com/sewer56lol/TONER/releases TONER mod] (PC mod for [https://github.com/sewer56lol/Reloaded-Mod-Loader/releases Reloaded Mod Loader] only); if that happens, when importing, HPP will warn you of that, however with the [https://github.com/sewer56lol/TONER/releases TONER mod] you can bypass this issue. If you wish to stay within these limits for console versions or if you're not using [https://github.com/sewer56lol/Reloaded-Mod-Loader/releases Reloaded] and the [https://github.com/sewer56lol/TONER/releases TONER mod] for some reason, split your files into more chunks. However please note that there is a limit of 256 chunks per stage.
  
It'll spit out a .BSP with the same name of your .OBJ. Name it according to the explanation above. Create an empty file in HeroesONE and add all your .BSPs to it. Save and replace the original file. If your level has a _h file (such as s01_h.one), replace that as well.
+
Export each mesh to a separate OBJ or DAE file (remember to use Y axis = up). The model must use triangular faces, contain vertex positions and texture coordinates. Vertex normals are ignored as the game doesn't use them, and for DAE, vertex colors are supported (Heroes uses vertex colors extensively for shading and shadows on the models). Texture names will be the same ones of the textures you're using in 3ds Max. Their names cannot contain spaces. [http://www.scriptspot.com/3ds-max/scripts/batch-exportimport This addon for 3ds Max] can automatically export each model to a separate file just as we need.
 +
 
 +
Now, import your models using HPP's Level Editor. Double-click the files to rename them if needed, then save. Take a look into your original game's dvdroot folder. If there's a s(tg){{red|LL}}_h.one file for your level, then that should be your ONE file name; if there isn't, save it as s(tg){{red|LL}}.one. Save it inside your mod's Files folder, don't replace any of the original files.
 +
 
 +
Since you have no visibility file set up yet, nothing will initially show up; disable the Render By Chunk checkbox in the Viewport Config (or the H shortcut key) to disable per-chunk rendering. If you did everything correctly, your models should show up in HPP.
 +
 
 +
Except they probably have no textures. HPP can display texures either from a TXD file or from a folder containing PNGs. You can choose any number of them under HPP'S Resources tab.
  
 
=== Visibility ===
 
=== Visibility ===
 
For more information, see [[SCHG:Sonic Heroes/Visibility Editing|Visibility Editing]].
 
For more information, see [[SCHG:Sonic Heroes/Visibility Editing|Visibility Editing]].
  
Each chunk is rendered if the camera is inside the visibility boundaries defined in the ''_blk.bin'' file. We'll use [[Heroes Visibility Editor]] to edit it. The file is named s{{red|LL}}_blk.bin or stg{{red|LL}}_blk.bin. Open the file in the editor and set the minimum and maximum coordinates you want the model to be visible at; for more precise values, create a box in 3ds Max and make sure it encompasses the entire chunk, or the entire area you want your chunk to be visible in. Then, export the box to a .OBJ, open it in a text editor and get the values from there. You should test your model ingame now, or wait to do so after adding the textures.
+
Ingame, each chunk is rendered if the camera is inside the visibility boundaries defined in the ''_blk.bin'' file. The level editor in HPP includes a visibility editor, where you can add chunks, set the number that they refer to (there can be multiple), edit their maximums and minimums and see the chunk boundaries displayed in the viewport (disabled by default, check Chunk Boxes in the Viewport Config or press B to toggle that). The AutoChunk function will automatically calculate chunk boundaries for you with an offset. You can verify that the chunks are rendered in the proper locations by disabling Render By Chunk and checking them out in HPP. When you're happy with your visibility layout, save the file as s(tg){{red|LL}}_blk.bin in your mod stages Files folder along with the ONE. From now on, when opening the ONE in the Level Editor, the visibility file will be loaded as well.
 +
 
 +
If you run your game with the mod enabled now, you'll probably be able to see the custom models, except they have no textures since we didn't add that yet. Also, you have no start position and the collision is still the original level's. It's a good idea to test it now, because if the game crashes, that probably means one of your BSP files is too big (the game doesn't crash if you have an invalid BSP or visibility file, only if it's valid but too big).
  
 
=== Textures ===
 
=== Textures ===
 
We'll be using [https://www.gtamodding.com/wiki/Magic.TXD Magic.TXD] for the textures.
 
We'll be using [https://www.gtamodding.com/wiki/Magic.TXD Magic.TXD] for the textures.
  
HeroesOBJ2BSP will try getting the texture names from the files specified in the .OBJ's referenced .MTL file. If you exported your model with the default 3ds Max settings, it should do this with no problem. If it fails to, it will use the material names (set by usemtl in the .OBJ file) as texture names. It will warn you if it does so.
+
The TXD files for level textures are located in dvdroot/textures. You'll probably figure out by now the name of your level's. Copy the original TXD from your game to your mod's Files\textures folder and open it in Magic.TXD.
  
The TXD files for level textures are located in dvdroot/textures. You'll probably figure out by now the name of your level's. Open it in Magic.TXD. Use Edit->Add or the Insert shortcut key or just drag your images into the list to add them to the file. Save and make sure the version of the TXD is correct (it should be Sonic Heroes PC, or GameCube or PlayStation 2 if you're editing those versions). Don't delete the original textures from the file unless you're sure of what you're doing (some levels will crash without certain textures). Remember this file contains textures for both level and object models. If you extracted the textures from the game already you obviously don't need to add them a second time. You should test your model now and it should render correctly.
+
Use Edit->Add or the Insert shortcut key or just drag your new textures into the list to add them to the file. I reccomend setting each texture to have mipmaps and DXT1 compression, but you can choose any format you see fit, except for textures with alpha (you can manipulate those settings in Magic.TXD by pressing M with the texture selected; just take a look the format the original textures use and try to mimic it).
  
== Level Collision ==
+
Save and make sure the version of the TXD is correct (it should be Sonic Heroes PC, or GameCube or PlayStation 2 if you're editing those versions). Don't delete the original textures from the file unless you're sure of what you're doing (some levels will crash without certain textures). Remember this file contains textures for both level and object models. If your model uses the same textures from the game that are already in the file (such as shaders) you obviously don't need to add them a second time. You should test your level again now and it should render correctly.
 +
 
 +
== Collision ==
 
For more information, see [[SCHG:Sonic Heroes/Collision Format|Collision Format]].
 
For more information, see [[SCHG:Sonic Heroes/Collision Format|Collision Format]].
  
First, you must create a collision model. You should start from your level's original model, but get rid of details such as plants that are not supposed to be touchable. You can also add invisible geometry to your collision model. Replace stairs with ramps. Make sure the model is as simple as possible. Split it into multiple meshes, as this division will be kept in the file. This model has a maximum size of 65535 vertices and/or triangles. Export it as .OBJ and convert it to .CL using HeroesOBJ2CL or HeroesCollisionGenerator. Once converted, replace the file in the dvdroot\collisions folder (it's named s(tg){{red|LL}}.cl).
+
First, you must create a collision model. You should start from your level's original model, but get rid of details such as plants and complex items that are not supposed to be touchable. You can also add invisible geometry to it. Replace stairs with ramps. Make sure the model is as simple as possible. Split it into multiple meshes, as this division will be kept in the file. This model has a maximum size of 65535 vertices and/or triangles. Export it as OBJ and import it with HPP's Collision Editor window. Save it in the mod's root\dvdroot\collisions folder (it's named s(tg){{red|LL}}.cl).
  
If you test your model and notice collision is buggy in some parts (such as floor clipping), it's probably because some of your meshes have too many triangles. Try simplifying the mesh, and if you absolutely can't, split it into 2 or more.
+
Notice there are a few settings in the collision editor: depth level, power flag and flip normals. If you're just a regular stage modder and have zero idea how Sonic Heroes internally handles collision, just leave them as they are (depth level at 5 and power flag at 0xD). If you want to, you can set the depth level to auto. This will usually result in your collision quadtree's depth level being from 8 to 10. This means the game will take less CPU to check for collisions and will run better (at a higher resolution, no framerate drops) on lower-end computers, which is your goal (you want people to play your level even if they have bad PCs) (if you set your depth level to 1 or 2, even if you have a nice PC your game will lag terribly). But custom collision files with high depth levels are known to make the game crash at random spots while running (we have no idea why) and that's why we can just leave it at 5 for now, as it won't crash and won't make your game lag unless you have a computer with terrible specs. If it works, why bother? As for the power flag, it defines a few numbers that are added to the quadtree's settings, we don't know much about what it does. Most of the original files leave it at 0xD so that's what we do.
  
=== Using HeroesOBJ2CL ===
+
Once your model is imported and saved, you can check Show Collision or use the X shortcut to display it. The file's quadtree can be displayed as well if Show QuadTree is checked, although there's not too much need for this except maybe for debugging purposes. If you test your model and notice collision is buggy in some parts (such as floor clipping), it's probably because some of your meshes have too many triangles. Try simplifying the mesh, and if you absolutely can't, split it into 2 or more.
Drag your .OBJ into HeroesOBJ2CL. It will ask you for a maximum depth level. To test, you should try something between 3-5, as you probably want to try the level right away and don't want the operation to take too long. Choosing lower levels will have the file generated very quickly, but the game will take more of your CPU when running and you might have framerate drops. You should go for higher levels (10 if you can) when releasing as they are more optimized and will run better, but they can take a long time to get ready (it increases exponentially by depth level). Type 0 for the level to be chosen automatically.
 
  
==== Collision Flags ====
+
=== Collision Flags ===
When creating your collision model, you must name your meshes so each one of them represents a different part of the level. Currently, this is only supported by HeroesOBJ2CL as of Release 2. Append an underscore _ and one of the following letters to set the collision type for that mesh:
+
When creating your collision model, you must name your meshes so they represent different parts of the level. In HPP's readme, you can find a full list of flags which can be appended to the mesh name with an underscore _ to set the collision type for that mesh.
  
*_w - Wall. You can't walk or run on top of it
+
Note that the bingo and pinball types will only work in levels which originally had them. The difference between them is that you accelerate much faster and have more control on slides than tables.
*_s - Stairs. Model should be a ramp, but will act as stairs
 
*_i - Barrier. It's a wall that is only solid as long as you are touching the ground
 
*_b - Bingo slide
 
*_p - Pinball table
 
  
Note that the bingo and pinball types will only work in levels which originally had them. The difference between them is that you accelerate much faster and have more control on slides than tables.
+
If you want to experiment a bit, you can also set the flags manually. Export the collision from one of the original CL files to OBJ, import it in 3ds Max and take a look at how meshes are named. You can append the same type of formatting (_WWXXYYZZ, 4 bytes) and the flags will be that. You can play with flags that have not been documented yet with this.
  
If you want to set the flags manually, just add p, s, t or f (for the first, second, third and fourth bytes of the flags, respectively) followed by which bit you want to set for that flag to the name. You can combine multiple of them. For example, a mesh named ''mesh_p3t1f6'' would have bit 3 set in the first flag, bit 1 set in the third flag, and bit 6 set in the fourth flag (resulting in the combination 04 00 01 20). This should be used for experimental purposes only, as the flags have not been well documented yet.
+
=== sewer56lol's Collision Library ===
 +
sewer56lol has worked on a tool and library for handling CL files.
 +
Its collision generator can be considered superior to HPP's for a few technical reasons.  
 +
You can get the source [https://github.com/sewer56lol/Heroes-Collision-Library here].
  
=== Using HeroesCollisionGenerator ===
+
The project README contains instructions on how to operate the tool and use the library in your own programs if desired.
HeroesCollisionGenerator is an alternative for OBJ2CL made by sewer56lol. It uses a faster algorithm, but doesn't generate any collision flags yet. It requires .NET Core 2.0 to run. You can get the source [https://github.com/sewer56lol/Heroes-Collision-Generator-II here].
 
  
 
=== Death Zones and Water ===
 
=== Death Zones and Water ===
''There are no tools to create those yet''
+
CL files that have _xx or _wt appended to their names contain collision for death and water boundaries, respectively. You can import them with HPP, make sure all models have _a or _x to their names as specified above. When importing, make sure Flip Normals is checked as these files use reversed normals; they'll show up upside down and you'll have to disable culling to see them right side up. Also, make sure to set the quadtree depth level to 1 (or 2, maximum).
  
 
== Objects ==
 
== Objects ==
For this, you'll need [[Heroes Layout Editor]] to edit layout data and [[Heroes SET ID Table Editor]] to change object availability for use on certain stages. Object layouts are contained in s**_p**.bin for each level and team. Once you open a layout file in the editor, it should be pretty straightforward; just place objects wherever you want. Please read the [[SCHG:Sonic Heroes/Object Editing|Object Editing]] and [[SCHG:Sonic Heroes/Object Porting|Object Porting]] pages for all the info on this.
+
HPP's Layout Editor window can open and edit layout data; HPP's SET ID Table Editor can be used to change object availability for use on certain stages. Object layouts are contained in s(tg)**_p**.bin for each level and team; save them to your Files folder. Once you open a layout file in the editor, it should be pretty straightforward; just place objects wherever you want. You can click to select them, move them, rotate, set misc. settings, see a preview of them. Please read the [[SCHG:Sonic Heroes/Object Editing|Object Editing]] and [[SCHG:Sonic Heroes/Object Porting|Object Porting]] pages for all the info on this.
  
== Starting Positions, Ending Positions and Splines ==
+
== Start Positions and Splines ==
 
For more information, see [[SCHG:Sonic Heroes/EXE Editing|EXE Editing]].
 
For more information, see [[SCHG:Sonic Heroes/EXE Editing|EXE Editing]].
  
You'll need to use [[HeroesTweaker]] for all of those. This data is located in Tsonic_win.exe.
+
You can set start, ending (victory animation) and bragging (for the start of multiplayer levels) positions in HPP's Mod Loader Config Editor. These will be saved to the Config.cc file. For starting and ending positions, the only thing that shouldn't be self-explanatory is the hold time; it's the time you spend running before you gain control of the characters. It only applies to a Running start mode. Get the coordinates from the object layout editor for convenience.
  
For starting and ending positions, the only thing that shouldn't be self-explanatory is the hold time; it's the time you spend running before you gain control of the characters. It only applies to a Running start mode. Get the coordinates from the object layout editor for convenience.
+
As for splines, you can import those in the Spline Editor window. It is reliant on the Config Editor to display and import splines (that's why it will only show up if you have a config file open).
  
Splines are located in Tsonic_win.exe. There are 3 types of splines: autoloops, rails and ball paths. Ball paths are those tubes used in Casino Park and BINGO Highway (it's them in those Power Plant green spheres as well).
+
When importing a new OBJ file, make sure the only thing in the file is the spline; all the program will do is read all the vertices in order and create the new spline with them. There are 3 types of splines: autoloops, rails and ball paths. Ball paths are those tubes used in Casino Park and BINGO Highway (it's them in those [[Power Plant]] (level, not program) green spheres as well). You can pick one for each spline (setting it to null will make the spline do nothing, this is useful if you want to disable it without deleting it). The splines can be seen in the view if the option is checked; remember to save.
  
HeroesTweaker lets you edit splines for most levels (we have all single player levels, but not all bosses and 2P levels yet; if you find the pointer list to the splines of any level, add its offset and amount of pointers to SplinePointers.ini and to this wiki please). It can edit the spline type for each spline, as well as export and import an OBJ file with them (when importing, make sure the only thing in the OBJ file is the spline). The imported file must have the same amount of vertices as the original one. You can't add or remove splines or vertices. If you wanna add more vertices to a spline, you must hex edit Tsonic_win.exe and do that there (if you wanna add more points to a spline, you'll have to switch some pointers around, but you can import the spline in HeroesTweaker after that).
+
Note that not all levels have spline loaders, meaning you can't add splines for them. These are the levels which did not contain splines originally (such as Sea Gate and Egg Hawk).
  
Note that if you want a very long rail or autoloop and your level doesn't include that, you can glue the end of a spline to the start of the next and it will act like it's the same one (the original game actually does this all the time).
+
If you wish to extract and take a look at the original game's splines and start positions, [[HeroesTweaker|Heroes Tweaker]] lets you open Tsonic_win.exe and do that. It can also export the splines as OBJ.
 +
 
 +
== Cameras ==
 +
See [[SCHG:Sonic Heroes/Camera Editing|Camera Editing]].
 +
 
 +
== Particles (PTCL) ==
 +
See [[SCHG:Sonic Heroes/Particle Editing|Particle Editing]].
 +
 
 +
== Texture Patterns (TXC) ==
 +
See [[SCHG:Sonic Heroes/Texture Animation Editing|Texture Animation Editing]].
 +
 
 +
== Indirect Info ==
 +
See [[SCHG:Sonic Heroes/Indirect Editing|Indirect Editing]].
 +
 
 +
== Custom Mod DLL ==
 +
The Reloaded Generic Stage Injection Mod, although it has the useful features of replacing start positions and splines for any number of levels at once from your Stage.json and Splines folder (and mid-game file swapping), can't do much more than that. If you want to edit stuff such as bobsleds, Team Chaotix's mission goals, the amount of items you must collect in their missions, the amount of minutes you have for Team Sonic's Extra mission, the ranking requirements (A, B, C, D ranks) for each team, you must create your own mod DLL, and for that you must know at least the basics of programming in C# with Microsoft Visual Studio. Not only that, you can also add your own code to the game, such as the custom coded mid-level music change implemented in the Emerald Coast stage mod. More details on this will be added later, for know if you want to know more about this, you can ask on our Heroes Hacking Central server on Discord.
  
 
== Other Stuff ==
 
== Other Stuff ==
Lightning data in s**_light.bin files. We don't know their format yet, but we do know they contain multiple light data entries. They are applied to characters and objects only (it's not environmental lightning). The main entry is applied all the time, and each of the other entries is applied by trigger objects.
+
Lighting data in s**_light.bin files. We don't know their format yet, but we do know they contain multiple light data entries. They are applied to characters and objects only (it's not environmental lighting). The main entry is applied all the time, and each of the other entries is applied by trigger objects.
  
 
Music is located in looping ADX files in the bgm folder. If the music's not looped, it won't start again after ending.
 
Music is located in looping ADX files in the bgm folder. If the music's not looped, it won't start again after ending.
  
We also have [[SCHG:Sonic Heroes/Indirect Editing|Indirect Editing]] and [[SCHG:Sonic Heroes/Particle Editing|Particle Editing]]. In [[SCHG:Sonic Heroes/EXE Editing|EXE Editing]] there's a lot of stuff we don't have programs to edit yet, too.
+
You can add all of those files to your stage mod's Files folder (or subfolders) and they will be redirected by the Mod Loader.
 
 
There's one thing we do not know anything about yet; those are cameras. For now, just replace the ''_cam.bin'' file with an empty one. Eventually we'll be able to edit them as well.
 
  
 +
{{SCHGuides}}
 
[[Category:SCHG How-tos]]
 
[[Category:SCHG How-tos]]

Latest revision as of 14:35, 7 August 2020

SCHG: Sonic Heroes
Main Article
Mechanic Editing

DOL Editing
EXE Editing
Music Pointers
Object Parameter Data
Relocatable Editing (PC)
File Offsets

Model Editing
Collision Format
Model Format
Level Editing

Camera Editing
Event Editing
ID list
Indirect Editing
Light Editing
Level List
Object Editing
Object Porting
Spline Editing
Texture Animation Editing
Visibility Editing

Particle Editing
Particle Editing
Sound Editing
Music List

Sound Editing
Voices

SCHG How-Tos

Custom Object Material Effect Tutorial
Level Editing Tutorial

(Original guide by igorseabra4)

WARNING: the text on this page is obsolete. Please check the Heroes Power Plant wiki for up-to-date modding information.

Introduction

This guide will show you how to create a custom level in Sonic Heroes. We will mainly be using Heroes Power Plant and creating a Reloaded Mod Loader compatible level mod.

First of all, you should come here and download the latest version of Heroes Power Plant (I'll just refer to it as HPP from now on). Get Magic.TXD as well, as we're gonna need that to edit TXD texture archives. For model editing, we're gonna use 3ds Max, although it's possible to use other model editors as well, 3ds Max is reccomended due to being easy to export different parts of the model to separate files (which we're gonna need to do). Reloaded Mod Loader will be used to load the levels for testing and playing ingame, and HeroesONE is optional but necessary if you're porting objects between levels.

In the PC version of Sonic Heroes, level models are multiple BSP files located inside ONE archives; their visibility data in the level's s*_blk.bin file. Both are located in the dvdroot folder. The collision model is a CL file in the dvdroot/collisions folder. HPP can handle editing of those. Textures are located in a TXD archive, which we'll edit with Magic.TXD.

If this is your first time creating a level for this game, it's a good idea to first extract and take a look at the original levels, to see stuff like their size, shape, how they're laid out etc. HPP can export level models and collision models in OBJ format. Magic.TXD can rip the textures.

Since the console versions of Sonic Heroes use the same file types for most files and do accept .BSPs from the PC version, you can create custom levels for the PC or any of them, as long as you remember to save the .TXD in the correct version (Magic.TXD allows you to choose either PC, GameCube, Xbox or PlayStation2). However, data located in the EXE such as start positions can't be modified in those as there's no mod loader for these versions.

Setting Up a Mod

First of all, we're going to set up a mod folder for your work. Your stage is going to use the Generic Stage Injection Mod to replace start positions and splines at runtime by the Mod Loader, without need to edit the game's EXE. None of the game's original files will be replaced during this.

Notice the HPP package has a folder called Generic Stage Injection Mod. In it, there's a small readme with steps on setting up your Reloaded mod. Follow them and come back to this once you have your mod set up.

Before using HPP, noticed the readme. It explains a bit about how to use the program and I really reccomend you to read it as I'm not gonna explain here.

Open the Mod Loader Config Editor window and create a new file. In the Level Flag box, choose which level you want your custom one to replace; this is an important step as some objects will only work in the level slots they originally belonged to (such as frogs) and pinball table and bingo slide collision also only works in slots which originally had them. So once you've picked a level that suits your desires, save the file as Stage.json in your mod stage folder.

If you try your mod now, since there are no new files, all you're gonna get ingame is the original level but you'll start at the 0, 0, 0 position and there will be no splines.

Level Models

For more information, see Model Format.

I assume you already have a model of a level you want to import in 3ds Max right now.

Chunks

Chunks are the game's way of splitting a level into multiple parts, so only a some of them will show up at a time. Each chunk has a number and is made up of multiple BSP files, if your curiosity made you open one of the game's original ONEs you should have noticed that. This is how a BSP is named:

SLL_MM_NN.BSP (or STG instead of S)

LL is the level number, MM is the material setting identifier and NN is the chunk number. Check the Level List page to see your level's number (in the File Names and Data list). That will also tell you whether your files start with S or STG.

For the game to know which chunk to display at a given time, the camera must be inside boundaries set in the s*_blk.bin file, which we'll discuss soon; if the last part of the name is ommited (SLL_MM.BSP) the file will always be displayed (this is used for some levels' skyboxes).

The files also have different MM material settings. They will set how the model is rendered. They are the following:

Identifier Description
DN Sky model material
O Reflective material
OS Reflective floor material
ON Regular material
ONS Regular floor material
ONW Regular material without culling
ONWS Regular floor material without culling
P Alpha testing with reflective material
PS Alpha testing with reflective floor material
PN Alpha testing material
PNS Alpha testing floor material
PNW Alpha testing material without culling
PNWS Alpha testing floor material without culling
DA Alpha sky material
AF Alpha reflective material
AFS Alpha reflective floor material
AFN Alpha material
AFNS Alpha floor material
K Additive alpha material
KW Additive alpha material without culling
A Alpha reflective material
AS Alpha reflective floor material
AN Alpha material
ANS Alpha floor material

Importing Your Models

In 3ds Max, you should split your models into meshes so that each mesh will be converted into one BSP file. You can first split the model into multiple by chunk, then split each chunk into the different components of it: floors should be in their own mesh (ONS) as they recieve shadows and walls (ON) don't. Parts of the model with textures with alpha testing should have the PN in their name, textures with normal alpha should have the AFN in their name, the skybox will be DN, effects such as water and glow will be K and so on. You can name your meshes the same name of their BSP so you won't have trouble renaming them later. A file name for the floor models of the third chunk in Seaside Hill would be S01_ONS_03.BSP, a name for a model with alpha textures for the fourth chunk in Casino Park would be STG05_AFN_04.BSP. Note that you can use the shaders from the original stages as well (such as animated water and blue roads from the city levels). Just take a look at the texture name in the original TXD and name your texture accordingly.

There's a maximum of 65535 vertices and triangles per BSP, but each one shouldn't be even close to that (as HPP will add extra vertices to fix UV coordinates and vertex colors). Each resulting BSP shouldn't be much bigger than around 400 kb or the game will crash in the game without the TONER mod (PC mod for Reloaded Mod Loader only); if that happens, when importing, HPP will warn you of that, however with the TONER mod you can bypass this issue. If you wish to stay within these limits for console versions or if you're not using Reloaded and the TONER mod for some reason, split your files into more chunks. However please note that there is a limit of 256 chunks per stage.

Export each mesh to a separate OBJ or DAE file (remember to use Y axis = up). The model must use triangular faces, contain vertex positions and texture coordinates. Vertex normals are ignored as the game doesn't use them, and for DAE, vertex colors are supported (Heroes uses vertex colors extensively for shading and shadows on the models). Texture names will be the same ones of the textures you're using in 3ds Max. Their names cannot contain spaces. This addon for 3ds Max can automatically export each model to a separate file just as we need.

Now, import your models using HPP's Level Editor. Double-click the files to rename them if needed, then save. Take a look into your original game's dvdroot folder. If there's a s(tg)LL_h.one file for your level, then that should be your ONE file name; if there isn't, save it as s(tg)LL.one. Save it inside your mod's Files folder, don't replace any of the original files.

Since you have no visibility file set up yet, nothing will initially show up; disable the Render By Chunk checkbox in the Viewport Config (or the H shortcut key) to disable per-chunk rendering. If you did everything correctly, your models should show up in HPP.

Except they probably have no textures. HPP can display texures either from a TXD file or from a folder containing PNGs. You can choose any number of them under HPP'S Resources tab.

Visibility

For more information, see Visibility Editing.

Ingame, each chunk is rendered if the camera is inside the visibility boundaries defined in the _blk.bin file. The level editor in HPP includes a visibility editor, where you can add chunks, set the number that they refer to (there can be multiple), edit their maximums and minimums and see the chunk boundaries displayed in the viewport (disabled by default, check Chunk Boxes in the Viewport Config or press B to toggle that). The AutoChunk function will automatically calculate chunk boundaries for you with an offset. You can verify that the chunks are rendered in the proper locations by disabling Render By Chunk and checking them out in HPP. When you're happy with your visibility layout, save the file as s(tg)LL_blk.bin in your mod stages Files folder along with the ONE. From now on, when opening the ONE in the Level Editor, the visibility file will be loaded as well.

If you run your game with the mod enabled now, you'll probably be able to see the custom models, except they have no textures since we didn't add that yet. Also, you have no start position and the collision is still the original level's. It's a good idea to test it now, because if the game crashes, that probably means one of your BSP files is too big (the game doesn't crash if you have an invalid BSP or visibility file, only if it's valid but too big).

Textures

We'll be using Magic.TXD for the textures.

The TXD files for level textures are located in dvdroot/textures. You'll probably figure out by now the name of your level's. Copy the original TXD from your game to your mod's Files\textures folder and open it in Magic.TXD.

Use Edit->Add or the Insert shortcut key or just drag your new textures into the list to add them to the file. I reccomend setting each texture to have mipmaps and DXT1 compression, but you can choose any format you see fit, except for textures with alpha (you can manipulate those settings in Magic.TXD by pressing M with the texture selected; just take a look the format the original textures use and try to mimic it).

Save and make sure the version of the TXD is correct (it should be Sonic Heroes PC, or GameCube or PlayStation 2 if you're editing those versions). Don't delete the original textures from the file unless you're sure of what you're doing (some levels will crash without certain textures). Remember this file contains textures for both level and object models. If your model uses the same textures from the game that are already in the file (such as shaders) you obviously don't need to add them a second time. You should test your level again now and it should render correctly.

Collision

For more information, see Collision Format.

First, you must create a collision model. You should start from your level's original model, but get rid of details such as plants and complex items that are not supposed to be touchable. You can also add invisible geometry to it. Replace stairs with ramps. Make sure the model is as simple as possible. Split it into multiple meshes, as this division will be kept in the file. This model has a maximum size of 65535 vertices and/or triangles. Export it as OBJ and import it with HPP's Collision Editor window. Save it in the mod's root\dvdroot\collisions folder (it's named s(tg)LL.cl).

Notice there are a few settings in the collision editor: depth level, power flag and flip normals. If you're just a regular stage modder and have zero idea how Sonic Heroes internally handles collision, just leave them as they are (depth level at 5 and power flag at 0xD). If you want to, you can set the depth level to auto. This will usually result in your collision quadtree's depth level being from 8 to 10. This means the game will take less CPU to check for collisions and will run better (at a higher resolution, no framerate drops) on lower-end computers, which is your goal (you want people to play your level even if they have bad PCs) (if you set your depth level to 1 or 2, even if you have a nice PC your game will lag terribly). But custom collision files with high depth levels are known to make the game crash at random spots while running (we have no idea why) and that's why we can just leave it at 5 for now, as it won't crash and won't make your game lag unless you have a computer with terrible specs. If it works, why bother? As for the power flag, it defines a few numbers that are added to the quadtree's settings, we don't know much about what it does. Most of the original files leave it at 0xD so that's what we do.

Once your model is imported and saved, you can check Show Collision or use the X shortcut to display it. The file's quadtree can be displayed as well if Show QuadTree is checked, although there's not too much need for this except maybe for debugging purposes. If you test your model and notice collision is buggy in some parts (such as floor clipping), it's probably because some of your meshes have too many triangles. Try simplifying the mesh, and if you absolutely can't, split it into 2 or more.

Collision Flags

When creating your collision model, you must name your meshes so they represent different parts of the level. In HPP's readme, you can find a full list of flags which can be appended to the mesh name with an underscore _ to set the collision type for that mesh.

Note that the bingo and pinball types will only work in levels which originally had them. The difference between them is that you accelerate much faster and have more control on slides than tables.

If you want to experiment a bit, you can also set the flags manually. Export the collision from one of the original CL files to OBJ, import it in 3ds Max and take a look at how meshes are named. You can append the same type of formatting (_WWXXYYZZ, 4 bytes) and the flags will be that. You can play with flags that have not been documented yet with this.

sewer56lol's Collision Library

sewer56lol has worked on a tool and library for handling CL files. Its collision generator can be considered superior to HPP's for a few technical reasons. You can get the source here.

The project README contains instructions on how to operate the tool and use the library in your own programs if desired.

Death Zones and Water

CL files that have _xx or _wt appended to their names contain collision for death and water boundaries, respectively. You can import them with HPP, make sure all models have _a or _x to their names as specified above. When importing, make sure Flip Normals is checked as these files use reversed normals; they'll show up upside down and you'll have to disable culling to see them right side up. Also, make sure to set the quadtree depth level to 1 (or 2, maximum).

Objects

HPP's Layout Editor window can open and edit layout data; HPP's SET ID Table Editor can be used to change object availability for use on certain stages. Object layouts are contained in s(tg)**_p**.bin for each level and team; save them to your Files folder. Once you open a layout file in the editor, it should be pretty straightforward; just place objects wherever you want. You can click to select them, move them, rotate, set misc. settings, see a preview of them. Please read the Object Editing and Object Porting pages for all the info on this.

Start Positions and Splines

For more information, see EXE Editing.

You can set start, ending (victory animation) and bragging (for the start of multiplayer levels) positions in HPP's Mod Loader Config Editor. These will be saved to the Config.cc file. For starting and ending positions, the only thing that shouldn't be self-explanatory is the hold time; it's the time you spend running before you gain control of the characters. It only applies to a Running start mode. Get the coordinates from the object layout editor for convenience.

As for splines, you can import those in the Spline Editor window. It is reliant on the Config Editor to display and import splines (that's why it will only show up if you have a config file open).

When importing a new OBJ file, make sure the only thing in the file is the spline; all the program will do is read all the vertices in order and create the new spline with them. There are 3 types of splines: autoloops, rails and ball paths. Ball paths are those tubes used in Casino Park and BINGO Highway (it's them in those Power Plant (level, not program) green spheres as well). You can pick one for each spline (setting it to null will make the spline do nothing, this is useful if you want to disable it without deleting it). The splines can be seen in the view if the option is checked; remember to save.

Note that not all levels have spline loaders, meaning you can't add splines for them. These are the levels which did not contain splines originally (such as Sea Gate and Egg Hawk).

If you wish to extract and take a look at the original game's splines and start positions, Heroes Tweaker lets you open Tsonic_win.exe and do that. It can also export the splines as OBJ.

Cameras

See Camera Editing.

Particles (PTCL)

See Particle Editing.

Texture Patterns (TXC)

See Texture Animation Editing.

Indirect Info

See Indirect Editing.

Custom Mod DLL

The Reloaded Generic Stage Injection Mod, although it has the useful features of replacing start positions and splines for any number of levels at once from your Stage.json and Splines folder (and mid-game file swapping), can't do much more than that. If you want to edit stuff such as bobsleds, Team Chaotix's mission goals, the amount of items you must collect in their missions, the amount of minutes you have for Team Sonic's Extra mission, the ranking requirements (A, B, C, D ranks) for each team, you must create your own mod DLL, and for that you must know at least the basics of programming in C# with Microsoft Visual Studio. Not only that, you can also add your own code to the game, such as the custom coded mid-level music change implemented in the Emerald Coast stage mod. More details on this will be added later, for know if you want to know more about this, you can ask on our Heroes Hacking Central server on Discord.

Other Stuff

Lighting data in s**_light.bin files. We don't know their format yet, but we do know they contain multiple light data entries. They are applied to characters and objects only (it's not environmental lighting). The main entry is applied all the time, and each of the other entries is applied by trigger objects.

Music is located in looping ADX files in the bgm folder. If the music's not looped, it won't start again after ending.

You can add all of those files to your stage mod's Files folder (or subfolders) and they will be redirected by the Mod Loader.

Sonic Community Hacking Guide
General
SonED2 Manual | Subroutine Equivalency List
Game-Specific
Sonic the Hedgehog (16-bit) | Sonic the Hedgehog (8-bit) | Sonic CD (prototype 510) | Sonic CD | Sonic CD (PC) | Sonic CD (2011) | Sonic 2 (Simon Wai prototype) | Sonic 2 (16-bit) | Sonic 2 (Master System) | Sonic 3 | Sonic 3 & Knuckles | Chaotix | Sonic Jam | Sonic Jam 6 | Sonic Adventure | Sonic Adventure DX: Director's Cut | Sonic Adventure DX: PC | Sonic Adventure (2010) | Sonic Adventure 2 | Sonic Adventure 2: Battle | Sonic Adventure 2 (PC) | Sonic Heroes | Sonic Riders | Sonic the Hedgehog (2006) | Sonic & Sega All-Stars Racing | Sonic Unleashed (Xbox 360/PS3) | Sonic Colours | Sonic Generations | Sonic Forces
Technical information
Sonic Eraser | Sonic 2 (Nick Arcade prototype) | Sonic CD (prototype; 1992-12-04) | Dr. Robotnik's Mean Bean Machine | Sonic Triple Trouble | Tails Adventures | Sonic Crackers | Sonic 3D: Flickies' Island | Sonic & Knuckles Collection | Sonic R | Sonic Shuffle | Sonic Advance | Sonic Advance 3 | Sonic Battle | Shadow the Hedgehog | Sonic Rush | Sonic Classic Collection | Sonic Free Riders | Sonic Lost World
Legacy Guides
The Nemesis Hacking Guides The Esrael Hacking Guides
ROM: Sonic 1 | Sonic 2 | Sonic 2 Beta | Sonic 3

Savestate: Sonic 1 | Sonic 2 Beta/Final | Sonic 3

Sonic 1 (English / Portuguese) | Sonic 2 Beta (English / Portuguese) | Sonic 2 and Knuckles (English / Portuguese)
Move to Sega Retro
Number Systems (or scrap) | Assembly Hacking Guide | 68000 Instruction Set | 68000 ASM-to-Hex Code Reference | SMPS Music Hacking Guide | Mega Drive technical information