require("spreadthebutter");
local Original_FireBullets = debug.getregistry().Entity.FireBullets;
debug.getregistry().Entity.FireBullets = function(...)
hook.Call("FireBullets", GAMEMODE || GM || _G || {}, ...);
Original_FireBullets(...);
end
local tblCones = {
["weapon_smg1"] = -0.04362,
["weapon_pistol"] = -0.0100,
["weapon_ar2"] = 0.02618
};
local function Hooked_FireBullets(pEntity, bulletInfo, suppressHostEvents)
if (!pEntity) then
return;
end
if (!IsValid(pEntity)) then
return;
end
if (pEntity != LocalPlayer()) then
return;
end
local pWeapon = pEntity:GetActiveWeapon() || nil;
if (!pWeapon) then
return;
end
if (!IsValid(pWeapon)) then
return;
end
local strWeaponClass = pWeapon:GetClass() || "unknown_class";
local flWeaponCone = bulletInfo.Spread || 0.0;
tblCones[strWeaponClass] = flWeaponCone;
end
hook.Add("FireBullets", "Hooked_FireBullets", Hooked_FireBullets);
local function PredictSpread(CUserCmd, angAngle)
local pWeapon = LocalPlayer():GetActiveWeapon() || nil;
if (!pWeapon) then
return angAngle;
end
if (!IsValid(pWeapon)) then
return angAngle;
end
local strWeaponClass = pWeapon:GetClass() || "unknown_class";
if (tblCones[strWeaponClass]) then
local angCone = Angle(0, 0, 0);
local outCone = tblCones[strWeaponClass];
local bIsNumber = tonumber(outCone);
local bIsVector = (type(outCone) == "Vector");
if (bIsNumber) then
angCone = Vector(-outCone, -outCone, -outCone);
elseif (bIsVector) then
angCone = outCone * -1;
end
return DS_manipulateShot(DS_md5PseudoRandom(CUserCmd:CommandNumber()), angAngle:Forward(), angCone):Angle() || angAngle;
end
return angAngle;
end