Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
CursedDamage.cs
Go to the documentation of this file.
1 using System.Linq;
2 using Loot.Api.Attributes;
3 using Loot.Api.Core;
4 using Loot.Api.Ext;
5 using Loot.Modifiers.Base;
6 using Terraria;
7 using Terraria.ID;
8 
9 namespace Loot.Modifiers.WeaponModifiers
10 {
12  {
13  public int CurseCount;
14 
15  public override void ResetEffects()
16  {
17  CurseCount = 0;
18  }
19 
20  // There are two ways to delegate your method,
21  // you can either specify by enum (safest) like here
22  // or by string (see below)
23  [AutoDelegation(DelegationTarget.PostUpdateEquips)]
24  private void CurseHolding()
25  {
26  Item checkItem = Main.mouseItem != null && !Main.mouseItem.IsAir ? Main.mouseItem : player.HeldItem;
27 
28  if (checkItem == null || checkItem.IsAir || !checkItem.IsWeapon()
29  || !LootModItem.GetInfo(checkItem).IsActivated)
30  return;
31 
32  int c = LootModItem.GetActivePool(checkItem).Count(x => x.GetType() == typeof(CursedDamage));
33  if (c > 0)
34  {
35  DelegatorPlayer.GetEffect<CursedEffect>().CurseCount += c;
36  }
37  }
38 
39  // The alternative way is providing the target name yourself
40  // in the form of a string. It can be preceded by "On"
41  // but it may also be left out.
42  [AutoDelegation("OnUpdateBadLifeRegen")]
43  private void Curse()
44  {
45  if (CurseCount <= 0 || player.buffImmune[BuffID.Cursed])
46  return;
47 
48  if (player.lifeRegen > 0)
49  {
50  player.lifeRegen = 0;
51  }
52 
53  player.lifeRegen -= 2 * CurseCount;
54  player.lifeRegenTime = 0;
55  }
56  }
57 
58  [UsesEffect(typeof(CursedEffect))]
60  {
62  {
63  return base.GetTooltip()
64  .WithPositive($"+{Properties.RoundedPower}% damage, but you are cursed while holding this item");
65  }
66 
68  {
69  return base.GetModifierProperties(item)
70  .WithMinMagnitude(5f)
71  .WithMaxMagnitude(15f)
72  .IsUniqueModifier(true);
73  }
74 
75  public override bool CanRoll(ModifierContext ctx)
76  {
77  return base.CanRoll(ctx) && ctx.Method != ModifierContextMethod.SetupStartInventory;
78  }
79 
80  public override void ModifyWeaponDamage(Item item, Player player, ref float add, ref float mult, ref float flat)
81  {
82  base.ModifyWeaponDamage(item, player, ref add, ref mult, ref flat);
83  add += Properties.RoundedPower / 100f;
84  }
85  }
86 }
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...
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...
override ModifierProperties.ModifierPropertiesBuilder GetModifierProperties(Item item)
Definition: CursedDamage.cs:67
ModifierContextMethod
Defines a method for a context in which a Modifier might be rolled Used in ModifierContext ...
Defines an item that may be modified by modifiers from mods
Definition: LootModItem.cs:21
override void ModifyWeaponDamage(Item item, Player player, ref float add, ref float mult, ref float flat)
Definition: CursedDamage.cs:80
Defines a modifier that can roll on a weapon item You can use this class and add to CanRoll by callin...
static List< Modifier > GetActivePool(Item item)
Defines the properties of a modifier
static LootModItem GetInfo(Item item)
Defines a tooltip line of a modifier A modifier can have multiple lines
DelegationTarget
Defines a target that can be used in conjunction with AutoDelegation for identifying the target event...
ModifierContextMethod Method
override ModifierTooltipLine.ModifierTooltipBuilder GetTooltip()
Definition: CursedDamage.cs:61
bool IsActivated
Keeps track of if the particular item was activated (&#39;delegated&#39;) Specific usecase see CursedEffect a...
Definition: LootModItem.cs:45
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: CursedDamage.cs:75
override void ResetEffects()
Automatically called when the ModPlayer does its ResetEffects Also automatically called when the dele...
Definition: CursedDamage.cs:15