UI.AddLabel("          enoyaw by shify#7361");
UI.AddCheckbox("Enable");
UI.AddCheckbox("Show currently mindamage");
UI.AddHotkey("Minimum Damage Override");
UI.AddSliderInt("General Mindmg", 0, 130);
UI.AddSliderInt("Pistol Mindmg", 0, 130);
UI.AddSliderInt("Heavy Pistol Mindmg", 0, 130);
UI.AddSliderInt("Scout Mindmg", 0, 130);
UI.AddSliderInt("AWP Mindmg", 0, 130);
UI.AddSliderInt("Auto Mindmg", 0, 130);

// auto
setDMG_auto = false
setDMG_auto_return = true
// awp
setDMG_awp = false
setDMG_awp_return = true
// scout
setDMG_scout = false
setDMG_scout_return = true
// heavy pistol
setDMG_HVpistol = false
setDMG_HVpistol_return = true
// pistol
setDMG_pistol = false
setDMG_pistol_return = true
// general
setDMG_general = false
setDMG_general_return = true

function SetEnabled()
{

    if (UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Enable"))
	{
		UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Show currently mindamage", 1);
		UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Minimum Damage Override", 1);
		UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "General Mindmg", 1);
	    UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Pistol Mindmg", 1);
        UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Heavy Pistol Mindmg", 1);
        UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Scout Mindmg", 1);
        UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "AWP Mindmg", 1);
        UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Auto Mindmg", 1);
	}
	else
	{
		UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Show currently mindamage", 0);
		UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Minimum Damage Override", 0);
		UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "General Mindmg", 0);
	    UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Pistol Mindmg", 0);
        UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Heavy Pistol Mindmg", 0);
        UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Scout Mindmg", 0);
        UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "AWP Mindmg", 0);
        UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Auto Mindmg", 0);
    }
}

function isActive(a)
{
    return UI.IsHotkeyActive("Script items", a)
}
function setValue(cat, value)
{
    UI.SetValue("Rage", cat.toUpperCase(), "Targeting", "Minimum damage", value)
}


function isHeavyPistol(name)
{
    if (name == "r8 revolver" || name == "desert eagle")
    {
        return true
    }
}

function isPistol(name)
{
    if (name == "glock 18" || name == "five seven" || name == "dual berettas" || name == "p250" || name == "tec 9" || name == "usp s" || name == "cz75 auto" || name == "p2000")
    {
        return true
    }
}

function isAutoSniper(name)
{
    if(name == "scar 20" || name == "g3sg1")
    {
        return true
    }
}

function onCM()
{
	var general_value = UI.GetValue("Script items", "General Mindmg")
	var pistol_value = UI.GetValue("Script items", "Pistol Mindmg")
	var heavy_value = UI.GetValue("Script items", "Heavy Pistol Mindmg")
    var scout_value = UI.GetValue("Script items", "Scout Mindmg")
    var awp_value = UI.GetValue("Script items", "AWP Mindmg")
    var auto_value = UI.GetValue("Script items", "Auto Mindmg")
	local_weapon_name =  Entity.GetName(Entity.GetWeapon(Entity.GetLocalPlayer()))

	// GENERAL

        if (isActive("Minimum Damage Override"))
        {
			if (!setDMG_general)
			{
			   general_cache = UI.GetValue("Rage", "GENERAL", "Targeting", "Minimum damage")
			   setValue("GENERAL", general_value)
			   setDMG_general = true
               setDMG_general_return = false
			}
        }
        else
	    {
			if (!setDMG_general_return)
			{
		       setValue("GENERAL", general_cache)
		       setDMG_general = false
               setDMG_general_return = true
			}
		}	

	// PISTOL

	if (isPistol(local_weapon_name))
	{
        if (isActive("Minimum Damage Override"))
        {
			if (!setDMG_pistol)
			{
			   pistol_cache = UI.GetValue("Rage", "PISTOL", "Targeting", "Minimum damage")
			   setValue("PISTOL", pistol_value)
			   setDMG_pistol = true
               setDMG_pistol_return = false
			}
        }
        else
	    {
			if (!setDMG_pistol_return)
			{
		       setValue("PISTOL", pistol_cache)
		       setDMG_pistol = false
               setDMG_pistol_return = true
			}
		}
	}

	// HEAVY PISTOL

	if (isHeavyPistol(local_weapon_name))
	{
        if (isActive("Minimum Damage Override"))
        {
			if (!setDMG_HVpistol)
			{
			   HVpistol_cache = UI.GetValue("Rage", "HEAVY PISTOL", "Targeting", "Minimum damage")
			   setValue("HEAVY PISTOL", heavy_value)
			   setDMG_HVpistol = true
               setDMG_HVpistol_return = false
			}
        }
        else
	    {
			if (!setDMG_HVpistol_return)
			{
		       setValue("HEAVY PISTOL", HVpistol_cache)
		       setDMG_HVpistol = false
               setDMG_HVpistol_return = true
			}
		}
	}

	// SCOUT

	if (local_weapon_name == "ssg 08")
	{
        if (isActive("Minimum Damage Override"))
        {
			if (!setDMG_scout)
			{
			   scout_cache = UI.GetValue("Rage", "SCOUT", "Targeting", "Minimum damage")
			   setValue("SCOUT", scout_value)
			   setDMG_scout = true
               setDMG_scout_return = false
			}
        }
        else
	    {
			if (!setDMG_scout_return)
			{
		       setValue("SCOUT", scout_cache)
		       setDMG_scout = false
               setDMG_scout_return = true
			}
		}
	}

	// AWP

	if (local_weapon_name == "awp")
	{
        if (isActive("Minimum Damage Override"))
        {
			if (!setDMG_awp)
			{
			   awp_cache = UI.GetValue("Rage", "AWP", "Targeting", "Minimum damage")
			   setValue("AWP", awp_value)
			   setDMG_awp = true
               setDMG_awp_return = false
			}
        }
        else
	    {
			if (!setDMG_awp_return)
			{
		       setValue("AWP", awp_cache)
		       setDMG_awp = false
               setDMG_awp_return = true
			}
		}
	}

	// AUTO

	if (isAutoSniper(local_weapon_name))
	{
        if (isActive("Minimum Damage Override"))
        {
			if (!setDMG_auto)
			{
			   auto_cache = UI.GetValue("Rage", "AUTOSNIPER", "Targeting", "Minimum damage")
			   setValue("AUTOSNIPER", auto_value)
			   setDMG_auto = true
               setDMG_auto_return = false
			}
        }
        else
	    {
			if (!setDMG_auto_return)
			{
		       setValue("AUTOSNIPER", auto_cache)
		       setDMG_auto = false
               setDMG_auto_return = true
			}
		}
	}
}

