risk-of-thunder / R2API

A modding API for Risk of Rain 2
https://thunderstore.io/package/tristanmcpherson/R2API/
MIT License
136 stars 55 forks source link

Level Scaling Stats for RecalculateStatsAPI #512

Closed Priscillalala closed 10 months ago

Priscillalala commented 10 months ago

Mainly made to address #510 but expanded to include all level-scaling stats. This is a more general solution than providing a scaling regen stat and a safer solution than attempting to expose the current player level.

Intended use case is mostly for regen items and buffs, which should scale by +20% per level.

Example:

private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody sender, RecalculateStatsAPI.StatHookEventArgs args)
{
    int count = sender.inventory?.GetItemCount(MyItem) ?? 0;
    float baseRegenFromItem = 3f * count;
    args.baseRegenAdd += baseRegenFromItem;
    args.levelRegenAdd += baseRegenFromItem * StandardLevelScaling.Regen;
}

StandardLevelScaling is a collection of constants to maintain stat scaling consistency and is completely optional to use. This implementation is very customizable for the client.

This PR also updates the recalculate stats api documentation to account for the new stats and reduce the burden of maintenance.

Priscillalala commented 10 months ago

Havent had time to thoroughly review this one yet but it should be in a good enough state to get some feedback on