var screen_size = Global.GetScreenSize();



//Polygon Points
LPx = [(screen_size[0] /2) - 50, (screen_size[1] /2) + 10];
LPy = [(screen_size[0] /2) - 50, (screen_size[1] /2) - 10];
LPz = [(screen_size[0] /2) - 70, (screen_size[1] /2)];
RPx = [(screen_size[0] /2) + 50, (screen_size[1] /2) + 10];
RPy = [(screen_size[0] /2) + 50, (screen_size[1] /2) - 10];
RPz = [(screen_size[0] /2) + 70, (screen_size[1] /2)];
LPxx = [(screen_size[0] /2) - 49, (screen_size[1] /2) + 12];
LPyy = [(screen_size[0] /2) - 49, (screen_size[1] /2) - 12];
LPzz = [(screen_size[0] /2) - 73, (screen_size[1] /2)];
RPxx = [(screen_size[0] /2) + 49, (screen_size[1] /2) + 12];
RPyy = [(screen_size[0] /2) + 49, (screen_size[1] /2) - 12];
RPzz = [(screen_size[0] /2) + 73, (screen_size[1] /2)];
BPx = [(screen_size[0] /2) + 10, (screen_size[1] /2) + 50];
BPy = [(screen_size[0] /2) - 10, (screen_size[1] /2) + 50];
BPz = [(screen_size[0] /2), (screen_size[1] /2) + 70];
BPxx = [(screen_size[0] /2) + 12, (screen_size[1] /2) + 49];
BPyy = [(screen_size[0] /2) - 12, (screen_size[1] /2) + 49];
BPzz = [(screen_size[0] /2), (screen_size[1] /2) + 73];

       
function drawString()
{

    isFakeduck = UI.IsHotkeyActive("Anti-Aim", "Extra", "Fake duck");
    isDoubletap = UI.IsHotkeyActive("Rage", "Exploits", "Doubletap");
    localplayer_index = Entity.GetLocalPlayer( );
    localplayer_alive = Entity.IsAlive( localplayer_index );
    
    x = screen[0]/2 + 5
    y = screen[1]/2 + 70

    var difference = Math.abs( Local.GetRealYaw( ) - Local.GetFakeYaw( ) );
    
    if (localplayer_alive == true){


	
	Render.String(screen_size[0] /2 + 1, screen_size[1] /2 +60, 1, "FAKE", [ 0, 0, 0, 255 ], 7 );
    Render.String(screen_size[0] /2 + 1, screen_size[1] /2 +70, 1, isDoubletap ? "DoubleTap" : "DoubleTap", isDoubletap ? [ 0, 0, 0, 255 ] : [ 0, 0, 0, 255 ], 7 );
   
    

    Render.String(screen_size[0] /2, screen_size[1] /2 +60, 1, "FAKE", [ difference * 255 / 58, 255 - ( difference * 255 / 58 ), 180 , 255], 7 );
    Render.String(screen_size[0] /2, screen_size[1] /2 +70, 1, isDoubletap ? "DoubleTap" : "DoubleTap", isDoubletap ? [ 255, 105, 180, 255 ] : [ 255, 0, 0, 255 ], 7 );
    
    
    

}}

function do_indicators( )
{

    const me = entity_get_local_player( );


    if (!entity_is_valid(me) || !entity_is_alive(me))
        return;


    const y = render_get_screen_size( )[1];


    const yaw = local_get_real_yaw( ), fake = local_get_fake_yaw( );
    var delta = Math.round(normalize_yaw(yaw - fake) / 2), abs = Math.abs(delta);


    if (menu.get(ref_ragebot))
        delta *= -1;



    render_filled_rect(12, y - 68, 64, 4, [10, 10, 10, 125]);


    render_filled_rect(43, y - 67, 1, 2, [232, 232, 232, 200]);


    render_string(41, y - 63, 1, abs.toString( ), [232, 232, 232, 200], 3);
    render_circle(48, y - 61, 1, [232, 232, 232, 200]);


    if (delta > 0)
    {

        render_filled_rect(44, y - 67, abs * 31 / 60, 2, [232, 232, 232, 200]);
        return;
    }


    render_filled_rect(44 - abs * 31 / 60, y - 67, abs * 31 / 60, 2, [232, 232, 232, 200]);
}




