Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
ImmunityTimePlus.cs
Go to the documentation of this file.
1 using Loot.Api.Attributes;
2 using Loot.Api.Core;
3 using Loot.Api.Delegators;
4 using Loot.Modifiers.Base;
5 using Terraria;
6 
7 namespace Loot.Modifiers.EquipModifiers.Defensive
8 {
10  {
11  public int BonusImmunityTime; // Extra immunity frames
12 
13  public override void ResetEffects()
14  {
15  BonusImmunityTime = 0;
16  }
17 
18  [AutoDelegation("OnPostHurt")]
20  private void Immunity(bool pvp, bool quiet, double damage, int hitDirection, bool crit)
21  {
22  int frames = damage <= 1
23  ? BonusImmunityTime / 2
24  : BonusImmunityTime;
25  if (player.immuneTime > 0)
26  {
27  player.immuneTime += frames;
28  }
29  }
30  }
31 
32  [UsesEffect(typeof(ImmunityEffect))]
34  {
36  {
37  return base.GetTooltip()
38  .WithPositive($"+{Properties.RoundedPower} immunity frames");
39  }
40 
42  {
43  return base.GetModifierProperties(item)
44  .WithMaxMagnitude(3f)
45  .WithRollChance(0.222f);
46  }
47 
48  public override void UpdateEquip(Item item, Player player)
49  {
50  ModifierDelegatorPlayer.GetPlayer(player).GetEffect<ImmunityEffect>().BonusImmunityTime += (int) Properties.RoundedPower;
51  }
52  }
53 }
The ModifierPropertiesBuilder implements the builder pattern for ModifierProperties It provides a str...
This attribute may be used to skip usage of AttachDelegations and DetachDelegations Which is a cumber...
A ModifierEffect signifies the effect of a modifier on a player It should house the implementation...
void Immunity(bool pvp, bool quiet, double damage, int hitDirection, bool crit)
Defines a modifier that can roll on an equip item (armor or accessory) These modifiers will have 60% ...
override ModifierProperties.ModifierPropertiesBuilder GetModifierProperties(Item item)
override ModifierTooltipLine.ModifierTooltipBuilder GetTooltip()
DelegationPrioritization
Specify when you want your delegation to happen in the chain
static ModifierDelegatorPlayer GetPlayer(Player player)
override void UpdateEquip(Item item, Player player)
Defines the properties of a modifier
Defines a tooltip line of a modifier A modifier can have multiple lines
override void ResetEffects()
Automatically called when the ModPlayer does its ResetEffects Also automatically called when the dele...
Holds player-entity data and handles it