var easing = {
lerp: function(a, b, percentage) {
return a + (b - a) * percentage
}
}
var mouse_on_object = function(x, y, length, height) {
var cursor = Input.GetCursorPosition()
if (cursor[0] > x && cursor[0] < x + length && cursor[1] > y && cursor[1] < y + height)
return true
return false
}
Render.Arc = function(x, y, radius, radius_inner, start_angle, end_angle, segments, color) {
segments = 360 / segments
for (var i = start_angle; i < start_angle + end_angle; i = i + segments) {
var rad = i * Math.PI / 180
var rad2 = (i + segments) * Math.PI / 180
var rad_cos = Math.cos(rad)
var rad_sin = Math.sin(rad)
var rad2_cos = Math.cos(rad2)
var rad2_sin = Math.sin(rad2)
var x1_inner = x + rad_cos * radius_inner
var y1_inner = y + rad_sin * radius_inner
var x1_outer = x + rad_cos * radius
var y1_outer = y + rad_sin * radius
var x2_inner = x + rad2_cos * radius_inner
var y2_inner = y + rad2_sin * radius_inner
var x2_outer = x + rad2_cos * radius
var y2_outer = y + rad2_sin * radius
Render.Polygon([[x1_outer, y1_outer], [x2_outer, y2_outer], [x1_inner, y1_inner]], color)
Render.Polygon([[x1_inner, y1_inner], [x2_outer, y2_outer], [x2_inner, y2_inner]], color)
}
}
function calcDist(local, target) {
var lx = local[0];
var ly = local[1];
var lz = local[2];
var tx = target[0];
var ty = target[1];
var tz = target[2];
var dx = lx - tx;
var dy = ly - ty;
var dz = lz - tz;
return Math.sqrt(dx * dx + dy * dy + dz * dz);
}
var ind_x = UI.AddSliderInt("bomb_ind_x", 0, Global.GetScreenSize()[0])
var ind_y = UI.AddSliderInt("bomb_ind_y", 0, Global.GetScreenSize()[1])
UI.SetEnabled("Script items", "bomb_ind_x", false)
UI.SetEnabled("Script items", "bomb_ind_y", false)
var ind_theme = UI.AddDropdown("Timer theme", ["Dark Blue", "Light", "Dark"])
var timer = {
theme: {
color: {
[0]: {
r: 13,
g: 18,
b: 31,
t_r: 255,
t_g: 255,
t_b: 255
},
[1]: {
r: 204,
g: 204,
b: 204,
t_r: 0,
t_g: 0,
t_b: 0
},
[2]: {
r: 15,
g: 15,
b: 15,
t_r: 255,
t_g: 255,
t_b: 255
}
}
},
stored: false,
drag: new Array(0, 0, 0),
on_draw: function() {
var set = {
x: UI.GetValue.apply(null, ind_x),
y: UI.GetValue.apply(null, ind_y),
width: 212,
height: 40,
}
var font = {
icon: Render.AddFont("bomb", 23, 400),
main: Render.AddFont("MuseoSansCyrl-700", 10, 700),
second: Render.AddFont("MuseoSansCyrl-700", 8, 700)
}
var color = timer.theme.color[UI.GetValue.apply(null, ind_theme)]
var c4 = Entity.GetEntitiesByClassID(129)[0]
if(c4 != undefined) {
var bomb_timer = (Entity.GetProp(c4, "CPlantedC4", "m_flC4Blow") - Globals.Curtime())
var bombsite = Entity.GetProp(c4, "CPlantedC4", "m_nBombSite")
var isbombticking = Entity.GetProp(c4, "CPlantedC4", "m_bBombTicking")
var bomb_site = "None"
var distance = calcDist(Entity.GetRenderOrigin(c4), Entity.GetRenderOrigin(Entity.GetLocalPlayer()))
var armor = Entity.GetProp(Entity.GetLocalPlayer(), "CCSPlayerResource", "m_iArmor")
var health = Entity.GetProp(Entity.GetLocalPlayer(), "CBasePlayer", "m_iHealth")
var a = 450.7;
var b = 75.68;
var c = 789.2;
var d = (distance - b) / c
var damage = a * Math.exp(-d * d)
if(armor > 0) {
var newDmg = damage * 0.5
var armorDmg = (damage - newDmg) * 0.5
if(armorDmg > armor) {
armor = armor * (1 / .5)
newDmg = damage - armorDmg
}
damage = newDmg;
}
var dmg = parseInt(damage);
var gotdefused = Entity.GetProp(c4, "CPlantedC4", "m_bBombDefused")
var isbeingdefused = Entity.GetProp(c4, "CPlantedC4", "m_hBombDefuser")
var deftimer = (Entity.GetProp(c4, "CPlantedC4", "m_flDefuseCountDown") - Globals.Curtime())
var d_time = Entity.GetProp(Entity.GetLocalPlayer(), "CCSPlayer", "m_bHasDefuser") ? 5 : 10
bomb_timer = isbeingdefused > 0 ? deftimer : bomb_timer
if (bomb_timer <= 0) {
bomb_timer = 0
}
if (bombsite == 0) {
bomb_site = "A"
} else {
bomb_site = "B"
}
if(!isbombticking) return
if(gotdefused) return
Render.FilledRect(set.x, set.y - 1, set.width - 2, set.height, [color.r, color.g, color.b, 160])
Render.FilledRect(set.x - 1, set.y, set.width, set.height - 2, [color.r, color.g, color.b, 160])
Render.StringCustom(set.x + 7, set.y + 3, 0, "W", [color.t_r, color.t_g, color.t_b, 240], font.icon)
Render.StringCustom(set.x + 46, set.y + 3, 0, "Site: ", [color.t_r, color.t_g, color.t_b, 240], font.main)
Render.StringCustom(set.x + 46 + Render.TextSizeCustom("Site: ", font.main)[0], set.y + 3, 0, bomb_site, [43, 155, 255, 240], font.main)
Render.StringCustom(set.x + 46, set.y + 20, 0, "Damage: ", [color.t_r, color.t_g, color.t_b, 240], font.main)
Render.StringCustom(set.x + 46 + Render.TextSizeCustom("Damage: ", font.main)[0], set.y + 20, 0, dmg.toString(), dmg >= health ? [255, 74, 74, 255] : [43, 155, 255, 240], font.main)
Render.Arc(set.x + 186, set.y + 18 , 17, 14, 0, 360, 20, UI.GetValue.apply(null, ind_theme) == 1 ? [17, 17, 17, 50] : [255, 255, 255, 15])
Render.Arc(set.x + 186, set.y + 18 , 17, 14, -90, bomb_timer / (isbeingdefused > 0 ? d_time : Convar.GetInt("mp_c4timer")) * 360, 20, [72, 161, 75, 255], [43, 155, 255, 255])
Render.StringCustom(set.x + 187, set.y + 13, 1, bomb_timer.toFixed(1), [color.t_r, color.t_g, color.t_b, 240], font.second)
}
var cursor = Input.GetCursorPosition()
if(mouse_on_object(set.x, set.y, set.width, set.height)){
if ((Input.IsKeyPressed(0x01)) && (timer.drag[0] == 0)) {
timer.drag[0] = 1
timer.drag[1] = set.x - cursor[0]
timer.drag[2] = set.y - cursor[1]
}
}
if (!Input.IsKeyPressed(0x01)) timer.drag[0] = 0
if (timer.drag[0] == 1 && UI.IsMenuOpen()) {
UI.SetValue("Script items", "bomb_ind_x", cursor[0] + timer.drag[1])
UI.SetValue("Script items", "bomb_ind_y", cursor[1] + timer.drag[2])
}
}
}
Cheat.RegisterCallback("Draw", "timer.on_draw")