Skip to content

Commit

Permalink
tentative fix for #117
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxfaby committed Aug 7, 2023
1 parent 6a659bb commit cb7812e
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions ModComponents/ItemStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static void Initialize()
RegisterStat(RoR2Content.Items.Firework, "BETTERUI_FIREWORKS", 8, 4, statFormatter: StatFormatter.Charges);

Check failure on line 64 in ModComponents/ItemStats.cs

View workflow job for this annotation

GitHub Actions / build / build

The call is ambiguous between the following methods or properties: 'ItemStats.RegisterStat(ItemDef, string, float, float, ItemStats.StackingFormula, ItemStats.StatFormatter, ItemStats.ItemTag)' and 'ItemStats.RegisterStat(ItemDef, string, float, float, int, ItemStats.StackingFormula, ItemStats.StatFormatter, ItemStats.ItemTag)'
RegisterStat(RoR2Content.Items.FlatHealth, "BETTERUI_HEALTH", 25, statFormatter: StatFormatter.HP);
RegisterStat(RoR2Content.Items.FocusConvergence, "BETTERUI_CHARGESPEED", 0.30f);
RegisterStat(RoR2Content.Items.FocusConvergence, "BETTERUI_TELEPORTERZONE", 2, 3, FocusedConvergenceStacking);
RegisterStat(RoR2Content.Items.FocusConvergence, "BETTERUI_TELEPORTERZONE", 2, stackLimit: 3, stackingFormula: FocusedConvergenceStacking);

Check failure on line 67 in ModComponents/ItemStats.cs

View workflow job for this annotation

GitHub Actions / build / build

There is no argument given that corresponds to the required formal parameter 'stackValue' of 'ItemStats.RegisterStat(ItemDef, string, float, float, int, ItemStats.StackingFormula, ItemStats.StatFormatter, ItemStats.ItemTag)'
RegisterStat(RoR2Content.Items.GhostOnKill, "BETTERUI_GHOSTDURATION", 30, statFormatter: StatFormatter.Seconds);
RegisterStat(RoR2Content.Items.GoldOnHit, "BETTERUI_GOLDGAINED", 2, statFormatter: StatFormatter.Charges);
RegisterStat(RoR2Content.Items.GoldOnHit, "BETTERUI_GOLDLOST", 1);
Expand Down Expand Up @@ -165,7 +165,7 @@ public static void Initialize()

RegisterStat(DLC1Content.Items.AttackSpeedAndMoveSpeed, "BETTERUI_ATTACKSPEED", 0.075f);
RegisterStat(DLC1Content.Items.AttackSpeedAndMoveSpeed, "BETTERUI_MOVEMENTSPEED", 0.07f, itemTag: ItemTag.MovementSpeed);
RegisterStat(DLC1Content.Items.BearVoid, "BETTERUI_RECHARGETIME", 15, 0.9f, ExponentialStacking, StatFormatter.Seconds);
RegisterStat(DLC1Content.Items.BearVoid, "BETTERUI_RECHARGETIME", 15, 0.9f, 65, ExponentialStacking, StatFormatter.Seconds);
RegisterStat(DLC1Content.Items.BleedOnHitVoid, "BETTERUI_CHANCE", 0.1f, itemTag: ItemTag.Luck);
RegisterProc(DLC1Content.Items.BleedOnHitVoid, 0.1f, stackingFormula: LinearStacking, capFormula: LinearCap);
RegisterStat(DLC1Content.Items.ChainLightningVoid, "BETTERUI_HITS", 3, statFormatter: StatFormatter.Charges);
Expand Down Expand Up @@ -255,12 +255,27 @@ public static ItemStat RegisterStat(
StatFormatter statFormatter = null,
ItemTag itemTag = null
)
{
return RegisterStat(itemDef, nameToken, value, stackValue, stackingFormula: stackingFormula, statFormatter: statFormatter, itemTag: itemTag);
}

public static ItemStat RegisterStat(
ItemDef itemDef,
string nameToken,
float value,
float stackValue,
int stackLimit = int.MaxValue,
StackingFormula stackingFormula = null,
StatFormatter statFormatter = null,
ItemTag itemTag = null
)
{
ItemStat itemStat = new ItemStat()
{
nameToken = nameToken,
value = value,
stackValue = stackValue,
stackLimit = stackLimit,
stackingFormula = stackingFormula ?? LinearStacking,
statFormatter = statFormatter ?? StatFormatter.Percent
};
Expand Down Expand Up @@ -361,6 +376,7 @@ public static void GetItemStats(StringBuilder stringBuilder, ItemDef itemDef, in
{
if (itemStats.TryGetValue(itemDef, out var stats))
{
stacks = Math.Max(stacks, itemStats.stackLimit);
foreach (var itemStat in stats)
{
float baseValue = itemStat.stackingFormula(itemStat.value, itemStat.stackValue, stacks);
Expand Down Expand Up @@ -605,7 +621,7 @@ public static float DivideByStacks(float value, float extraStackValue, int stack
}
public static float FocusedConvergenceStacking(float value, float extraStackValue, int stacks)
{
return 1 / (value * Math.Min(stacks, extraStackValue));
return 1 / (value * stacks);
}
public static float HyperbolicStacking(float value, float extraStackValue, int stacks)
{
Expand Down Expand Up @@ -690,6 +706,7 @@ public class ItemStat
public StackingFormula stackingFormula;
public float value;
public float stackValue;
public int stackLimit;
public StatFormatter statFormatter;
}

Expand Down

0 comments on commit cb7812e

Please sign in to comment.