function indicator()
{
    render_get_screen_size = Render.GetScreenSize
    const y = render_get_screen_size()[1];
	wep = Entity.GetName(Entity.GetWeapon(Entity.GetLocalPlayer()))
	general = UI.GetValue("Rage", "GENERAL", "Targeting", "Minimum damage")
	pistol = UI.GetValue("Rage", "PISTOL", "Targeting", "Minimum damage")
    heavy = UI.GetValue("Rage", "HEAVY PISTOL", "Targeting", "Minimum damage")
    scout = UI.GetValue("Rage", "SCOUT", "Targeting", "Minimum damage")
    awp = UI.GetValue("Rage", "AWP", "Targeting", "Minimum damage")
    auto = UI.GetValue("Rage", "AUTOSNIPER", "Targeting", "Minimum damage")
	font = Render.AddFont("Verdana", 18, 700);

    var str = ""
    if (UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Enable") && UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Show currently mindamage") && Entity.IsValid(Entity.GetLocalPlayer()) && Entity.IsAlive(Entity.GetLocalPlayer()))
    {
		if (isPistol(wep))
        {
            str = pistol
        }
        else if (isHeavyPistol(wep))
        {
            str = heavy
        }
        else if(wep == "ssg 08")
        {
            str = scout
        }
        else if(wep == "awp")
        {
            str = awp
        }
        else if (isAutoSniper(wep))
        {
            str = auto
        }
		else
		{
			str = general
		}
    }
         Render.StringCustom(18, y - 312, 0, str+"", [ 100, 149, 237, 255 ], font);
         Render.StringCustom(17, y - 312, 0, str+"", [100, 149, 237, 255], font)
}

Global.RegisterCallback("Draw", "SetEnabled");
Cheat.RegisterCallback("CreateMove", "onCM");
Cheat.RegisterCallback("Draw", "indicator");

var keybinds = [];
keybinds.push({path: ["Rage", "Exploits", "Hide shots"], name: "Hide-shots"});
keybinds.push({path: ["Rage", "GENERAL", "Exploits", "Doubletap"], name: "Double-tap"});
keybinds.push({path: ["Rage", "GENERAL", "Force body aim"], name: "Body-aim"});
keybinds.push({path: ["Anti-Aim", "Fake angles", "Inverter"], name: "AA Switch"});
keybinds.push({path: ["Rage", "GENERAL", "Force safe point"], name: "Force Safepoint"});
keybinds.push({path: ["Misc", "Movement", "Auto peek"], name: "Auto Peek"});
keybinds.push({path: ["Anti-Aim", "Extra", "Slow walk"], name: "Slow Walk"});
keybinds.push({path: ["Anti-Aim", "Extra", "Fake duck"], name: "Fake Duck"});


const print = function(text, color){
    if(color == undefined)
    Cheat.Print(text.toString() + "\n");
    else
    Cheat.PrintColor(color, text.toString() + "\n");
}