function Main()
{
    Global.RegisterCallback("Draw", "drawString")

}

Main();





function HSVtoRGB(h, s, v)
{
    var r, g, b, i, f, p, q, t;

    i = Math.floor(h * 6);
    f = h * 6 - i;
    p = v * (1 - s);
    q = v * (1 - f * s);
    t = v * (1 - (1 - f) * s);

    switch (i % 6)
    {
        case 0: r = v, g = t, b = p; break;
        case 1: r = q, g = v, b = p; break;
        case 2: r = p, g = v, b = t; break;
        case 3: r = p, g = q, b = v; break;
        case 4: r = t, g = p, b = v; break;
        case 5: r = v, g = p, b = q; break;
    }

    return { r: Math.round(r * 255), g: Math.round(g * 255), b: Math.round(b * 255) };
}

function watermark()
{
 

   var invert = UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter" );

	
	
	if(invert)
	{
		Render.String(x - 11, y - 65, 0, ">", [255, 105, 180, 255], 36);
		Render.String(x - 40, y - 65, 0, "<", [216, 191, 216, 70], 36);
		
	}
	else
	{
		Render.String(x - 40, y - 65, 0, "<", [255, 105, 180, 255], 36);
		Render.String(x - 11, y - 65, 0, ">", [216, 191, 216, 70], 36);
		
	}
	
   
}


Global.RegisterCallback("Draw", "watermark");
UI.AddSliderFloat("RGB", 0.36, 1.0);
UI.SetValue("MISC", "JAVASCRIPT", "Script Items", "RGB", 0.1);

var oldTick = Global.Tickcount()
var ticksToDelay = 1 //1 second you can do the math from this point :D

UI.AddCheckbox("Rainbow glow pulse");
;


var alpha = 50
var up = true
function rainbowColors()
{
    var min_alpha = 50

    var enabled = UI.GetValue("Misc", "JAVASCRIPT", "Script Items", "Rainbow glow pulse");
    var speed = 1
    if (Entity.IsValid(Entity.GetLocalPlayer()) && enabled) {
        var curTick = Global.Tickcount()
        if (oldTick > curTick + ticksToDelay * speed * 3) {
            oldTick = Global.Tickcount()
        }
        if (curTick > oldTick + (ticksToDelay * speed)){
            if (up) {
                alpha += 10
            }
            if (!up) {
                alpha -= 10
            }
            oldTick = Global.Tickcount()
        }
        if (alpha >= 255) {
            alpha = 255
            up = false
        }
        if (alpha <= min_alpha) {
            alpha = min_alpha
            up = true
        }
        tickcount = Global.Tickcount();
        color = HSVtoRGB(tickcount % 350 / 350, 1, 1, 1, 255);
		UI.SetColor("Visual", "SELF", "Chams", "Desync Color", [color.r, color.g, color.b, alpha]);
		UI.SetColor("Visual", "SE1LF", "ESP", "Taser range", [color.r, color.g, color.b, alpha]);
		UI.SetColor("Visual", "SELF", "ESP", "Knife range", [color.r, color.g, color.b, alpha]);
  
    }
}
Global.RegisterCallback("Draw", "rainbowColors");




function coinToss() {

  return Math.floor(Math.random() * 2);

}

coinToss();

function getRandomInt(min, max) {
  return Math.floor(Math.random() * (max - min)) + min;
}

getRandomInt(10, 20)

var fakel = UI.GetValue("MISC", "JAVASCRIPT", "Script Items", "Fakelag");
var trigger = UI.GetValue("MISC", "JAVASCRIPT", "Script Items", "Trigger");

var BreakLeg = true
var Loop = 1;
var Loop2 = 1;


