Skip to main content
The project's repository is archived as part of the GitHub Archive Program. RogueLibs' code and the documentation will no longer be updated.

Creating a Custom Ability

Special abilities in SoR are actually implemented as items. They have SetupDetails, Count, and exist in the owner's inventory, just like items. The CustomAbility class provided by RogueLibs inherits from the CustomItem class and provides a default implementation of SetupDetails. Just like with custom items, you can use interfaces to expand your ability's functionality: IAbilityRechargeable, IAbilityChargeable, IAbilityTargetable.

CustomAbility class

To make a custom ability, you need to create a class deriving from CustomAbility:

MyCustomAbility.cs
public class MyCustomAbility : CustomAbility
{
/* ... */
}

You only need to implement 2 methods: OnAdded is called when a character receives this special ability, and OnPressed is called when the player uses the ability. There's no OnRemoved at the moment, because it's not implemented in SoR.

MyCustomAbility.cs
public class MyCustomAbility : CustomAbility
{
public override void OnAdded() { /* ... */ }
public override void OnPressed() { /* ... */ }
}

SetupDetails

SetupDetails is overriden by CustomAbility and here's its implementation:

    public override void SetupDetails()
{
Item.stackable = true;
Item.initCount = 0;
Item.lowCountThreshold = 100;
}

This method should work for most abilities, but if you need something more sophisticated, then override it yourself.

Initialization

Just call the CreateCustomAbility method with your ability's type as a parameter:

MyCustomAbility.cs
public class MyCustomAbility : CustomAbility
{
[RLSetup]
public static void Setup()
{
RogueLibs.CreateCustomAbility<MyCustomAbility>();
}
}
note

See more about the RLSetup attribute here.

You can set your ability's name and description using WithName and WithDescription methods:

MyCustomAbility.cs
public class MyCustomAbility : CustomAbility
{
[RLSetup]
public static void Setup()
{
RogueLibs.CreateCustomAbility<MyCustomAbility>()
.WithName(new CustomNameInfo("My Custom Ability"))
.WithDescription(new CustomNameInfo("My Custom Ability is very cool and does a lot of great stuff"));
}
}

You can do the same with sprites and unlocks:

MyCustomAbility.cs
public class MyCustomAbility : CustomAbility
{
[RLSetup]
public static void Setup()
{
RogueLibs.CreateCustomAbility<MyCustomAbility>()
.WithName(new CustomNameInfo("My Custom Ability"))
.WithDescription(new CustomNameInfo("My Custom Ability is very cool and does a lot of great stuff"));
.WithSprite(Properties.Resources.MyCustomAbility)
.WithUnlock(new AbilityUnlock { UnlockCost = 10, CharacterCreationCost = 5 });
}
}
info

See Custom Names, Custom Sprites for more info.

Unlock Properties

You can use the following properties when initializing AbilityUnlocks:

PropertyDefaultDescription
UnlockCost0Unlock cost of the ability, in nuggets. If set to 0, it will unlock automatically, once all prerequisites are unlocked.
CharacterCreationCost1Cost of the ability in Character Creation, in points.
IsAvailabletrueDetermines whether the ability is available in the ... Well, there's no menu for custom abilities at the moment, but if there was, this property would determine whether it's available in that menu.
IsAvailableInCCtrueDetermines whether the ability is available in the Character Creation menu.
PrerequisitesDetermines what unlocks must be unlocked in order to unlock this ability.
RecommendationsJust shows these unlocks in a separate Recommendations paragraph in the menus.

Other properties should not be used during initialization.

Examples


The project's repository is archived as part of the GitHub Archive Program. RogueLibs' code and the documentation will no longer be updated.