const getval = function(name){
    return UI.GetValue("Script items", name);
}

const setval = function(name, value){
    return UI.SetValue("Script items", name, value);
}

const getcol = function(name){
    return UI.GetColor("Script items", name);
}

const get_active_keybinds = function(){
    var ret = [];
    for(var i in keybinds){
        if(UI.IsHotkeyActive.apply(null, keybinds[i].path))
            ret.push(keybinds[i].name);
    }
    return ret;
}

const get_spectators = function()
{
    const players = Entity.GetPlayers();
    var spectators = [];
    for (var i = 0; i < players.length; i++)
    {
        const m_hObserverTarget = Entity.GetProp(players[i], "CBasePlayer", "m_hObserverTarget");
        if (m_hObserverTarget !== "m_hObserverTarget") {
            if (m_hObserverTarget === Entity.GetLocalPlayer())
            {
                const name = Entity.GetName(players[i]);
                spectators.push(name.length >= 22 ? name.substr(0, 20) + "..." : name);
            }
        }
    }
    return spectators;
}

const point_in_rect = function(pos, min, max, debug) {
    if(debug) {
        if(pos[0] > min[0] && pos[1] > min[1] && pos[0] < max[0] && pos[1] < max[1])
             Render.Rect(min[0], min[1], max[0] - min[0], max[1] - min[1], [0, 255, 0, 255])
        else Render.Rect(min[0], min[1], max[0] - min[0], max[1] - min[1], [255, 0, 0, 255])             
    }
    return pos[0] > min[0]
        && pos[1] > min[1]
        && pos[0] < max[0]
        && pos[1] < max[1];
}

const get_dropdown_value = function(value, index)
{
    const mask = 1 << index;
    return value & mask ? true : false;
}

Cheat.Print("\nLoaded ");
Cheat.PrintColor([255,0,0,255], keybinds.length + " ");
print("keybinds!\n");
print("You may add yours by using:");
Cheat.PrintColor([62,95,138,255], 'keybinds.push({path: ["Legit", "Triggerbot", "Enabled"], name: "Trigger bot"}); ');
print("for example.");

const screen_size = Global.GetScreenSize();

const render_container = function(x1, y1, w, h, name, color1, color2, font, to_write, state, custom){

    if(getval(name + "_x") <= 0){
        UI.AddCheckbox(name+" stored");
        UI.AddSliderInt(name+"_x", 1, screen_size[0]);
        UI.AddSliderInt(name+"_y", 1, screen_size[0]);
        UI.AddSliderInt(name+"_x_off", 1, screen_size[0]);
        UI.AddSliderInt(name+"_y_off", 1, screen_size[0]);
        setval(name+"_x", x1);
        setval(name+"_y", y1);
        UI.SetEnabled("Script items", name+" stored", false);
        UI.SetEnabled("Script items", name+"_x", false);
        UI.SetEnabled("Script items", name+"_y", false);
        UI.SetEnabled("Script items", name+"_x_off", false);
        UI.SetEnabled("Script items", name+"_y_off", false);
    }

    const cursor_pos = Input.GetCursorPosition();
    if(UI.IsMenuOpen() && Input.IsKeyPressed(0x1)){
        if(point_in_rect(cursor_pos, [getval(name+"_x"), getval(name+"_y")], [getval(name+"_x") + w, getval(name+"_y") + h])){
            if(getval(name + " stored") == 0){
                setval(name+"_x_off", cursor_pos[0] - getval(name+"_x"));
                setval(name+"_y_off", cursor_pos[1] - getval(name+"_y"));
                setval(name + " stored", 1);
            }
            setval(name+"_x", cursor_pos[0] - getval(name+"_x_off"));
            setval(name+"_y", cursor_pos[1] - getval(name+"_y_off"));
        }
    } else if(getval(name + " stored")) setval(name + " stored", 0);

    x = getval(name+"_x");
    y = getval(name+"_y");
    
    Render.GradientRect(x, y, w, 2, 1, color1, color2);
    Render.GradientRect(x + 1, y + 2, w - 2, h, 0, [0, 0, 0, 125], [0,0,0,0]);
    
    const text_size = Render.TextSizeCustom(name, font);
    Render.FilledCircle(x + 12, y + 12, text_size[1] / 2 + 1, [20,20,20,255]);
    Render.FilledCircle(x + 12 + text_size[0], y + 12, text_size[1] / 2 + 1, [20,20,20,255]);
    Render.FilledRect(x + 12, y + 6, text_size[0], text_size[1] + 1, [20,20,20,255]);

    Render.StringCustom(x + 13, y + 6, 0, name, [255,255,255,255], font);
    Render.StringCustom(x + w - 27, y + 6, 0, "<", [255,255,255,255], font);
    Render.FilledCircle(x + w - 14, y + 12, 6, [20,20,20,100]);
    Render.StringCustom(x + w - 16, y + 5, 0, "x", [255,255,255,255], font);

    const text_size_state = Render.TextSizeCustom(state, font);
    for(var i in to_write){
        if(custom != null){
            const text_size_state = Render.TextSizeCustom(custom[i], font);
            state = custom[i];
        }
        Render.StringCustom(x + 10, y + 25 + (i * 13), 0, to_write[i], [100, 149, 237, 255], font);
        Render.StringCustom(x + w - text_size_state[0] - 15, y + 25 + (i * 13), 0, "[" + state + "]", [100, 149, 237, 255], font);
    }
}