function legss () {

    var Amount = 5 * 0
    if (BreakLeg == true) {
        if ( Loop2 > Amount ) {
			UI.SetValue("Misc", "GENERAL", "Movement", "Slide walk", 1)




			



            Loop2 = 0;
            BreakLeg = false
        }
    }else if (BreakLeg == false) {
        if ( Loop2 > Amount ){
			UI.SetValue("Misc", "GENERAL", "Movement", "Slide walk", 0)








            Loop2 = 0;
            BreakLeg = true
        }
    }

    Loop2 = Loop2 + 1;
}

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



function main(){

    var FakeOffset = UI.GetValue ("Misc", "JAVASCRIPT", "Script Items", "REAL SETTINGS")



    var inverted = UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter" )


if(inverted){
      AntiAim.SetOverride(1);
        AntiAim.SetFakeOffset(getRandomInt(6, 8));
        AntiAim.SetRealOffset(-getRandomInt(14, 16));
        AntiAim.SetLBYOffset(getRandomInt(21, 23));
    } else {
        AntiAim.SetOverride(1);
        AntiAim.SetFakeOffset(-getRandomInt(8, 10));
        AntiAim.SetRealOffset(getRandomInt(14, 16));
        AntiAim.SetLBYOffset(-getRandomInt(21, 23));
    }



}

var run = false;
var estimate = 0;
var firstBuy = 0;
var alias = [
	["awp", "vesthelm"],
    ["ssg08", "vesthelm"],
    ["scar20", "g3sg1", "vesthelm"]
]



function roundEnded() {
    run = true;
    estimate = Globals.Curtime()+Convar.GetInt("mp_round_restart_delay");
    firstBuy = 0;
}

function purchase(index) {
    alias[index].forEach(function(v) { Cheat.ExecuteCommand("buy "+v); })
    run = false;
}

function onDraw() {
    run && Globals.Curtime()+(Local.Latency()/1000) >= estimate && purchase(UI.GetValue.apply(this, dropdown));
}

function purchased() {
    if (firstBuy == 0) firstBuy = Globals.Curtime()-estimate;
    if (!Entity.GetEntityFromUserID(Event.GetInt("userid")) || firstBuy == -1) return;

    Cheat.Print("Buy " + firstBuy + "s, you purchased at " + (Globals.Curtime()-estimate) + "s.\n");
    firstBuy = -1;
}

var dropdown = UI.AddDropdown("Fastest Autobuy", ["AWP", "Scout", "Auto", "none"]);

Cheat.RegisterCallback("round_end", "roundEnded");
Cheat.RegisterCallback("Draw", "onDraw");
Cheat.RegisterCallback("item_purchase", "purchased");

Cheat.RegisterCallback("CreateMove", "main");
UI.AddSliderInt( "Aspect ratio", 0, 500 );

function fsn( ) {
    ui_arat_val = UI.GetValue( "Aspect ratio" );

    switch ( Global.FrameStage( ) ) {
        case 5: {
            Global.ExecuteCommand( "r_aspectratio " + ui_arat_val.toString()/100 );

            break;
        }
        default: break;
    }
}


Global.RegisterCallback( "FrameStageNotify", "fsn" );


function can_shift_shot(ticks_to_shift) {
    var me = Entity.GetLocalPlayer();
    var wpn = Entity.GetWeapon(me);

    if (me == null || wpn == null)
        return false;

    var tickbase = Entity.GetProp(me, "CCSPlayer", "m_nTickBase");
    var curtime = Globals.TickInterval() * (tickbase-ticks_to_shift)

    if (curtime < Entity.GetProp(me, "CCSPlayer", "m_flNextAttack"))
        return false;

    if (curtime < Entity.GetProp(wpn, "CBaseCombatWeapon", "m_flNextPrimaryAttack"))
        return false;

    return true;
}

function _TBC_CREATE_MOVE() {
    var is_charged = Exploit.GetCharge()
   
    Exploit[(is_charged != 1 ? "Enable" : "Disable") + "Recharge"]()

    if (can_shift_shot(14) && is_charged != 1) {
        Exploit.DisableRecharge();
        Exploit.Recharge()
    }
}

