Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
AmmoReduce.cs
Go to the documentation of this file.
1 using Loot.Api.Core;
2 using Loot.Modifiers.Base;
3 using Terraria;
4 
5 namespace Loot.Modifiers.WeaponModifiers
6 {
7  public class AmmoReduce : WeaponModifier
8  {
10  {
11  return base.GetTooltip()
12  .WithPositive($"{Properties.RoundedPower}% chance to not consume ammo");
13  }
14 
16  {
17  return base.GetModifierProperties(item)
18  .WithMaxMagnitude(10f);
19  }
20 
21  public override bool CanRoll(ModifierContext ctx)
22  {
23  // Only apply on items that consume ammo
24  return base.CanRoll(ctx) && ctx.Item.useAmmo > 0;
25  }
26 
27  public override bool ConsumeAmmo(Item item, Player player)
28  {
29  return Main.rand.NextFloat() > Properties.RoundedPower / 100;
30  }
31  }
32 }
override bool ConsumeAmmo(Item item, Player player)
Definition: AmmoReduce.cs:27
override ModifierProperties.ModifierPropertiesBuilder GetModifierProperties(Item item)
Definition: AmmoReduce.cs:15
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 bool CanRoll(ModifierContext ctx)
If this Modifier can roll at all in the given context Properties are available here, apart from magnitude and power
Definition: AmmoReduce.cs:21
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: AmmoReduce.cs:9