This repository has been archived by the owner on Jul 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRODHTDSPlayer.cs
92 lines (88 loc) · 3.22 KB
/
RODHTDSPlayer.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
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.GameInput;
using Terraria;
using Microsoft.Xna.Framework;
using Terraria.DataStructures;
namespace RODHTDS
{
public class ROTHTDSPlayer : ModPlayer
{
public override void ProcessTriggers(TriggersSet triggersSet)
{
if ((RODHTDS.safeRodKey.JustPressed || RODHTDS.unsafeRodKey.JustPressed) && player.itemTime <= 0)
{
Item item = null;
for (int i = 0; i < 58; i++)
{
item = player.inventory[i];
if (item.type == ItemID.RodofDiscord)
{
break;
}
else
{
item = null;
}
}
if (item == null || !CheckValidWarpLocation(Main.MouseWorld))
return;
if (RODHTDS.safeRodKey.JustPressed)
{
if (player.HasBuff(BuffID.ChaosState))
return;
player.Teleport(Main.MouseWorld, 1);
player.AddBuff(BuffID.ChaosState, 360);
}
else if (RODHTDS.unsafeRodKey.JustPressed)
{
player.Teleport(Main.MouseWorld, 1);
player.AddBuff(BuffID.ChaosState, 360);
if (player.HasBuff(BuffID.ChaosState))
OofOuchOwie(player);
}
}
}
public bool CheckValidWarpLocation(Vector2 position)
{
Vector2 mousePos = default;
mousePos.X = Main.mouseX + Main.screenPosition.X;
if (player.gravDir == 1f)
{
mousePos.Y = Main.mouseY + Main.screenPosition.Y - player.height;
}
else
{
mousePos.Y = Main.screenPosition.Y + Main.screenHeight - Main.mouseY;
}
ref float x = ref mousePos.X;
x -= player.width / 2;
if (mousePos.X > 50f && mousePos.X < Main.maxTilesX * 16 - 50 && mousePos.Y > 50f && mousePos.Y < Main.maxTilesY * 16 - 50)
{
int integerX = (int)(mousePos.X / 16f);
int integerY = (int)(mousePos.Y / 16f);
if (Main.tile[integerX, integerY].wall != 87 && !Collision.SolidCollision(position, player.width, player.height))
{
player.itemTime = 30; // This only fires if it's teleporting, so this means it's a valid warp - teleport us!
return true;
}
}
return false;
}
public void OofOuchOwie(Player player)
{
player.statLife -= player.statLifeMax2 / 7;
PlayerDeathReason damageSource = PlayerDeathReason.ByOther(13);
if (Main.rand.Next(2) == 0)
{
damageSource = PlayerDeathReason.ByOther(player.Male ? 14 : 15);
}
if (player.statLife <= 0)
{
player.KillMe(damageSource, 1.0, 0, false);
}
player.lifeRegenCount = 0;
player.lifeRegenTime = 0;
}
}
}