UI.AddMultiDropdown( "Windows", [ "enoyaw" ] );
UI.AddCheckbox("Only with information");
UI.AddColorPicker("color 1");
UI.AddColorPicker("color 2");
UI.AddCheckbox("indicators");

const watermark = [Cheat.GetUsername().length > 14 ? Cheat.GetUsername().substr(0,14) + "..." : Cheat.GetUsername(), World.GetServerString() != "" ? World.GetServerString() : "unknown", Math.round(Local.Latency() * 1000 - 16).toString(), Globals.Tickrate().toString()];
const watermark_custom = ["user", "server", "latency", "tickrate"];
const for_test = ["chk:", "dsy:", "hit:","spd:","hgt:","ping:","dmg:"];
const main = function(){
    const font = Render.AddFont("Verdana", 7, 300);

    if(get_dropdown_value(getval("Windows"), 0)){
        const active_binds = get_active_keybinds();
        if(!(active_binds.length <= 0 && getval("Show windows only with information")))
        render_container(300, 300, 150, 25, "enoyaw", getcol("Gradient color 1"), getcol("Gradient color 2"), font, active_binds, "on")
    }

    if(get_dropdown_value(getval("Windows"), 1)){
        const spectators = get_spectators();
        if(!(spectators.length <= 0 && getval("Show windows only with information")))
        render_container(300, 450, 200, 25, "Spectators", getcol("Gradient color 1"), getcol("Gradient color 2"), font, spectators, "watching")
    }
    if(getval("indicators"))
        render_container(300, 100, 150, 25, "indicators", getcol("Gradient color 1"), getcol("Gradient color 1"), font, for_test, "22")
}
Cheat.RegisterCallback("Draw", "main");


var screen_size = Render.GetScreenSize();







/*
Quake Flying damage numbers...
*/

//Vars
var iVictim_index, First_pos, Second_pos, Third_pos, Fourth_pos, Fifth_pos, First, Second, Third, Fourth, Five, iDamageCount = iOffsetCount = YOffsetFirst = YOffsetSecond = YOffsetThird = YOffsetFourth = YOffsetFive = loadFont = HitAttack = 0;  

//Store coordinates array
const first_screen_pos = [], second_screen_pos = [], third_screen_pos = [], fourth_screen_pos = [], fifth_screen_pos = [];

//>_<
//Damage event
function EVENT_PLAYER_HURT()
{
    //Get attacker
    iAttacker = Event.GetInt("attacker"); iAttacker_index = Entity.GetEntityFromUserID(iAttacker);
   
    //Get victim
    iVictim = Event.GetInt("userid"); iVictim_index = Entity.GetEntityFromUserID(iVictim);  
   
    if(Entity.GetLocalPlayer() == iVictim_index && Entity.GetLocalPlayer() !== iAttacker_index)    return;
   
    //BEGIN ANIM
    if(Entity.GetLocalPlayer() == iAttacker_index)
    {
        //First hit
        HitAttack = 1;
       
        //Reset every 5 hit
        if(iDamageCount == 5) iDamageCount = 0; if(iOffsetCount == 5) iOffsetCount = 0;
       
        //Collect them and set only 5 hits
        iDamageCount+=1;
       
        //This is offset for Y for each
        iOffsetCount+=1;        
       
        //This shit reads every hit with a new var...
        if(iDamageCount == 1)    {    First = Event.GetInt("dmg_health");    First_pos = Entity.GetRenderOrigin(iVictim_index);    }  
        if(iDamageCount == 2)    {    Second = Event.GetInt("dmg_health");    Second_pos = Entity.GetRenderOrigin(iVictim_index);    }              
        if(iDamageCount == 3)    {    Third = Event.GetInt("dmg_health");    Third_pos = Entity.GetRenderOrigin(iVictim_index);    }      
        if(iDamageCount == 4)    {    Fourth = Event.GetInt("dmg_health");    Fourth_pos = Entity.GetRenderOrigin(iVictim_index);    }      
        if(iDamageCount == 5)    {    Five = Event.GetInt("dmg_health");    Fifth_pos = Entity.GetRenderOrigin(iVictim_index);    }

        //Setup offsets
        if(iOffsetCount == 1)    YOffsetFirst = 255; if(iOffsetCount == 2)    YOffsetSecond = 255; if(iOffsetCount == 3)    YOffsetThird = 255; if(iOffsetCount == 4)    YOffsetFourth = 255; if(iOffsetCount == 5)    YOffsetFive = 200;              
    }      
}

