Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
HealthyFoesBonus.cs
Go to the documentation of this file.
1 using System;
2 using Loot.Api.Attributes;
3 using Loot.Api.Core;
4 using Loot.Api.Delegators;
5 using Loot.Modifiers.Base;
6 using Terraria;
7 
8 namespace Loot.Modifiers.EquipModifiers.Offensive
9 {
11  {
12  public float Multiplier;
13 
14  public override void OnInitialize()
15  {
16  Multiplier = 1f;
17  }
18 
19  public override void ResetEffects()
20  {
21  Multiplier = 1f;
22  }
23 
24  [AutoDelegation("OnModifyHitNPC")]
26  public void ModifyHitNPC(Item item, NPC target, ref int damage, ref float knockback, ref bool crit)
27  {
28  if (target.life == target.lifeMax)
29  {
30  HealthyFoes(ref damage);
31  }
32  }
33 
34  [AutoDelegation("OnModifyHitPvp")]
36  private void ModifyHitPvp(Item item, Player target, ref int damage, ref bool crit)
37  {
38  if (target.statLife == target.statLifeMax2)
39  {
40  HealthyFoes(ref damage);
41  }
42  }
43 
44  private void HealthyFoes(ref int damage)
45  {
46  damage = (int) (Math.Ceiling(damage * Multiplier));
47  }
48  }
49 
50  [UsesEffect(typeof(HealthyFoesEffect))]
52  {
54  {
55  return base.GetTooltip()
56  .WithPositive($"+{Properties.RoundedPower}% damage vs max life foes");
57  }
58 
60  {
61  return base.GetModifierProperties(item)
62  .WithMinMagnitude(5f)
63  .WithMaxMagnitude(15f);
64  }
65 
66  public override void UpdateEquip(Item item, Player player)
67  {
68  ModifierDelegatorPlayer.GetPlayer(player).GetEffect<HealthyFoesEffect>().Multiplier += Properties.RoundedPower / 100f;
69  }
70  }
71 }
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...
override ModifierTooltipLine.ModifierTooltipBuilder GetTooltip()
A ModifierEffect signifies the effect of a modifier on a player It should house the implementation...
Defines a modifier that can roll on an equip item (armor or accessory) These modifiers will have 60% ...
override void ResetEffects()
Automatically called when the ModPlayer does its ResetEffects Also automatically called when the dele...
void ModifyHitPvp(Item item, Player target, ref int damage, ref bool crit)
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
override ModifierProperties.ModifierPropertiesBuilder GetModifierProperties(Item item)
Defines a tooltip line of a modifier A modifier can have multiple lines
Holds player-entity data and handles it
void ModifyHitNPC(Item item, NPC target, ref int damage, ref float knockback, ref bool crit)
override void OnInitialize()
Called when the ModPlayer initializes the effect