local replicated_storage = game:GetService("ReplicatedStorage");
local camera = [Link];
local modules = {}; do
for _, module in replicated_storage.module:GetDescendants() do
if ([Link]([Link], "Script")) then
modules[[Link]] = module;
end
end
end
local caster = require([Link]); -- important (bullet casting)
local stats = require(modules.shared_state).SHARED_STATE; -- some cool stuff in
here, [Link] to check it out
local ray_casts = require(modules.parallel_raycast); -- not as important, their
raycasts
local get_closest_player = function()
local closest_distance = 300;
local closest_player = nil;
for _, player in [Link]:GetChildren() do
if (player:FindFirstChild("hitbox") == nil) then
continue;
end
local center = [Link]([Link].X / 2, [Link].Y
/ 2);
local position, on_screen =
camera:WorldToViewportPoint([Link]);
if (on_screen == false) then
continue;
end
local distance = (center - [Link](position.X, position.Y)).Magnitude;
if (distance > closest_distance) then
continue;
end
closest_distance = distance;
closest_player = player;
end
return closest_player;
end
--local projectiles = getupvalue(caster.fire_server, 5); -- (all alive projectiles
r stored here, might do something with this in the future)
old_fire_server = hookfunction([Link], function(_, origin_pos, direction,
data, ...)
local closest_player = get_closest_player();
if (closest_player) then
origin_pos += [Link](0, 30, 0); -- bullets fire from higher up, pretty
op..
direction = (closest_player.[Link] - origin_pos).Unit * 1000;
end
return old_fire_server(_, origin_pos, direction, data, ...);
end)