-
Notifications
You must be signed in to change notification settings - Fork 0
/
StarflowerPlayer.cs
44 lines (39 loc) · 1.19 KB
/
StarflowerPlayer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using Terraria.ModLoader;
using Terraria;
using static Terraria.ModLoader.ModContent;
namespace Starflower
{
class StarflowerPlayer : ModPlayer
{
public bool hasDusk;
public override void ResetEffects()
{
hasDusk = false;
}
// Moved into it's own method so I don't have to repeat code.
private void ApplyNightfall(NPC target)
{
// Nightfall will not apply to bosses.
if (!target.boss)
{
target.AddBuff(BuffType<Buffs.Nightfall>(), 60 * Main.rand.Next(5, 10), false);
}
}
// Melee weapons.
public override void OnHitNPC(Item item, NPC target, int damage, float knockback, bool crit)
{
if (hasDusk)
{
ApplyNightfall(target);
}
}
// Ranged weapons with melee damage type.
public override void OnHitNPCWithProj(Projectile proj, NPC target, int damage, float knockback, bool crit)
{
if ((proj.DamageType == DamageClass.Melee) && hasDusk && !proj.noEnchantments)
{
ApplyNightfall(target);
}
}
}
}