-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTeleport.cs
143 lines (110 loc) · 4.01 KB
/
Teleport.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
using BrokeProtocol.Collections;
using BrokeProtocol.Entities;
using BrokeProtocol.Utility.Networking;
using BrokeProtocolClient.settings;
using BrokeProtocolClient.utils;
using ENet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
namespace BrokeProtocolClient.modules.exploit
{
class Teleport : Module
{
ModeSetting mode = new ModeSetting("Mode", Mode.Crosshair);
BindSetting teleportBind = new BindSetting(0, "Quick teleport bind");
InputSetting targetInput = new InputSetting("Target Username/ID", 16, "");
ActionSetting teleport;
Vector3 teleportPos;
public Teleport() : base(Categories.Exploit, "Teleport", "Allows to teleport")
{
addSetting(mode);
addSetting(new InfoSetting("Teleport bind:"));
addSetting(teleportBind);
addSetting(targetInput);
teleport = new ActionSetting("Teleport", TeleportToPlayer);
addSetting(teleport);
}
public override void onActivate()
{
}
public override void onDeactivate()
{
}
public override void onRender()
{
if (mode.isMode(Mode.Crosshair))
{
if (teleportPos == Vector3.zero) return;
ShPlayer local = getClient().ClManager.myPlayer;
if (!local) return;
Color circleColor = new Color(0, 1, 0, 0.5f);
Color lineColor = new Color(0, 1, 1, 0.25f);
Render.DrawWorldCircle(teleportPos, 1.5f, 16, circleColor, 2);
Render.DrawWorldLine(local.GetPosition, teleportPos, lineColor, 2);
}
}
public override void onUpdate()
{
ShPlayer local = getClient().ClManager.myPlayer;
if (!local) return;
Camera camera = getClient().MainCamera.worldCamera;
if (!camera) return;
if (mode.isMode(Mode.Crosshair))
{
RaycastHit raycastHit;
if (!Physics.Raycast(camera.transform.position, camera.transform.forward, out raycastHit, 9985))
{
teleportPos = Vector3.zero;
return;
}
teleportPos = raycastHit.point;
if (teleportBind.WasPressedThisFrame())
TeleportTo(teleportPos);
}
}
private void TeleportToPlayer()
{
ShPlayer target;
if (!EntityCollections.TryGetPlayerByNameOrID(targetInput.getValue(), out target))
{
Log($"{targetInput.getValue()} not found!");
return;
}
if (target.headCollider.bounds.size == Vector3.zero)
{
Log($"{targetInput.getValue()} is too far away!");
return;
}
TeleportTo(target.GetPosition);
}
private void TeleportTo(Vector3 pos)
{
ShPlayer local = getClient().ClManager.myPlayer;
if (!local) return;
float distance = local.DistanceSqr(pos);
int jumps = 1;
float velocity = 0;
do
{
jumps++;
velocity += 14f;
} while (distance > velocity * velocity * 0.25f + 1.5f); // From SvTryUpdateSmooth in Scripts.dll
for (int i = 0; i < jumps; i++)
{
getClient().ClManager.SendToServer(PacketFlags.Reliable, SvPacket.Jump, new object[] { });
}
getClient().ClManager.myPlayer.SetPosition(pos);
}
enum Mode
{
Player,
Crosshair
}
}
}