Difference between revisions of "User:Iamyoyoman/Sandbox"

From Stoneshard wiki
Jump to navigation Jump to search
(→‎Creation of the sprites: Some colors to one of the images)
 
(15 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=Modding=
=Modding=
Even though Stoneshard does not have integrated modding support it is still possible to mod the game via external tools, such as UndertaleModTool[https://github.com/krzys-h/UndertaleModTool], that allows one to dig into GameMaker Studio game files.
Even though Stoneshard does not have integrated modding support it is still possible to mod the game via external tools, such as UndertaleModTool[https://github.com/krzys-h/UndertaleModTool], which allows one to dig into GameMaker Studio game files.
<br>
<br>
It is also possible to share modded games by sharing the difference of the modded game files compared to the vanilla ones, this is usually done with Delta Patcher[https://www.romhacking.net/utilities/704/] software to avoid piracy.
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[https://www.romhacking.net/utilities/704/] software to avoid piracy.


==What is required?==
==What is required?==
Other than a working PC. It is advised to:
Other than a working PC. It is advised to:
*Download and use the Bleeding Edge[https://github.com/krzys-h/UndertaleModTool/releases|bleeding edge] of UndertaleModTool.
*Download and use the Bleeding Edge[https://github.com/krzys-h/UndertaleModTool/releases] of UndertaleModTool.
*Have basic knowledge of coding.
*Have basic knowledge of coding.
*Have an understanding of how GameMaker Studio works
*Have an understanding of how GameMaker Studio works
Line 12: Line 12:
==OK but how do I actually mod the game?==
==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.
Once you have downloaded UndertaleModTool, create a copy of your game files from "SteamLibrary\steamapps\common\Stoneshard" to keep the original's integrity.
<br>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.
<br>
<br>Of course not everything can be edited that way. for example, as GameMaker Studio saves audio files outside it's data.win file, to edit those you will need to add extra files to the game folder.
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.
<br>
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==
==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?===
===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 to a possible one.
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?===
===Is there a way to debug?===
As the debugger in UndertaleModTool does not work with stoneshard. using the "scr_actionsLogUpdate()" script is a very good 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.
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?===
===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.
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 regular apple from the second floor of the Black Boar Inn with a modded golden apple.
==Creation of the sprites==
[[File:Modding-addsprite.png|thumb|250px|exporting sprites]]
[[File:Modding-appledesign.png|thumb|250px|editing sprites to match the art style]]
<br>
We are going to need to create two sprites.
<br>
One for when the new golden apple is on the ground and one for when it is in the player's inventory.
<br>
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.
<br>
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.
<br>
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.
<br>
Knowing all that, we need to create a new image that will include both our sprites. It is better to make the image's size a number which is a power of two, in this example 32 by 32 pixels.
<br>
[[File:Modding-spritetable.png|thumb|250px|making a map of both sprites]]
<br>
Now, add 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".
<br>
[[File:Modding-addobject.png|thumb|250px|adding a new texture page item]]
<br>
[[File:Modding-textureexplained.png|thumb|400px|{{C|Energy|Blue areas}}: where in the embedded texture to take the sprite <br> {{C|Unholy|Red areas}}: size of the sprite.<br> For now, fill the red all the same.]]
<br>
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.
<br>
The sprite files also need to be set up as seen in the picture.
[[File:Modding-spriteexplained.png|700px]]
<br>
1) the name of the sprite.
<br>
2) the size of the sprite.
<br>
3) the borders of the sprite. useful if you have empty space to the left and to the right of the sprite.
<br>
4) the image of the sprite, where you need to put the texture page item.
<br>
5) the mask of the sprite, you can just take the ones from the normal apple sprites.
<br>
6) for now just set it up as in the image, almost all of the sprites are set up this way.
<br clear=all>
==Creation of the object==
Now that we can safely add the sprites to the new object it is about time we make them.
<br>
First, we need to add two new object pages, just like we added the new pages for the sprites, and set them up.
<br>
[[File:Modding-objectexplained.png|thumb|250px|the red areas represent where changes are needed.]]
<br>
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!
<br>
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.
<br>
[[File:Modding-addingscript.png|thumb|250px|how to add a new script to a gameobject]]
<br>
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 once again only going to copy from the existing apple objects.
<br>
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.
<br>
[[File:Modding-script.png|thumb|250px]]
<br>
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.
<br>
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.
<br>
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.
<br>
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.
<br>
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.
<br>
'''It is recommended to save at this point because opening those tables can be very long and may even freeze UndertaleModTool if handled incorrectly.'''
<br>
Those tables are located at "gml_GlobalScript_table_Consumable_Parameters" and "gml_GlobalScript_table_consumables"
<br>
To make more sense of what you are seeing you can convert them into sheets via external tools, as seen in the images below.
<br>
<li style="display: inline-block;"> [[File:Modding-tablenames.png|thumb|Sheet made from gml_GlobalScript_table_consumables]] </li>
<li style="display: inline-block;"> [[File:Modding-tablestats.png|thumb|sheet made from gml_GlobalScript_table_Consumable_Parameters]] </li>
<br>
Note that WHERE you put your new entry 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 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.
<br>
The reason why we changed the number to text is that we do 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.
<br>
Of course, you can edit the text and the stats of the new golden apple as you see fit with those entries.
<li style="display: inline-block;"> [[File:Modding-edittable.png|thumb|an image of where to put the new text in gml_GlobalScript_table_Consumable_Parameters]] </li>
<li style="display: inline-block;"> [[File:Modding-editsecondtable.png|thumb|an image of where to put the new text in gml_GlobalScript_table_consumables]] </li>
<br clear=all>
==Adding the golden apple instead of the regular one==
To replace the regular apple we must first find what spawns it.
<br>
For that we need to open the "room" for the second floor of the Black Boar Inn, its name is "r_taverninside2floor"
<li style="display: inline-block;"> [[File:Modding-rooms.png|thumb|500px|The room of the second floor of the Black Boar Inn]] </li>
Under layers > foregroundInstances we can find an instance of "o_loot_marker", an object that spawns items.
<li style="display: inline-block;"> [[File:Modding-spawnitem.png|thumb|500px]] </li>
<br>
But if you look inside that object it seems like there is nothing in there that helps us! It is full of generic stuff. But we do see what creates the loot, it is "gml_RoomCC_r_taverninside2floor_22_Create". So we should double-click and open that. In the object you will see two lines.The first line in this script represents what is the chance of the item of spawning, this time 100%. But the second line is more interesting "loot = choose(2025)", What do you think "2025" represent?
<li style="display: inline-block;"> [[File:Modding-changeid.png|thumb|730px|the script of gml_RoomCC_r_taverninside2floor_22_Create]] </li>
<br>
Each object in GameMaker studio has an id, it can be seen in the downright corner of the objects' page with UndertaleModTool.
<li style="display: inline-block;"> [[File:Modding-findID.png|thumb|780px]] </li>
<br>
And it seems like 2025 is the ID of the regular o_loot_apple. So all we need to do is open our new o_loot_golden_apple, see what is its ID, and replace "2025" with the number we have found.
<br>
That is it! if you have done everything correctly you should have a golden apple instead of a regular one. If not, feel free to ask for help.
<br>
<li style="display: inline-block;"> [[File:Modding-goldenappleinv.png|thumb|700px|the script of gml_RoomCC_r_taverninside2floor_22_Create]] </li>
<li style="display: inline-block;"> [[File:Modding-goldenapplespawn.png|thumb|500px|the script of gml_RoomCC_r_taverninside2floor_22_Create]] </li>

Latest revision as of 00:08, 24 March 2023

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 regular apple from the second floor of the Black Boar Inn with a modded golden apple.

Creation of the sprites

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 to make the image's size a number which is a power of two, in this example 32 by 32 pixels.

making a map of both sprites


Now, add 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


Blue areas: where in the embedded texture to take the sprite
Red areas: 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 once 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.
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 images below.

  • Sheet made from gml_GlobalScript_table_consumables
  • sheet made from gml_GlobalScript_table_Consumable_Parameters

  • Note that WHERE you put your new entry 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 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 that we do 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.
    Of course, you can edit the text and the stats of the new golden apple as you see fit with those entries.

  • 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

  • Adding the golden apple instead of the regular one

    To replace the regular apple we must first find what spawns it.
    For that we need to open the "room" for the second floor of the Black Boar Inn, its name is "r_taverninside2floor"

  • The room of the second floor of the Black Boar Inn
  • Under layers > foregroundInstances we can find an instance of "o_loot_marker", an object that spawns items.

  • Modding-spawnitem.png

  • But if you look inside that object it seems like there is nothing in there that helps us! It is full of generic stuff. But we do see what creates the loot, it is "gml_RoomCC_r_taverninside2floor_22_Create". So we should double-click and open that. In the object you will see two lines.The first line in this script represents what is the chance of the item of spawning, this time 100%. But the second line is more interesting "loot = choose(2025)", What do you think "2025" represent?

  • the script of gml_RoomCC_r_taverninside2floor_22_Create

  • Each object in GameMaker studio has an id, it can be seen in the downright corner of the objects' page with UndertaleModTool.

  • Modding-findID.png

  • And it seems like 2025 is the ID of the regular o_loot_apple. So all we need to do is open our new o_loot_golden_apple, see what is its ID, and replace "2025" with the number we have found.
    That is it! if you have done everything correctly you should have a golden apple instead of a regular one. If not, feel free to ask for help.

  • the script of gml_RoomCC_r_taverninside2floor_22_Create
  • the script of gml_RoomCC_r_taverninside2floor_22_Create