Cpimhoff.Sts2.ModSmith
0.0.1
dotnet add package Cpimhoff.Sts2.ModSmith --version 0.0.1
NuGet\Install-Package Cpimhoff.Sts2.ModSmith -Version 0.0.1
<PackageReference Include="Cpimhoff.Sts2.ModSmith" Version="0.0.1" />
<PackageVersion Include="Cpimhoff.Sts2.ModSmith" Version="0.0.1" />
<PackageReference Include="Cpimhoff.Sts2.ModSmith" />
paket add Cpimhoff.Sts2.ModSmith --version 0.0.1
#r "nuget: Cpimhoff.Sts2.ModSmith, 0.0.1"
#:package Cpimhoff.Sts2.ModSmith@0.0.1
#addin nuget:?package=Cpimhoff.Sts2.ModSmith&version=0.0.1
#tool nuget:?package=Cpimhoff.Sts2.ModSmith&version=0.0.1
Slay the Spire II ~ ModSmith
Base mod for adding content to Slay The Spire II
For Mod Users
This mod provides shared logic which other mods may build off of, in a way that allows for multiple mods to contribute logic without conflicting with one another. You may see this mod in the "dependencies" or "required" section of other mods.
If you are installing mods by hand, you may need to install this mod. Otherwise, the installation of this mod is generally done automatically, and this can be ignored.
Introduction to Modding
Slay the Spire II is built using a fork of Godot called MegaDot. Patches (modifications to game code) are handled using Harmony.
Patching is the main source of why mods break when the game updates, and why mods may conflict. Patches are naturally fickle things -- they instruct the game to run different than the developers intended for a given function. When that code changes, or multiple mods attempt to patch the same function, problems can arise. ModSmith is designed specifically to patch common sections of the game code so multiple mods can all contribute content without conflicting (and making contributing content easier). In addition, ModSmith can handle if those common injection sites change between game versions, making mods built with ModSmith more robust to game updates.
A packaged mod for Slay the Spire II is comprised of 3 major components:
- A
.dllfile, which contains all code for the mod. - A
.pck(Godot resource pack) file, which contains asset files (art, Godot scenes, etc) for use by the Godot game engine. - A
.jsonmetadata file, which describes the mod.
The .dll file will be generated by the dotnet build system. You will need to install dotnet tools on your system to build C# code.
The .pck file will be generated by using MegaDot, which must be installed on your computer using the instructions at the link.
The .json file is a simple text file you can author by hand.
Prerequisites
- Install Slay the Spire II from Steam: https://store.steampowered.com/app/2868840/Slay_the_Spire_2/
- Install the
dotnet9.0 SDK: https://dotnet.microsoft.com/en-us/download/dotnet/9.0/ - Install MegaDot: https://megadot.megacrit.com/
(Optional) Decompile Slay the Spire II
Slay the Spire II's source code and complete Godot package cannot be publicly shared since it is a paid game. However, the developers at Megacrit were extremely kind in compiling their game without obfuscation. If you own a copy of the game, you can decompile it to get the fully game as its full Godot project, including its source code.
This is a hugely helpful resource, both directly for modding and for any hobbyist who wants to see a complete example of a production video game.
Install https://github.com/GDRETools/gdsdecomp.
Open the app. Select "Recover project..." and select the base Slay the Spire II .pck. This is likely located in your steamapps/common/Slay The Spire II directory.
Quick Start: Your First Mod
The best way to get started with modding in Slay the Spire II is to get a mod working end to end. We'll add a single potion called "Drop of Gold", which, when used, grants 1 gold. This is not a particularly interesting addition, but doing so will allow us to ensure all the components to build and inject custom content is working.
Our mod will need to:
- Register itself as a mod for the game
- Define our new potion in code
- Register the new potion as part of the mod
- Add art for our new potion
Step 0: Init a new mod project
This project publishes a script that can generate a new starting point for a mod. It asks for some basic details, such as your name and your mod's name. Both of these can be changed later.
Step 2: Subclass ModSmith.PotionModel
using MegaCrit.Sts2.Core.Entities.Potions;
using MegaCrit.Sts2.Core.Commands;
using MegaCrit.Sts2.Core.Helpers;
namespace ExampleMod;
public sealed class DropOfGold : ModSmith.PotionModel
{
public override PotionRarity Rarity => PotionRarity.Common;
public override PotionUsage Usage => PotionUsage.AnyTime;
public override TargetType TargetType => TargetType.AnyPlayer;
public override ImagePath ImagePath => ModSmith.ResPath("drop_of_gold.png"),
protected override async Task OnUse(PlayerChoiceContext choiceContext, Creature? target)
{
PotionModel.AssertValidForTargetedPotion(target);
NCombatRoom.Instance?.PlaySplashVfx(target, StsColors.gold);
await PlayerCmd.GainGold(1m, target);
}
}
Step 3: Add to registry
ModSmith performs no automatic registration of added content. If you define a new potion but do not register it with ModSmith, it will do nothing.
To attach new content to ModSmith, add ModSmith.Register<T>() somewhere within your mod's initialization block:
ModSmith.Register<DropOfGold>();
ModSmith.PotionModel
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|
Current