Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
ManaReduce.cs
Go to the documentation of this file.
1 using System;
2 using Loot.Api.Core;
3 using Loot.Modifiers.Base;
4 using Terraria;
5 
6 namespace Loot.Modifiers.WeaponModifiers
7 {
8  public class ManaReduce : WeaponModifier
9  {
11  {
12  return base.GetTooltip()
13  .WithPositive($"-{Properties.RoundedPower}% mana cost");
14  }
15 
17  {
18  return base.GetModifierProperties(item)
19  .WithMaxMagnitude(10f);
20  }
21 
22  public override bool CanRoll(ModifierContext ctx)
23  => base.CanRoll(ctx) && ctx.Item.mana > 0;
24 
25  public override void Apply(Item item)
26  {
27  base.Apply(item);
28  // Always reduce by at least 1 mana cost
29  item.mana = (int) Math.Floor(item.mana * (1 - Properties.RoundedPower / 100f));
30 
31  // Don't go below 1 mana cost! 0 cost is too OP :P
32  if (item.mana < 1)
33  {
34  item.mana = 1;
35  }
36  }
37  }
38 }
Defines a context in which a Modifier might be rolled Which fields are available (not null) depends o...
The ModifierPropertiesBuilder implements the builder pattern for ModifierProperties It provides a str...
override void Apply(Item item)
Allows modders to do something when this modifier is applied If a modder needs ModPlayer hooks...
Definition: ManaReduce.cs:25
Defines a modifier that can roll on a weapon item You can use this class and add to CanRoll by callin...
Defines the properties of a modifier
Defines a tooltip line of a modifier A modifier can have multiple lines
override ModifierTooltipLine.ModifierTooltipBuilder GetTooltip()
Definition: ManaReduce.cs:10
override ModifierProperties.ModifierPropertiesBuilder GetModifierProperties(Item item)
Definition: ManaReduce.cs:16