-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomRotations.lua
More file actions
64 lines (59 loc) · 2.41 KB
/
Copy pathCustomRotations.lua
File metadata and controls
64 lines (59 loc) · 2.41 KB
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
local prevAngle;
local hasAttacked;
local rots = {};
local wrapAngleTo180 = function(value)
value = value % 360.0;
if (value >= 180.0) then
value = value - 360.0;
end
if (value < -180.0) then
value = value + 360.0;
end
return value;
end
module_manager.register("Custom Rotations", {
on_enable = function()
hasAttacked = false;
prevAngle = 0;
end,
on_pre_motion = function(event)
local target = player.kill_aura_target();
if (module_manager.is_module_on("killaura") and target ~= nil) then
world.entities();
local width, height = world.width_height(target);
local x, y, z = world.position(target);
local diff = { x - event.x,
y + ((module_manager.option("Custom Rotations", "Pitch Correction") / 100.0) * height) -
(y + player.eye_height()), z - event.z };
local angle = math.deg(math.atan(diff[3], diff[1]));
local yaw = angle - 90.0;
local pitch = -math.deg(math.atan(diff[2], player.distance_to_entity(target)));
local cYaw = player.angles();
if (hasAttacked or not module_manager.option("Custom Rotations", "Rotate on Attack")) then
if (
module_manager.option("Custom Rotations", "Rotate on Attack") or
math.abs(angle - prevAngle) > module_manager.option("Custom Rotations", "Angle Step")) then
rots[1] = cYaw + wrapAngleTo180(yaw - cYaw);
rots[2] = wrapAngleTo180(pitch);
prevAngle = angle;
hasAttacked = false;
end
end
event.yaw = rots[1];
event.pitch = rots[2];
end
return event;
end,
on_send_packet = function(event)
if (module_manager.is_module_on("killaura") and player.kill_aura_target() ~= nil) then
if (event.packet_id == 0x02) then
if (event.action == 2) then
hasAttacked = true;
end
end
end
end
});
module_manager.register_boolean("Custom Rotations", "Rotate on Attack", true);
module_manager.register_number("Custom Rotations", "Angle Step", 0, 180, 15);
module_manager.register_number("Custom Rotations", "Pitch Correction", 0, 100, 25);