Chao Garden Replacement - X-Hax/SADXModdingGuide GitHub Wiki
Custom Chao Garden
Introduction
Custom Chao Garden is similar to regular level replacement, but it will require extra work in order to make your Chao able to use their (new) favorite playground. The whole process is a long and difficult task, it will need efforts, but the final result is worth.
In this tutorial, we will learn how to port a new map to replace a Chao Garden from scratch. Note that the process to replace a Chao Garden is similar in SA2, despite few small differences.
Note: At the time I’m writing those lines; the following features are only possible to be edited with a DLL Mod because they are directly hardcoded:
- Trees position
- Chao Spawn Position (16 per garden, all of them are hardcoded).
- Chao Transporter position
- Chao Warp position
- Chao Waypoints (Determine where a Chao should move in a garden.)
- Water
I highly recommend that you use a DLL Mod for this, it may sound incredibly hard, but with some practice you will see that it’s much more convenient. It will allow you to have the full control of what you want to edit and increase a lot the possibilities in general with your custom Chao Garden. Don’t worry, you don’t need to be a programmer, though having some C experience would be a good plus, more specifically knowing variables, arrays and functions. That being said, we will see in this tutorial the basics on how to edit all of that, trust me, if I can do it, you can do it!
If you really don’t want to involve coding at any point, you can technically make a Chao Garden without a DLL mod, but you will be incredibly limited. You will have to make sure that your new map matches the position of all the features listed above, mostly because you don’t want to have your Chao spawn in the void or have unreachable objects.
Requirement:
• SA Tools (download)
• Blender (download)
• Justin’s SA addon (download, guide)
• A DLL Mod (highly recommended)
• Patience and perseverance
For convenience, this tutorial will be split into two different parts: Making/Porting your map, building your mod. As for the coding part, it will be on a different tutorial.
Part 1 Making your new Map
Go to the SA Tools folder then Run SAToolsHub, create a new project, then follow the guide to set up a SADX project, once it’s done, we can actually start.
Getting the map
Obviously your first step is to get the map that you want to port in the game. Most people will get it on Model Resource or any other link found on Google. Sometimes you may have to directly extract the map from the game that you want if you can’t find it on the internet.
- I recommend using a map not too big, preferably from a game that came from the same era as PS2/ GameCube/Xbox or before. Mostly because using a modern map might be too greedy and could result to the game (or even the addon) not being able to handle it.
- Another reason is, on a rare occasion, you can have the addon not able to handle auto textures for your stage and you will have to manually assign each textures and trust me you don't want to do that.
- Finally, you need to know that if the player is too far from a Chao, it will have its collision unloaded and will clip the floor. This is due to how limited the game is when it comes to collision and distance. You can use some tweaks to avoid that, but it will require coding, I had to do that in SA2 Past Garden. It’s not really hard or long, but just so you know.
Besides the criteria above, you should be able to use any map you want, as long as you are able to import it in Blender.
So, you have your map, you can now import it in Blender and… let the fun start. If you never used Blender before, I can tell you this won’t be a fun task.
Importing a map to Blender
Start by removing the cube light and camera. Right click on “Collection” -> Delete Hierarchy.
Now go to File -> Import then select whatever format your map is and import it.
If your map comes with an armature (sometimes they do for some reason.), you can delete it, you only need the meshes.
Small tip, press N to open Blender's toolbox then go to “View” and increase the number on the “End” field. (Something like 100 000 is good.) You can thank me later.
Since we have the Blender toolbox open, let's use this opportunity to talk quickly about how to use the addon. In the toolbox, you should see a tab called "SA Tools", that's where most of the features of the addon are available so please remember that for the future. Every time you want to do something with the addon such as collision or textures, press N and go to the SA Tools tab.
Once you are on the SA Tools tab, click on "Scene Information" and check "Enable level Tools". We will need that later.
Also, if you want to see the textures of your map, you need to click on the arrow on top and select “texture”
Alternately you can click directly on “Viewport Shading” at the top right of Blender but this will cost extra performance.
If the map is still blank after that, then your textures aren’t loaded properly. Please note that the way the map looks in Blender will be different in-game, this includes transparency and other extra stuff.
Scaling the map:
Each game has different size, difference perspective or whatever you want to call that. There is 99.9% of chance that the map you downloaded is either; too big or too small for SADX and so it won’t render properly in-game. Thankfully, we can fix that by manually scaling it.
Each modder has their own preference to do that, personally, I like to import Sonic Model to have a visual cue on how I should adjust the size of the map. If you have the game files extracted (you do if you did a new project with Tool Hub). You can do File -> Import -> Sonic Adv Mdl. Then import Sonic character from your Project folder. (It should be located at “figure/sonic/models”). Once it’s done, you will be able to see what adjustments your map need. Select all the meshes from your map (make sure to not select Sonic if you imported him) then press S, this will enable the scale feature from Blender. You can now adjust the size of the map with your mouse.
Example of a map being scaled with Sonic model
(Note: you can hold CTRL during the process to get a more precise size.)
Once you reach an acceptable size, you can stop. Delete the Sonic model, then press Ctrl + A and select “All transforms”. This will make Blender applies all the change that you just did. Please remember this manip, we will do it a lot in this tutorial.
Setting Collisions:
Now let's talk about collisions. This is the most important step followed by textures so please read that multiple times if you have to. You don’t want Sonic to not be able to stand on the map, so you will need to add collisions, but how do you do that? It’s not really hard, but this task can become incredibly annoying and long depending on the map form. Anyway, first you have to make sure that your map is split into different meshes, if the whole map is only one giant mesh, this won’t work. So first of all, select that one mesh, then press tab to swap to “Edit Mode”. Next, press A to select the whole mesh then press P -> By material. This will split the whole map into different meshes. Re press tab to go back to Object Mode. You can now apply all transform again.
Now to actually set up collision, select a mesh that need a collision (the ground for example) then press N -> "SA Tools" -> "Surface Flags" then check “Solid” and “Visible”.
ALL YOUR MESHES SHOULD HAVE THE FLAG "VISIBLE" EVEN IF THEY AREN'T COLLISION, OTHERWISE THEY WON'T SHOW UP IN-GAME!!!
Congrats, you made a collision. Now you can repeat that for every mesh that will need it, this is why this step can take forever.
One thing you can do to make this process a bit quicker is using the "Quick Edit menu". From the "SA Tools" tab, look for "Quick Edit Menu" then check "LandEntry Quick Edit". Next, click on the arrow to show the whole thing and again, check "Visible" and "Solid". Finally, press the big button "SET" to apply everything.
Some tips and info about Collisions in general:
- SADX uses the visual geometry as collision most of the time (which means the collision aren't a separate model unlike SA2).
- Small collisions tend to not work, it's best to have a model big enough but not too big either. You can join meshes if needed (select meshes and press ctrl + J).
- Ideally, each model that will be a collision should have a dimension inferior to 1000. (You can check that in the Item tab when you press N).
- If the model is too big, you can manually make it smaller in Edit Mode. (Select a part of the model, press P then "By selection".)
- You shouldn't have collisions bigger than that.
- You can import original level from the game to see how they did it, that can sometimes help. (They can be found in your project files.)
- Complex collisions models like stairs/buildings/towers tend to not work properly. It's best to make a simpler model yourself for them. (For example, SADX tends to use a simple plane/slope for stairs. You can easily add simple model form with the top bar menu "Add -> Mesh".)
- If one of your model is too spaced like this, select it in Edit Mode, then press P -> "By Loose part".
- The game has just a terrible collision system in general, so this will be trial and error most likely.
Setting Textures
Great we have our collisions, now the next step is to make the textures of our map working for both: the game, and Blender. This part is really important if you want to make your map working in-game so please read carefully. Let’s start.
We need to assign the textlist pointer of the Chao Garden you are replacing. If you don't know, a Textlist is what the game uses to determine which textures are loaded. Most of the time, the geometry file of a level store data (such as textlist) so the game can read (and take) information from them directly. In that case, you will need to add the Texlist pointer from the Chao Garden you are replacing so the game will be able to apply the textures to your stage properly. Each garden has an unique textlist pointer that you can get by opening the stage you want to replace in SALVL.
Here are the textlist pointer for all the gardens.
Station Square: 363687C
Mystics Ruin Day and Evening: 100073FC
Mystic Ruins Night: 1000724C
Egg Carrier: 33D0F5C
Now, click on "SA Tools" tab again then: "Level Info" -> "Textlist Pointer". From that field, paste the Texlist pointer of the garden.
Example if you replace the Egg Carrier Garden
Adding the textlist pointer is important because otherwise the geometry won’t show up in-game.
You may have noticed that there is a empty field "Texture Filename", don't worry, we will fill that later.
Making a Texture Pack:
Now that your geometry has the textlist pointer, you need to make a new Texture Pack. Leave Blender for now and go back to your SA Tools folder. Open Texture Editor and select "File" -> "New" -> "PVMX".
Now, click on “Add...” and, as you guessed, you can now import all your textures. Great, your texture pack is ready. Go to “File” -> “Export Texture Packs” and give it a name. This will create a folder with all the textures inside. Now you can also save your textures as a PVMX, this file will be used by the game to load the textures, so don’t lose it.
Setting Textures to your map:
We will now make Blender loads the textures that you just exported. Click on "SA Tools" tab again, then click on "Scene Information" -> “Texture List Info”.
You should see a small arrow on the right side: click on it -> “Import SA TexFile”.
Browse your files and go to the folder that you exported earlier with Texture Editor (the one that has all the textures) select the txt file and here we go, you should see something like this:
Look for the “Tex-file name” field, you need to put the name of your textures pack that you created with Texture Editor earlier. The name MUST match your textures pack, this is really important since this is where the game will take the information to know which PVM it needs to load. Otherwise the textures won’t be loaded and the game will crash. Note that both actions that we just did can be done from SALVL too.
Assigning new texture ID
Luckily this process is now a lot faster than what it used to be (most of the time at least).
- Make sure your textures pack is loaded.
- Click on "Auto Assign Textures" from "Scene Information" (SA Tools Tab).
- Click on "Update Materials"
If everything has been done correctly, the textures of your map should now have their tex ID assigned properly. If all the textures look very wrong, then it failed. In that case, you will have to manually assign all the tex IDs. If it worked you can skip the next section of this guide.
Fixing Tex ID Manually (skip if it worked for you)
This is where the fun start, and by fun, I mean that you will most likely understand what the word “pain” means. You need to manually assign the correct texture ID to each mesh.
Let’s do it. Select the first mesh of your map, then go to “Material Properties” from the SA Tools tab. Now Look for “SA Material Properties”, notice the “Texture ID”, that’s the part that we are interested for. You will now need to assign the correct ID. Blender should show you the name of the texture that it needs. For example, let’s say the name of the texture is “material0137”, then you can check in Texture Editor to see which ID matches this name.
If the mesh has multiple materials, you will have to set the id for all of them. Repeat the whole process for every mesh. During this task, you can check if your textures are assigned properly by simply clicking on “Update Materials”.
Exporting your Map:
Congratulation you made it really far, this is the final step for the Blender part. Make sure you are in object Mode, then press A to select everything, Ctrl + A -> Apply all Transform. Then right click -> “Set Origin” -> “Origin to Geometry”. Before we export, I recommend that you turn on the console to have the log in real time in case the export fail. To do that go to the Window menu and select “Toggle system Console”. Now you are ready to export: File -> Export -> SA Formats -> SA1 Level. Check the case “Console Output” so you can see the log in real time, then click on “SA1 level”.
Patience, the process can take between 5 seconds and 10 minutes depending on the size of the map and other factors. Note that if it takes more, you most likely did something wrong somewhere. If it freezes on a specific mesh and never unlock itself, then something is wrong with it, it could be the collision that you set. With that said, the Blender part is done.
Part 2 Building your Mod
Congratulation you have a map ready (also called LandTable by the game which is the geometry), but we aren’t done yet. At this point, I bet you would like to see your level in-game (well if you haven’t tried already). Let’s just do that.
Open your project folder (the one you created with Tool hub at the beginning of this tutorial), look for the “chao” folder. From here, check for the garden you want to replace (ie: stg_garden0X_XX). In this tutorial, I’m replacing the Egg Carrier one, so I will go in “stg_garden01_ec”. Once you are in the garden folder that you want to replace, you should see a file named “landtablegarden0X.c.sa1lvl”. (If you picked the Mystic Ruins version there is an extra folder for all the time of the day variation.)
The main idea is to rename your LandTable by the same name of the garden you are replacing, then replace the file in your project folder.
Now you can open SA Tools Hub, then click on “Build Option” (the icon with a hammer.)
A new window will open, this one allows you to select the data from your project that you want to build with your mod. If you are replacing Station Square or the Egg Carrier Garden; you can check “Chao, Chao Race, SS Garden, EC Garden” from the “EXE Data” tab, otherwise the Mystics Ruins one is in DLL Data.
Once you checked what you need, click on “Automatic” this will make SA Tools Hub automatically detect what files got edited and build them to make your mod. You’re almost done, now you can go to your SADX mods folder (where the game is installed) then look for your mod. (It should have your project name). If you open it, it should look like this:
Finally, you need to add your texture pack that you created earlier, from your mod folder, create a folder and name it "textures" then put your PVMX in it.
You can now start the Mod Manager, check your mod and test it. If you want to save time with your tests, go to the Debug tab of the Mod Manager, check “Level:” select the level you replaced, then click on “Play” this will boot the game directly on the stage, if you crash instantly, then you know you did something wrong.
Don’t forget that pretty much any other mod that edits the same level than you will overwrite your changes such as DC Conversion, so make sure to disable the level you are replacing in the mod settings.
If you don’t want to code like I said earlier, you can stop here. However, if you plan to improve your mod (and you should) see you in in the next tutorial.