function HUD_REDRAW()
{
    //Once and lock font load
    if(loadFont == 0)
    {
        //this font u can get here https://onetap.su/threads/beta-in-development-onetap-hud-engine-0-1-dev-18945-18952-dec-27-2019.13647/
        fontSM2 = Render.AddFont("Verdana", 8, 550)
        loadFont = 1;
    }
   
    /*Render.StringCustomCustom(Global.GetScreenSize()[0]/2, Global.GetScreenSize()[1]/2, 1, "" + iDamageCount, [ 255, 255, 255, 255 ], fontSM2);
    Render.StringCustomCustom(Global.GetScreenSize()[0]/2, Global.GetScreenSize()[1]/2+50, 1, "" + iOffsetCount, [ 255, 255, 255, 255 ], fontSM2);*/

    //Stop flooding
    if(!HitAttack || !getCustomValue('Quake Damage Numbers'))    return;

    //Doing cycle through all players will affect on FPS heavily... so
    if(Entity.IsValid(iVictim_index))
    {
         
   
        //Setup x,y,z
        if(iDamageCount < 6)    
		{
			first_screen_pos = Render.WorldToScreen(First_pos);
			second_screen_pos = Render.WorldToScreen(Second_pos);
			third_screen_pos = Render.WorldToScreen(Third_pos);
		}
		
		color = UI.GetColor("Misc", "JAVASCRIPT", "Script items", "Color");
        //Five pieces of damage, the hell
			Render.StringCustom(first_screen_pos[0]-15+1, first_screen_pos[1]-50+YOffsetFirst-255+1, 1, "" + First, [ 0, 0,0, YOffsetFirst ], fontSM2);
			Render.StringCustom(first_screen_pos[0]-15, first_screen_pos[1]-50+YOffsetFirst-255, 1, "" + First, alp( color, YOffsetFirst ), fontSM2);
		
			Render.StringCustom(second_screen_pos[0]+15+1, second_screen_pos [1]-50+YOffsetSecond-255+1, 1, "" + Second, [ 0, 0, 0, YOffsetSecond ], fontSM2);
			Render.StringCustom(second_screen_pos[0]+15, second_screen_pos [1]-50+YOffsetSecond-255, 1, "" + Second, alp( color, YOffsetSecond ), fontSM2);
		
			Render.StringCustom(third_screen_pos[0]-25+1, third_screen_pos[1]-50+YOffsetThird-255+1, 1, "" + Third, [ 0,0,0, YOffsetThird ], fontSM2);
			Render.StringCustom(third_screen_pos[0]-25, third_screen_pos[1]-50+YOffsetThird-255, 1, "" + Third, alp( color, YOffsetThird ), fontSM2);
		
			Render.StringCustom(fourth_screen_pos[0]+25+1, fourth_screen_pos[1]-50+YOffsetFourth-255+1, 1, "" + Fourth, [ 0, 0, 0, YOffsetFourth ], fontSM2);
			Render.StringCustom(fourth_screen_pos[0]+25, fourth_screen_pos[1]-50+YOffsetFourth-255, 1, "" + Fourth, alp(color, YOffsetFourth ), fontSM2);
		
			Render.StringCustom(fifth_screen_pos[0]-10+1, fifth_screen_pos[1]-50+YOffsetFive-255+1, 1, "" + Five, [ 0, 0, 0, YOffsetFive ], fontSM2);
			Render.StringCustom(fifth_screen_pos[0]-10, fifth_screen_pos[1]-50+YOffsetFive-255, 1, "" + Five, alp( color, YOffsetFive ), fontSM2);
		
    }      
}  

function getCustomValue(name)
{
    var value = UI.GetValue("Misc", "JAVASCRIPT", "Script items", name);
    return value;
}

function pushY()
{
	//Push Y
        if(YOffsetFirst > 1)    YOffsetFirst--; if(YOffsetSecond > 1)    YOffsetSecond--; if(YOffsetThird > 1)    YOffsetThird--; if(YOffsetFourth > 1)    YOffsetFourth--; if(YOffsetFive > 1)    YOffsetFive--; 
}

function alp(c, a) {
  return [c[0], c[1], c[2], a]
}

function Main()
{
    Global.RegisterCallback("Draw", "HUD_REDRAW");
    Global.RegisterCallback("player_hurt", "EVENT_PLAYER_HURT");
	Global.RegisterCallback("CreateMove", "pushY");
    UI.AddCheckbox('Quake Damage Numbers');
	UI.AddColorPicker("Color");
	UI.AddCheckbox("Premade Settings");
}

