Nospread code for dickwrap with dickwrap dl
Can somebody post an code in the comments with the download for original or standard dickwrap and the code for the module to nospread?
int GetWeaponCone(lua_State* L)
{
if (LUA->IsType(1, Type::USERCMD) && LUA->IsType(2, Type::ANGLE) && LUA->IsType(3, Type::VECTOR))
{
CUserCmd* cmd = GET(CUserCmd*, 1);
uint uiSeed = MD5_PseudoRandom(cmd->command_number) & 0x7FFFFFFF;
RandomSeed(uiSeed & 255);
QAngle qAngs = *GET(QAngle*, 2);
Vector* vSpread = GET(Vector*, 3);
float x = RandomFloat(-0.5, 0.5) + RandomFloat(-0.5, 0.5);
float y = RandomFloat(-0.5, 0.5) + RandomFloat(-0.5, 0.5);
QAngle spreadAngles;
Vector forward, right, up;
AngleVectors(qAngs, &forward, &right, &up);
Vector vecDir = forward + (x * vSpread->x * right) + (y * vSpread->y * up);
VectorAngles(vecDir, spreadAngles);
spreadAngles -= qAngs;
ILuaInterface* gLua = new ILuaInterface(L);
gLua->GetGlobal("Angle")->Push();
gLua->Push(spreadAngles.x);
gLua->Push(spreadAngles.y);
gLua->Push(spreadAngles.z);
gLua->Call(3, 1);
gLua->Push(gLua->GetReturn(1));
}
return 1;
}
--norecoil
local Angle = Angle;
local pcall = pcall;
local require = require;
local print = print;
local Vector = Vector;
local math = math;
local fa;
local e, err = pcall(function() require("dickwrap") end);
if(err) then print("nononono"); return; end
local ofb = em.FireBullets;
local cones = {};
local nullvec = Vector() * -1;
function em.FireBullets(p, data)
local spread = data.Spread * -1;
local class = p:GetActiveWeapon():GetClass();
if (spread != cones[class] && spread != nullvec) then
cones[class] = spread;
end
return(ofb(p, data));
end
local function PredictSpread(ucmd, ang)
local w = LocalPlayer():GetActiveWeapon();
if (!w || !w:IsValid() || !cones[w:GetClass()]) then return ang; end
local ang = (dickwrap.Predict(ucmd, ang:Forward(), cones[w:GetClass()])):Angle();
ang.y, ang.x = math.NormalizeAngle(ang.y), math.NormalizeAngle(ang.x);
return(ang);
end
hook.Add("CalcView", "", function(p, o, a, f)
local view = {};
view.angles = (fa && fa || a);
view.fov = f;
view.origin = o;
return view;
end);
hook.Add("CreateMove", "", function(ucmd)
if(!fa) then fa = ucmd:GetViewAngles(); end
fa = fa + Angle(ucmd:GetMouseY() * .023, ucmd:GetMouseX() * -.023, 0);
fa.p, fa.y, fa.x = math.Clamp(fa.p, -89, 89), math.NormalizeAngle(fa.y), math.NormalizeAngle(fa.x);
local ang = fa;
if(ucmd:KeyDown(IN_ATTACK)) then
ang = PredictSpread(ucmd, ang);
end
ucmd:SetViewAngles(ang);
end);