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
:
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.
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:
public class MyCustomAbility : CustomAbility
{
[RLSetup]
public static void Setup()
{
RogueLibs.CreateCustomAbility<MyCustomAbility>();
}
}
See more about the RLSetup
attribute here.
You can set your ability's name and description using WithName
and WithDescription
methods:
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:
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 });
}
}
See Custom Names, Custom Sprites for more info.
Unlock Properties
You can use the following properties when initializing AbilityUnlock
s:
Property | Default | Description |
---|---|---|
UnlockCost | 0 | Unlock cost of the ability, in nuggets. If set to 0, it will unlock automatically, once all prerequisites are unlocked. |
CharacterCreationCost | 1 | Cost of the ability in Character Creation, in points. |
IsAvailable | true | Determines 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. |
IsAvailableInCC | true | Determines whether the ability is available in the Character Creation menu. |
Prerequisites | Determines what unlocks must be unlocked in order to unlock this ability. | |
Recommendations | Just shows these unlocks in a separate Recommendations paragraph in the menus. |
Other properties should not be used during initialization.
Examples