-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDUPlayer.cs
107 lines (91 loc) · 3.41 KB
/
DUPlayer.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using DarknessUnbound.Items.Consumables;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using Terraria;
using Terraria.DataStructures;
using Terraria.Graphics.Effects;
using Terraria.ID;
using Terraria.ModLoader;
namespace DarknessUnbound
{
public class DUPlayer : ModPlayer
{
public bool eldritchCore;
public bool icyStone;
public bool frostfireNecklace;
public bool godMode;
public int eldritchCore_CountDown;
public override void Initialize()
{
//SkyManager.Instance.Activate("DarknessUnbound:PillarSky");
//Filters.Scene["DUPillar"].Activate(default);
}
public override void SetupStartInventory(IList<Item> items, bool mediumcoreDeath)
{
Item item = new Item();
item.SetDefaults(ModContent.ItemType<RestlessShadows>());
items.Add(item);
}
public override void ResetEffects()
{
eldritchCore = false;
icyStone = false;
frostfireNecklace = false;
godMode = false;
eldritchCore_CountDown--;
if (eldritchCore_CountDown < 0) eldritchCore_CountDown = 0;
}
#region OnHitBy
public override void OnHitByNPC(NPC npc, int damage, bool crit)
{
if (eldritchCore && eldritchCore_CountDown == 0) OnHitBy_EldritchCore();
}
public override void OnHitByProjectile(Projectile proj, int damage, bool crit)
{
if (eldritchCore && eldritchCore_CountDown == 0) OnHitBy_EldritchCore();
}
private void OnHitBy_EldritchCore()
{
for (int i = 0; i < 4; i++)
{
Projectile proj = Projectile.NewProjectileDirect(player.Center - new Vector2(Main.rand.Next(-215, 216), 800 + Main.rand.Next(-100, 101)), Vector2.UnitY * 8, ProjectileID.LunarFlare, 250, 6f, player.whoAmI);
proj.velocity = proj.velocity.RotatedBy(proj.DirectionTo(player.Center).ToRotation() - MathHelper.PiOver2);
}
eldritchCore_CountDown = 24;
}
#endregion
#region OnHit
public override void OnHitNPC(Item item, NPC target, int damage, float knockback, bool crit)
{
if (icyStone && item.magic) OnHit_IcyStone(target);
if (frostfireNecklace && (item.summon || item.sentry)) OnHit_IcyStone(target);
}
public override void OnHitNPCWithProj(Projectile proj, NPC target, int damage, float knockback, bool crit)
{
if (icyStone && proj.magic) OnHit_IcyStone(target);
if (frostfireNecklace && (proj.minion || proj.sentry)) OnHit_IcyStone(target);
}
private void OnHit_IcyStone(NPC target) => target.AddBuff(BuffID.Frostburn, Main.rand.Next(2, 7) * 60);
#endregion
#region Update
public override void PostUpdateBuffs()
{
if (godMode)
{
player.statLife = player.statLifeMax2;
player.statMana = player.statManaMax2;
for (int i = 0; i < BuffLoader.BuffCount; i++)
{
if (!Main.debuff[i]) continue;
player.buffImmune[i] = true;
}
}
}
public override void UpdateDead()
{
if (godMode)
player.dead = false;
}
#endregion
}
}