SunLikeModLib (latest version is Nov 29)


How to use this library in mod development

1. Add reference to library to .csproj file

2. Add BepInEx dependency annotation in plugin code


3. Use library methods to register new items, effects, cheatcodes, etc.

4. Use ILSpy to see game classes, methods. I use ILSpy_selfcontained_x64_8.0.0. Open game's Assembly-CSharp.dll there.


How to create a new item

1. I recommend creating new class (after public class Plugin : BaseUnityPlugin). For example, FiredemonPotion - a new consumable item.

2. It will have 2 static methods, which we would pass into function that registers our item.

3. public static void LoadPotion(string name, Item result) - this will be called after item was loaded, to adjust it stats

4. public static bool PotionEffect(Stats target) - this will be called when player uses our item in game


when this method returns true - it means that item was successfuly used and the item charge will be consumed.

5. Register our item in the Awake() method


registerItemConsumable() - adds new consumable's effect. Game searches those effects by item name. So here we write our item name, and pass PotionEffect method from our class.

registerItem() - adds new item, so the game will know how to convert item name into item class, when it loads a save, or your item is added from cheat menu. Here we pass itemLoadingStruct, but for now, a simplified version. (Edit: in later versions of SunLikeModLib, itemLoadingStruct is moved to SunLikeModLib.ModItemStats.*; this was made so all "register" methods are in Plugin class, and other classes are mostly for internal use inside of library)

Item name here begins with ^ symbol, because its a regex, and this symbol means start of the string. Without it, regex would trigger for item "FakeFiredemonPotion" that is not ours. Second string is the name of item our item is based on. Use the name of similar existing consumable from the game. And finally, third line is our method of adjusting item stats.

6. Compile your plugin. Add its .dll into BepInEx plugin folder, add mod library dll too. Run game, use "item FiredemonPotion" cheat to add your item.

Update Jul 25: fixed critical bug when displaying units with fewer than 4 skills.

Files

SunLikeModLib_src.zip 4.9 kB
Jun 26, 2023
SunLikeModLib_src.zip - (Jul 25) 18 kB
Jul 25, 2023
SunLikeModLib_src.zip - (Nov 29) 24 kB
Nov 29, 2023
SunLikeModLib.dll - (Nov 29, game ver 0.25+) 71 kB
Nov 29, 2023

Get Portals of Phereon BepInEx mods

Leave a comment

Log in with itch.io to leave a comment.