Main();


UI.AddDropdown("Anti Bruteforce", ["Off", "On Hit", "On Shot"]);
function GetScriptOption(name)
{
    var Value = UI.GetValue("Misc", "JAVASCRIPT", "Script items", name);
    return Value;
}

function radian(degree)
{
    return degree * Math.PI / 180.0;
}

function ExtendVector(vector, angle, extension)
{
    var radianAngle = radian(angle);
    return [extension * Math.cos(radianAngle) + vector[0], extension * Math.sin(radianAngle) + vector[1], vector[2]];
}

function VectorAdd(a, b)
{
    return [a[0] + b[0], a[1] + b[1], a[2] + b[2]];
}

function VectorSubtract(a, b)
{
    return [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
}

function VectorMultiply(a, b)
{
    return [a[0] * b[0], a[1] * b[1], a[2] * b[2]];
}

function VectorLength(x, y, z)
{
    return Math.sqrt(x * x + y * y + z * z);
}

function VectorNormalize(vec)
{
    var length = VectorLength(vec[0], vec[1], vec[2]);
    return [vec[0] / length, vec[1] / length, vec[2] / length];
}

function VectorDot(a, b)
{
    return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
}

function VectorDistance(a, b)
{
    return VectorLength(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
}

function ClosestPointOnRay(target, rayStart, rayEnd)
{
    var to = VectorSubtract(target, rayStart);
    var dir = VectorSubtract(rayEnd, rayStart);
    var length = VectorLength(dir[0], dir[1], dir[2]);
    dir = VectorNormalize(dir);

    var rangeAlong = VectorDot(dir, to);
    if (rangeAlong < 0.0)
    {
        return rayStart;
    }
    if (rangeAlong > length)
    {
        return rayEnd;
    }
    return VectorAdd(rayStart, VectorMultiply(dir, [rangeAlong, rangeAlong, rangeAlong]));
}

function Flip()
{
    UI.ToggleHotkey("Anti-Aim", "Fake angles", "Inverter");
}

var lastHitTime = 0.0;
var lastImpactTimes =
[
    0.0
];
var lastImpacts =
[
    [0.0, 0.0, 0.0]
];

function OnHurt()
{
    if (GetScriptOption("Anti Bruteforce") == 0) return;
    if (Entity.GetEntityFromUserID(Event.GetInt("userid")) !== Entity.GetLocalPlayer()) return;
    var hitbox = Event.GetInt('hitgroup');

    if (hitbox == 1 || hitbox == 6 || hitbox == 7)  //head, both toe
    {
        var curtime = Global.Curtime();
        if (Math.abs(lastHitTime - curtime) > 0.5)   //0.2s backtrack + 0.2 extand + 0.1 extra
        {
            lastHitTime = curtime;
            Flip();
        }
    }
}

function OnBulletImpact()
{
    if (GetScriptOption("Anti Bruteforce") !== 2) return;

    var curtime = Global.Curtime();
    if (Math.abs(lastHitTime - curtime) < 0.5) return;

    var entity = Entity.GetEntityFromUserID(Event.GetInt("userid"));
    var impact = [Event.GetFloat("x"), Event.GetFloat("y"), Event.GetFloat("z"), curtime];
    var source;
    if (Entity.IsValid(entity) && Entity.IsEnemy(entity))
    {
        if (!Entity.IsDormant(entity))
        {
            source = Entity.GetEyePosition(entity);
        }
        else if (Math.abs(lastImpactTimes[entity] - curtime) < 0.1)
        {
            source = lastImpacts[entity];
        }
        else
        {
            lastImpacts[entity] = impact;
            lastImpactTimes[entity] = curtime;
            return;
        }
        var local = Entity.GetLocalPlayer();
        var localEye = Entity.GetEyePosition(local);
        var localOrigin = Entity.GetProp(local, "CBaseEntity", "m_vecOrigin");
        var localBody = VectorMultiply(VectorAdd(localEye, localOrigin), [0.5, 0.5, 0.5]);

        var bodyVec = ClosestPointOnRay(localBody, source, impact);
        var bodyDist = VectorDistance(localBody, bodyVec);
        
        if (bodyDist < 85.0)       //he clearly shot at us!
        {
            var realAngle = Local.GetRealYaw();
            var fakeAngle = Local.GetFakeYaw();

            var headVec = ClosestPointOnRay(localEye, source, impact);
            var headDist = VectorDistance(localEye, headVec);
            var feetVec = ClosestPointOnRay(localOrigin, source, impact);
            var feetDist = VectorDistance(localOrigin, feetVec);

            var closestRayPoint;
            var realPos;
            var fakePos;

            if (bodyDist < headDist && bodyDist < feetDist)     //that's a pelvis
            {                                                   //pelvis direction = goalfeetyaw + 180       
                closestRayPoint = bodyVec;
                realPos = ExtendVector(bodyVec, realAngle + 180.0, 10.0);
                fakePos = ExtendVector(bodyVec, fakeAngle + 180.0, 10.0);
            }
            else if (feetDist < headDist)                       //ow my toe
            {                                                   //toe direction = goalfeetyaw -30 +- 90
                closestRayPoint = feetVec;
                var realPos1 = ExtendVector(bodyVec, realAngle - 30.0 + 60.0, 10.0);
                var realPos2 = ExtendVector(bodyVec, realAngle - 30.0 - 60.0, 10.0);
                var fakePos1 = ExtendVector(bodyVec, fakeAngle - 30.0 + 60.0, 10.0);
                var fakePos2 = ExtendVector(bodyVec, fakeAngle - 30.0 - 60.0, 10.0);
                if (VectorDistance(feetVec, realPos1) < VectorDistance(feetVec, realPos2))
                {
                    realPos = realPos1;
                }
                else
                {
                    realPos = realPos2;
                }
                if (VectorDistance(feetVec, fakePos1) < VectorDistance(feetVec, fakePos2))
                {
                    fakePos = fakePos1;
                }
                else
                {
                    fakePos = fakePos2;
                }
            }
            else                                                //ow my head i feel like i slept for 2 days
            {
                closestRayPoint = headVec;
                realPos = ExtendVector(bodyVec, realAngle, 10.0);
                fakePos = ExtendVector(bodyVec, fakeAngle, 10.0);
            }

            if (VectorDistance(closestRayPoint, fakePos) < VectorDistance(closestRayPoint, realPos))        //they shot at our fake. they will probably not gonna shoot it again.
            {
                lastHitTime = curtime;
                Flip();
            }
        }

        lastImpacts[entity] = impact;
        lastImpactTimes[entity] = curtime;
    }
}

Cheat.RegisterCallback("player_hurt", "OnHurt");
Cheat.RegisterCallback("bullet_impact", "OnBulletImpact");
  




UI.AddLabel(" Antiaim            ");
UI.AddSliderInt("Antiaim_x", 0, Global.GetScreenSize()[0]);
UI.AddSliderInt("Antiaim_y", 0, Global.GetScreenSize()[1]);
UI.AddColorPicker("changing the color");
var color = UI.GetColor("Misc", "JAVASCRIPT", "Script items", "poloska blya");

if (color[3] == 0)
	UI.SetColor("Misc", "JAVASCRIPT", "Script items", "poloska blya", [102, 111, 99, 255]);

function in_bounds(vec, x, y, x2, y2) {
    return (vec[0] > x) && (vec[1] > y) && (vec[0] < x2) && (vec[1] < y2)
}

function draw_arc(x, y, radius, start_angle, percent, thickness, color) {
        var precision = (2 * Math.PI) / 30;
        var step = Math.PI / 180;
        var inner = radius - thickness;
        var end_angle = (start_angle + percent) * step;
        var start_angle = (start_angle * Math.PI) / 180;

        for (; radius > inner; --radius) {
            for (var angle = start_angle; angle < end_angle; angle += precision) {
                var cx = Math.round(x + radius * Math.cos(angle));
                var cy = Math.round(y + radius * Math.sin(angle));

                var cx2 = Math.round(x + radius * Math.cos(angle + precision));
                var cy2 = Math.round(y + radius * Math.sin(angle + precision));

                Render.Line(cx, cy, cx2, cy2, color);
            }
        }
}

function main_aa() {
    if (!World.GetServerString()) return;

    const x = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Antiaim_x"),
        y = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Antiaim_y");

    var font = Render.AddFont("Verdana", 7, 100);
    var RealYaw = Local.GetRealYaw();
    var FakeYaw = Local.GetFakeYaw();
    var delta = Math.min(Math.abs(RealYaw - FakeYaw) / 2, 60).toFixed(1);
    var safety = Math.min(Math.round(1.7 * Math.abs(delta)), 100);
    if (UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter")) {
        var side = "<";
    } else {
        var side = ">";
    }
    var text = "FAKE (" + delta.toString() + "  ) | safety: " + safety.toString() + "% | side: " + side;
    var w = Render.TextSizeCustom(text, font)[0] + 8;
    var x3 = x - w - 3;
    color = UI.GetColor("Misc", "JAVASCRIPT", "Script items", "poloska blya");

    Render.FilledRect(x3, y + 2, 2, 18, [ color[0], color[1], color[2], 255 ]);
    Render.StringCustom(x + 5 - w, y + 5, 0, text, [0, 0, 0, 180], font);
    Render.StringCustom(x + 4 - w, y + 4, 0, text, [255, 255, 255, 255], font);
    Render.Circle(x + 5 - w + Render.TextSizeCustom("FAKE (" + delta.toString(), font)[0], y + 8, 1, [255, 255, 255, 255]);
    if (Global.IsKeyPressed(1) && UI.IsMenuOpen()) {
        const mouse_pos = Global.GetCursorPosition();
        if (in_bounds(mouse_pos, x - w, y, x + w, y + 30)) {
            UI.SetValue("Misc", "JAVASCRIPT", "Script items", "Antiaim_x", mouse_pos[0] + w / 2);
            UI.SetValue("Misc", "JAVASCRIPT", "Script items", "Antiaim_y", mouse_pos[1] - 20);
        }
    }
}
Global.RegisterCallback("Draw", "main_aa");









UI.AddLabel(" strafefix");
var a = UI.AddSliderInt("Turn speed",200, 500)
function d()
{
    UI.SetValue("Misc", "GENERAL", "Movement", "Turn speed", UI.GetValue.apply(null,a))
}
Cheat.RegisterCallback("Draw", "d")




UI.AddCheckbox("Team based model")
UI.AddDropdown("CT Model", ["None", "'TwoTimes' McCoy", "Seal Team 6 Soldier", "Buckshot", "Lt. Commander Ricksaw", "Dragomir", "Rezan The Ready", "Maximus", "Blackwolf", "The Doctor' Romanov", "B Squadron Officer", "3rd Commando Company", "Special Agent Ava", "Operator", "Markus Delrow", "Michael Syfers", "Enforcer", "Slingshot", "Soldier", "The Elite Mr. Muhlik", "Ground Rebel", "Osiris", "Prof. Shahmat", "Heavy armor"])
UI.AddDropdown("T Model", ["None", "'TwoTimes' McCoy", "Seal Team 6 Soldier", "Buckshot", "Lt. Commander Ricksaw", "Dragomir", "Rezan The Ready", "Maximus", "Blackwolf", "The Doctor' Romanov", "B Squadron Officer", "3rd Commando Company", "Special Agent Ava", "Operator", "Markus Delrow", "Michael Syfers", "Enforcer", "Slingshot", "Soldier", "The Elite Mr. Muhlik", "Ground Rebel", "Osiris", "Prof. Shahmat", "Heavy armor"])

function onFSN(){
    if(Cheat.FrameStage() != 2)
        return
    var team = Entity.GetProp(Entity.GetLocalPlayer(),"DT_BaseEntity", "m_iTeamNum")
    if(!UI.GetValue("Script Items", "Team based model")){
        UI.SetEnabled("Script Items", "CT Model", false)
        UI.SetEnabled("Script Items", "T Model", false)
        return;
    }
    UI.SetEnabled("Script Items", "T Model", true)
    UI.SetEnabled("Script Items", "CT Model", true)
    if(team == 2){ // T
        UI.SetValue("Misc", "SKINS", "Player", "Player model", UI.GetValue("Script Items", "T Model"))
    }
    else if(team == 3){ // CT
        UI.SetValue("Misc", "SKINS", "Player", "Player model", UI.GetValue("Script Items", "CT Model"))
    }
}
Cheat.RegisterCallback("FrameStageNotify","onFSN")



var screen_size = Render.GetScreenSize();

UI.AddCheckbox("Indicator");
UI.AddColorPicker("Indicator color");

function draw() {
    local = Entity.GetLocalPlayer();
    if (!UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Indicator") || !Entity.IsValid(local) || !Entity.IsAlive(local)) return;
    font = Render.AddFont("Verdana", 8, 400);
    x = screen_size[0];
    y = screen_size[1];
    col = UI.GetColor("Misc", "JAVASCRIPT", "Script items", "Indicator color");
    real_yaw = Local.GetRealYaw();
    fake_yaw = Local.GetFakeYaw();
    delta = Math.min(Math.abs(real_yaw - fake_yaw) / 2, 40).toFixed(0);
    delta_size = Render.TextSizeCustom(delta, font);
    Render.StringCustom(x / 2, y / 2 + 20, 1, delta, [255, 255, 255, 255], font);
    Render.Circle(x / 2 + delta_size[0] - 2, y / 2 + 23, 1, [255, 255, 255, 255])
    Render.GradientRect(x / 2, y / 2 + 40, (125 / 110) * delta, 3, 1, col, [0, 0, 0, 0]);
    Render.GradientRect(x / 2 - (125 / 110) * delta + 1, y / 2 + 40, (125 / 110) * delta, 3, 1, [0, 0, 0, 0], col);
    {
		Render.String(screen_size[0] /2 -27, screen_size[1] /2 +50, 0, "ENOYAW", [ 236, 235, 189, 150 ],15 );
	}
}

Cheat.RegisterCallback("Draw", "draw");
