User:Iamyoyoman/Sandbox

From Stoneshard wiki
Jump to navigation Jump to search

Modding

Even though Stoneshard does not have integrated modding support it is still possible to mod the game via external tools, such as UndertaleModTool[1], which allows one to dig into GameMaker Studio game files.
It is also possible to share modded games by sharing the difference between the modded game files compared to the vanilla ones, this is usually done with Delta Patcher[2] software to avoid piracy.

What is required?

Other than a working PC. It is advised to:

  • Download and use the Bleeding Edge[3] of UndertaleModTool.
  • Have basic knowledge of coding.
  • Have an understanding of how GameMaker Studio works

OK but how do I actually mod the game?

Once you have downloaded UndertaleModTool, create a copy of your game files from "SteamLibrary\steamapps\common\Stoneshard" to keep the original's integrity.
Open the "data.win" with the tool. There you can find all the game's objects, be it Scripts, Sprites, GameObjects, or else, create new or edit existing ones. Note that UndertaleModTool is very limited, and you might encounter some files that it can't decompile.
Of course, not everything can be edited that way. for example, as GameMaker Studio saves audio files outside its data.win file, to edit those you will need to add extra files to the game folder.

Tips and tricks

How do I find a specific thing?

In the top left of the window, under "Scripts" and "Builtin Scripts", "Search.csx" can be found. It is a very helpful script that allows you to search any text in all of the scripts.

What if I can't decompile a script?

Always remember that you can still see and edit the assembly code of the script. it might be harder to understand and edit but it could also make an impossible task into a possible one.

Is there a way to debug?

As the debugger in UndertaleModTool does not work with Stoneshard. using the "scr_actionsLogUpdate()" script is an excellent way to achieve a similar result. but that won't work for edits to stuff as the main menu does not include the game's actions log.

I am stuck, Where can i get help?

It depends on what problem you are facing. but both the UndertaleModTool community and Stoneshard modding community are very welcoming and you are advised to visit both at their Discord servers.

Step By Step Example Mod

For this example, we will create a mod that will replace the golden apple from the second floor of the The Black Boar Inn with a modded golden apple.

Creation of the sprite

exporting sprites
editing sprites to match the art style


We are going to need to create two sprites.
One for when the new golden apple is on the ground and one for when it is in the player's inventory.
To make the sprites look fitting for the game's art style, in this example, we take the sprites of the apples and recolour them with colours from the sprite of the golden nugget.
To export the images we can go into the sprite pages, by searching their name on the left panel and exporting with the "export all frames" button.
Before we add the new sprites into the game we must first understand the hierarchy and structure of sprites in GameMaker Studio. In GameMaker Studio each gameobject takes its sprite from a sprite file that, takes its sprite from a "texture page item" file that, takes its sprite from an "embedded textures" file, a file that includes a map of multiple sprites. gameobject > sprite > texture page item > embedded textures.
Knowing all that, we need to create a new image that will include both our sprites. It is better

making a map of both sprites


Now, one new embedded texture, two new texture page items and, two new sprites. To do that we need to right-click each category from the left panel and click "add".

adding a new texture page item


the blue areas represent from where in the embedded texture to take the sprite and the red the size of the sprite. for now, fill the red all the same.


Once you have added the new pages, you must first import the new map to the embedded texture. then add the embedded texture to both texture page items and set their borders as in the picture. only once you have done all that you can add the new texture page items to the sprite files.
The sprite files also need to be set up as seen in the picture. Modding-spriteexplained.png
1) the name of the sprite.
2) the size of the sprite.
3) the borders of the sprite. useful if you have empty space to the left and to the right of the sprite.
4) the image of the sprite, where you need to put the texture page item.
5) the mask of the sprite, you can just take the ones from the normal apple sprites.
6) for now just set it up as in the image, almost all of the sprites are set up this way.

Creation of the object

Now that we can safely add the sprites to the new object it is about time we make them.
First, we need to add two new object pages, just like we added the new pages for the sprites, and set them up.

the red areas represent where changes are needed.


It is useful to look at another existing object and to copy how it is set from. So just copy from the corresponding object, the one that will fit the o_inv_apple to o_inv_golden_apple and o_loot_apple to o_loot_golden_apple. Remember to drag and drop the new sprites and not the old ones!
Once we have set up the gameobjects it is time we add scripts to them. In this example, we won't really need to write anything new, but we will need to change a few things.

how to add a new script to a gameobject


As you can see there are many places to add scripts to for each gameobject, each of them trigger at another point, but for now, we are, again, only going to copy from the existing apple objects.
To add a new script you need to double-click where you want to add it, and then click on the + sign to the right then double-click to edit.

Modding-script.png


For o_loot_goloden_apple you just need to copy the scripts from the "create" and "preCreate" types of scripts, but for o_inv_goloden_apple it is a bit more complicated.
For the inventory version, other than the "create" and "preCreate" scripts, you also need to add three different scripts under "other", note that before you click the little + you are going to want to change their subtypes to "User3", "User0" and, "user14". This is because what the code you have just copied, "event_inherited()", does is essentially inheriting the code from their parent object, in this case from o_inv_food, and if the subtypes would have been different the game wouldn't know what script it is supposed to inherit.
In addition to that, we also need to change the "create" script. The last line should be changed to "scr_consum_atr("golden_apple")". The explanation will come up soon.
Well, now, even thought the gameobjects are complete, you might have noted that nowhere we saw anything about what an apple actually does, not the effects of being eaten nor how much it is worth.
This is because Stoneshard likes to store stats like those in "tables". so we need to find two tables, one that store the text (in many languages) for the name of the apple, and one that stores more important stuff, like the effect of eating the apple or how much times it takes to rot.
It is recommended to save at this point because opening those tables can be very long and may even freeze UndertaleModTool if handled incorrectly.
Those tables are located at "gml_GlobalScript_table_Consumable_Parameters" and "gml_GlobalScript_table_consumables"
To make more sense of what you are seeing you can convert them into sheets via external tools, as seen in the image to the right.

sheet made from gml_GlobalScript_table_consumables


sheet made from gml_GlobalScript_table_Consumable_Parameters


an image of where to put the new text in gml_GlobalScript_table_Consumable_Parameters


an image of where to put the new text in gml_GlobalScript_table_consumables


Note that WHERE you put your new text inside the tables is VERY important, going back to the edit we made to the "create" script of o_inv_goloden_apple, the number that was before we changed it to text, what slot from the table the the script takes its data from, this is why if you are going to add something in the middle of the table without knowing how it works can cause in all of the other items in the game to read from the wrong place, or to just crash the game.
The reason why we changed the number to text is because we do know know what number inside the table our new entry represents. luckily the devs added a way for the script to handle strings as well, as long as it fits the name that we put as our first string in the text we added to the tables.