Untitled
user_2494498
lua
a year ago
10 kB
10
Indexable
getgenv().Equations = {
["rbxassetid://7444113542"] = {
a = 6.24E-03;
b = 8.66;
ReleaseWindow = 1.25;
UseBar = true;
};
["rbxassetid://7450518733"] = { -- driving layup / side
a = 5.81E-03;
b = 10.6;
ReleaseWindow = 1.27;
};
["rbxassetid://7450517825"] = { -- driving layup / side
a = 5.81E-03;
b = 10.6;
ReleaseWindow = 1.27;
};
["rbxassetid://7444122897"] = { -- back drift
a = 4.68e-3;
b = 8.62;
ReleaseWindow = 1.25;
};
["rbxassetid://7469960428"] = { -- back layup right
a = 6.83E-03;
b = 10.7;
ReleaseWindow = 1.25;
};
["rbxassetid://7469958722"] = { -- back layup left
a = 6.83E-03;
b = 10.7;
ReleaseWindow = 1.25; --
};
["rbxassetid://746992327"] = { -- Side Layup
a = 5.96E-03;
b = 8.23;
ReleaseWindow = 1.25;
};
["rbxassetid://7469961493"] = { -- Side layup
a = 5.96E-03;
b = 8.23;
ReleaseWindow = 1.25;
};
["rbxassetid://7450532971"] = { -- reverse layup right
a = 5.69E-03;
b = 10.2;
ReleaseWindow = 1.15;
};
["rbxassetid://7450532132"] = { -- reverse layup left
a = 5.69E-03;
b = 10.2;
ReleaseWindow = 1.15;
};
["rbxassetid://7444125621"] = { -- drift forgot ngl
a = 4.8E-03;
b = 8.28;
ReleaseWindow = 1.05;
};
["rbxassetid://7444128118"] = { -- drift right right
a = 4.8E-03;
b = 8.28;
ReleaseWindow = 1.05;
};
}
if getgenv().executed then return end
getgenv().executed = true;
local MovingAverage = {};
MovingAverage.__index = MovingAverage;
function MovingAverage.new()
local self = setmetatable({}, MovingAverage); do
self.Data = {};
end
return self;
end
function MovingAverage:AddValue(x)
if #self.Data > 30 then
table.remove(self.Data, 1)
end
if #self.Data >= 4 then
local Q1, Q3 = self:GetIQR();
local IQR = Q3 - Q1;
local LowerBound = Q1 - 1.5 * IQR;
local UpperBound = Q3 + 1.5 * IQR;
if x >= LowerBound and x <= UpperBound then
table.insert(self.Data, x);
else
warn(tostring(x) .. " is considered an outlier.");
end
return;
end
table.insert(self.Data, x);
end
function MovingAverage:GetAverage()
if getgenv().UseAverage then
local TotalPing = 0;
for _, x in pairs(self.Data) do
TotalPing = TotalPing + x;
end
return TotalPing / #self.Data;
end
return game:GetService("Stats").Network.ServerStatsItem["Data Ping"]:GetValue()
end
function MovingAverage:GetMedian(NewData)
local Length = #NewData;
if Length % 2 == 0 then
return (NewData[Length / 2] + NewData[Length / 2 + 1]) / 2;
else
return NewData[math.ceil(Length / 2)]
end
end
function MovingAverage:GetIQR()
if #self.Data < 4 then
return self:GetAverage();
end
local SortedData = {table.unpack(self.Data)}; table.sort(SortedData);
local Mid = math.floor(#SortedData / 2);
local LowerHalf = {table.unpack(SortedData, 1, Mid)};
local UpperHalf = {table.unpack(SortedData, Mid + 1)};
return self:GetMedian(LowerHalf), self:GetMedian(UpperHalf);
end
function MovingAverage:Reset()
table.clear(self.Data);
end
local PingObject = MovingAverage.new();
task.spawn(function()
while true do
if getgenv().ResetAverage then
PingObject:Reset();
getgenv().ResetAverage = false;
end
PingObject:AddValue(game:GetService("Stats").Network.ServerStatsItem["Data Ping"]:GetValue())
task.wait(1);
end
end)
local PlayerClass = {};
PlayerClass.__index = PlayerClass;
function PlayerClass.new()
local self = setmetatable({}, PlayerClass); do
self.Player = game:GetService("Players").LocalPlayer;
self.Character = self.Player.Character or self.Player.CharacterAdded:Wait();
end
self.Player.CharacterAdded:Connect(function()
self.Character = self.Player.Character;
if self.CharacterAdded then
self.CharacterAdded();
end
end)
return self;
end
local Bar = {};
Bar.__index = Bar;
function Bar.new()
local self = PlayerClass.new(); do
setmetatable(self, Bar);
self.ShotMeterUI = self.Character:WaitForChild("ShotMeterUI");
self.MeterFrame = self.ShotMeterUI:WaitForChild("Meter");
self.BarFrame = self.MeterFrame:WaitForChild("Bar");
self.CharacterAdded = function()
self.ShotMeterUI = self.Character:WaitForChild("ShotMeterUI");
self.MeterFrame = self.ShotMeterUI:WaitForChild("Meter");
self.BarFrame = self.MeterFrame:WaitForChild("Bar");
end
end
return self;
end
function Bar:GetSize()
return self.BarFrame.Size
end
local MarketplaceInfo = {};
MarketplaceInfo.__index = MarketplaceInfo;
function MarketplaceInfo.new()
local self = setmetatable({}, MarketplaceInfo); do
self.Service = game:GetService("MarketplaceService");
self.Cache = {};
end
return self;
end
function MarketplaceInfo:GetAssetName(id)
if self.Cache[tostring(id)] then
return self.Cache[tostring(id)];
end
local Success, Result = pcall(self.Service.GetProductInfo, self.Service, id); do
if Success then
self.Cache[tostring(id)] = Result.Name;
return self.Cache[tostring(id)];
end
end
end
local AnimationLogger = {};
AnimationLogger.__index = AnimationLogger;
function AnimationLogger.new()
local self = PlayerClass.new(); do
setmetatable(self, AnimationLogger);
self.Marketplace = MarketplaceInfo.new();
self.Humanoid = self.Character:WaitForChild("Humanoid");
self.Animator = self.Humanoid:WaitForChild("Animator");
self.CharacterAdded = function()
self.Humanoid = self.Character:WaitForChild("Humanoid");
self.Animator = self.Humanoid:WaitForChild("Animator");
end
end
return self;
end
function AnimationLogger:GetPlayingAnimations()
return self.Animator:GetPlayingAnimationTracks()
end
function AnimationLogger:IsPlayingAnimation(id)
local AnimationTracks = self.Animator:GetPlayingAnimationTracks();
local Yes = false;
for _, v in pairs(AnimationTracks) do
for i, b in pairs(getgenv().Equations) do
if i == v.Animation.AnimationId and v.Animation.AnimationId == id then
Yes = true;
break;
end
end
if Yes then
break;
end
end
return Yes;
end
function AnimationLogger:LogTracks()
local AnimationTracks = self.Animator:GetPlayingAnimationTracks();
for i,v in pairs(AnimationTracks) do
local AnimationName = self.Marketplace:GetAssetName(tonumber(string.match(v.Animation.AnimationId, "%d+")));
print(AnimationName, v.Animation.AnimationId);
end
end
function AnimationLogger:GetShotValue()
local Entry = nil;
for i, v in pairs(getgenv().Equations) do
if self:IsPlayingAnimation(i) then
Entry = v;
break;
end
end
return Entry
end
local Shot = false;
local ShotLogger = {};
ShotLogger.__index = ShotLogger;
function ShotLogger.new()
local self = setmetatable({}, ShotLogger); do
self.Bar = Bar.new();
self.AnimationLogger = AnimationLogger.new();
self.UserInputService = game:GetService("UserInputService");
self.AnimationId = ""
self.Timing = false;
self.LastUsed = 0;
end
self:Init();
return self;
end
function ShotLogger:ParseIntoString()
local Ping = PingObject:GetAverage();
local Size = self.Bar:GetSize().Y.Scale;
local String = string.format("{%s, %s}", Ping, tostring(Size))
return String;
end
function ShotLogger:Init()
local function findTForValue(v)
return math.log(v.ReleaseWindow / v.a) / v.b;
end
local function solve(v, t)
return v.a * math.exp(v.b * t);
end
local list = {};
local doneGraphing = false;
local start;
game.Players.LocalPlayer.Character:GetAttributeChangedSignal("ShotMeter"):Connect(function()
if getgenv().Graph and not doneGraphing then
if not start then
start = os.clock();
print("new shot");
end
local value = game.Players.LocalPlayer.Character:GetAttribute("ShotMeter");
local t = os.clock() - start;
table.insert(list, {t, value})
if value >= 2 then
doneGraphing = true;
end
print(t, value);
end
if not self.Timing and (tick() - self.LastUsed) > 3 and not getgenv().Graph then
self.Timing = true;
if not start then start = os.clock() end;
local data = self.AnimationLogger:GetShotValue()
if not data then
self.Timing = false;
start = nil;
return;
end
local targetValue = data.ReleaseWindow
local predictedTime = findTForValue(data)
if data.UseBar then
while game.Players.LocalPlayer.Character:GetAttribute("ShotMeter") < solve(data, predictedTime - (PingObject:GetAverage() / 1000)) do
task.wait()
end
else
while os.clock() - start < (predictedTime - (PingObject:GetAverage() / 1000)) do
task.wait()
end
end
game.ReplicatedStorage.GameEvents.ClientAction:FireServer("Shoot", false);
self.Timing = false;
start = nil;
end
end)
game:GetService("ReplicatedStorage"):WaitForChild("GameEvents"):WaitForChild("ClientAction").OnClientEvent:Connect(function(...)
local Arguments = {...};
if Arguments[1] == "Show Shot Feedback" then
if self.Callback then self.Callback(Arguments[2]) end
end
end)
task.spawn(function()
while true do
if doneGraphing then
local string = "";
for i,v in pairs(list) do
string = string .. v[1] .. ", " .. v[2] .. "\n";
end
writefile("newAnimation.txt", string);
doneGraphing = false;
start = nil;
warn('saved');
end
task.wait()
end
end)
end
ShotLogger.new();
local a = AnimationLogger.new();
task.spawn(function()
while true do
if getgenv().LogAnimations then
a:LogTracks();
end
task.wait(1)
end
end)
warn("tobiware")Editor is loading...
Leave a Comment