function draw_circle_3d(x, y, z, radius, degrees, start_at, clr, fill_clr) {
var accuracy = 8;
var old_x, old_y;
degrees = degrees < 361 && degrees || 360; degrees = degrees > -1 && degrees || 0
start_at = start_at + 1
for (rot = start_at; rot < degrees + start_at + 1; rot += start_at * accuracy) {
rot_r = rot * (Math.PI / 180)
line_x = radius * Math.cos(rot_r) + x, line_y = radius * Math.sin(rot_r) + y
var curr = Render.WorldToScreen([line_x, line_y, z]), cur = Render.WorldToScreen([x, y, z]);
if (cur[0] != null && curr[0] != null && old_x != null) {
Render.Polygon([[curr[0], curr[1]], [old_x, old_y], [cur[0], cur[1]]], fill_clr)
Render.Line(curr[0], curr[1], old_x, old_y, clr)
}
old_x = curr[0], old_y = curr[1];
}
}
UI.AddSubTab(["Visuals", "SUBTAB_MGR"], "Grenade visuals");
UI.AddCheckbox(["Visuals", "Grenade visuals", "SHEET_MGR", "Grenade visuals"], "Enable molotov radius");
UI.AddColorPicker(["Visuals", "Grenade visuals", "SHEET_MGR", "Grenade visuals"], "Molotov line color");
UI.AddColorPicker(["Visuals", "Grenade visuals", "SHEET_MGR", "Grenade visuals"], "Molotov radius color");
UI.AddSliderInt(["Visuals", "Grenade visuals", "SHEET_MGR", "Grenade visuals"], "", 0, 0);
UI.AddCheckbox(["Visuals", "Grenade visuals", "SHEET_MGR", "Grenade visuals"], "Enable smoke radius");
UI.AddColorPicker(["Visuals", "Grenade visuals", "SHEET_MGR", "Grenade visuals"], "Smoke line color");
UI.AddColorPicker(["Visuals", "Grenade visuals", "SHEET_MGR", "Grenade visuals"], "Smoke radius color");
var molotov = [];
const molotovStart = function () {
entity = Event.GetInt("entityid");
x = Event.GetFloat("x");
y = Event.GetFloat("y");
z = Event.GetFloat("z");
molotov.push({ entity: entity, position: [x, y, z] });
}
const molotovExpire = function () {
for (var i = 0; i < molotov.length; i++) {
if (molotov[i].entity == Event.GetInt("entityid")) {
molotov.splice(i, 1);
}
}
}
const molotovDraw = function () {
if (!UI.GetValue(["Visuals", "Grenade visuals", "SHEET_MGR", "Grenade visuals", "Enable molotov radius"])) return;
for (var i = 0; i < molotov.length; i++) {
vecOrigin = molotov[i].position;
const lineColor = UI.GetColor(["Visuals", "Grenade visuals", "SHEET_MGR", "Grenade visuals", "Molotov line color"]);
const radiusColor = UI.GetColor(["Visuals", "Grenade visuals", "SHEET_MGR", "Grenade visuals", "Molotov radius color"]);
draw_circle_3d(vecOrigin[0], vecOrigin[1], vecOrigin[2], 160, 360, 0, [lineColor[0], lineColor[1], lineColor[2], lineColor[3]], [radiusColor[0], radiusColor[1], radiusColor[2], radiusColor[3]]);
}
}
var smoke = [];
const smokeStart = function () {
entity = Event.GetInt("entityid");
x = Event.GetFloat("x");
y = Event.GetFloat("y");
z = Event.GetFloat("z");
smoke.push({ entity: entity, position: [x, y, z] });
}
const smokeExpire = function () {
for (var i = 0; i < smoke.length; i++) {
if (smoke[i].entity == Event.GetInt("entityid")) {
smoke.splice(i, 1);
}
}
}
const smokeDraw = function () {
if (!UI.GetValue(["Visuals", "Grenade visuals", "SHEET_MGR", "Grenade visuals", "Enable smoke radius"])) return;
for (var i = 0; i < smoke.length; i++) {
vecOrigin = smoke[i].position;
const lineColor = UI.GetColor(["Visuals", "Grenade visuals", "SHEET_MGR", "Grenade visuals", "Smoke line color"]);
const radiusColor = UI.GetColor(["Visuals", "Grenade visuals", "SHEET_MGR", "Grenade visuals", "Smoke radius color"]);
draw_circle_3d(vecOrigin[0], vecOrigin[1], vecOrigin[2], 160, 360, 0, [lineColor[0], lineColor[1], lineColor[2], lineColor[3]], [radiusColor[0], radiusColor[1], radiusColor[2], radiusColor[3]]);
}
}
const onDraw = function () {
molotovDraw();
smokeDraw();
}
const clearData = function () {
for (var i = 0; i < molotov.length; i++) {
molotov.splice(i, 1);
}
for (var i = 0; i < smoke.length; i++) {
smoke.splice(i, 1);
}
}
Cheat.RegisterCallback("round_start", "clearData");
Cheat.RegisterCallback("smokegrenade_detonate", "smokeStart");
Cheat.RegisterCallback("smokegrenade_expired", "smokeExpire");
Cheat.RegisterCallback("inferno_startburn", "molotovStart");
Cheat.RegisterCallback("inferno_expire", "molotovExpire");
Cheat.RegisterCallback("Draw", "onDraw");