function _TBC_UNLOAD() {
    Exploit.EnableRecharge();
}

Cheat.RegisterCallback("CreateMove", "_TBC_CREATE_MOVE");
Cheat.RegisterCallback("Unload", "_TBC_UNLOAD");

UI.AddCheckbox("Display indicator")
UI.AddHotkey("Heavy Pistol Override")
UI.AddSliderInt("Heavy Pistol Mindmg", 0, 130)
UI.AddHotkey("Scout Override")
UI.AddSliderInt("Scout Mindmg", 0, 130)
UI.AddHotkey("AWP Override")
UI.AddSliderInt("AWP Mindmg", 0, 130)
UI.AddHotkey("Auto Override")
UI.AddSliderInt("Auto Mindmg", 0, 130)

var heavy_cache = UI.GetValue("Rage", "HEAVY PISTOL", "Targeting", "Minimum damage")
var scout_cache = UI.GetValue("Rage", "SCOUT", "Targeting", "Minimum damage")
var awp_cache = UI.GetValue("Rage", "AWP", "Targeting", "Minimum damage")
var auto_cache = UI.GetValue("Rage", "AUTOSNIPER", "Targeting", "Minimum damage")
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 isAutoSniper(name)
{
    if(name == "scar 20" || weapon_name == "g3sg1")
    {
        return true
    }
}
function onCM()
{
    heavy_value = UI.GetValue("Script items", "Heavy Pistol Mindmg")
    scout_value = UI.GetValue("Script items", "Scout Mindmg")
    awp_value = UI.GetValue("Script items", "AWP Mindmg")
    auto_value = UI.GetValue("Script items", "Auto Mindmg")
    weapon_name = Entity.GetName(Entity.GetWeapon(Entity.GetLocalPlayer()))
    
    if (isActive("Heavy Pistol Override") && isHeavyPistol(weapon_name))
    {
        setValue("HEAVY PISTOL", heavy_value)
    }
    else{
        setValue("HEAVY PISTOL", heavy_cache)
    }
    
    if (isActive("Scout Override") && weapon_name == "ssg 08")
    {
        setValue("SCOUT", scout_value)
    }
    else{
        setValue("SCOUT", scout_cache)
    }

    if (isActive("AWP Override") && weapon_name == "awp")
    {
        setValue("AWP", awp_value)
    }
    else{
        setValue("AWP", awp_cache)
    }

    if (isActive("Auto Override") && isAutoSniper(weapon_name))
    {
        
        setValue("AUTOSNIPER", auto_value)
    }
    else
    {
        setValue("AUTOSNIPER", auto_cache)
    }
    
}
function indicator()
{
    screen = Render.GetScreenSize()
    wep = Entity.GetName(Entity.GetWeapon(Entity.GetLocalPlayer()))
    x = screen[0]/2 + 5
    y = screen[1]/2 + 70
    heavy = "DMG: " + UI.GetValue("Rage", "HEAVY PISTOL", "Targeting", "Minimum damage")
	
    scout = "DAMAGE: " + UI.GetValue("Rage", "SCOUT", "Targeting", "Minimum damage")
    awp = "DAMAGE: " + UI.GetValue("Rage", "AWP", "Targeting", "Minimum damage")
    auto = "DAMAGE: " + UI.GetValue("Rage", "AUTOSNIPER", "Targeting", "Minimum damage")
    var str = ""
    if (UI.GetValue("Script items", "Display indicator") && Entity.IsValid(Entity.GetLocalPlayer()) && Entity.IsAlive(Entity.GetLocalPlayer()))
    {
        if (isHeavyPistol(wep))
        {
            str = heavy
        }
        else if(wep == "ssg 08")
        {
            str = scout
        }
        else if(wep == "awp")
        {
            str = awp
        }
        else if (isAutoSniper(wep))
        {
            str = auto
        }
    }
    Render.String(x - 29, y + 15, 0, str+"", [255,255,255,255], 3)
}
Cheat.RegisterCallback("Draw", "indicator")
Cheat.RegisterCallback("CreateMove", "onCM")