var materials = []

UI.AddSliderInt("", 0, 0);
UI.AddLabel("Infinite.js");
UI.AddLabel("Karambot Aka. Cat HvH#1372");
UI.AddCheckbox( "Developer Mode" );
const getmultidrop = function(value, index) { const mask = 1 << index; return value & mask ? true : false; }
const addmultidropdown = function(name, list) { return UI.AddMultiDropdown(name, list); }
const getvalue = function(name) { return UI.GetValue("Script items", name); }
const adddropdown = function(name, list) { return UI.AddDropdown(name, list); }
const addtextbox = function(name) { return UI.AddTextbox(name); }
addmultidropdown("Watermark", ["Enable", "Username", "Time", "Ping", "Tickrate", "FPS"])
adddropdown("Watermark Location", ["Top left", "Top right", "Bottom left", "Botton right"])
addtextbox("Username")
addmultidropdown("Indicators", [ "Desync", "Inverter", "Doubletap", "Tickbase", "Keybinds", "Spectators"])
adddropdown("Indicators Style", ["Default", "Special" ])
function adjustAngle(angle) {
    if (angle < 0) {
        angle = (90 + angle * (-1));
    } else if (angle > 0) {
        angle = (90 - angle);
    }

    return angle;
}

function getCustomValue(name) {
    var value = UI.GetValue("MISC", "JAVASCRIPT", "Script items", name);
  
    return value;
  }
  
  function handler() {
    if (Global.FrameStage() != 2) {
      return;
    }
  
    var me = Entity.GetLocalPlayer();
  
    if (!getCustomValue('enable fake-score')) {
      return;
    }
  
    if (getCustomValue('kills') !== 0) {
      Entity.SetProp(me, 'CPlayerResource', 'm_iKills', getCustomValue('kills'));
    }
  
    if (getCustomValue('deaths') !== 0) {
      Entity.SetProp(me, 'CPlayerResource', 'm_iDeaths', getCustomValue('deaths'));
    }
  
    if (getCustomValue('assists') !== 0) {
      Entity.SetProp(me, 'CPlayerResource', 'm_iAssists', getCustomValue('assists'));
    }
  }
 
    UI.AddCheckbox('enable fake-score');
  
    UI.AddSliderInt('kills', 0, 300);
    UI.AddSliderInt('assists', 0, 300);
    UI.AddSliderInt('deaths', 0, 300);
  
    Global.RegisterCallback('FrameStageNotify', 'handler');
 

function drawArc(x, y, radius, start_angle, percent, thickness, color) {
    var precision = (2 * Math.PI) / 300;
    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 normalizeYaw(angle) {
angle = (angle % 360 + 360) % 360;
return angle > 180 ? angle - 360 : angle;
}

const screen_size = Global.GetScreenSize();
var stored = false;
var x_offs = 0;
var y_offs = 0;
UI.AddSliderInt("spectators x", 0, screen_size[0]);
UI.AddSliderInt("spectators y", 0, screen_size[1]);
UI.SetEnabled("Script items", "spectators x", false);
UI.SetEnabled("Script items", "spectators y", false);
const in_bounds = function(vec, x, y, x2, y2) {
    return (vec[0] > x) && (vec[1] > y) && (vec[0] < x2) && (vec[1] < y2)
}
const get_spectators = function() {
    var spectators = [];
    const players = Entity.GetPlayers();
    if (UI.IsMenuOpen( ) == true)
    {
    spectators.push("Spectator list");
    }
    for (i = 0; i < players.length; i++) {
        const cur = players[i];
        if (Entity.GetProp(cur, "CBasePlayer", "m_hObserverTarget") != "m_hObserverTarget") {
            const obs = Entity.GetProp(cur, "CBasePlayer", "m_hObserverTarget")
            if (obs === Entity.GetLocalPlayer()) {
                const name = Entity.GetName(cur);
                spectators.push(name);
            }
        }
    } return spectators;
}
const spectators = function() {
    if(!getmultidrop(getvalue("Indicators"), 5))
        return;
    const x = UI.GetValue("Script items", "spectators x"),
    y = UI.GetValue("Script items", "spectators y");
    const font = Render.AddFont("Calibri", 13, 600);
    const spects = Render.AddFont( "Microsoft JhengHei Light", 11.5, 100);
    //const icon = Render.AddFont("untitled-font-1", 14, 100);
    const names = get_spectators();
    if(getvalue("Indicators Style") == 0)
    {
    Render.FilledRect(x, y, 180, 26, [0, 0, 0, 179]);
    //Render.StringCustom(x + 5, y + 3, 0, "b", [0, 130, 255, 255], icon);
    Render.StringCustom(x + 52, y + 3, 0, "Spectators", [245, 245, 245, 255], font);
    Render.FilledRect(x, y + 24, 180, 26 + 19 * (names.length - 1), [0, 0, 0, 40]);
    for (i = 0; i < names.length; i++){
        Render.StringCustom(x + 10, y + 27 + 20 * i, 0, names[i], [245, 245, 245, 255], spects);
        //Render.StringCustom(x + 6, y + 26 + 20 * i, 0, "d", [200, 200, 200, 255], icon);
    }
}
else
{
    const main = Render.AddFont("Calibri", 12, 600)
    var I = names.length - 1
    if(names.length == 0)
        return;

        Render.GradientRect( x, y, 145, 33 + 17 * I, 1, [ 52, 100, 235, 255 ], [ 52, 100, 235, 0 ]);
        Render.FilledRect(x, y + 2, 155, 29 + 17 * I, [0, 0, 0, 255]);
        //Render.GradientRect( x, y + 2, 8, 29 + 17 * I, 1, [ 52, 100, 235, 255 ], [ 0, 0, 0, 255 ]);
        Render.GradientRect( x - 6, y, 6, 33 + 17 * I, 1, [ 52, 100, 235,0 ], [ 52, 100, 235, 255 ]);
        for (i = 0; i < names.length; i++){
        Render.StringCustom(x + 20, y + 6 + 16 * i, 0, names[i], [255, 255, 255, 255], main);
        }
}
    if(UI.IsMenuOpen() && Input.IsKeyPressed(0x1)){
        const mouse_pos = Global.GetCursorPosition();
        if (in_bounds(mouse_pos, x, y, x + 150, y + 30)) {
            if(!stored){
                x_offs = mouse_pos[0] - x;
                y_offs = mouse_pos[1] - y;
                stored = true;
            }
            UI.SetValue("Script items", "spectators x", mouse_pos[0] - x_offs);
            UI.SetValue("Script items", "spectators y", mouse_pos[1] - y_offs);
        }
    } else if(stored) stored = false;
}
Global.RegisterCallback("Draw", "spectators");









UI.AddDropdown( "Clantag", [ "Off", "Infinity"] );
var lasttime = 0;
const getstring = function(name) { return UI.GetString("Script items", name); }
UI.AddSliderInt("", 0, 0);
UI.AddLabel("Ragebot");
UI.AddLabel(" ");
UI.AddLabel("Ragebot Logging");
UI.AddCheckbox( "Output in chat" );
var InitiazedTag = 0;

UI.AddLabel(" ");

function Clantag(){
    var time = parseInt((Globals.Curtime() * 2))
    var tag = getvalue("Clantag");
    var speed = parseInt((Globals.Curtime() * 2))
    if (time != lasttime)
    {
        if(tag == 0 && InitiazedTag == 1) {  Local.SetClanTag(""); InitiazedTag = 0; }
        if(tag == 1)
        {
            if(InitiazedTag == 0)
                InitiazedTag = 1;

                switch((speed) % 20)
            {
            case 1: { Local.SetClanTag(" | "); break; }
            case 2: { Local.SetClanTag("I | "); break; }
            case 3: { Local.SetClanTag("In | "); break; }
            case 4: { Local.SetClanTag("Inf | "); break; }
            case 5: { Local.SetClanTag("Infi | "); break; }
            case 6: { Local.SetClanTag("Infin | "); break; }
            case 7: { Local.SetClanTag("Infini | "); break; }
            case 8: { Local.SetClanTag("Infinit | "); break; }
             case 9: { Local.SetClanTag("Infinite | "); break; }
            case 10: { Local.SetClanTag("Infinite  | "); break; }
            case 11: { Local.SetClanTag("Infinite   | "); break; }
            case 12: { Local.SetClanTag("Infinite  | "); break; }
            case 13: { Local.SetClanTag("Infinite | "); break; }
            case 14: { Local.SetClanTag("Infinit | "); break; }
            case 15: { Local.SetClanTag("Infini | "); break; }
            case 16: { Local.SetClanTag("Infin | "); break; }
            case 17: { Local.SetClanTag("Infi | "); break; }
            case 18: { Local.SetClanTag("Inf | "); break; }
            case 19: { Local.SetClanTag("In | "); break; }
            case 20: { Local.SetClanTag("I | "); break; }
	   
            }
        }
        
    }
    lasttime = time;
}

Cheat.RegisterCallback("CreateMove", "Clantag");
var iExploitID = 0;
var bDoubleTapped = false;
var bShouldRecharge = false;
var ForceCharge = false;
var iLastShotTime = 0;
UI.AddCheckbox("Instant Recharge");
UI.AddCheckbox("Improve Doubletap Recharge");
UI.AddDropdown("Recharge mode", ["None", "Agressive", "Passive"]);
UI.SetValue( "Rage", "GENERAL", "Exploits", "Doubletap", 1 );
UI.AddCheckbox( "Visible Minimum Damage" );
UI.AddSliderInt("Visible Min Damage", 0, 130);
UI.AddSliderInt("Occluded Min Damage", 0, 130);


function HandleVisibiltyMath()
{

    localPlayer_index = Entity.GetLocalPlayer();
    localPlayer_eyepos = Entity.GetEyePosition(localPlayer_index);
    enemies = Entity.GetEnemies();
    for ( i = 0; i < enemies.length; i++)
    {
        if (Entity.IsValid(enemies[i]) == true && Entity.IsAlive(enemies[i]) && Entity.IsDormant(enemies[i]) == false)
        {
        hitbox_pos = Entity.GetHitboxPosition(localPlayer_index, 0);
        bot_eyepos = Entity.GetEyePosition(enemies[i])
        
        w2s_s = Render.WorldToScreen(bot_eyepos)
        w2s_e = Render.WorldToScreen(hitbox_pos)
        Render.Line(w2s_s[0], w2s_s[1], w2s_e[0], w2s_e[1], [255, 255, 255, 255])
        Render.String(w2s_s[0], w2s_s[1], 0, "START", [255, 0, 0, 255])
        Render.String(w2s_e[0], w2s_e[1], 0, "END", [255, 0, 0, 255])
        }
    }
}

function HandleVisibiltyMathInUse()
{
    var Dev = getvalue("Developer Mode");
    var switchhh = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Visible Minimum Damage");
if(switchhh)
{
    localPlayer_index = Entity.GetLocalPlayer();
    localPlayer_eyepos = Entity.GetEyePosition(localPlayer_index);
    enemies = Entity.GetEnemies();
    
    for ( i = 0; i < enemies.length; i++)
    {
        if (Entity.IsValid(enemies[i]) == true && Entity.IsAlive(enemies[i]) && Entity.IsDormant(enemies[i]) == false)
        {
        hitbox_pos = Entity.GetHitboxPosition(localPlayer_index, 0);
        bot_eyepos = Entity.GetEyePosition(enemies[i])
        result = Trace.Bullet(enemies[i], localPlayer_index, bot_eyepos, hitbox_pos);

                if(result[2] == 1)
                {
                Ragebot.ForceTargetMinimumDamage(enemies[i], UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Visible Min Damage"))
            //Cheat.Print("Visible")
                }
                else 
                {
            Ragebot.ForceTargetMinimumDamage(enemies[i], UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Occluded Min Damage"))
            //Cheat.Print("Invisible")
                }
        if(Dev)
            Cheat.Print("Local::Trace->Entity[Ragebot::Main->GetTarget()]" + ".CallDamage(" + result[1] + "); \nLocal::Trace->Entity[Ragebot::Main->GetTarget()]" + ".Output = " + result[2] + "\nLocal::Trace->Entity[Ragebot::Main->GetTarget()].Result[15] ? Hitboxes[i] : 0 = " + result[3] + "\n")
        //Cheat.Print("Trace result:: " + Entity.GetName(enemies[i]) + " can see player: " + Entity.GetName(result[0]) + " damage:: " + result[1] + " visible:: " + result[2] + " hitbox :: " + result[3] + "\n")
        }
    }
}


}
//Cheat.RegisterCallback("Draw", "HandleVisibiltyMath");
Cheat.RegisterCallback("CreateMove", "HandleVisibiltyMathInUse");
function on_ragebot_fire()
{
    ragebot_target_exploit = Event.GetInt("exploit");
    if (UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Improve Doubletap Recharge"))
    {
        if (ragebot_target_exploit == 2)
        {
            UI.SetValue("Rage", "GENERAL", "Exploits", "Doubletap fast recovery", true);
        }
        else
        {
            UI.SetValue("Rage", "GENERAL", "Exploits", "Doubletap fast recovery", false);
        }
    }
}

function event_rbot_fire( ) {
    iExploitID = Event.GetInt( "exploit" );
    if ( !UI.GetValue( "Misc", "JAVASCRIPT", "Script Items", "Improve Doubletap Recharge" ) )
        return;

    if ( iExploitID == 2 ) {
        iLastShotTime = Global.Tickcount( );
        bDoubleTapped = true;
        UI.SetValue( "Rage", "GENERAL", "Exploits", "Doubletap", 0 );
        bShouldRecharge = true;
    }

    ForceCharge = bShouldRecharge ? true : false;

    if ( ForceCharge && Global.Tickcount( ) >= ( Global.TickInterval( ) * 10 + iLastShotTime ) )
        UI.SetValue( "Rage", "GENERAL", "Exploits", "Doubletap", 1 );
}

function modecheck()
{
  if(UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Recharge mode") == 1) { on_ragebot_fire(); }
  if(UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Recharge mode") == 2) { event_rbot_fire(); }
}

Global.RegisterCallback("ragebot_fire", "modecheck");

hitboxes = [
    'generic',
    'head',
    'chest',
    'stomach',
    'left arm',
    'right arm',
    'left leg',
    'right leg',
    '?'
];
var scriptitems = ("Misc", "JAVASCRIPT", "Script items");
var shots = 0;
var predicthc = 0;
var safety = 0;
var hitboxName = "";
var choked = 0;
var exploit = 0;
var logs = [];
var logsct = [];
var logsalpha = [];
function getHitboxName(index)
{
    switch (index)
    {
        case 0:
            hitboxName = "head";
            break;
        case 1:
            hitboxName = "head";
            break;
        case 2:
            hitboxName = "stomach";
            break;
        case 3:
            hitboxName = "stomach";
            break;
        case 4:
            hitboxName = "stomach";
            break;
        case 5:
            hitboxName = "chest";
            break;
        case 6:
            hitboxName = "chest";
            break;
        case 7:
            hitboxName = "left leg";
            break;
        case 8:
            hitboxName = "right leg";
            break;
        case 9:
            hitboxName = "left leg";
            break;
        case 10:
            hitboxName = "right leg";
            break;
        case 11:
            hitboxName = "left leg";
            break;
        case 12:
            hitboxName = "right leg";
            break;
        case 13:
            hitboxName = "left arm";
            break;
        case 14:
            hitboxName = "right arm";
            break;
        case 15:
            hitboxName = "left arm";
            break;
        case 16:
            hitboxName = "left arm";
            break;
        case 17:
            hitboxName = "right arm";
            break;
        case 18:
            hitboxName = "right arm";
            break;
        default:
            hitboxName = "body";
    }
    return hitboxName;
}
function HitgroupName(index) {
    return hitboxes[index] || 'body';
}

var target = -1;
var shots_fired = 0;
var hits = 0;
var lastUpdate = 0;
var logged = false;

function ragebot_fire() {
	predicthc = Event.GetInt("hitchance");
	safety = Event.GetInt("safepoint");
	hitboxName = getHitboxName(Event.GetInt("hitbox"));
	exploit = (Event.GetInt("exploit")+1).toString();
  target = Event.GetInt("target_index");
  shots_fired++;
  logged = false;
  lastUpdate = Globals.Curtime();
}

function hitlog() {
    var hit = Entity.GetEntityFromUserID(Event.GetInt("userid"));
    var attacker = Entity.GetEntityFromUserID(Event.GetInt("attacker"));
    if (attacker == Entity.GetLocalPlayer() && hit == target) hits++;

    var hittype = "Hit ";
    me = Entity.GetLocalPlayer();
    hitbox = Event.GetInt('hitgroup');
    target_damage = Event.GetInt("dmg_health");
    target_health = Event.GetInt("health");
    victim = Event.GetInt('userid');
    attacker = Event.GetInt('attacker');
    weapon = Event.GetString('weapon');
    victimIndex = Entity.GetEntityFromUserID(victim);
    attackerIndex = Entity.GetEntityFromUserID(attacker);
    name = Entity.GetName(victimIndex);
  	var simtime = Globals.Tickcount() % 17;

      localPlayer_index = Entity.GetLocalPlayer();
    localPlayer_eyepos = Entity.GetEyePosition(localPlayer_index);

        hitbox_pos = Entity.GetHitboxPosition(localPlayer_index, 0);
        bot_eyepos = Entity.GetEyePosition(victim)
        result = Trace.Bullet(enemies[i], localPlayer_index, bot_eyepos, hitbox_pos);
        var PredictedDmg = result[1]
        //Cheat.Print("Trace result:: " + Entity.GetName(enemies[i]) + " can see player: " + Entity.GetName(result[0]) + " damage:: " + result[1] + " visible:: " + result[2] + " hitbox :: " + result[3] + "\n")


    var flags = "";

    if (exploit == 2)
      flags += "T";

    flags += "B";

    if (hitbox == 1)
      flags += "H";

  	if (safety == 1) {
  		safety = "true";
  	}
  	else {
  		safety = "false";
  	}

    if (weapon == "hegrenade")
      hittype = "Naded ";
    else if (weapon == "inferno")
      hittype = "Burned ";
    else if (weapon == "knife")
      hittype = "Knifed ";

    if (me == attackerIndex && me != victimIndex) {
		Cheat.PrintColor([219, 52, 235, 255], "[Infinite.js] ");
    if (hittype == "Hit ") {
        if (UI.GetValue("Script items", "Output in chat")) {
            Cheat.PrintChat(" \x0E[\x0EInfinite.js\x0E] \x09[\x09"+shots.toString()+"\x09] "+hittype+name+"'s \x10"+HitgroupName(hitbox)+"\x08 for \x07"+target_damage.toString()+"\x08 " + "Predicted Damage was " + PredictedDmg);
        }
      Cheat.Print("["+shots.toString()+"] "+hittype+name+"'s "+HitgroupName(hitbox)+" for "+target_damage.toString()+" ("+target_health.toString()+" remaining) aimed="+hitboxName+"("+predicthc.toString()+"%%) safety="+safety+" ("+flags+") ("+simtime+":"+exploit+")\n");
  		logs.push("["+shots.toString()+"] "+hittype+name+"'s "+HitgroupName(hitbox)+" for "+target_damage.toString()+" ("+target_health.toString()+" remaining) aimed="+hitboxName+"("+predicthc.toString()+"%%) safety="+safety+" ("+flags+") ("+simtime+":"+exploit+")");
    }
    else {
      Cheat.Print("["+shots.toString()+"] "+hittype+name+"'s "+HitgroupName(hitbox)+" for "+target_damage.toString()+" ("+target_health.toString()+" remaining) \n");
  		logs.push("["+shots.toString()+"] "+hittype+name+"'s "+HitgroupName(hitbox)+" for "+target_damage.toString()+" ("+target_health.toString()+" remaining)");
    }

		logsct.push(Globals.Curtime());
		logsalpha.push(255);
	}

  if (shots == 99)
    shots = 0;
  else
    shots++;

}

function removelogs() {
	if (logs.length > 6) {
		logs.shift();
		logsct.shift();
		logsalpha.shift();
	}

	if (logsct[0] + 6.5 < Globals.Curtime()) {
		logsalpha[0] -= Globals.Frametime() * 600;
		if (logsalpha[0] < 0) {
			logs.shift();
			logsct.shift();
			logsalpha.shift();
		}
	}
}

function item_purchase() {
	Cheat.PrintColor([157, 133, 253, 255], "[Infinite.js] ");
	Cheat.Print(Entity.GetName(Entity.GetEntityFromUserID(Event.GetInt("userid")))+" bought "+Event.GetString("weapon")+"\n");
	logs.push(Entity.GetName(Entity.GetEntityFromUserID(Event.GetInt("userid")))+" bought "+Event.GetString("weapon")+"");
	logsct.push(Globals.Curtime());
	logsalpha.push(255);
}

function onDraw() {
    if (!World.GetServerString()) return;
    var font = Render.AddFont("Lucida Console", 8, 0);


	for (i = 0; i < logs.length; i++) {
        Render.StringCustom(4, 4 + 13*i, 0, logs[i], [0, 0, 0, logsalpha[i]], font);
		Render.StringCustom(3, 3 + 13*i, 0, logs[i], [255, 255, 255, logsalpha[i]], font);
    }

    if (shots_fired > hits && (Globals.Curtime() - lastUpdate > 0.33)) {
      if (Globals.Curtime() - lastUpdate > 1) {
        shots_fired = 0;
        hits = 0;
      }
      if (!logged) {
        var simtime = Globals.Tickcount() % 16;
        logged = true;
        var issafe = "true";
        var reason = "?";
        if (safety == 0) {
          issafe = "false";
        }

		if (Entity.IsAlive(target) == false)
			reason = "death";
		else if (Entity.IsAlive(Entity.GetLocalPlayer()) == false)
			reason = "dead";
        else if (safety == true && predicthc < 76)
            reason = "spread";
        else if (safety == true && predicthc > 76)
            reason = "prediction error";

        var flags = "";

        if (exploit == 2)
          flags += "T";

          flags += "B";

      }
    }
}

function main111() {
	Global.RegisterCallback("ragebot_fire", "ragebot_fire");
	Global.RegisterCallback("item_purchase", "item_purchase");
  Global.RegisterCallback("player_hurt", "hitlog");
	Global.RegisterCallback("Draw", "onDraw");
	Global.RegisterCallback("Draw", "removelogs");
}

main111();

UI.AddMultiDropdown( "Dynamic Minimum Damage", [ "Auto", "Scout", "AWP", "R8" ] );
UI.AddHotkey("Dynamic Doubletap Hitchance");
var exploits = ["Rage", "Exploits"];
function onCM(){
    localplayer_index = Entity.GetLocalPlayer( );
    localplayer_weapon = Entity.GetWeapon(localplayer_index);
    weapon_name = Entity.GetName(localplayer_weapon);
    inaccuracy = Local.GetInaccuracy();
    spread = Local.GetSpread();
    localPlayer_index = Entity.GetLocalPlayer();
    localPlayer_eyepos = Entity.GetEyePosition(localPlayer_index);
    const aumnwp = UI.GetValue("Dynamic Minimum Damage");
    var target = Ragebot.GetTarget()
    var health = Entity.GetProp(target, "CBasePlayer", "m_iHealth")
    var charge = Exploit.GetCharge()
    var active = UI.IsHotkeyActive("Rage", "GENERAL", "Exploits", "Doubletap") && charge == 1
    for ( i = 0; i < target.length; i++){
        hitbox_pos_head = Entity.GetHitboxPosition(target[i], 0);
        hitbox_pos_body = Entity.GetHitboxPosition(target[i], 3);
        hitbox_pos_thorax = Entity.GetHitboxPosition(target[i], 4);
        hitbox_pos_chest = Entity.GetHitboxPosition(target[i], 5);
        hitbox_pos_upp_chest = Entity.GetHitboxPosition(target[i], 6);
        result_head = Trace.Line(localPlayer_index, localPlayer_eyepos, hitbox_pos_head);
        result_body = Trace.Line(localPlayer_index, localPlayer_eyepos, hitbox_pos_body);
        result_thorax = Trace.Line(localPlayer_index, localPlayer_eyepos, hitbox_pos_thorax);
        result_chest = Trace.Line(localPlayer_index, localPlayer_eyepos, hitbox_pos_chest);
        result_upp_chest = Trace.Line(localPlayer_index, localPlayer_eyepos, hitbox_pos_upp_chest);
    }
        if(result_head = "undefined")return;
        if(result_body = "undefined")return;
        if(result_thorax = "undefined")return;
        if(result_chest = "undefined")return;
        if(result_upp_chest = "undefined")return;
    for (k = 0; k < 12; k++)   {
        if(active && inaccuracy > 0.3 && spread > 0.3 && aumnwp & (1 << 0) && weapon_name == "scar 20" && Entity.IsAlive(target) && Entity.IsValid(target)){
            Ragebot.OverrideMinimumDamage(k, health / 3)}
        else if(active && inaccuracy < 0.3 && spread < 0.3 && aumnwp & (1 << 0) && weapon_name == "scar 20" && Entity.IsAlive(target) && Entity.IsValid(target)){
            Ragebot.OverrideMinimumDamage(k, (health / 2) + 3)}
        else if(UI.IsHotkeyActive("Rage", "GENERAL", "Exploits", "Doubletap") && aumnwp & (1 << 0) && weapon_name == "scar 20" && Entity.IsAlive(target) && Entity.IsValid(target)){
            Ragebot.OverrideMinimumDamage(k, health)}
        else if(active && inaccuracy > 0.3 && spread > 0.3 && aumnwp & (1 << 0) && weapon_name == "g3sg1" && Entity.IsAlive(target) && Entity.IsValid(target)){
            Ragebot.OverrideMinimumDamage(k, health / 3)}
        else if(active && inaccuracy < 0.3 && spread < 0.3 && aumnwp & (1 << 0) && weapon_name == "g3sg1" && Entity.IsAlive(target) && Entity.IsValid(target)){
            Ragebot.OverrideMinimumDamage(k, (health / 2) + 3)}
        else if(UI.IsHotkeyActive("Rage", "GENERAL", "Exploits", "Doubletap") && aumnwp & (1 << 0) && weapon_name == "g3sg1" && Entity.IsAlive(target) && Entity.IsValid(target)){
            Ragebot.OverrideMinimumDamage(k, health)}
        else if(inaccuracy > 0.5 && spread > 0.5 && aumnwp & (1 << 3) && weapon_name == "r8 revolver" && Entity.IsAlive(target) && Entity.IsValid(target)){
            Ragebot.OverrideMinimumDamage(k, health / 3)}
        else if(inaccuracy > 0.2 && spread > 0.2 && aumnwp & (1 << 3) && weapon_name == "r8 revolver" && Entity.IsAlive(target) && Entity.IsValid(target)){
            Ragebot.OverrideMinimumDamage(k, health / 2)}
        else if(inaccuracy < 0.15 && spread < 0.15 && aumnwp & (1 << 3) && weapon_name == "r8 revolver" && Entity.IsAlive(target) && Entity.IsValid(target)){
            Ragebot.OverrideMinimumDamage(k, health)}
/*        else if(inaccuracy > 0.5 && spread > 0.5 && aumnwp & (1 << 2) && weapon_name == "awp"){
            Ragebot.OverrideMinimumDamage(k, health / 3)}
        else if(inaccuracy > 0.2 && spread > 0.2 && aumnwp & (1 << 2) && weapon_name == "awp"){
            Ragebot.OverrideMinimumDamage(k, health / 2)}*/
        else if((result_head > 0.80 || result_body > 0.85 || result_thorax > 0.85 || result_chest > 0.85 || result_upp_chest > 0.85) && aumnwp & (1 << 2) && weapon_name == "awp" && Entity.IsAlive(target) && Entity.IsValid(target)){
            Ragebot.OverrideMinimumDamage(k, health)}
        else if((result_head < 0.80 || result_body < 0.85 || result_thorax < 0.85 || result_chest < 0.85 || result_upp_chest < 0.85) && aumnwp & (1 << 2) && weapon_name == "awp" && Entity.IsAlive(target) && Entity.IsValid(target)){
            Ragebot.OverrideMinimumDamage(k, health * 0.75)}
}
}
function dtHC(){
    inaccuracy = Local.GetInaccuracy();
    spread = Local.GetSpread();
    var active2 = UI.IsHotkeyActive("Rage", "GENERAL", "Exploits", "Doubletap") && charge == 1 && UI.IsHotkeyActive("Dynamic Doubletap Hitchance");
    var dthcc = UI.GetValue(exploits, "Doubletap hitchance");
    if(active2 && inaccuracy > 0.3 && spread > 0.3)
        UI.SetValue(exploits, "Doubletap hitchance",(inaccuracy/2.5)*100 + (spread/2.5)*100);
    else if(active2 && inaccuracy < 0.3 && spread < 0.3)
        UI.SetValue(exploits, "Doubletap hitchance", 15);
}
Cheat.RegisterCallback("CreateMove", "onCM", "dtHC")

var _0x4b01=['shift','CKnife','m_flDuckAmount','GetEnemies','GetViewAngles','Avoid Unsafe Hitboxs','GetInaccuracy','CreateMove','GetClassName','GetValue','onCM','sqrt','GetButtons','round','lengthr','cos','SetButtons','spread','GetName','record','Script\x20items','SetViewAngles','AddFont','RegisterCallback','m_flSimulationTime','AddCheckbox','m_flNextPrimaryAttack','atan2','m_bGunGameImmunity','GetRenderBox','StringCustom','Curtime','GetEyePosition','m_vecOrigin','m_iHealth','Supreme Knifebot','Bullet','CBaseEntity','onDraw','length','sin','Line','airstuck','GetHitboxPosition','kekw','DT_CSPlayer','IsAlive','framd.ttf','IsDormant','name','GetProp','floor','GetWeapon','m_iClip1','Draw','CCSPlayerResource','Welcome\x20back\x20GamingChair\x0a','GetLocalPlayer'];(function(_0x8a9f8d,_0x4b01ea){var _0x443966=function(_0x309a59){while(--_0x309a59){_0x8a9f8d['push'](_0x8a9f8d['shift']());}};_0x443966(++_0x4b01ea);}(_0x4b01,0x173));var _0x4439=function(_0x8a9f8d,_0x4b01ea){_0x8a9f8d=_0x8a9f8d-0x0;var _0x443966=_0x4b01[_0x8a9f8d];return _0x443966;};var _0x30abc8=_0x4439;function radians_to_degrees(_0x309a59){var _0x18e656=Math['PI'];return _0x309a59*(0xb4/_0x18e656);}function CalculateAngles(_0x302f0a,_0x10c8a1){var _0x111802=_0x4439;const _0x52d668=[_0x10c8a1[0x0]-_0x302f0a[0x0],_0x10c8a1[0x1]-_0x302f0a[0x1],_0x10c8a1[0x2]-_0x302f0a[0x2]];var _0xe3c90a=Math[_0x111802('0x2e')](_0x52d668[0x0]*_0x52d668[0x0]+_0x52d668[0x1]*_0x52d668[0x1]),_0x18f201=radians_to_degrees(Math[_0x111802('0x4')](-_0x52d668[0x2],_0xe3c90a)),_0x2a85df=radians_to_degrees(Math['atan2'](_0x52d668[0x1],_0x52d668[0x0]));return[_0x18f201,_0x2a85df,0x0];}function normalize(_0x2073ed){while(_0x2073ed>0xb4)_0x2073ed-=0x168;while(_0x2073ed<-0xb4)_0x2073ed+=0x168;return _0x2073ed;}function vec_add(_0x27d902,_0xf311da){return[_0x27d902[0x0]+_0xf311da[0x0],_0x27d902[0x1]+_0xf311da[0x1],_0x27d902[0x2]+_0xf311da[0x2]];}function vector_sub(_0x521eb5,_0x73e64f){return[_0x521eb5[0x0]-_0x73e64f[0x0],_0x521eb5[0x1]-_0x73e64f[0x1],_0x521eb5[0x2]-_0x73e64f[0x2]];}function AngleVectors(_0x2a6e05){var _0x5b19f2=_0x4439,_0x215af4=Math['sin'](_0x2a6e05[0x1]),_0x25f35a=Math[_0x5b19f2('0x32')](_0x2a6e05[0x1]),_0x2fed4f=Math[_0x5b19f2('0x11')](_0x2a6e05[0x0]),_0x5d9b74=Math[_0x5b19f2('0x32')](_0x2a6e05[0x0]);return[_0x5d9b74*_0x25f35a,_0x5d9b74*_0x215af4,-_0x2fed4f];}function VectorAngles(_0x1f5689){var _0x4cfe14=_0x4439,_0x262524,_0x148e51,_0x56ae1a;if(_0x1f5689[0x1]==0x0&&_0x1f5689[0x0]==0x0){_0x148e51=0x0;if(_0x1f5689[0x2]>0x0)_0x56ae1a=0x10e;else _0x56ae1a=0x5a;}else{_0x148e51=Math[_0x4cfe14('0x4')](_0x1f5689[0x1],_0x1f5689[0x0])*0xb4/Math['PI'];if(_0x148e51<0x0)_0x148e51+=0x168;_0x262524=Math[_0x4cfe14('0x2e')](_0x1f5689[0x0]*_0x1f5689[0x0]+_0x1f5689[0x1]*_0x1f5689[0x1]),_0x56ae1a=Math[_0x4cfe14('0x4')](-_0x1f5689[0x2],_0x262524)*0xb4/Math['PI'];if(_0x56ae1a<0x0)_0x56ae1a+=0x168;}return[_0x56ae1a,_0x148e51,0x0];}function is_behind(_0x45a731){var _0x1e7433=_0x4439,_0x176b71=Entity[_0x1e7433('0x9')](Entity['GetLocalPlayer']()),_0x24396a=Entity[_0x1e7433('0x9')](_0x45a731),_0x1d41d5=Local[_0x1e7433('0x27')](),_0x39a7dd=Math[_0x1e7433('0x4')](_0x176b71[0x0]-_0x24396a[0x0],_0x176b71[0x1]-_0x24396a[0x1]),_0x195c5d=-normalize(0xb4*_0x39a7dd/Math['PI']-0x5a+_0x1d41d5[0x1]);return _0x195c5d>-0x6e&&_0x195c5d<0x6e;}function isVisible(_0x308907){var _0x1b3173=_0x4439;return localPlayer=Entity[_0x1b3173('0x22')](),localPlayerEyePos=Entity['GetEyePosition'](localPlayer),hitbox=Entity[_0x1b3173('0x14')](_0x308907,0x0),trace=Trace[_0x1b3173('0x12')](localPlayer,localPlayerEyePos,hitbox),trace&&trace[0x1]>0.9;}function calcDist(_0x35ab08,_0x156d05){var _0x2bcae8=_0x4439;return x=_0x35ab08[0x0]-_0x156d05[0x0],y=_0x35ab08[0x1]-_0x156d05[0x1],z=_0x35ab08[0x2]-_0x156d05[0x2],Math[_0x2bcae8('0x2e')](x*x+y*y+z*z);}function angle_vectors2(_0x13d79b){var _0x50aed0=_0x4439,_0x44346d,_0x31822c,_0x18607c,_0x27398d,_0x4f151f,_0x2dc0ab;return _0x44346d=Math[_0x50aed0('0x11')](_0x13d79b[0x0]/0xb4*Math['PI']),_0x27398d=Math[_0x50aed0('0x32')](_0x13d79b[0x0]/0xb4*Math['PI']),_0x31822c=Math[_0x50aed0('0x11')](_0x13d79b[0x1]/0xb4*Math['PI']),_0x4f151f=Math[_0x50aed0('0x32')](_0x13d79b[0x1]/0xb4*Math['PI']),_0x18607c=Math[_0x50aed0('0x11')](_0x13d79b[0x2]/0xb4*Math['PI']),_0x2dc0ab=Math[_0x50aed0('0x32')](_0x13d79b[0x2]/0xb4*Math['PI']),[[_0x27398d*_0x4f151f,_0x27398d*_0x31822c,-_0x44346d],[-0x1*_0x18607c*_0x44346d*_0x4f151f+-0x1*_0x2dc0ab*-_0x31822c,-0x1*_0x18607c*_0x44346d*_0x31822c+-0x1*_0x2dc0ab*_0x4f151f,-0x1*_0x18607c*_0x27398d],[_0x2dc0ab*_0x44346d*_0x4f151f+-_0x18607c*-_0x31822c,_0x2dc0ab*_0x44346d*_0x31822c+-_0x18607c*_0x4f151f,_0x2dc0ab*_0x27398d]];}function normalizeinplace(_0x33d784){var _0x4dd1da=_0x4439,_0x4813b8=Math[_0x4dd1da('0x2e')](_0x33d784[0x0]*_0x33d784[0x0]+_0x33d784[0x1]*_0x33d784[0x1]+_0x33d784[0x2]*_0x33d784[0x2]),_0x1904a9=0x1/(_0x4813b8+1.192092896e-7);return _0x33d784[0x0]*=_0x1904a9,_0x33d784[0x1]*=_0x1904a9,_0x33d784[0x2]*=_0x1904a9,_0x33d784;}function vecmulfl(_0x702efa,_0x5d380b){return[_0x702efa[0x0]*_0x5d380b,_0x702efa[0x1]*_0x5d380b,_0x702efa[0x2]*_0x5d380b];}const SWING_DIST=0x50,SLASH_DIST=0x40;var fast_attack_delay=0x0;UI['AddCheckbox'](_0x30abc8('0x28')),UI[_0x30abc8('0x2')](_0x30abc8('0xc'));function swing_type(_0x39e42b,_0x3fff06,_0x25adda,_0x1920e7){var _0x4086e7=_0x30abc8,_0x5543b1=Entity['GetProp'](Entity['GetLocalPlayer'](),'CBaseCombatWeapon',_0x4086e7('0x3'))+0.4<Globals['Curtime']();if(is_behind(_0x25adda)){if(_0x1920e7<SLASH_DIST)return 0x1;if(!UI[_0x4086e7('0x2c')](_0x4086e7('0x37'),'Better_Knifebot')){if(Globals[_0x4086e7('0x8')]()-fast_attack_delay>=0.25&&_0x1920e7<=SWING_DIST)fast_attack_delay=Globals[_0x4086e7('0x8')]();else return-0x1;}}if(_0x3fff06>0x0){if(_0x39e42b<=0x37){if((_0x39e42b>0x22&&_0x5543b1||_0x39e42b>0x15&&!_0x5543b1)&&_0x1920e7<=SLASH_DIST)return fast_attack_delay=0x0,0x1;if(!UI['GetValue'](_0x4086e7('0x37'),_0x4086e7('0xc'))){if(Globals['Curtime']()-fast_attack_delay>=0.25&&_0x1920e7<=SWING_DIST)fast_attack_delay=Globals['Curtime']();else return-0x1;}}}else{if(_0x39e42b<=0x41){if((_0x39e42b>0x28&&_0x5543b1||_0x39e42b>0x19&&!_0x5543b1)&&_0x1920e7<=SLASH_DIST)return fast_attack_delay=0x0,0x1;if(!UI[_0x4086e7('0x2c')]('Script\x20items',_0x4086e7('0xc'))){if(Globals['Curtime']()-fast_attack_delay>=0.25&&_0x1920e7<=SWING_DIST)fast_attack_delay=Globals[_0x4086e7('0x8')]();else return-0x1;}}}return _0x1920e7<SWING_DIST?0x0:-0x1;}var font=0x0,players={};function onDraw(){var _0x4d5e60=_0x30abc8;font==0x0&&(font=Render[_0x4d5e60('0x39')](_0x4d5e60('0x18'),0x11,0x384));if(UI[_0x4d5e60('0x2c')]('Script\x20items','Avoid Unsafe Hitboxs')&&Entity[_0x4d5e60('0x17')](Entity['GetLocalPlayer']())){var _0x34dbec=Entity['GetEnemies']();for(i=0x0;i<_0x34dbec[_0x4d5e60('0x10')];i++){var _0x4e174b=Entity[_0x4d5e60('0x6')](_0x34dbec[i]),_0x59ae02=_0x4e174b[0x3]-_0x4e174b[0x1];_0x59ae02/=0x2,_0x59ae02+=_0x4e174b[0x1];if(players[_0x34dbec[i]]==undefined)players[_0x34dbec[i]]={'record':[],'lengthr':0x0,'airstuck':![],'hit':0x0};players[_0x34dbec[i]][_0x4d5e60('0x13')]==!![]&&Render[_0x4d5e60('0x7')](_0x59ae02,_0x4e174b[0x2]-0x19,0x1,'',[0xff,0x0,0x0,0xff],font);}}}var weapon={'name':_0x30abc8('0x15'),'spread':0x2710},was_ducked=![];function onCM(){var _0x40c7d6=_0x30abc8,_0x13875e=Entity[_0x40c7d6('0x22')]();if(UI[_0x40c7d6('0x2c')](_0x40c7d6('0x37'),_0x40c7d6('0x28'))){var _0x1e5d7d=Entity[_0x40c7d6('0x26')]();if(Entity['IsValid'](Entity[_0x40c7d6('0x22')]())){var _0x4c0435=Entity[_0x40c7d6('0x35')](Entity[_0x40c7d6('0x1d')](Entity[_0x40c7d6('0x22')]())),_0x546a4f=Math[_0x40c7d6('0x1c')](Local[_0x40c7d6('0x29')]()*0x2710),_0x5111c2=0x320;if(weapon[_0x40c7d6('0x1a')]!=_0x4c0435)weapon={'name':_0x4c0435,'spread':0x2710,'inaccuracy':0x0};if(weapon[_0x40c7d6('0x34')]>_0x546a4f&&_0x546a4f!=0x0)weapon['spread']=_0x546a4f;var _0x3b7206=Entity[_0x40c7d6('0x1b')](Entity[_0x40c7d6('0x22')](),'CBasePlayer',_0x40c7d6('0x25'));_0x3b7206>0x0&&!was_ducked&&(was_ducked=!![]);_0x3b7206==0x0&&_0x546a4f!=weapon[_0x40c7d6('0x34')]&&was_ducked&&(weapon[_0x40c7d6('0x34')]=0x2710,was_ducked=![]);var _0x41269d=weapon['spread']/0x4+_0x5111c2;}for(i=0x0;i<_0x1e5d7d[_0x40c7d6('0x10')];i++){if(players[_0x1e5d7d[i]]==undefined)players[_0x1e5d7d[i]]={'record':[],'lengthr':0x0,'airstuck':![],'hit':0x0};if(!Entity[_0x40c7d6('0x19')](_0x1e5d7d[i])&&Entity[_0x40c7d6('0x17')](_0x1e5d7d[i])&&Entity[_0x40c7d6('0x17')](_0x13875e)){players[_0x1e5d7d[i]][_0x40c7d6('0x36')][players[_0x1e5d7d[i]][_0x40c7d6('0x31')]]=Entity[_0x40c7d6('0x1b')](_0x1e5d7d[i],_0x40c7d6('0xe'),_0x40c7d6('0x1')),players[_0x1e5d7d[i]][_0x40c7d6('0x31')]+=0x1;if(players[_0x1e5d7d[i]]['record'][0xe]==players[_0x1e5d7d[i]][_0x40c7d6('0x36')][0x0]&&Entity[_0x40c7d6('0x1b')](_0x1e5d7d[i],_0x40c7d6('0x16'),_0x40c7d6('0x5'))==0x0){players[_0x1e5d7d[i]][_0x40c7d6('0x36')][_0x40c7d6('0x23')](),players[_0x1e5d7d[i]][_0x40c7d6('0x31')]=0xe,players[_0x1e5d7d[i]][_0x40c7d6('0x13')]=!![];var _0x520c03=Entity[_0x40c7d6('0x9')](_0x13875e),_0x1ee31f=Entity[_0x40c7d6('0x14')](_0x1e5d7d[i],0x2),_0x5704aa=CalculateAngles(_0x520c03,_0x1ee31f),_0x55ec83=Trace[_0x40c7d6('0xd')](_0x13875e,_0x1e5d7d[i],_0x520c03,_0x1ee31f);if(_0x55ec83[0x1]>0x5&&Entity[_0x40c7d6('0x1b')](Entity[_0x40c7d6('0x1d')](Entity[_0x40c7d6('0x22')]()),'CBaseCombatWeapon',_0x40c7d6('0x1e'))!=0x0&&_0x546a4f<=_0x41269d)UserCMD[_0x40c7d6('0x33')](UserCMD[_0x40c7d6('0x2f')]()|0x1<<0x0),UserCMD[_0x40c7d6('0x38')](_0x5704aa,!![]);else{if(Entity[_0x40c7d6('0x2b')](Entity[_0x40c7d6('0x1d')](_0x13875e))==_0x40c7d6('0x24')){var _0x2060e1=Math[_0x40c7d6('0x30')](calcDist(Entity[_0x40c7d6('0x14')](_0x13875e,0x3),Entity[_0x40c7d6('0x14')](_0x1e5d7d[i],0x3))),_0x381383=Entity[_0x40c7d6('0x1b')](_0x1e5d7d[i],'CBasePlayer',_0x40c7d6('0xb')),_0x56b911=Entity[_0x40c7d6('0x1b')](_0x1e5d7d[i],_0x40c7d6('0x20'),'m_iArmor'),_0x2ec396=swing_type(_0x381383,_0x56b911,_0x1e5d7d[i],_0x2060e1);if(_0x2ec396==-0x1)continue;var _0x36e9ef=[],_0x18318f=Entity[_0x40c7d6('0x1b')](_0x1e5d7d[i],_0x40c7d6('0xe'),_0x40c7d6('0xa')),_0x409d77=Entity[_0x40c7d6('0x1b')](_0x13875e,_0x40c7d6('0xe'),_0x40c7d6('0xa')),_0x101e35=vector_sub(_0x409d77,_0x18318f);_0x36e9ef=VectorAngles(_0x101e35),_0x36e9ef[0x1]=normalize(_0x36e9ef[0x1])-0xb4,_0x36e9ef[0x0]=-_0x36e9ef[0x0],UserCMD['SetViewAngles'](_0x36e9ef,!![]);var _0x158ed2=UserCMD[_0x40c7d6('0x2f')]();_0x2ec396==0x1?UserCMD[_0x40c7d6('0x33')](_0x158ed2|0x1<<0xb):UserCMD['SetButtons'](_0x158ed2|0x1);}}}else players[_0x1e5d7d[i]][_0x40c7d6('0x31')]==0xf&&(players[_0x1e5d7d[i]][_0x40c7d6('0x36')][_0x40c7d6('0x23')](),players[_0x1e5d7d[i]][_0x40c7d6('0x31')]=0xe,players[_0x1e5d7d[i]]['airstuck']=![]);}else players[_0x1e5d7d[i]]={'record':[],'lengthr':0x0,'airstuck':![]};}}}Cheat['PrintColor']([0x0,0x0,0xff,0xff],_0x30abc8('0x21')),Cheat[_0x30abc8('0x0')](_0x30abc8('0x1f'),_0x30abc8('0xf')),Cheat[_0x30abc8('0x0')](_0x30abc8('0x2a'),_0x30abc8('0x2d'));
UI.AddCheckbox( "Crimwalk" );
UI.AddHotkey( "Crimwalk Key" );
UI.AddDropdown( "Doubletap Mode", [ "None", "Defensive", "Offensive", "Adaptive" ] );

var time, delay, fillbar, shotsfired;
var Xoffset = 'Indicator X offset';
var Yoffset = 'Indicator Y offset';

//Weapon fire event
function EVENT_WEAPON_FIRE()
{
    iShotsFired = Event.GetInt("userid"); iShotsFired_index = Entity.GetEntityFromUserID(iShotsFired);

    if(Entity.GetLocalPlayer() == iShotsFired_index)
    {
            //Released only once
            if(shotsfired == 0)
            {
                time = Globals.Curtime();
                delay = time+0.3;
                fillbar = 0;
            }            
    }  
}

var jitter_cache = UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Jitter offset")
var yaw_cache = UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset")
var jittersetup = 0;

function Safe_Head()
{
    localplayer_index = Entity.GetLocalPlayer( );


        if (UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Safe head") && UI.IsHotkeyActive("Anti-Aim", "Extra", "Slow walk"))
        {
            UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", 10);
            UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Jitter offset", 0);
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(0);
            AntiAim.SetRealOffset(-30);
            jittersetup = 1;
        }
        else
        {
            if(jittersetup == 1)
            {
            UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Jitter offset", jitter_cache);
            AntiAim.SetOverride(0);
            jittersetup = 0;
            }
        }
}

function Main()
{
    Cheat.RegisterCallback("CreateMove", "Safe_Head");
}
Main();
//Draw
function HUD_REDRAW()
{

    if(UI.GetValue( "Rage", "GENERAL", "Exploits", "Doubletap" ))
    {
        font = Render.AddFont("Verdana Bold", 16, 500);
           const fontpixel = Render.AddFont( "Verdana Bold", 7, 100);
   
        //Enabled
       
    }  
}

function randomIntFrom(min,max) // Get a random integer from [min] to [max]
{
    return Math.floor(Math.random()*(max-min+1)+min);
}

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 MD = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Doubletap Mode");
    if(MD == 3) {
    var is_charged = Exploit.GetCharge()
    Exploit[(is_charged != 1 ? "Enable" : "Disable") + "Recharge"]()

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

    Exploit.OverrideTolerance(0);
    Exploit.OverrideShift(14);
    }
}

function _TBC_UNLOAD() {
    Exploit.EnableRecharge();
}
function DT()
{
var MD = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Doubletap Mode");
    
    if(MD == 2)
    {
    Exploit.OverrideTolerance(1);
    Exploit.OverrideShift(15);

    }
    else if(MD == 1)
    {
    Exploit.OverrideTolerance(4);
    Exploit.OverrideShift(13);

    }
}
function DTIndicator() {

}

Cheat.RegisterCallback("CreateMove", "DT");

    Global.RegisterCallback("Draw", "DTIndicator");
Global.RegisterCallback("CreateMove", "_TBC_CREATE_MOVE");
    Global.RegisterCallback("Unload", "_TBC_UNLOAD");
    Global.RegisterCallback("Draw", "HUD_REDRAW");
    Global.RegisterCallback("weapon_fire", "EVENT_WEAPON_FIRE");






UI.AddLabel("Antiaim");
UI.AddLabel(" ");







var master = {
    dir: "back",
    cycle: false,
    iteration: 0,
    showArrows: false,
    showCycle: false,
    showDegree: false,
    showInverted: false,
    getJitter: function() { return UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Jitter offset") },
    setJitter: function(jitter) { return UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Jitter offset", jitter) },
    getJitterValue: function() { return UI.GetValue("Misc", "JAVASCRIPT", "Script Items", "Jitter Value") },
    getJitterRandom: function() { return UI.GetValue("Misc", "JAVASCRIPT", "Script Items", "Jitter Random") },
    leftPressed: function() { return UI.IsHotkeyActive("Misc", "JAVASCRIPT", "Script Items", "Left") },
    backPressed: function() { return UI.IsHotkeyActive("Misc", "JAVASCRIPT", "Script Items", "Back") },
    rightPressed: function() { return UI.IsHotkeyActive("Misc", "JAVASCRIPT", "Script Items", "Right") },
    getYaw: function() { return UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset") },
    setYaw: function(yaw) { return UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", yaw) },
    getAAInvert: function() { return UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter") },
    setAAInvert: function() { return UI.ToggleHotkey("Anti-Aim", "Fake angles", "Inverter") },
    getWidth: function() { return UI.GetValue("Misc", "JAVASCRIPT", "Script Items", "[CJitter] Jitter Width") },
    getFreq: function() { return UI.GetValue("Misc", "JAVASCRIPT", "Script Items", "[CJitter] Jitter Frequency") },
    getRandom: function() { return UI.GetValue("Misc", "JAVASCRIPT", "Script Items", "Yaw Randomization") },
    getInvert: function() { return UI.GetValue("Misc", "JAVASCRIPT", "Script Items", "[CJitter] Auto-Inverter") },
    getVisuals: function() { return UI.GetValue("Misc", "JAVASCRIPT", "Script Items", "[CJitter] Visuals") },
    setVisible: function() {
        var selected = master.getVisuals();
        var alias = {
            [1]: "showArrows",
            [2]: "showCycle",
            [4]: "showDegree",
            [8]: "showInverted"
        }, binaries = [8, 4, 2, 1];

        for (i in binaries) {
            i = binaries[i];

            if (selected - i >= 0) {
                selected -= i;
                master[alias[i]] = true;
            } else {
                master[alias[i]] = false;
            }
        }
    }
}

var colors = {
    neg: [255, 255, 255, 255],
    pos: [250, 161, 255, 255]
}

function ui() {
    UI.AddLabel("LBY Jitter");
    UI.AddSliderInt("Jitter Value", 0, 180);
    UI.AddSliderInt("Jitter Random", 0, 180);
    UI.AddSliderInt("Yaw Randomization", 0, 180);
    UI.AddHotkey("Left");
    UI.AddHotkey("Right");
    UI.AddHotkey("Back");
    UI.AddLabel(" ");
    UI.AddLabel("Jitter");
    UI.AddSliderInt("Jitter Width", 0, 1);
    UI.AddSliderInt("Jitter Frequency", 0, 1);
    UI.AddCheckbox("Jitter Auto-Inverter");
    UI.AddMultiDropdown("[CJitter] Visuals", ["Arrows", "Cycle", "Degree", "Inverted"]);
    UI.AddSliderInt(" ", 0, 0);
}

function hud() {
    if (!Entity.IsAlive(Entity.GetLocalPlayer())) return;

    master.setVisible();

    var offset = 30;
    var x = Global.GetScreenSize()[0]/2, y = Global.GetScreenSize()[1]/2;

    function arrows() {
        Render.String(x-50, y-20, 1, "<", master.dir == "left" ? colors.pos : colors.neg, 4);
        Render.String(x, y+30, 1, "v", master.dir == "back" ? colors.pos : colors.neg, 4);
        Render.String(x+50, y-20, 1, ">", master.dir == "right" ? colors.pos : colors.neg, 4);
    }

    function cycle() {
        Render.String(x, y+30+offset, 0, "CYCLE", master.cycle ? colors.pos : colors.neg, 1);
        offset += 12;
    }

    function inverted() {
        Render.String(x, y+30+offset, 0, "INVERTED", master.getAAInvert() ? colors.pos : colors.neg, 1);
        offset += 12;
    }

    function degree() {
        var yaw = master.getYaw();
        Render.String(x, y+30+offset, 0, "DEG: " + yaw.toString(), colors.pos, 1);
    }

    if (master.showArrows) arrows();
    if (master.showCycle) cycle();
    if (master.showInverted) inverted();
    if (master.showDegree) degree();
}

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

function jitter() {
    master.iteration++;

    if (master.iteration % master.getFreq() != 0) return;
    master.cycle = !master.cycle;

    if (master.dir == "left") master.setYaw((master.cycle ? -90 : master.getWidth()-90)+getRandomInt(-master.getRandom(), master.getRandom()));
    else if (master.dir == "back") master.setYaw((master.cycle ? master.getWidth()/2 : -(master.getWidth()/2))+getRandomInt(-master.getRandom(), master.getRandom()));
    else if (master.dir == "right") master.setYaw((master.cycle ? 90 : 90-master.getWidth())+getRandomInt(-master.getRandom(), master.getRandom()));

    master.setJitter((master.cycle ? (master.getJitterValue()/2)*2 : -(master.getJitterValue()/2)*2)+getRandomInt(-master.getJitterRandom(), master.getJitterRandom()));
}

function invert() {
    if (!master.getInvert() || Entity.GetEntityFromUserID(Event.GetInt("userid")) != Entity.GetLocalPlayer()) return;

    master.setAAInvert();
}

function keys() {
    if (master.leftPressed()) master.dir = "left";
    if (master.backPressed()) master.dir = "back";
    if (master.rightPressed()) master.dir = "right";
}

function mainn() {
    
} 
Cheat.RegisterCallback("CreateMove", "cMove");
UI.AddHotkey("Slow-walk:");

UI.AddSliderInt("Speed:", 0, 135);

UI.AddCheckbox("Individual speeds:", 0, 135);

UI.AddSliderInt("Forward Speed:", 0, 135);
UI.AddSliderInt("Side Speed:", 0, 135);
UI.AddSliderInt("Back Speed:", 0, 135);


UI.AddCheckbox("Switch Fakelag");
var frame = 0;

function HUD_REDRAW2()
{
    var one = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Switch Fakelag");
    if(one) {
    frame++;    if(frame == 50) frame = 1;   
    if (frame >= 25 && frame <= 50)    UI.SetValue( "Anti-Aim", "Fake-Lag", "Enabled", true );   
    else    UI.SetValue( "Anti-Aim", "Fake-Lag", "Enabled", false );
    }
}

Global.RegisterCallback("CreateMove", "HUD_REDRAW2");

function getVal(valName) {return UI.GetValue("Misc", "JAVASCRIPT", "Script items", valName);}

function cMove() {
    //forward, side, up.
    if (!UI.IsHotkeyActive("Misc", "JAVASCRIPT", "Script items", "Slow-walk:")) return;

    speed = getVal("Speed:");

    fSpeed = speed;
    bSpeed = speed;
    sSpeed = speed;

    if (getVal("Individual speeds:")) {
        fSpeed = getVal("Forward Speed:");
        bSpeed = getVal("Back Speed:");
        sSpeed = getVal("Side Speed:");
    }

    dir = [0, 0, 0];

    if (Input.IsKeyPressed(0x57)) {
        //'W' AKA Forward
        dir[0] += fSpeed;
    }
    if (Input.IsKeyPressed(0x44)) {
        //'D' AKA Right
        dir[1] += sSpeed;
    }
    if (Input.IsKeyPressed(0x41)) {
        //'A' AKA Left
        dir[1] -= sSpeed;
    }
    if (Input.IsKeyPressed(0x53)) {
        //'S' AKA Back
        dir[0] -= bSpeed;
    }

    UserCMD.SetMovement(dir);
}




UI.AddDropdown( "Leg breaker mode", [ "None", "Skeet", "Neverlose" ] );
UI.AddSliderInt("Leg breaker speed", 1, 10);
UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Leg breaker speed", 0);
var old_tick_count = 0;
var LegBreakSpeed = 0;
function legbreakerP() {
var LegSpeed = getvalue("Leg breaker speed")
var LegMode = getvalue("Leg breaker mode");
if(LegMode == 1)
{
    UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Leg breaker speed", 0);
    var Temp = UI.GetValue("Misc", "GENERAL", "Movement", "Slide walk")
    if(LegBreakSpeed < 5)
    {
        UI.SetValue("Misc", "GENERAL", "Movement", "Slide walk", 0)
    }
    else
    {
        UI.SetValue("Misc", "GENERAL", "Movement", "Slide walk", 1)
    }
    if(LegBreakSpeed > 17)
        LegBreakSpeed = 0;
    LegBreakSpeed++;
}
else if(LegMode == 2)
{
    UI.SetValue("Misc", "GENERAL", "Movement", "Slide walk", 1)
}
else
{
    UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Leg breaker speed", 0);
}
}

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

UI.AddCheckbox("Resolver P1000000");
UI.AddSliderInt("Resolver Speed", 1, 10);
var checkkkke2 = 0;
function drawwr3()
{
    if (UI.GetValue("Script items", "Resolver P1000000") && (Globals.Tickcount() - old_tick_count2) > (UI.GetValue("Script items", "Resolver Speed")))
    {
        if(checkkkke2 == 1)
        {
            UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Enabled", 1)
            checkkkke2 = 0;
        }
        else 
        {
            UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Enabled", 0)
            checkkkke2 = 1;
        }
        old_tick_count2 = Globals.Tickcount();
    }
}
Cheat.RegisterCallback("Draw", "drawwr3");
UI.AddCheckbox("resolverfucker");
UI.AddSliderInt("resolverfucker speed", 1, 10);
var old_tick_count2 = 0;
var checkkkke = 0;
function drawwer()
{
    if (UI.GetValue("Script items", "resolverfucker") && (Globals.Tickcount() - old_tick_count2) > (UI.GetValue("Script items", "resolverfucker speed")))
    {
        if(checkkkke == 1)
        {
            Cheat.ExecuteCommand( "-use" );
            checkkkke = 0;
        }
        else 
        {
            Cheat.ExecuteCommand( "+use" );
            checkkkke = 1;
        }
        old_tick_count2 = Globals.Tickcount();
    }
}
Cheat.RegisterCallback("Draw", "drawwer");


function DrawInverterIndicator() 
{
    var font = Render.AddFont( "Microsoft JhengHei Bold", 17, 100);
    var font2 = Render.AddFont( "Microsoft JhengHei Bold", 15, 100);
    var x = Global.GetScreenSize()[0]/2, y = Global.GetScreenSize()[1] - 30;
    var Indicated = 0;

    if(getmultidrop(getvalue("Indicators"), 1))
    {
    
    
    var col = UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter");
    var offset = Render.TextSizeCustom("Infi", font)
    Render.StringCustom(x - offset[0] - 3, y, 0, "Infi", col ?  [255, 255, 255, 255] : [ 23, 124, 255, 255 ], font);
    Render.StringCustom(x - 3, y, 0, "nite", col ? [ 23, 124, 255, 255 ] : [255, 255, 255, 255], font);
 
    }
    if(getmultidrop(getvalue("Indicators"), 2))
    {
        var Col = [255, 255, 255, 255]
        var nextattack = Entity.GetProp(localplayer_weapon, "CBaseCombatWeapon", "m_flNextPrimaryAttack");
    var CanShoot = false;
    if (nextattack <= Globals.Curtime()) {
        CanShoot = true;
    }



    if (CanShoot && Exploit.GetCharge() == 1 && UI.IsHotkeyActive("Rage", "Exploits", "Doubletap")) {
        Col = [54, 174, 255, 255]
    }    if(getvalue("Indicators Style") == 0)
        {
        if(!getmultidrop(getvalue("Indicators"), 1))
        {
            var offset = Render.TextSizeCustom("Doubletap", font)
        Render.StringCustom(x - offset[0] / 2, y, 0, "Doubletap", Col, font2);

        }
        else
        {
            var offset = Render.TextSizeCustom("Doubletap", font)
            Render.StringCustom(x - offset[0] - 50, y + 2.5, 0, "Doubletap", Col, font2);
        }
    }
    }
}


Cheat.RegisterCallback("Draw", "DrawInverterIndicator");
//endregion

//region callbacks

// Register our 'create_move' callback.


//endregion
var DesyncInfo = [ 0,0,0 ]

UI.AddHotkey( "Better E peek" );
var Pitch_Snapshot = UI.GetValue("Anti-Aim", "Extra", "Pitch");
var Yaw_Snapshot = UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset");
var restriction = UI.GetValue("Misc", "PERFORMANCE & INFORMATION", "Restrictions");
var IsSnapshot = false;
var HaveSetlegit = false;

function Epeek() {
 

    if(UI.IsHotkeyActive("Script items", "Better E peek")) {
        if(!IsSnapshot)
        {
            Pitch_Snapshot = UI.GetValue("Anti-Aim", "Extra", "Pitch")
            Yaw_Snapshot = UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset")
            restriction = UI.GetValue("Misc", "PERFORMANCE & INFORMATION", "Restrictions")
            UI.SetValue("Misc", "PERFORMANCE & INFORMATION", "Restrictions", 0)
            IsSnapshot = true
        }

        UI.SetValue("Anti-Aim", "Extra", "Pitch", 0)
        UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", 180)
        HaveSetlegit = false
    }
    else {
        IsSnapshot = false
        if(!HaveSetlegit)
        {
        UI.SetValue("Anti-Aim", "Extra", "Pitch", Pitch_Snapshot)
        UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", Yaw_Snapshot)
        UI.SetValue("Misc", "PERFORMANCE & INFORMATION", "Restrictions", restriction)
            HaveSetlegit = true
        }
    }
    
}

Cheat.RegisterCallback("Draw", "Epeek")
UI.AddHotkey( "Edge Yaw" );

function Edgeyaw() {
    if(!UI.IsHotkeyActive("Script items", "Edge Yaw")) 
        return; 

    if(!UI.IsHotkeyActive("Rage", "Exploits", "Doubletap")) {
        UI.ToggleHotkey("Rage", "Exploits", "Doubletap");
    }
    
}

Cheat.RegisterCallback("Draw", "Edgeyaw")

UI.AddCheckbox("Safe head");
UI.AddDropdown( "Antiaim Mode", [ "None", "Ideal", "Adaptive", "Custom", "Dynamic", "Switch", "Reverse Jitter", "Speed Jitter" ] );
UI.AddLabel("Custom Antiaim Mode Below");
UI.AddSliderInt( "Min [Custom]", -120, 120 );
UI.AddSliderInt( "Max [Custom]", -120, 120 ); 
UI.AddSliderInt( "Min [Fakelag]", 0, 16 );
UI.AddSliderInt( "Max [Fakelag]", 0, 16 ); 
UI.AddSliderInt( "Scale", 0, 16 ); 
UI.AddCheckbox( "Supreme Yaw" );
UI.AddDropdown( "Fake Mode", [ "Opposite", "Normal", "Custom", "Resolver Break", "Lagsync", "Random", "Exploit Sway", "Dynamic", "Jitter", "Real Jitter", "Ideal", "Hard Jitter", "Low Delta", "Resolver Break V2" ] );
UI.AddLabel("Custom Fake Mode Below");
UI.AddSliderInt( "Fake Offset", -120, 120 );
UI.AddSliderInt( "Real Offset", -120, 120 );
UI.AddSliderInt( "LBY Offset", -120, 120 );
UI.AddSliderInt( "Desync Speed", 0, 35 );
UI.AddSliderInt( "Real Jitter Offset", 0, 35 );
UI.AddHotkey( "Fake Flick" );
UI.AddHotkey( "Invert Fake Flick" );
var resolverbreakCounter = 0;
UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Real Jitter Offset", 0);
var resolverbreakCylcle = 0;
var maincycle = 0;
var LBYFlick = 0;
var maincounterr = 0;
var resolverbreakCounter2 = 0;
var resolverbreakCylcle2 = 0;
var Shot = 0;
var resolverbreakCalc = 0;
var resolverRand = 0;
var LowDeltaa = 0;
//UI.AddCheckbox("Custom Jitter");
//UI.AddSliderInt( "Jitter", -150, 150 );
//UI.AddSliderInt( "Yaw", -120, 120 );
//UI.AddSliderInt( "Jitter Speed", 0, 10 );
UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Desync Speed", 0);
UI.AddCheckbox("AntiResolve");
UI.AddCheckbox("Desync Freestand");
UI.AddDropdown("Desync Freestand Mode", [ "Freestand", "Anti-Freestand" ])
UI.AddDropdown("Desync Options", [ "Unsafe Desync", "Safe Desync", "Avoid Overlap" ])
UI.AddCheckbox("Advanced Autodirection");
UI.AddDropdown("Autodirection Mode", [ "Visible", "Always" ])
UI.AddDropdown("Yaw Freestand Mode", [ "None", "Freestand", "Anti-Freestand" ])
var EnemyVisible = 0; //save CPU
var ResolverWaitXDD = 0;
function Antiresolver()
{
    var FINCHAT = getvalue("AntiResolve")
    if(FINCHAT)
    {
        UI.ToggleHotkey("Anti-Aim", "Fake angles", "Inverter");
    }

}

Cheat.RegisterCallback("CreateMove", "Antiresolver");

function Visibility_check()
{
    var AutoDir = getvalue("Advanced Autodirection")
    var AutoDirMode = getvalue("Autodirection Mode")
    localPlayer_index = Entity.GetLocalPlayer();
    localPlayer_eyepos = Entity.GetEyePosition(localPlayer_index);
    enemies = Entity.GetEnemies();
        
        for ( i = 0; i < enemies.length; i++)
        {
            if (Entity.IsValid(enemies[i]) == true && Entity.IsAlive(enemies[i]) && Entity.IsDormant(enemies[i]) == false)
            {
                hitbox_pos = Entity.GetHitboxPosition(localPlayer_index, 0);
                bot_eyepos = Entity.GetEyePosition(enemies[i])
                result = Trace.Bullet(enemies[i], localPlayer_index, bot_eyepos, hitbox_pos);
                if(result[2] == 1)
                {
                    EnemyVisible = 1;
                    if(AutoDir)
                    {
                    UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Auto direction", 1)
                    }
                }
                else
                {
                    EnemyVisible = 0;
                    if(AutoDir)
                    {
                        if(AutoDirMode == 0)
                            UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Auto direction", 0)
                        else
                            UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Auto direction", 1)
                    }
                }
            }
        }

    if(!AutoDir)
        UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Auto direction", 0)
}



Cheat.RegisterCallback("CreateMove", "Visibility_check");

function DesyncMath(Real, fake)
{
    var Intm = Real - fake;
    if(Intm < 0)
        return(-Intm)
    else
        return(Intm)
}

function SafeDesync()
{
    viewYaw = Local.GetViewAngles()[1] - 180;
    fake = adjustAngle(Local.GetFakeYaw()-viewYaw);
    real = adjustAngle(Local.GetRealYaw()-viewYaw);
    var Calculation = DesyncMath(real, fake)
    var Mode = getvalue("Desync Options")
    if(Calculation < 33 && Mode == 2) //avoid overlap
        UI.ToggleHotkey("Anti-Aim", "Fake angles", "Inverter");

        if(Calculation > 38 && Mode == 1) //avoid overlap
        UI.ToggleHotkey("Anti-Aim", "Fake angles", "Inverter");

    
}


Cheat.RegisterCallback("CreateMove", "SafeDesync");

var AutoDirection_Snapshot_X1 = 0;
var AutoDirection_Snapshot_X2 = 0;
//var AutoDirection_Snapshot_X2 = 0;
var Initialized_Autodirection = 0; // nuninitialized
var AutoDirectio_side = 0; // back
var AutoDirectio_side2 = 0; // back
var SetInvert = 0;
var Initialized_Autodirection2 = 0;
function FreeStandingCode2()
{
    var SafeHead = getvalue("Yaw Freestand Mode")
    
    if(SafeHead == 0)
        return;

    
    var SideMovement = UserCMD.GetMovement();
    var CurrentSizeMovement = SideMovement[1]
    if(Initialized_Autodirection2 == 0)
    {
        Initialized_Autodirection2 = 1;
        AutoDirection_Snapshot_X2 = SideMovement[1]
    }
    if(CurrentSizeMovement > AutoDirection_Snapshot_X2 + 4)
    {
        //Cheat.PrintChat("Right")
        AutoDirectio_side2 = 2;
        Initialized_Autodirection = 0;
    }
    else if(CurrentSizeMovement < AutoDirection_Snapshot_X2 - 4)
    {
        //Cheat.PrintChat("Left")
        AutoDirectio_side2 = 1;
        //UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", -90)
        Initialized_Autodirection = 0;
    }
    else
    {
        AutoDirectio_side2 = 3;
    }
    if(AutoDirectio_side2 == 1 && EnemyVisible != 1)
    {
        if(SafeHead == 1)
    {
        var fin2 = 39
        if(UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter"))
            fin2 = 30
        UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", fin2)
    }
    else 
    {
        var fin1 = -30
        if(UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter"))
            fin1 = -39
        UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", fin1)
        }
    }
    else if(AutoDirectio_side2 == 2 && EnemyVisible != 1)
    {

        if(SafeHead == 1)
        {
        var fin1 = -30
        if(UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter"))
            fin1 = -39
        UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", fin1)
        }
        else
        {
            var fin2 = 39
        if(UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter"))
            fin2 = 30
        UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", fin2)
        }
    }
    else if(AutoDirectio_side2 == 3)
    {
        var fin3 = 0
        UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", fin3)
    }
}


Cheat.RegisterCallback("CreateMove", "FreeStandingCode2");

function FreeStandingCode()
{
    
    var mainable = getvalue("Desync Freestand")
    if(!mainable)
        return;
    var mode = getvalue("Desync Freestand Mode")
    var SideMovement = UserCMD.GetMovement();
    var CurrentSizeMovement = SideMovement[1]
    if(Initialized_Autodirection == 0)
    {
        Initialized_Autodirection = 1;
        AutoDirection_Snapshot_X1 = SideMovement[1]
    }
    if(CurrentSizeMovement > AutoDirection_Snapshot_X1 + 4)
    {
        //Cheat.PrintChat("Right")
        AutoDirectio_side = 2;
        Initialized_Autodirection = 0;
    }
    else if(CurrentSizeMovement < AutoDirection_Snapshot_X1 - 4)
    {
        //Cheat.PrintChat("Left")
        AutoDirectio_side = 1;
        //UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", -90)
        Initialized_Autodirection = 0;
    }
    if(AutoDirectio_side == 1)
    {
       if(mode == 0)
       {
           var shuud = UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter");
           if(!shuud)
           {
           UI.ToggleHotkey("Anti-Aim", "Fake angles", "Inverter");
           }
       }
       else if(mode == 1)
       {
        var shuud = UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter");
        if(shuud)
        {
        UI.ToggleHotkey("Anti-Aim", "Fake angles", "Inverter");
        }  
       }

    }
    else if(AutoDirectio_side == 2)
    {
        if(mode == 0)
        {
            var shuud = UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter");
            if(shuud)
            {
            UI.ToggleHotkey("Anti-Aim", "Fake angles", "Inverter");
            }
        }
        else
        {
            var shuud = UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter");
           if(!shuud)
           {
           UI.ToggleHotkey("Anti-Aim", "Fake angles", "Inverter");
           }
        }
    }
}


Cheat.RegisterCallback("CreateMove", "FreeStandingCode");

function FakeAngles() {
    
}
Cheat.RegisterCallback("CreateMove","FakeAngles");
var worldclock = 0;
var resolverbreakS1;
var resolverbreakS2;
var aaqww = 0;
var dynamic_jitter_time = 0;
function antiaim() {
    if(!getvalue("Instant Recharge"))
        Exploit.EnableRecharge()
var master = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Supreme Yaw");
var FM = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Fake Mode")
var FO = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Fake Offset");
var RO = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Real Offset");
var LO = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "LBY Offset");
var original = UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset");
var ideal = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Antiaim Mode");
var ddos = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Crimwalk");
    var minn = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Min [Custom]");
    var maxx = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Max [Custom]");
    var minnn = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Min [Fakelag]");
    var maxxx = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Max [Fakelag]");
var scale = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Scale");
var CWON = UI.IsHotkeyActive( "Misc", "JAVASCRIPT", "Script items", "Crimwalk Key" );
var LBBY = UI.IsHotkeyActive( "Misc", "JAVASCRIPT", "Script items", "Fake Flick");
var LBBYI = UI.IsHotkeyActive( "Misc", "JAVASCRIPT", "Script items", "Invert Fake Flick");
var cw = 0;
var main = 0;
if(ddos && CWON) {
UI.ToggleHotkey("Rage", "Exploits", "Doubletap");
UI.ToggleHotkey("Rage", "Exploits", "Hide shots");
UI.SetValue("Rage", "Exploits", "Doubletap instant", true);
UI.SetValue("Rage", "Exploits", "Doubletap", true);
UI.SetValue("Rage", "Exploits", "Hide shots", true);
if(cw == 3)
{
UI.SetValue("Anti-Aim", "Fake-Lag", "Limit", 5);
UI.SetValue("Anti-Aim", "Fake-Lag", "Enabled", true);
}
else
{
UI.SetValue("Anti-Aim", "Fake-Lag", "Limit", 16);
}
if(cw == 5)
{
cw = 0;
}
cw++;
UI.SetValue("Anti-Aim", "Fake-Lag", "Limit", randomIntFrom(10, 16));
}


    if(master) {    
        if(FM == 0)
	{
	AntiAim.SetOverride(1);
        AntiAim.SetFakeOffset(30);
        AntiAim.SetRealOffset(-30);
        AntiAim.SetLBYOffset(90); 
        UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Desync Speed", 0);
        UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Real Jitter Offset", 0);
        DesyncInfo = [ 30, -30, 90]
	}
	else if(FM == 1)
	{
	AntiAim.SetOverride(1);
        AntiAim.SetFakeOffset(30);
        AntiAim.SetRealOffset(-10);
        AntiAim.SetLBYOffset(60); 
        UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Desync Speed", 0);
        UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Real Jitter Offset", 0);
        DesyncInfo = [ 30, -10, 60]
	}
	else if(FM == 2)
	{
	AntiAim.SetOverride(1);
        AntiAim.SetFakeOffset(FO);
        AntiAim.SetRealOffset(RO);
        AntiAim.SetLBYOffset(LO)
        UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Desync Speed", 0);
        UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Real Jitter Offset", 0);
        DesyncInfo = [ FO, RO, LO]
	}
    else if(FM == 3)
    {
        AntiAim.SetOverride(1);
        AntiAim.SetFakeOffset(1);
        AntiAim.SetRealOffset(-16);
        UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Desync Speed", 1);
        UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Real Jitter Offset", 0);
        AntiAim.SetLBYOffset(resolverbreakCounter)
        DesyncInfo = [ 1, -16, resolverbreakCounter]
        UI.SetValue("Misc", "JAVASCRIPT", "Script items", "Fake Offset", 1);
        UI.SetValue("Misc", "JAVASCRIPT", "Script items", "Real Offset", -16);
        UI.SetValue("Misc", "JAVASCRIPT", "Script items", "LBY Offset", resolverbreakCounter);
        if(resolverbreakCounter < 120 && resolverbreakCylcle == 0)
        {
            resolverbreakCounter += UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Desync Speed");
            
        }
        else if(resolverbreakCounter > -120 && resolverbreakCylcle == 1)
        {
            resolverbreakCounter -= UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Desync Speed");
        }

        if(resolverbreakCounter >= 120)
            resolverbreakCylcle = 1;
        else if(resolverbreakCounter <= -120)
            resolverbreakCylcle = 0;
    }       
    else if(FM == 4)
    {
        var LS = randomIntFrom(5,6)
        switch(LS)
        {
            case 5: 
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(3);
            AntiAim.SetRealOffset(0);
            AntiAim.SetLBYOffset(5);
            DesyncInfo = [ 3, 0, 5]
            break;
            case 6: 
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(-8);
            AntiAim.SetRealOffset(-80);
            AntiAim.SetLBYOffset(22);
            DesyncInfo = [ -8, -80, 22]
            break;
            case 7: AntiAim.SetOverride(1); break;
        } 
    }
    else if(FM == 5)
    {
        var F = randomIntFrom(7, 20)
        var R = randomIntFrom(-80, 7)
        var L = randomIntFrom(120)
        AntiAim.SetOverride(1);
        AntiAim.SetFakeOffset(F);
        AntiAim.SetRealOffset(R);
        AntiAim.SetLBYOffset(L);
        DesyncInfo = [ F, R, L]
    }
    else if(FM == 6)
    {
        AntiAim.SetOverride(1);
        AntiAim.SetFakeOffset(1);
        AntiAim.SetRealOffset(-resolverbreakCounter);
        UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Desync Speed", 1);
        UI.SetEnabled("Misc", "JAVASCRIPT", "Script items", "Real Jitter Offset", 0);
        AntiAim.SetLBYOffset(resolverbreakCounter)
        DesyncInfo = [ 1, -resolverbreakCounter, resolverbreakCounter]
        UI.SetValue("Misc", "JAVASCRIPT", "Script items", "Fake Offset", 1);
        UI.SetValue("Misc", "JAVASCRIPT", "Script items", "Real Offset", -resolverbreakCounter);
        UI.SetValue("Misc", "JAVASCRIPT", "Script items", "LBY Offset", resolverbreakCounter);
        if(resolverbreakCounter < 120 && resolverbreakCylcle == 0)
        {
            resolverbreakCounter += UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Desync Speed");
            
        }
        else if(resolverbreakCounter > -120 && resolverbreakCylcle == 1)
        {
            resolverbreakCounter -= UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Desync Speed");
        }

        if(resolverbreakCounter >= 120)
            resolverbreakCylcle = 1;
        else if(resolverbreakCounter <= -120)
            resolverbreakCylcle = 0;
    }
    else if(FM == 7)
    {
        if(shots == 0)
        {
        AntiAim.SetOverride(1);
        AntiAim.SetFakeOffset(3);
        AntiAim.SetRealOffset(-31);
        AntiAim.SetLBYOffset(-3);
        DesyncInfo = [ 3, -31, -3]
        }
        else if(shots == 1)
        {
        AntiAim.SetOverride(1);
        AntiAim.SetFakeOffset(-20);
        AntiAim.SetRealOffset(60);
        AntiAim.SetLBYOffset(-20);
        DesyncInfo = [ -20, 60, -20]
        }
        else if(shots == 2)
        {
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(-20);
            AntiAim.SetRealOffset(60);
            AntiAim.SetLBYOffset(-20);
            DesyncInfo = [ -20, 60, -20]
        }
        else if(shots == 3)
        {
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(10);
            AntiAim.SetRealOffset(-44);
            AntiAim.SetLBYOffset(-4);
            DesyncInfo = [ 10, -44, -4]
        }
        else if(shots == 4)
        {
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(10);
            AntiAim.SetRealOffset(-44);
            AntiAim.SetLBYOffset(-4);
            DesyncInfo = [ 10, -44, -4]
        }
        else if(shots > 4)
        {
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(15);
            AntiAim.SetRealOffset(-40);
            AntiAim.SetLBYOffset(-20);
            DesyncInfo = [ 15, -40, -20]
        }
    }
    else if(FM == 8)
    {
        var idk = randomIntFrom(5,6)
        switch(idk)
        {
            case 5: AntiAim.SetOverride(1); break;
            case 6: AntiAim.SetOverride(0); break;
            case 7: AntiAim.SetOverride(1); break;
        }
    }
    else if(FM == 9)
    {
        var id2k = randomIntFrom(5,6)
        switch(id2k)
        {
            case 5: 
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(3);
            AntiAim.SetRealOffset(-24);
            AntiAim.SetLBYOffset(5);
            DesyncInfo = [ 3, -24, 5]
            break;
            case 6: 
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(-8);
            AntiAim.SetRealOffset(-59);
            AntiAim.SetLBYOffset(22);
            DesyncInfo = [ -8, -59, 22]
            break;
            case 7: AntiAim.SetOverride(1); break;
        }
    }
    else if(FM == 10)
    {
        var i2k = randomIntFrom(5,6)
        switch(i2k)
        {
            case 5: 
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(2);
            AntiAim.SetRealOffset(-56);
            AntiAim.SetLBYOffset(-3);
            DesyncInfo = [ 2, -56, -3]
            break;
            case 6: 
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(-2);
            AntiAim.SetRealOffset(91);
            AntiAim.SetLBYOffset(-33);
            DesyncInfo = [ -2, 91, -33]
            break;
            case 7: AntiAim.SetOverride(1); break;
        }
    }
    else if(FM == 11)
    {
        if(aaqww < 3)
        {
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(3);
            AntiAim.SetRealOffset(-120);
            AntiAim.SetLBYOffset(74);
            DesyncInfo = [ 3, -120, 74]
            UI.SetValue("Misc", "JAVASCRIPT", "Script items", "Fake Offset", 3);
        UI.SetValue("Misc", "JAVASCRIPT", "Script items", "Real Offset", -120);
        UI.SetValue("Misc", "JAVASCRIPT", "Script items", "LBY Offset", 74);
        
        }
        else if(aaqww > 3)
        {
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(3);
            AntiAim.SetRealOffset(-15);
            AntiAim.SetLBYOffset(74);
            DesyncInfo = [ 3, -15, 74]
            UI.SetValue("Misc", "JAVASCRIPT", "Script items", "Fake Offset", 3);
        UI.SetValue("Misc", "JAVASCRIPT", "Script items", "Real Offset", -15);
        UI.SetValue("Misc", "JAVASCRIPT", "Script items", "LBY Offset", 74);

        }
        aaqww++;
        if(aaqww > 6)
        {
            aaqww = 0;
        }
        
    }
    else if(FM == 12)
    {
        AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(3);
            AntiAim.SetRealOffset(-21);
            AntiAim.SetLBYOffset(10);
            DesyncInfo = [ 3, -21, 10]
    }
    else if(FM == 13)
    {
        if(resolverbreakCalc > 20)
            resolverRand = randomIntFrom(5,7)

        switch(resolverRand)
        {
            case 5:
                var i5k = randomIntFrom(5,6)
        switch(i5k)
        {
            case 5: 
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(3);
            AntiAim.SetRealOffset(-120);
            AntiAim.SetLBYOffset(74);
            DesyncInfo = [ 3, -120, 74]
            break;
            case 6: 
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(3);
            AntiAim.SetRealOffset(-15);
            AntiAim.SetLBYOffset(74);
            DesyncInfo = [ 3, -15, 74]
            break;
            case 7: AntiAim.SetOverride(1); break;
        }
        break;

            case 6:
                var i2k3 = randomIntFrom(5,6)
                switch(i2k3)
                {
                    case 5: 
                AntiAim.SetOverride(1);
                AntiAim.SetFakeOffset(-3);
                AntiAim.SetRealOffset(120);
                AntiAim.SetLBYOffset(-74);
                DesyncInfo = [ -3, 120, -74]
            break;
            case 6: 
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(-3);
            AntiAim.SetRealOffset(15);
            AntiAim.SetLBYOffset(-74);
            DesyncInfo = [ -3, 15, -74]
            break;
            case 7: AntiAim.SetOverride(1); break;
                }
            break;
        

            case 7:

                var i122k = randomIntFrom(5,6)
        switch(i122k)
        {
            case 5: 
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(-15);
            AntiAim.SetRealOffset(-56);
            AntiAim.SetLBYOffset(-3);
            DesyncInfo = [ -15, -56, -3]
            break;
            case 6: 
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(-15);
            AntiAim.SetRealOffset(91);
            AntiAim.SetLBYOffset(-33);
            DesyncInfo = [ -15, 91, -33]
            break;
            case 7: AntiAim.SetOverride(1); break;
        }
            break;
        }

        
        if(resolverbreakCalc > 21)
            resolverbreakCalc = 0;
        resolverbreakCalc++;
    }
}
    else {
        AntiAim.SetOverride(0);

    }
    if(ideal == 1) {
    UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", randomIntFrom(-55, 0));
    UI.SetValue("Anti-Aim", "Fake-Lag", "Limit", randomIntFrom(10 - scale, 16 - scale));
    UI.SetValue("Anti-Aim", "Fake-Lag", "Enabled", true);
    }
    else if(ideal == 2) {
    UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", randomIntFrom(-50, 50));
UI.SetValue("Anti-Aim", "Fake-Lag", "Limit", randomIntFrom(10 - scale, 16 - scale));
UI.SetValue("Anti-Aim", "Fake-Lag", "Enabled", true);
    }
    else if(ideal == 3) {
    UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", randomIntFrom(minn, maxx));
UI.SetValue("Anti-Aim", "Fake-Lag", "Limit", randomIntFrom(minnn - scale, maxxx - scale));
UI.SetValue("Anti-Aim", "Fake-Lag", "Enabled", true);
    }
    else if(ideal == 4) {
        if(worldclock == 0) {
        UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", -20);
        worldclock = 1;
        }
        else {
        UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", 20);
        worldclock = 0;
        }
    }
    else if(ideal == 5) {
        if(worldclock < 2) {
        UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", -60);
        worldclock++;
        }
        else {
        UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", 60);
        if(worldclock > 4) {
	    worldclock = 0;
            }
        worldclock++;
        }
    }
    else if(ideal == 6)
    {
        switch(maincounterr)
        {
            case 1: UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", 30); break;
            case 2: UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", -30); break;
            case 3: UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", 30); break;
            case 4: UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", -30); break;
            case 5: UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", 30); break;
            case 6: UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", -30); break;
            case 7: UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", 30); break;
            case 8: UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", -30); break;
        }
        maincounterr += randomIntFrom(1,4);
        if(maincounterr > 8)
            maincounterr = 0;
    }
    else if(ideal == 7)
    {
        UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", maincounterr);
        if(maincounterr < 30 && maincycle == 0)
        {
            maincounterr += randomIntFrom(1, 30);
            
        }
        else if(maincounterr > -30 && maincycle == 1)
        {
            maincounterr -= randomIntFrom(1, 30);
        }

        if(maincounterr >= 30)
            maincycle = 1;
        else if(maincounterr <= -30)
            maincycle = 0;
    }


    if(LBBY)
    {

        var LBYYYY = randomIntFrom(5,10)
        var Fake1 = 30;
        var Real1 = 120;
        var LBY1 = -97;
        var Fake2 = 30;
        var Real2 = -120;
        var LBY2 = -97;
        if(LBYYYY == 6)
        {
            if(!LBBYI)
            {
                AntiAim.SetOverride(1);
                AntiAim.SetFakeOffset(-Fake1);
                AntiAim.SetRealOffset(-Real1);
                AntiAim.SetLBYOffset(-LBY1);
            }
            else
            {
            AntiAim.SetOverride(1);
            AntiAim.SetFakeOffset(Fake1);
            AntiAim.SetRealOffset(Real1);
            AntiAim.SetLBYOffset(LBY1);
            }

        }
        else
        {
            if(!LBBYI)
            {
                AntiAim.SetOverride(1);
                AntiAim.SetFakeOffset(-Fake2);
                AntiAim.SetRealOffset(-Real2);
                AntiAim.SetLBYOffset(-LBY2);
            }
            else
            {
                AntiAim.SetOverride(1);
                AntiAim.SetFakeOffset(Fake2);
                AntiAim.SetRealOffset(Real2);
                AntiAim.SetLBYOffset(LBY2);
            }
        }
            
        
        
    }

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

    var DesyncFake = DesyncInfo[0]
    var DesyncReal = DesyncInfo[1]
    var DesyncLBY = DesyncInfo[2]
    if(tempp)
    {

            AntiAim.SetFakeOffset(-DesyncFake);
            AntiAim.SetRealOffset(-DesyncReal);
            AntiAim.SetLBYOffset(-DesyncLBY);
        
    }
}

function InstantRecharge() {
    if(getvalue("Instant Recharge"))
    { 
        for(var i; i < 80; i++) {
            if (i >= 30) {
            Exploit.DisableRecharge(); 
            Exploit.Recharge(); 
            return;
            }
        }
    }
}

function fire(){
    InstantRecharge();
    if(shots < 4)
        shots++;
    else
        shots = 0;

LowDeltaa++;
}





//Callbacks;
Cheat.RegisterCallback("weapon_fire", "fire");

function aaa() {

}
Global.RegisterCallback("Draw", "aaa");
Cheat.RegisterCallback("CreateMove", "antiaim");

function createMat(name){
UI.AddSliderInt("", 0, 0);
UI.AddLabel("Visuals");

init();



UI.AddCheckbox("Supreme Hollow Chams")
    UI.AddColorPicker(name + " chams")
    Material.Create(name + " chams")
    materials.push([name,
         name + " chams",
         "Hollow " + name.toLowerCase() + " chams",
         "Pulse " + name.toLowerCase() + " chams",
         "Rainbow " + name.toLowerCase() + " chams",
         "Wireframe " + name.toLowerCase() + " chams"]);
}

function get_icon(a) {
    var letter = ""
    switch (a) {
        case "desert eagle":
            letter = "a"
            break
        case "dual berettas":
            letter = "b"
            break
        case "five seven":
            letter = "c"
            break
        case "glock 18":
            letter = "d"
            break
        case "ak 47":
            letter = "e"
            break
        case "aug":
            letter = "f"
            break
        case "awp":
            letter = "g"
            break
        case "famas":
            letter = "h"
            break
        case "m249":
            letter = "i"
            break
        case "g3sg1":
            letter = "j"
            break
        case "galil ar":
            letter = "k"
            break
        case "m4a4":
            letter = "l"
            break
        case "m4a1 s":
            letter = "m"
            break
        case "mac 10":
            letter = "n"
            break
        case "p2000":
            letter = "o"
            break
        case "mp5 sd":
            letter = "p"
            break
        case "ump 45":
            letter = "q"
            break
        case "xm1014":
            letter = "r"
            break
        case "pp bizon":
            letter = "s"
            break
        case "mag 7":
            letter = "t"
            break
        case "negev":
            letter = "u"
            break
        case "sawed off":
            letter = "v"
            break
        case "tec 9":
            letter = "w"
            break
        case "zeus x27":
            letter = "x"
            break
        case "p250":
            letter = "y"
            break
        case "mp7":
            letter = "z"
            break
        case "mp9":
            letter = "A"
            break
        case "nova":
            letter = "B"
            break
        case "p90":
            letter = "C"
            break
        case "scar 20":
            letter = "D"
            break
        case "sg 553":
            letter = "E"
            break
        case "ssg 08":
            letter = "F"
            break
        case "knife":
            letter = "G"
            break
        case "flashbang":
            letter = "H"
            break
        case "high explosive grenade":
            letter = "I"
            break
        case "smoke grenade":
            letter = "J"
            break
        case "molotov":
            letter = "K"
            break
        case "decoy grenade":
            letter = "L"
            break
        case "incendiary grenade":
            letter = "M"
            break
        case "c4 explosive":
            letter = "N"
            break
        case "usp s":
            letter = "P"
            break
        case "cz75 auto":
            letter = "Q"
            break
        case "r8 revolver":
            letter = "R"
            break
        case "bayonet":
            letter = "V"
            break
        case "flip knife":
            letter = "W"
            break
        case "gut knife":
            letter = "X"
            break
        case "karambit":
            letter = "Y"
            break
        case "m9 bayonet":
            letter = "Z"
            break
        case "falchion knife":
            letter = "1"
            break
        case "bowie knife":
            letter = "2"
            break
        case "butterfly knife":
            letter = "3"
            break
        case "shadow daggers":
            letter = "4"
            break
        case "ursus knife":
            letter = "5"
            break
        case "navaja knife":
            letter = "6"
            break
        case "stiletto knife":
            letter = "7"
            break
        case "skeleton knife":
            letter = "8"
            break
        case "huntsman knife":
            letter = "0"
            break
        case "talon knife":
            letter = "8"
            break
        case "classic knife":
            letter = "25"
            break
        case "paracord knife":
            letter = "Z"
            break
        case "survival knife":
            letter = "Z"
            break
        case "nomad knife":
            letter = "Z"
            break
        default:
            letter = ""
            break
    }
    return letter
}
UI.AddSliderInt("", 0, 0);
UI.AddLabel("Tickbase Indicator");
UI.AddSliderInt("Tickbase_x", 0, Global.GetScreenSize()[0]);
UI.AddSliderInt("Tickbase_y", 0, Global.GetScreenSize()[1]);
var Colorr = [255, 255, 255, 255]
var storede = false;
var x_offws = 0;
var y_offws = 0;
function in_bounds(vec, x, y, x2, y2) {
    return (vec[0] > x) && (vec[1] > y) && (vec[0] < x2) && (vec[1] < y2)
}
var fa = 0;
var sa = 0;
var alphaa = 179;
var DT_Circle = 0;
var Init_DT = false;
var DT_Tick = 0;
function main_dt() {
    if (!World.GetServerString()) return;
   
    var IDK = 0;
    const x = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Tickbase_x"),
        y = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "Tickbase_y");

    localplayer_index = Entity.GetLocalPlayer();
    localplayer_weapon = Entity.GetWeapon(localplayer_index);
    weapon_name = Entity.GetName(localplayer_weapon);
    g_Local_classname = Entity.GetClassName(localplayer_weapon);
    var nextattack = Entity.GetProp(localplayer_weapon, "CBaseCombatWeapon", "m_flNextPrimaryAttack");
    var CanShoot = false;
    if (nextattack <= Globals.Curtime()) {
        CanShoot = true;
    }

    var frames = 8 * Globals.Frametime();
    
    var font = Render.AddFont( "Microsoft JhengHei Light", 11.5, 100);
    var fontbullet = Render.AddFont("bullet", 18, 100);
    if (CanShoot && Exploit.GetCharge() == 1 && UI.IsHotkeyActive("Rage", "Exploits", "Doubletap")) {
        var text = "DT | Ready | 16";
        var color = [157, 133, 253, 255];
        Colorr = [255, 255, 255, 255]
    } else if (CanShoot && Exploit.GetCharge() == 1 && UI.IsHotkeyActive("Rage", "Exploits", "Hide shots")) {
        var text = "HS | Ready | 7";
        var color = [157, 133, 253, 255];
        Colorr = [255, 255, 255, 255]
    } else {
        IDK = 2;
        Colorr = [235, 67, 52, 255]
    }
    
    if(!UI.IsHotkeyActive("Rage", "Exploits", "Doubletap") && !UI.IsMenuOpen())
        return;
        var text_width = Render.TextSize(get_icon(weapon_name));
    //Render.FilledRect(x, y, w, 2, color);
    if(getvalue("Indicators Style") == 0)
    {
        if(!getmultidrop(getvalue("Indicators"), 3)) 
            return;
        if(IDK == 2)
        return;
    if(IDK == 1)
    {
      
        Render.FilledRect(x, y, 225, 26, [0, 0, 0, 179]);
 
    }
    else
    {
        if(get_icon(weapon_name) == "D")
        {
            Render.FilledRect(x, y, 190, 26, [0, 0, 0, 179]);
        }
        else if(get_icon(weapon_name) == "F")
        {
            Render.FilledRect(x, y, 190, 26, [0, 0, 0, 179]);
        }
        else if(get_icon(weapon_name) == "J")
        {
            Render.FilledRect(x, y, 190, 26, [0, 0, 0, 179]);
        }
        else if(get_icon(weapon_name) == "G")
        {
            Render.FilledRect(x, y, 190, 26, [0, 0, 0, 179]);
        }
        else
        {
        
        Render.FilledRect(x, y, 175, 26, [0, 0, 0, alphaa]);
        }
    }
    //Render.StringCustom(x + 5, y + 5, 0, text, [0, 0, 0, 255], font);
    

    Render.String(x + 4, y + 4, 0, get_icon(weapon_name), [255, 255, 255, 255], 5);
    //var StringSize =  Render.TextSize(get_icon(weapon_name))
    if(get_icon(weapon_name) == "D")
    {
        Render.StringCustom(x + 80, y + 4, 0, text, [255, 255, 255, 255], font);
    }
    else if(get_icon(weapon_name) == "F")
    {
        Render.StringCustom(x + 80, y + 4, 0, text, [255, 255, 255, 255], font);
    }
    else if(get_icon(weapon_name) == "J")
    {
        Render.StringCustom(x + 80, y + 4, 0, text, [255, 255, 255, 255], font);
    }
    else if(get_icon(weapon_name) == "G")
    {
        Render.StringCustom(x + 80, y + 4, 0, text, [255, 255, 255, 255], font);
    }
    else
    {
    Render.StringCustom(x + 65, y + 4, 0, text, [255, 255, 255, 255], font);
    }
}
    else {
        if(!getmultidrop(getvalue("Indicators"), 2)) 
            return;
        const main = Render.AddFont("Calibri", 12, 600)
        var collll = CanShoot && Exploit.GetCharge() == 1 
        if(!collll && Init_DT == false && UI.IsHotkeyActive("Rage", "Exploits", "Doubletap")) { Init_DT = true; DT_Circle = 0; }
        if(DT_Circle < 360 && Init_DT) { DT_Circle += 10 }
        else if(Init_DT && collll) { Init_DT = false; DT_Tick = randomIntFrom(10, 15) }
        Render.GradientRect( x, y, 145, 50, 1, [ 52, 100, 235, 255 ], [ 52, 100, 235, 0 ]);
        Render.FilledRect(x, y + 2, 155, 46, [0, 0, 0, 255]);
        //Render.GradientRect( x, y + 2, 8, 46, 1, [ 52, 100, 235, 255 ], [ 0, 0, 0, 255 ]);
        Render.GradientRect( x - 6, y, 6, 50, 1, [ 52, 100, 235,0 ], [ 52, 100, 235, 255 ]);
        drawArc(x + 30, y + 24, 17, 0, DT_Circle, 4, collll ? [99, 235, 66,255] : [235, 67, 52, 255])
        if(DT_Circle < 2)
            var Offsetr = 20
        else
            var Offsetr = 60
        Render.StringCustom(x + Offsetr, y + 6, 0, "Doubletap", [255, 255, 255, 255], main);
        if(getmultidrop(getvalue("Indicators"), 3)) 
        {
        
        var TextE = collll ? "12 Ticks" : "0 Ticks";
        switch(getvalue("Doubletap Mode"))
        {
            case 1: var TextE = collll ? "13 Ticks" : "0 Ticks"; break;
            case 2: var TextE = collll ? "14 Ticks" : "0 Ticks"; break;
            case 2: var TextE = collll ? DT_Tick.toString() : "0 Ticks"; break;
        }
        if(getvalue("Instant Recharge")) { var TextE = collll ? "15 Ticks" : "0 Ticks"; }
        Render.StringCustom(x + Offsetr, y + 25, 0, TextE, [255, 255, 255, 255], main);
        }
        
    }

    if ((g_Local_classname == "CKnife" || g_Local_classname == "CWeaponSSG08" || g_Local_classname == "CWeaponAWP" || weapon_name == "r8 revolver" || g_Local_classname == "CHEGrenade" || g_Local_classname == "CMolotovGrenade" || g_Local_classname == "CIncendiaryGrenade" || g_Local_classname == "CFlashbang" || g_Local_classname == "CSmokeGrenade" || g_Local_classname == "CDecoyGrenade" || g_Local_classname == "CWeaponTaser" || g_Local_classname == "CC4")) {
        //return
    } else {
        if (CanShoot) {
            fa = Math.min(fa + frames, 1);
            //Render.StringCustom(x + 10 + Render.TextSize(get_icon(weapon_name), 5)[0], y + 18, 0, "A", [255, 255, 255, fa * 255], fontbullet);
        } else {
            fa = 0;
        }
        if (CanShoot && Exploit.GetCharge() == 1 && UI.IsHotkeyActive("Rage", "Exploits", "Doubletap")) {
            sa = Math.min(sa + frames, 1);
            //Render.StringCustom(x + 30 + Render.TextSize(get_icon(weapon_name), 5)[0], y + 18, 0, "A", [255, 255, 255, sa * 255], fontbullet);
        } else {
            sa = 0;
        }
    }


    if (Input.IsKeyPressed(0x1) && UI.IsMenuOpen()) {
        const mouse_pos = Global.GetCursorPosition();
        if (mouse_pos[0] > x && mouse_pos[0] < x + 190 && mouse_pos[1] > y && mouse_pos[1] < y + 50) {
            if(!storede)
                {x_offws = mouse_pos[0] - x; y_offws = mouse_pos[1] - y; storede = true}
            UI.SetValue("Misc", "JAVASCRIPT", "Script items", "Tickbase_x", mouse_pos[0] - x_offws);
            UI.SetValue("Misc", "JAVASCRIPT", "Script items", "Tickbase_y", mouse_pos[1] - y_offws);
        }
    } else if(storede) {storede = false;}
}
Global.RegisterCallback("Draw", "main_dt");



var props = false;
var tonemapClass = 'CEnvTonemapController';

function getValue(name) {
  var value = UI.GetValue('Script Items', name);

  return value;
}

function getColor(name) {
  var value = UI.GetColor('MISC', 'JAVASCRIPT', 'Script items', name);

  return value;
}

function onRenderrr() {
  if (!Entity.GetLocalPlayer()) {
    return;
  }

  var worldColor = (
    getValue('enable world color modulation')
      ? getColor('world color')
      : [0, 0, 0]
  );

  Convar.SetFloat('mat_ambient_light_r', worldColor[0] / 100);
  Convar.SetFloat('mat_ambient_light_g', worldColor[1] / 100);
  Convar.SetFloat('mat_ambient_light_b', worldColor[2] / 100);

  var entities = Entity.GetEntities();

  for (var i = 0; i < entities.length; i++) {
    var entity = entities[i];
    var name = Entity.GetClassName(entity);

    if (name !== tonemapClass) {
      continue;
    }

    if (!props) {
      Entity.SetProp(entity, tonemapClass, 'm_bUseCustomAutoExposureMin', true);
      Entity.SetProp(entity, tonemapClass, 'm_bUseCustomAutoExposureMax', true);
      Entity.SetProp(entity, tonemapClass, 'm_bUseCustomBloomScale', true);

      props = true;
    }

    if (props) {
      var value = getValue('world exposure') / 10;
      Entity.SetProp(entity, tonemapClass, 'm_flCustomAutoExposureMin', value);
      Entity.SetProp(entity, tonemapClass, 'm_flCustomAutoExposureMax', value);

      Entity.SetProp(entity, tonemapClass, 'm_flCustomBloomScale', getValue('bloom scale') / 10);
    }

    Convar.SetFloat('r_modelAmbientMin', getValue('model ambient') / 10);
  }
}

function init() {
  UI.AddSliderFloat('world exposure', 0.0, 100.0);
  UI.AddSliderFloat('model ambient', 0.0, 100.0);
  UI.AddSliderFloat('bloom scale', 0.0, 100.0);
  UI.AddCheckbox('enable world color modulation');
  UI.AddColorPicker('world color');

  UI.SetValue('MISC', 'GENERAL', 'Hidden cvars', true);
  UI.SetValue('MISC', 'PERFORMANCE & INFORMATION', 'Disable post processing', false);

  Global.RegisterCallback("Draw", "onRenderrr");
}

function clamp(val, min, max)
{
    return Math.max(min,Math.min(max,val));
}

function HSVtoRGB(h,s,v){
    var r, g, b, i, f, p, q, t;
    if (arguments.length === 1) {
        s = h.s, v = h.v, h = h.h;
    }
    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 [
        Math.round(r * 255),
        Math.round(g * 255),
        Math.round(b * 255),
        255
    ]
}
function materialUpdate(){   
    for(i in materials){
        var mat = materials[i]
        var mat_index = Material.Get(mat[0] + " chams")
        if ( mat_index > 0 )
        {
            
            Material.SetKeyValue(mat_index, "$baseTexture", "vgui/white")
            var additive = UI.GetValue("Script items", "Hollow " + mat[0] .toLowerCase() + " chams")
            Material.SetKeyValue(mat_index, "$additive", additive ? "1" : "0")
            Material.SetKeyValue(mat_index, "$envmap", "models/effects/cube_white")
            Material.SetKeyValue(mat_index, "$envmapfresnel", "1")
            
            var uicol = UI.GetColor("Script items", mat[0]  + " chams")
            var pulse = UI.GetValue("Script items", mat[3])
            var rainbow = UI.GetValue("Script items", mat[4])
            if(rainbow){
                uicol = HSVtoRGB(Globals.Realtime() / 5 % 1, 1, 1)
                uicol[0] /= 10
                uicol[1] /= 10
                uicol[2] /= 10
            }
            if(pulse){
                var speed = 7
                var additive = 5
                var intensity = 0.6
                var sine = (Math.sin(Globals.Realtime() * 7) + 5) * intensity
                uicol[0] *= sine
                uicol[1] *= sine
                uicol[2] *= sine
            }
            var wireframe = UI.GetValue("Script items", mat[5])
            Material.SetKeyValue(mat_index, "$wireframe", wireframe ? "1" : "0")
            Material.SetKeyValue(mat_index, "$envmapfresnelminmaxexp", wireframe ? "[0 2 4]" : "[0 1 2]")
            Material.SetKeyValue(mat_index, "$envmaptint", "[" + uicol[0]/255 + " " + uicol[1]/255 + " " + uicol[2]/255 + "]")
            Material.SetKeyValue(mat_index, "$alpha", "1")
            Material.Refresh(mat_index)       
        }
    }
}
createMat("Supreme")
Cheat.RegisterCallback("Material", "materialUpdate")
function onUnload()
{
    for(i in materials)
    {
        Material.Destroy(materials[i][0])
    }
}
Cheat.RegisterCallback("Unload", "onUnload")
UI.AddSliderInt("", 0, 0);
UI.AddLabel("Grenade Helper");
UI.AddCheckbox("Draw locations through walls");
UI.AddHotkey("Auto throw");
UI.AddDropdown("Throw mode", ["Default", "Silent (rage)", "Legit"]);
UI.AddMultiDropdown("Enabled grenades", ["Molotovs", "high explosive grenades", "Flashbangs", "Smokes"]);
UI.AddSliderFloat("Legit aim speed", 0.01, 3);
UI.AddCheckbox("Nade location tools");
UI.AddHotkey("Grenade setup");

UI.AddCheckbox("Custom colors");
UI.AddColorPicker("Background");
UI.AddColorPicker("Gradient 1");
UI.AddColorPicker("Gradient 2");
UI.AddColorPicker("Text");
UI.AddColorPicker("Circle");
UI.AddColorPicker("Circle interior");
UI.AddColorPicker("Line");


_locations = require('locations.js');

var ticks_to_run = 22;

var chat_tut = false;
var chat_stage = 0;
var chat_start = 0;
var def_rect = [45, 43, 48, 255];
var def_grad = [[149, 0, 255, 255], [211, 3, 252, 255]];
var def_text = [255, 255, 255, 255];
var def_circle = [100,100,100, 200];
var def_circle_int = [56, 200, 56, 255];
var def_line = [211, 3, 252, 255];
var rect = [45, 43, 48, 255];
var grad = [[1, 65, 148, 255], [211, 3, 252, 255]];
var text_c = [255, 255, 255, 255];
var circle = [255, 255, 255, 200];
var circle_int = [56, 200, 56, 255];
var line = [211, 3, 252, 255];
var temp_nade = [];

function print_nade_stats() {
    if (UI.IsHotkeyActive("Script items", "Grenade setup") && !chat_tut && World.GetServerString() != "") {
        chat_start = Globals.Curtime();
        Cheat.PrintChat("Please enter a name for this grenade. (Type `cancel` to cancel setup!)");
        chat_stage = 0;
        chat_tut = true;
    }
}

function on_chat() {
    if(!Entity.IsLocalPlayer(Entity.GetEntityFromUserID(Event.GetInt('userid'))) || !chat_tut)
        return;

    var text = Event.GetString('text');

    if(text.toLowerCase() == "cancel") {
        chat_tut = false;
        temp_nade = [];
        chat_stage = 0;
        chat_start = 0;
        Cheat.PrintChat("You have cancelled this grenade setup!");
        return;
    }

    if(chat_stage == 0) {
        if(!~GRENADE_TYPES.indexOf(Entity.GetName(Entity.GetWeapon(Entity.GetLocalPlayer()))))
            return Cheat.PrintChat("Please hold a valid grenade!");

        temp_nade[0] = World.GetMapName();
        temp_nade[1] = Entity.GetRenderOrigin(Entity.GetLocalPlayer());
        temp_nade[2] = Local.GetViewAngles();
        temp_nade[3] = Entity.GetName(Entity.GetWeapon(Entity.GetLocalPlayer()));
        temp_nade[4] = text+"";
        Cheat.PrintChat("How do you throw this grenade? (0 = Throw, 1 = Run+Throw, 2 = Jump+Throw, 3 = Run+Jump+Throw, 4 = Half throw)");
        chat_start = Globals.Curtime();
        chat_stage++;
    } else

    if(chat_stage == 1) {
        if(isNaN(parseInt(text)) || parseInt(text) > 4 || parseInt(text) < 0) 
            return Cheat.PrintChat("Please enter a number!");

        if(parseInt(text) == 0)
            temp_nade[5] = "Throw";

        if(parseInt(text) == 1)
            temp_nade[5] = "Run+Throw";

        if(parseInt(text) == 2)
            temp_nade[5] = "Jump+Throw"

        if(parseInt(text) == 3)
            temp_nade[5] = "Run+Jump+Throw";

        if(parseInt(text) == 4)
            temp_nade[5] = "Half throw";

        chat_start = Globals.Curtime();
        
        if(parseInt(text) == 1) {
            chat_stage = 3;
            Cheat.PrintChat("How far should you run (in ticks) to throw this nade? (default = 22)");
        } else if(parseInt(text) == 3) {
            chat_stage = 4;
            Cheat.PrintChat("How far should you run (in units) to throw this nade? (default = 80)");
        } else {
            temp_nade[6] = 0;
            Cheat.PrintChat("Your grenade is ready to go, check console!");
            Cheat.Print("Your grenade is ready to go!\n");
            Cheat.Print("[ \"" + World.GetMapName() + "\", [" + Entity.GetEyePosition(Entity.GetLocalPlayer()) + "], [" + Local.GetViewAngles() + "], \"" + Entity.GetName(Entity.GetWeapon(Entity.GetLocalPlayer())) + "\",\""+ temp_nade[4] +"\", \""+temp_nade[5]+"\", 0 ]\n");
            chat_stage = 0;
            chat_tut = false;
            temp_nade = []; 
            chat_start = 0;
        }
    } else

    if(chat_stage == 3) {
        chat_start = Globals.Curtime();
        if(isNaN(parseInt(text)) || parseInt(text) < 1) 
            return Cheat.PrintChat("You must specify a valid time to run!");

        temp_nade[6] = parseInt(text);

        Cheat.PrintChat("Your grenade is ready to go, check console!");
        Cheat.Print("Your grenade is ready to go!\n");
        Cheat.Print("[ \"" + World.GetMapName() + "\", [" + Entity.GetEyePosition(Entity.GetLocalPlayer()) + "], [" + Local.GetViewAngles() + "], \"" + Entity.GetName(Entity.GetWeapon(Entity.GetLocalPlayer())) + "\",\""+ temp_nade[4] +"\", \""+temp_nade[5]+"\","+ parseInt(text) +" ]\n");
        chat_stage = 0;
        chat_tut = [];
        temp_nade = [];
        chat_start = 0;
    } else

    if(chat_stage == 4) {
        chat_start = Globals.Curtime();
        if(isNaN(parseInt(text)) || parseInt(text) < 1) 
            return Cheat.PrintChat("You must specify a valid distance to run!");

        temp_nade[6] = parseInt(text);

        Cheat.PrintChat("Your grenade is ready to go, check console!");
        Cheat.Print("Your grenade is ready to go!\n");
        Cheat.Print("[ \"" + World.GetMapName() + "\", [" + Entity.GetEyePosition(Entity.GetLocalPlayer()) + "], [" + Local.GetViewAngles() + "], \"" + Entity.GetName(Entity.GetWeapon(Entity.GetLocalPlayer())) + "\",\""+ temp_nade[4] +"\", \""+temp_nade[5]+"\","+ parseInt(text) +" ]\n");
        chat_stage = 0;
        chat_tut = [];
        temp_nade = [];
        chat_start = 0;
    }
}

Cheat.RegisterCallback("player_say", "on_chat");

var locations = _locations.locations;

var lerp_time = 0;

var map_cache = [];
var enabled_grenades = [];
var selection_cache = 0;
var hand_cache = 0;
const GRENADE_TYPES = ["high explosive grenade", "smoke grenade", "molotov", "decoy grenade", "incendiary grenade", "flashbang"];
import_grenade_selection();

var weapon = Entity.GetName(Entity.GetWeapon(Entity.GetLocalPlayer()));
if (weapon == "incendiary grenade")
    weapon = "molotov";

map_cache = locations.filter(function (e) {
    return e[0] == World.GetMapName() && ~enabled_grenades.indexOf(e[3].toLowerCase()) && e[3].toLowerCase() == weapon
});

Cheat.RegisterCallback("CreateMove", "print_nade_stats");

function draw() {

    var cust = UI.GetValue("Script items", "Custom colors");

    UI.SetEnabled("Script items", "Background", cust)
    UI.SetEnabled("Script items", "Gradient 1", cust)
    UI.SetEnabled("Script items", "Gradient 2", cust)
    UI.SetEnabled("Script items", "Text", cust)
    UI.SetEnabled("Script items", "Circle", cust)
    UI.SetEnabled("Script items", "Circle interior", cust)
    UI.SetEnabled("Script items", "Line", cust)

    var legit = UI.GetValue("Script items", "Throw mode") == 2 ? true : false;

    UI.SetEnabled("Script items", "Legit aim speed", legit);

    if(cust) {
        rect = UI.GetColor("Script items", "Background");
        grad[0] = UI.GetColor("Script items", "Gradient 1");
        grad[1] = UI.GetColor("Script items", "Gradient 2");
        text_c = UI.GetColor("Script items", "Text");
        circle = UI.GetColor("Script items", "Circle");
        circle_int = UI.GetColor("Script items", "Circle interior");
        line = UI.GetColor("Script items", "Line");
    }

    if(chat_tut && Globals.Curtime() - chat_start > 15 && chat_start != 0) {
        chat_stage = 0;
        chat_start = 0;
        chat_tut = false;
        temp_nade = [];
        Cheat.PrintChat("Grenade setup has timed out!");
    }
        
    UI.SetEnabled("Grenade setup", UI.GetValue("Script items", "Nade location tools"))

    var weapon = Entity.GetName(Entity.GetWeapon(Entity.GetLocalPlayer()));
    if (weapon == "incendiary grenade")
        weapon = "molotov";

    if (!~GRENADE_TYPES.indexOf(weapon))
        return;

    if ((selection_cache != UI.GetValue("Script items", "Enabled grenades")) || ((hand_cache != weapon) || !~GRENADE_TYPES.indexOf(weapon))) {
        import_grenade_selection();
        map_cache = locations.filter(function (e) {
            return e[0] == World.GetMapName() && ~enabled_grenades.indexOf(e[3].toLowerCase()) && e[3].toLowerCase() == weapon;
        });
    }

    if(map_cache.length == 0)
        return;

    for (var g in map_cache) {

        var world_stand = Render.WorldToScreen([map_cache[g][1][0], map_cache[g][1][1], map_cache[g][1][2] - 63]);

        if (!map_cache[g][7] && !UI.GetValue("Script items", "Draw locations through walls"))
            continue;


        var aim = angle_to_vec(map_cache[g][2][0], map_cache[g][2][1]);
        var eye_pos = map_cache[g][1];
        aim = Render.WorldToScreen([eye_pos[0] + aim[0] * 400, eye_pos[1] + aim[1] * 400, eye_pos[2] + aim[2] * 400]);
        var dist = calc_dist(Entity.GetRenderOrigin(Entity.GetLocalPlayer()), map_cache[g][1]);
        Render.Circle(world_stand[0], world_stand[1], 6, cust ? circle : def_circle);
        Render.Circle(world_stand[0], world_stand[1], 1, cust ? circle_int : def_circle_int);

        var size_area = Render.TextSize(map_cache[g][4], 8);
        var size_tut = Render.TextSize(map_cache[g][5], 8);
        Render.FilledRect(world_stand[0] + 9, world_stand[1] - size_area[1] / 1.5, size_area[0] + 7, size_area[1] + 4, cust ? rect : def_rect);
        Render.GradientRect(world_stand[0] + 10, world_stand[1] - size_area[1] / 1.5, size_area[0] + 5, 2, 1, cust ? grad[0] : def_grad[0], cust ? grad[1] : def_grad[1]);
        shadow(world_stand[0] + 12.5, world_stand[1] - 5, 0, map_cache[g][4], false, undefined, cust ? text_c : def_text, 8);

        if (dist > 70)
            continue;

        Render.Circle(aim[0], aim[1], 1, cust ? circle_int : def_circle_int);
        Render.FilledRect(aim[0] + 10, aim[1] - size_area[1] / 1.5, size_area[0] > size_tut[0] ? size_area[0] + 5 : size_tut[0] + 5, size_area[1] > size_tut[1] ? size_area[1] + 15 : size_tut[1] + 15, cust ? rect : def_rect);
        Render.GradientRect(aim[0] + 10, aim[1] - size_area[1] / 1.5, size_area[0] > size_tut[0] ? size_area[0] + 5 : size_tut[0] + 5, 2, 1, cust ? grad[0] : def_grad[0], cust ? grad[1] : def_grad[1]);
        
        
        shadow(aim[0] + 12.5, aim[1] - 5, 0, map_cache[g][4], false, undefined, cust ? text_c : def_text, 8);
        shadow(aim[0] + 12.5, aim[1] + 6.5, 0, map_cache[g][5], false, undefined, cust ? text_c : def_text, 8)
        Render.Circle(aim[0], aim[1], 6, [56, 200, 56, 255]);
        Render.Line(Render.GetScreenSize()[0]/2, Render.GetScreenSize()[1]/2, aim[0], aim[1], cust ? line : def_line);
    }
}


function lerp(start,end,time){
    var delta = end - start
    delta *= time
    delta += start
    return delta
}

function check_visibility() {
    if (map_cache.length == 0 || World.GetServerString() == "")
        return;

    var local = Entity.GetLocalPlayer();

    eye_angles = Local.GetViewAngles();
    head = Entity.GetProp(local, "CBasePlayer", "m_vecOrigin");
    offset = Entity.GetProp(local, "CBasePlayer", "m_vecViewOffset[2]");
    head = vector_add(head, [0, 0, offset[0]]);

    for (var g in map_cache) {
        var result = Trace.Line(local, head, map_cache[g][1]);

        if (map_cache[g][7] == undefined)
            map_cache[g].push(result[1] == 1);
        else
            map_cache[g][7] = result[1] == 1;
    }
}

var angles_met = false;

// thanks vex
function fix_move(ang, old_ang, old_move) {
    var deg2rad = function (a) {
        return a / 180 * Math.PI
    }
    var f1, f2, delta_y
    if (old_ang[1] < 0)
        f1 = 360 + old_ang[1]
    else
        f1 = old_ang[1]

    if (ang[1] < 0)
        f2 = 360 + ang[1]
    else
        f2 = ang[1]
    if (f2 < f1)
        delta_y = Math.abs(f2 - f1)
    else
        delta_y = 360 - Math.abs(f1 - f2)

    return [
        Math.cos(deg2rad(delta_y)) * old_move[0] + Math.cos(deg2rad(delta_y + 90)) * old_move[1],
        Math.sin(deg2rad(delta_y)) * old_move[0] + Math.sin(deg2rad(delta_y + 90)) * old_move[1],
        0
    ]
}

var lerp_time = 0;

// thanks vex
function move_forward(angle) {
    var speed = UI.GetValue("Script items", "Legit aim speed");
    var orig_angle = Local.GetViewAngles()
    var orig_inp = angle;
    var forward = [450, 0, 0]
    var newmove = fix_move(angle, orig_angle, forward)
    var silent = UI.GetValue("Script items", "Throw mode") == 1 ? true : false;
    var legit = UI.GetValue("Script items", "Throw mode") == 2 ? true : false;
    if(legit) {
        silent = false;
        lerp_time = clamp(lerp_time + Globals.TickInterval() * (1/speed), 0, 1);

        var p = lerp(Local.GetViewAngles()[0], closest[2][0], lerp_time);
        var y = lerp(Local.GetViewAngles()[1], closest[2][1], lerp_time);
        angle = [p, normalize(y), 0];
    }
    if(angle[2] == undefined)
        angle[2] = 0;
    UserCMD.SetViewAngles(angle, silent);

    if(Math.abs(angle[0]-orig_inp[0]) > 0.01 && Math.abs(angle[1]-orig_inp[1]) > .01 && legit) 
        return false;

    UserCMD.SetMovement(newmove);
    angles_met = true;
    return true;
    
}

function normalize(yaw) {
    while (yaw > 180)
        yaw -= 360
    while (yaw < -180)
        yaw += 360
    return yaw
}

var closest = [];

function move_on_key() {
    if(map_cache.length == 0)
        return;

    if(!~GRENADE_TYPES.indexOf(Entity.GetName(Entity.GetWeapon(Entity.GetLocalPlayer()))))
        return;

    var silent = UI.GetValue("Script items", "Throw mode") == 1 ? true : false;
    var legit = UI.GetValue("Script items", "Throw mode") == 2 ? true : false;
    
    if (!UI.IsHotkeyActive("Script items", "Auto throw") && Globals.Tickcount() - this.throw_time > 8) {
        this.running = false
        this.closest = [];
        this.ignore_input = false
        this.start_tick = 0
        this.next_tick_ang = []
        this.attacked = false;
        this.moved_base = false;
        this.run_start = 0;
        lerp_time = 0;
        this.hold = false;
        angles_met = false;
        closest = [];
        return;
    }

    if (this.attacked == null)
        this.attacked = false
    if (this.start_tick == null)
        this.start_tick = 0
    if (this.running == null)
        this.running = false
    if (this.closest == null)
        this.closest = []
    if (this.ignore_input == null)
        this.ignore_input = false
    if (this.run_start == null)
        this.run_start = 0;
    if(this.throw_time == null)
        this.throw_time = 0;

    var local = Entity.GetRenderOrigin(Entity.GetLocalPlayer());
    if(!this.running && !this.ignore_input) {
        closest = map_cache.sort(function (a, b) {
            return calc_dist(local, a[1]) - calc_dist(local, b[1]);
        })[0];
        this.closest = closest;
    }
 
    if (this.closest.length) {
        closest = this.closest
    }

    if (this.next_tick_ang == null)
        this.next_tick_ang = []

    if (this.next_tick_ang.length || Globals.Tickcount() - this.throw_time < 8) {
        if(legit) {
            silent = false;
            var speed = UI.GetValue("Script items", "Legit aim speed");
            lerp_time = clamp(lerp_time + Globals.TickInterval() * (1/speed), 0, 1);
            var angle = closest[2];
            var local_angs = Local.GetViewAngles();
    
            var p = lerp(local_angs[0], angle[0], lerp_time);
            var y = lerp(local_angs[1], angle[1], lerp_time);

            if(Math.abs(local_angs[0]-angle[0]) > 0.05 && Math.abs(local_angs[1]-angle[1]) > 0.05) {
                angles_met = false
            } else {
                angles_met = true;
            }
            this.next_tick_ang = [p, normalize(y), 0];
        } else {
            angles_met = true;
        }
        if(this.next_tick_ang[2] == undefined)
            this.next_tick_ang[2] = 0;
        UserCMD.SetViewAngles(this.next_tick_ang, silent)
    }

    if (this.ignore_input) {
        return;
    }

    if (calc_dist(local, closest[1]) > 200 && !this.ignore_input && !this.running) {
        return;
    }

    var moved = move_to_target(closest[1]);
    

    if (moved || this.running) {
        if (closest[5] == "Throw") {
            this.next_tick_ang = closest[2]
            if(angles_met) {
                UserCMD.SetButtons(UserCMD.GetButtons() | 1)
                this.throw_time = Globals.Tickcount();
                this.attacked = true
                this.ignore_input = true
            }
        }
        else if (closest[5] == "Run+Throw") {
            if (!this.closest.length)
                this.closest = closest

            this.next_tick_ang = closest[2]

            if(!angles_met)
                return;

            if (this.start_tick == 0) {
                this.start_tick = Globals.Tickcount()
            }

            if (this.run_start == 0)
                this.run_start = Globals.Tickcount();

            if(!move_forward(closest[2]))
                return;

            this.running = true

            if (this.running && (Globals.Tickcount() - this.run_start > closest[6])) {
                if(!this.attacked && angles_met) {
                    UserCMD.SetButtons(UserCMD.GetButtons() | 1)
                    this.throw_time = Globals.Tickcount();
                    this.attacked = true
                }
                if(Globals.Tickcount() - this.run_start > closest[6] + 8) {
                    this.running = false
                    this.attacked = false;
                    this.ignore_input = true
                    this.next_tick_ang = closest[2]
                    this.run_start = 0;
                }

            }
        }
        else if (closest[5] == "Jump+Throw") {
            this.next_tick_ang = closest[2]
            if(angles_met) {
                UserCMD.SetButtons(UserCMD.GetButtons() | 1 | 2)
                this.ignore_input = true
                this.attacked = true
                this.throw_time = Globals.Tickcount();
            }
        }
        else if (closest[5] == "Run+Jump+Throw") {
            if (!this.closest.length)
                this.closest = closest
            if (this.start_tick == 0) {
                this.start_tick = Globals.Tickcount()
            }
            var forward = angle_to_vec(closest[2][0], closest[2][1])
            if(closest[6] == undefined || closest[6] == 0 || typeof closest[6] == "boolean")
                closest[6] = 80;
            forward = vec_mul_fl(forward, closest[6])
            this.next_tick_ang = closest[2]

            if(!move_forward(closest[2]))
                return;

            this.running = true
            
            var delta = vector_sub(vector_add(forward, closest[1]), Entity.GetRenderOrigin(Entity.GetLocalPlayer()))
            var len = Math.hypot(delta[0], delta[1])
            if (len < 40 && angles_met) {
                UserCMD.SetButtons(UserCMD.GetButtons() | 1 | 2)

                this.attacked = true
                this.throw_time = Globals.Tickcount();
                this.running = false
                this.ignore_input = true
                this.next_tick_ang = closest[2]
            }
        } else if(closest[5] == "Half throw") {
            if (this.start_tick == 0) {
                this.start_tick = Globals.Tickcount()
            }
            if(angles_met)
                UserCMD.SetButtons(UserCMD.GetButtons() | 1<<0 | 1<<11)
            if(Globals.Tickcount() - this.start_tick > 24 && angles_met) {
                this.attacked = true
                this.throw_time = Globals.Tickcount();
                this.ignore_input = true
                this.next_tick_ang = closest[2]
            }
        }
    }
    /* else {
        this.running = false
        this.closest = []
        this.ignore_input = false
        this.start_tick = 0
        this.moved_base = false;
        this.run_start = 0;
    } */
}

function on_local_connect() {
    if (Entity.IsLocalPlayer(Entity.GetEntityFromUserID(Event.GetInt("userid")))) {
        // cache all locations for the player's map into an array
        map_cache = locations.filter(function (e) {
            return e[0] == World.GetMapName();
        });
    }
}

Cheat.RegisterCallback("Draw", "draw");
Cheat.RegisterCallback("CreateMove", "check_visibility");
Cheat.RegisterCallback("CreateMove", "move_on_key");
Cheat.RegisterCallback("player_connect_full", "on_local_connect");

function getAngles(localPos, pos) {
    newPos = vector_sub(pos, localPos);
    xyDist = Math.sqrt((newPos[0] * newPos[0] + newPos[1] * newPos[1]));
    yaw = Math.atan2(newPos[1], newPos[0]) * 180 / Math.PI;
    pitch = Math.atan2(-newPos[2], xyDist) * 180 / Math.PI;
    roll = 0;
    angles = [pitch, yaw, roll];
    return angles;
}
function vector_sub(vec1, vec2) {
    return [
        vec1[0] - vec2[0],
        vec1[1] - vec2[1],
        vec1[2] - vec2[2]
    ];
}
function degreesToRadians(degress) {
    return degress * Math.PI / 180.0;
}
function angle_to_vec(pitch, yaw) {
    var p = degreesToRadians(pitch);
    var y = degreesToRadians(yaw)
    var sin_p = Math.sin(p);
    var cos_p = Math.cos(p);
    var sin_y = Math.sin(y);
    var cos_y = Math.cos(y);
    return [cos_p * cos_y, cos_p * sin_y, -sin_p];
}

function vector_add(vec, vec2) {
    newVec = [
        vec[0] + vec2[0],
        vec[1] + vec2[1],
        vec[2] + vec2[2]
    ]
    return newVec;
}

function shadow(x,y,align,text,custom,font,color,size) {
    if(custom) {
        Render.StringCustom(x+((size/7.17)),y+((size/7.17)),align,text,[0,0,0,255],font);
        Render.StringCustom(x,y,align,text,color,font);
    } else {
        Render.String(x+((size/7.17)),y+((size/7.17)),align,text,[0,0,0,255],size);
        Render.String(x,y,align,text,color,size);
    }
}

function import_grenade_selection() {
    var val = UI.GetValue("Script items", "Enabled grenades");

    if (val == 0)
        enabled_grenades = [];

    if (getDropdownValue(val, 0) && !~enabled_grenades.indexOf("molotov"))
        enabled_grenades.push("molotov");
    else if (~enabled_grenades.indexOf("molotov") && !getDropdownValue(val, 0))
        enabled_grenades.splice(enabled_grenades.indexOf("molotov"), 1);

    if (getDropdownValue(val, 1) && !~enabled_grenades.indexOf("high explosive grenade"))
        enabled_grenades.push("high explosive grenade");
    else if (~enabled_grenades.indexOf("high explosive grenade") && !getDropdownValue(val, 1))
        enabled_grenades.splice(enabled_grenades.indexOf("high explosive grenade"), 1);

    if (getDropdownValue(val, 2) && !~enabled_grenades.indexOf("flashbang"))
        enabled_grenades.push("flashbang");
    else if (~enabled_grenades.indexOf("flashbang") && !getDropdownValue(val, 2))
        enabled_grenades.splice(enabled_grenades.indexOf("flashbang"), 1);


    if (getDropdownValue(val, 3) && !~enabled_grenades.indexOf("smoke grenade"))
        enabled_grenades.push("smoke grenade");
    else if (~enabled_grenades.indexOf("smoke grenade") && !getDropdownValue(val, 3))
        enabled_grenades.splice(enabled_grenades.indexOf("smoke grenade"), 1);


    selection_cache = val;
    hand_cache = Entity.GetName(Entity.GetWeapon(Entity.GetLocalPlayer()));
}
function vec_mul_fl(a, b) {
    return [a[0] * b, a[1] * b, a[2] * b]
}

function calc_dist(a, b) {
    x = a[0] - b[0];
    y = a[1] - b[1];
    z = a[2] - b[2];
    return Math.sqrt(x * x + y * y + z * z);
}

// thanks depresso man (vex)
function move_to_target(destination, a) {
    var local = Entity.GetLocalPlayer()
    var origin = Entity.GetRenderOrigin(local)
    origin[2] = Entity.GetEyePosition(local)[2]
    var delta = [destination[0] - origin[0], destination[1] - origin[1], destination[2] - origin[2]]
    var yaw = Local.GetViewAngles()[1]
    var cmdMove = []

    var speed = 20

    cmdMove[0] = (((Math.sin(yaw / 180 * Math.PI)) * delta[1]) + (Math.cos(yaw / 180 * Math.PI) * delta[0])) * speed
    cmdMove[1] = (((Math.sin(yaw / 180 * Math.PI)) * delta[0]) + (Math.cos(yaw / 180 * Math.PI) * -delta[1])) * speed
    cmdMove[2] = 0

    var length = Math.sqrt(delta[0] * delta[0] + delta[1] * delta[1] + delta[2] * delta[2])
    var velo = Entity.GetProp(local, "DT_CSPlayer", "m_vecVelocity[0]")
    var length2 = Math.sqrt(velo[0] * velo[0] + velo[1] * velo[1] + velo[2] * velo[2])

    UserCMD.SetMovement(cmdMove);
    return length < (a ? a : 1) && (length2 < 2 || a);
}

// thanks ed
function getDropdownValue(value, index) {
    var mask = 1 << index;
    return value & mask ? true : false;
}











/**
* kymiko's gs watermark
* last update 23 04 20
*/

var watermarksfinal = "";
function main()
{
  var Location = getvalue("Watermark Location");
  var OffsettX = 0;
  var OffsettY = 0;
  var watermark_name = getstring("Username");
  var today = new Date();
  var hours1 = today.getHours();
  var minutes1 = today.getMinutes();
  var seconds1 = today.getSeconds();
  var sizee = 0;
  var localplayer_index = Entity.GetLocalPlayer();
  var velocity = Entity.GetProp(localplayer_index, "CBasePlayer", "m_vecVelocity[0]");
  var speed = Math.sqrt(velocity[0] * velocity[0] + velocity[1] * velocity[1]);
  var finalspeed = Math.min( 9999, speed ) + 0.2
  var hours = hours1 <= 9 ? "0" + today.getHours() + ":" : today.getHours() + ":";
  var minutes = minutes1 <= 9 ? "0" + today.getMinutes() + ":" : today.getMinutes() + ":";
  var seconds = seconds1 <= 9 ? "0" + today.getSeconds() : today.getSeconds()    ;
  const tickrate = Globals.Tickrate();
   const ping = Math.floor(Global.Latency() * 1000 / 1.5);
   const fps = Math.floor( 1 / Global.Frametime() );
   const fontpixel = Render.AddFont( "Microsoft JhengHei Light", 11.5, 100);
   const fontpixel2 = Render.AddFont( "Verdana", 8.3, 100);

   if(getmultidrop(getvalue("Watermark"), 0))
   {
   watermarksfinal = "Infinite"
   }
   if(getmultidrop(getvalue("Watermark"), 1))
   {
   watermarksfinal += " | " + watermark_name
   }
   if(getmultidrop(getvalue("Watermark"), 2))
   {
   watermarksfinal +=  " | " + hours + minutes + seconds
   }
   if(getmultidrop(getvalue("Watermark"), 3))
   {
   watermarksfinal += " | " + ping + " ms"
   }
   if(getmultidrop(getvalue("Watermark"), 4))
   {
   watermarksfinal += " | " + tickrate + " tps"
   }
   if(getmultidrop(getvalue("Watermark"), 5))
   {
   watermarksfinal += " | " + fps + " fps"
   }
  

    // Get our drawing properties
    const x = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "watermark_x"),
            y = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "watermark_y");
    const x1 = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "watermark_x1"),
            y1 = UI.GetValue("Misc", "JAVASCRIPT", "Script items", "watermark_y1");

    // Rainbow color for our bar
    const rainbow = [
        Math.floor(Math.sin(Global.Realtime() * 2) * 127 + 128),
        Math.floor(Math.sin(Global.Realtime() * 2 + 2) * 127 + 128),
        Math.floor(Math.sin(Global.Realtime() * 2 + 4) * 127 + 128),
        255
    ];


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) };
}
var name_size = Render.TextSizeCustom(watermarksfinal, fontpixel);
switch(Location)
{
case 0: OffsettX = 7; OffsettY = 7; sizee = 20 + name_size[0]; break;
case 1: OffsettX = 1895 - name_size[0]; OffsettY = 7; sizee = 20 + name_size[0]; break;
case 2: OffsettX = 7; OffsettY = 1050; sizee = 20 + name_size[0]; break;
case 3: OffsettX = 1895 - name_size[0]; OffsettY = 1050; sizee = 20 + name_size[0]; break;
}
if(getmultidrop(getvalue("Watermark"), 0))
   {


    // skeetwater by kymiko
    
    Render.FilledRect(x + OffsettX, y + OffsettY, sizee, 27, [0, 0, 0, 179]);
    
    //Render.FilledRect(x + 1570 + 10, y + 5, 335 - 20, 2, [0, 0, 0, 179]);
    Render.StringCustom(x + OffsettX + 10, y + OffsettY + 4, 0, watermarksfinal, [255, 255, 255, 255], fontpixel);

   }
}
//endregion

//region callbacks

// Callback our main function
Global.RegisterCallback("Draw", "main")


const keybinds_x = UI.AddSliderInt("keybinds_x", 0, Global.GetScreenSize()[0])
const keybinds_y = UI.AddSliderInt("keybinds_y", 0, Global.GetScreenSize()[1])

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

var keybind_snapshot = false;
var KoffsetX = 0;
var KoffsetY = 0;

function keybinds()
 {
     var h = [];
     //const fontpixel = Render.AddFont( "Verdana", 8 , 100);
     const fontpixel = Render.AddFont( "Microsoft JhengHei Light", 11.5, 100);
     const main = Render.AddFont("Calibri", 13, 600)
    // const fontpixel2 = Render.AddFont( "Microsoft JhengHei Light", 9.5, 100);
    if (UI.IsMenuOpen( ) == true)
    {
        h.push("Keybinds List")
    }
     var CWON = UI.IsHotkeyActive( "Misc", "JAVASCRIPT", "Script items", "Crimwalk Key" );
     if(CWON) {
       h.push("Crim Walk")
     }
     if (UI.IsHotkeyActive("Anti-Aim", "Extra", "Slow walk")) {
       h.push("Slow motion")
     }
     if (UI.IsHotkeyActive("Anti-Aim", "Extra", "Fake duck")) {
       h.push("Fake Duck")
     }
     if (UI.IsHotkeyActive("Misc", "General", "Movement", "Auto peek")) {
       h.push("Quick peek")
     }
     if (UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter")) {
       h.push("Anti-Aim invert")
     }
     if (UI.IsHotkeyActive("Rage", "General", "General", "Force safe point")) {
       h.push("Safe point")
     }
     if (UI.IsHotkeyActive("Rage", "General", "General", "Force body aim")) {
       h.push("Body aim")
     }
     if (UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Desync on shot")) {
       h.push("On shot anti-aim")
     }
     if (UI.IsHotkeyActive("Rage", "Exploits", "Doubletap")) {
        h.push("Doubletap")
      }
     if (UI.IsHotkeyActive("Rage", "Exploits", "Hide shots")) {
       h.push("Hide shots")
     }
     if (UI.IsHotkeyActive("Legit", "GENERAL", "Triggerbot", "Enabled")) {
       h.push("Triggerbot")
     }

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

     const rainbow = [
         Math.floor(Math.sin(Global.Realtime() * 2) * 127 + 128),
         Math.floor(Math.sin(Global.Realtime() * 2 + 2) * 127 + 128),
         Math.floor(Math.sin(Global.Realtime() * 2 + 4) * 127 + 128),
         255
     ];
     
     if(getmultidrop(getvalue("Indicators"), 4))
     {
        if(getvalue("Indicators Style") == 0)
        {
     //Render.FilledRect(x, y, 180, 22, [15, 15, 15, 255]);
     Render.FilledRect(x, y, 180, 26, [0, 0, 0, 179]);
     Render.StringCustom(x + 58, y + 3, 0, "Keybinds", [255, 255, 255, 255], main);
     var Size = Render.TextSizeCustom(h[0], fontpixel)
     
     Render.FilledRect(x, y + 26, 180, Size[1] * (h.length) + 5, [0, 0, 0, 40]);
     //Render.FilledRect(x, y, 180, 2, [157, 133, 253, 255]);
     //Render.FilledRect(x, y + 20, 180, 20 + 15 * (h.length - 1), [15, 15, 15, 20]);
     for (i = 0; i < h.length; i++)
     {
        
        
        Render.StringCustom(x + 10, y + 27 + 20 * i, 0, h[i], [255, 255, 255, 255], fontpixel);
        Render.StringCustom(x + 150, y + 27 + 20 * i, 0, "On", [255, 255, 255, 255], fontpixel);
        //Render.StringCustom(x + 123, y + 23 + 15 * i, 0, "[toggled]", [255, 255, 255, 255], fontpixel);
     }
    }
    else
    {
        const main = Render.AddFont("Calibri", 12, 600)
        var I = h.length - 1
        if(h.length == 0)
            return;
        Render.GradientRect( x, y, 145, 33 + 17 * I, 1, [ 52, 100, 235, 255 ], [ 52, 100, 235, 0 ]);
        Render.FilledRect(x, y + 2, 155, 29 + 17 * I, [0, 0, 0, 255]);
        //Render.GradientRect( x, y + 2, 8, 29 + 17 * I, 1, [ 52, 100, 235, 255 ], [ 0, 0, 0, 255 ]);
        Render.GradientRect( x - 6, y, 6, 33 + 17 * I, 1, [ 52, 100, 235,0 ], [ 52, 100, 235, 255 ]);

        for (i = 0; i < h.length; i++)
        {
        Render.StringCustom(x + 20, y + 6 + 16 * i, 0, h[i], [255, 255, 255, 255], main);
        }
    }
    }
     if (Global.IsKeyPressed(1)) {
         const mouse_pos = Global.GetCursorPosition();
         if (mouse_pos[0] > x && mouse_pos[0] < x + 180 && mouse_pos[1] > y && mouse_pos[1] < y + 30) {
          if (UI.IsMenuOpen( ) == false)
            return;
            if(!keybind_snapshot)
            {
                KoffsetX = mouse_pos[0] - x
                KoffsetY = mouse_pos[1] - y
                keybind_snapshot = true;
            }
             UI.SetValue("Misc", "JAVASCRIPT", "Script items", "keybinds_x", mouse_pos[0] - KoffsetX);
             UI.SetValue("Misc", "JAVASCRIPT", "Script items", "keybinds_y", mouse_pos[1] - KoffsetY);
         }
     } else keybind_snapshot = false;

 }

Global.RegisterCallback("Draw", "keybinds");




UI.AddSliderInt("", 0, 0);
UI.AddLabel("Fakelag");

var js_items = ["Misc", "JAVASCRIPT", "Script items"];
var fakelag_conditions = ["Generic", "Standing", "Moving", "Slowwalking", "Aerial"]; //I use those way too much, so might as well move them here to avoid typing that much bullshit
var fakelag_modes = ["Passive", "Step", "Jitter", "Ping-pong", "Supreme"];
var last_visible_condition = 999;
var last_fl_flag_mode = 999;
var was_menu_visible = false;
function vec_length_2d(vec)
{
    return Math.sqrt(vec[0] * vec[0] + vec[1] * vec[1]);
}
function setup_menu() //far too much of a pita to do that many items without a special func tbqh
{
    UI.AddCheckbox("Enable modified fakelag");
    UI.AddMultiDropdown("Fakelag conditions", fakelag_conditions);
    UI.AddDropdown("Currently configured fakelag condition", fakelag_conditions);
    for(var i = 0; i <= 4; i++)
    {
        UI.AddDropdown("Fakelag mode for " + fakelag_conditions[i].toLowerCase() + " condition", fakelag_modes);
        UI.AddSliderInt(fakelag_conditions[i] + " passive limit", 1, 16);
        UI.AddSliderInt(fakelag_conditions[i] + " passive jitter", 1, 100);
        UI.AddSliderInt(fakelag_conditions[i] + " step", 1, 16); //I have no idea what this will do if "Maximum step" is set to less than "Step", it will probably reset and start over again every simtime update.
        UI.AddSliderInt(fakelag_conditions[i] + " maximum step", 1, 16);
        UI.AddSliderInt(fakelag_conditions[i] + " jitter minimum", 1, 16);
        UI.AddSliderInt(fakelag_conditions[i] + " jitter maximum", 1, 16);
        UI.AddSliderInt(fakelag_conditions[i] + " ping-pong minimum", 1, 16);
        UI.AddSliderInt(fakelag_conditions[i] + " ping-pong maximum", 1, 16);
        UI.AddSliderInt(fakelag_conditions[i] + " Supreme minimum", 1, 16);
        UI.AddSliderInt(fakelag_conditions[i] + " Supreme maximum", 1, 16);
        UI.AddSliderInt(fakelag_conditions[i] + " Maximum Maxes per Rotation", 1, 5);
    }
}
setup_menu();
function handle_visibility()
{
    if(!UI.IsMenuOpen()) //Why bother checking for visibility when menu is closed?
    {
        return;
    }
    var is_script_enabled = UI.GetValue(js_items, "Enable modified fakelag");
    if(!is_script_enabled && !was_menu_visible)
    {
        return;
    }
    var script_flags = UI.GetValue(js_items, "Fakelag conditions"); //If no flag for the mode is present, why bother setting things visible?
    UI.SetValue(js_items, "Fakelag conditions", script_flags |= (1 << 0)); //Generic is always picked, regardless of user choice because I don't wish to hear complaints on OT forums about "RRRREEEEEE WHY SCRIPT NO WORK" when there are no conditions selected
    UI.SetEnabled(js_items, "Fakelag conditions", is_script_enabled);
    var cur_fl_condition = UI.GetValue(js_items, "Currently configured fakelag condition");
    var cur_fl_mode_for_condition = UI.GetValue(js_items, "Fakelag mode for " + fakelag_conditions[cur_fl_condition].toLowerCase() + " condition");
    if(cur_fl_condition == last_visible_condition && is_script_enabled && was_menu_visible && fl_mode_for_condition == last_fl_flag_mode)
    {
        return; //I'm retarded for not thinking of that earlier.
    }
    last_visible_condition = cur_fl_condition;
    last_fl_flag_mode = cur_fl_mode_for_condition;
    UI.SetEnabled(js_items, "Currently configured fakelag condition", is_script_enabled);
    for(var i = 0; i <= 4; i++)
    {
        var fl_mode_for_condition = UI.GetValue(js_items, "Fakelag mode for " + fakelag_conditions[i].toLowerCase() + " condition");
        UI.SetEnabled(js_items, "Fakelag mode for " + fakelag_conditions[i].toLowerCase() + " condition", is_script_enabled && cur_fl_condition == i && script_flags & (1 << i));
        UI.SetEnabled(js_items, fakelag_conditions[i] + " passive limit", is_script_enabled && cur_fl_condition == i && fl_mode_for_condition == 0 && script_flags & (1 << i));
        UI.SetEnabled(js_items, fakelag_conditions[i] + " passive jitter", is_script_enabled && cur_fl_condition == i && fl_mode_for_condition == 0 && script_flags & (1 << i));
        UI.SetEnabled(js_items, fakelag_conditions[i] + " step", is_script_enabled && cur_fl_condition == i && fl_mode_for_condition == 1 && script_flags & (1 << i));
        UI.SetEnabled(js_items, fakelag_conditions[i] + " maximum step", is_script_enabled && cur_fl_condition == i && fl_mode_for_condition == 1 && script_flags & (1 << i));
        UI.SetEnabled(js_items, fakelag_conditions[i] + " jitter minimum", is_script_enabled && cur_fl_condition == i && fl_mode_for_condition == 2 && script_flags & (1 << i));
        UI.SetEnabled(js_items, fakelag_conditions[i] + " jitter maximum", is_script_enabled && cur_fl_condition == i && fl_mode_for_condition == 2 && script_flags & (1 << i));
        UI.SetEnabled(js_items, fakelag_conditions[i] + " ping-pong minimum", is_script_enabled && cur_fl_condition == i && fl_mode_for_condition == 3 && script_flags & (1 << i));
        UI.SetEnabled(js_items, fakelag_conditions[i] + " ping-pong maximum", is_script_enabled && cur_fl_condition == i && fl_mode_for_condition == 3 && script_flags & (1 << i));
        UI.SetEnabled(js_items, fakelag_conditions[i] + " Supreme minimum", is_script_enabled && cur_fl_condition == i && fl_mode_for_condition == 4 && script_flags & (1 << i));
        UI.SetEnabled(js_items, fakelag_conditions[i] + " Supreme maximum", is_script_enabled && cur_fl_condition == i && fl_mode_for_condition == 4 && script_flags & (1 << i));
        UI.SetEnabled(js_items, fakelag_conditions[i] + " Maximum Maxes per Rotation", is_script_enabled && cur_fl_condition == i && fl_mode_for_condition == 4 && script_flags & (1 << i));
    }
    was_menu_visible = is_script_enabled;
} //Fixed?



function get_condition(local) //code is retarded, but it works, so who honestly cares?
{
    var local_flags = Entity.GetProp(local, "CBasePlayer", "m_fFlags");
    var local_velocity = Entity.GetProp(local, "CBasePlayer", "m_vecVelocity[0]");
    var local_vel_length = vec_length_2d(local_velocity);
    var slowwalk_toggled = UI.IsHotkeyActive("Anti-Aim", "Extra", "Slow walk") && local_vel_length > 1.0;
    var script_flags = UI.GetValue(js_items, "Fakelag conditions");

    if(!(local_flags & (1 << 0))) //if we are not on ground (for the people who dont remember player flags by heart)
    {
        return script_flags & (1 << 4) ? 4 : 0; //if script flag is set, return aerial, else return generic
    }
    if(slowwalk_toggled)
    {
        return script_flags & (1 << 3) ? 3 : 0; //obviously
    }
    if(local_vel_length > 3.5)
    {
        return script_flags & (1 << 2) ? 2 : 0; //easy enough to understand aswell, 3.5 cause sometimes local vel seems to get fucked up lol (idk why, might be due to my inability to code)
    }
    else
    {
        return script_flags & (1 << 1) ? 1 : 0;
    }
    return 0;
}

var supreme_rotation = 0;

function get_fl_data_based_on_conditions(local)
{
    var condition = get_condition(local);
    var fl_data = {fl_mode: 0, min_lag: 0, max_lag: 1}; //Passive will place its lag amount into min_lag and jitter into max_lag (Can't be arsed to make anything separate for passive)
    fl_data.fl_mode = UI.GetValue(js_items, "Fakelag mode for " + fakelag_conditions[condition].toLowerCase() + " condition")
    switch(fl_data.fl_mode)
    {
        case 0:
            fl_data.min_lag = UI.GetValue(js_items, fakelag_conditions[condition] + " passive limit");
            fl_data.max_lag = UI.GetValue(js_items, fakelag_conditions[condition] + " passive jitter");
            break;
        case 1:
            fl_data.min_lag = UI.GetValue(js_items, fakelag_conditions[condition] + " step");
            fl_data.max_lag = UI.GetValue(js_items, fakelag_conditions[condition] + " maximum step");
            break;
        case 2:
            fl_data.min_lag = UI.GetValue(js_items, fakelag_conditions[condition] + " jitter minimum");
            fl_data.max_lag = UI.GetValue(js_items, fakelag_conditions[condition] + " jitter maximum");
            break;
        case 3:
            fl_data.min_lag = UI.GetValue(js_items, fakelag_conditions[condition] + " ping-pong minimum");
            fl_data.max_lag = UI.GetValue(js_items, fakelag_conditions[condition] + " ping-pong maximum");
            break;
        case 4:
            fl_data.min_lag = UI.GetValue(js_items, fakelag_conditions[condition] + " Supreme minimum");
            fl_data.max_lag = UI.GetValue(js_items, fakelag_conditions[condition] + " Supreme maximum");
            supreme_rotation = UI.GetValue(js_items, fakelag_conditions[condition] + " Maximum Maxes per Rotation");
            break;
    }
    return fl_data;
}



var fakelag_supreme = 0;
var supreme_flip = 0;
var indicator_supreme = 0;
function random_int(min, max)
{
    return Math.floor(Math.random() * (Math.ceil(max) - Math.floor(min) + 1)) + Math.floor(min);
}
var old_simtime = 0.0;
function handle_fakelag()
{
    if(UI.GetValue(js_items, "Enable modified fakelag"))
    {
        var local = Entity.GetLocalPlayer();
        if(Entity.IsValid(local) && Entity.IsAlive(local))
        {
            UI.SetValue("Anti-Aim", "Fake-Lag", "Triggers", 0); //Triggers may interfere with the script's work, so I'll just set them to zero for the meantime. Could restore them if script is disabled/unloaded?
            var fl_data = get_fl_data_based_on_conditions(local);
            var local_current_simtime = Entity.GetProp(local, "DT_BaseEntity", "m_flSimulationTime");
            var current_fakelag_amt = UI.GetValue("Anti-Aim", "Fake-Lag", "Limit");
            if(fl_data.fl_mode == 0)
            {
                UI.SetValue("Anti-Aim", "Fake-Lag", "Limit", fl_data.min_lag);
                UI.SetValue("Anti-Aim", "Fake-Lag", "Jitter", fl_data.max_lag);
                return;
            }
            else if(fl_data.fl_mode != 0)
            {
                UI.SetValue("Anti-Aim", "Fake-Lag", "Jitter", 0); // I don't know how that will interfere with the script's fakelag, so better disable it?
            }
            if(local_current_simtime != old_simtime)
            {
                var choosen = randomIntFrom(2,3);
                var proper_fl_amt = 0;
                old_simtime = local_current_simtime;
                switch(fl_data.fl_mode)
                {
                case 1: //Steps in step sizes you have set up to maximum amount you set on simulation time updates, then sets fakelag to 0 and starts over again.
                    if(current_fakelag_amt >= fl_data.max_lag)
                    {
                        break;
                    }
                    proper_fl_amt = clamp(current_fakelag_amt + fl_data.min_lag, 0, fl_data.max_lag);
                    break;
                case 2: //Not really a "jitter" and probably useless, sets fakelag to a random integer between min and max amounts every simulation time update.
                    proper_fl_amt = random_int(fl_data.min_lag, fl_data.max_lag);
                    break;
                case 3:  //Switches between minimum and maximum fakelag every simulation time update.
                    proper_fl_amt = fl_data.min_lag == current_fakelag_amt ? fl_data.max_lag : fl_data.min_lag;
                    break;
                case 4: //switches in intervals
                switch(fakelag_supreme)
                {
                    case 1: 
                    if(choosen == 2 && supreme_flip < supreme_rotation)
                    {
                        proper_fl_amt =  randomIntFrom(fl_data.max_lag,16);
                        supreme_flip++;
                    }
                    else
                    {
                        proper_fl_amt =  randomIntFrom(1,fl_data.min_lag); 
                    }
                    break;
                    case 2: 
                    if(choosen == 2 && supreme_flip < supreme_rotation)
                    {
                        proper_fl_amt =  randomIntFrom(fl_data.max_lag,16);
                        supreme_flip++;
                    }
                    else
                    {
                        proper_fl_amt =  randomIntFrom(1,fl_data.min_lag); 
                    }
                    break;
                    case 3: 
                    if(choosen == 2 && supreme_flip < supreme_rotation)
                    {
                        proper_fl_amt =  randomIntFrom(fl_data.max_lag,16);
                        supreme_flip++;
                    }
                    else
                    {
                        proper_fl_amt =  randomIntFrom(1,fl_data.min_lag); 
                    }
                    break;
                    case 4: 
                    if(choosen == 2 && supreme_flip < supreme_rotation)
                    {
                        proper_fl_amt =  randomIntFrom(fl_data.max_lag,16);
                        supreme_flip++;
                    }
                    else
                    {
                        proper_fl_amt =  randomIntFrom(1,fl_data.min_lag); 
                    }
                    break;
                    case 5: 
                    if(choosen == 2 && supreme_flip < supreme_rotation)
                    {
                        proper_fl_amt =  randomIntFrom(fl_data.max_lag,16);
                        supreme_flip++;
                    }
                    else
                    {
                        proper_fl_amt =  randomIntFrom(1,fl_data.min_lag); 
                    }
                    fakelag_supreme = 0; 
                    supreme_flip = 0;
                    break;
                }
                fakelag_supreme++;
                break;
                }
                UI.SetValue("Anti-Aim", "Fake-Lag", "Limit", proper_fl_amt);
                indicator_supreme = proper_fl_amt;
            }

        }
    }
}
var old_sup = 0;
var displaytext = " ";
function aaaaa() {
    var font2 = Render.AddFont("Verdana", 17, 500);
    var modif = 200;
    if(indicator_supreme != old_sup) {
        displaytext += " " + indicator_supreme.toString();
    }
    if(displaytext.length > 18) {
        displaytext = " ";
    }
        Render.StringCustom(Global.GetScreenSize()[0] - Global.GetScreenSize()[0] + 5, Global.GetScreenSize()[1] - modif, 0, displaytext, [ 255, 255, 255, 255 ], font2);
        old_sup = indicator_supreme;
}
Global.RegisterCallback("Draw", "aaaaa");

Cheat.RegisterCallback("Draw", "handle_fakelag");
Cheat.RegisterCallback("Draw", "handle_visibility");
UI.AddSliderInt("", 0, 0);
UI.AddLabel("Misc");


UI.AddMultiDropdown("Flags", ["Choke", "Desync", "Height", "Extend"])
var values = []
function addFlag(val, text){
    values.push([val, text])
}
function finishRender(){
    var scr = Render.GetScreenSize()
    var render_with_offset = function(offset){
        Render.FilledRect((scr[0]/10+offset) - 120, scr[1]/2+2, 18, 100, [50,50,50,100])
        var width = val * 96
        Render.FilledRect((scr[0]/10+offset+2) - 120, scr[1]/2+2, 14, width, [157, 133, 253,255])
        var font = Render.AddFont("Verdana", 8, 400)
        Render.StringCustom(scr[0]/10-14+offset+3 - 100,scr[1]/2-14 + 115,1,text,[0,0,0,255], font)
        Render.StringCustom(scr[0]/10-14+offset+3 - 100,scr[1]/2-15 + 115,1,text,[255,255,255,255], font)
    }
    for(i in values){
        var text = values[i][1]
        var val = values[i][0]
        render_with_offset(i*40)
    }
 
}
function clamp(val,min,max){
    if(val > max)
        return max
    if(val < min)
        return min
    return val
}
var fl_amount = 0
function onDraw11(){
    values = []
    var flags = UI.GetValue("Script Items", "Flags")
    var local = Entity.GetLocalPlayer()
    if(!local || !Entity.IsAlive(local))
        return
    if(flags & (1 << 0)){
        var simulation_time = Entity.GetProp(local, "DT_BaseEntity", "m_flSimulationTime");
        var simulation_time_delta = Globals.Curtime() - simulation_time;
        fl_amount = (simulation_time_delta / Globals.TickInterval());
        addFlag(clamp(Math.floor(fl_amount) / 16, 0, 1),"choke")
    }
     
    if(flags & (1 << 1)){
        var real = Local.GetRealYaw()
        var fake = Local.GetFakeYaw()
 
        var desync = real - fake
        if(desync > 180) desync -= 360
        if(desync < -180) desync += 360
        desync = Math.abs(desync) / 120
        addFlag(desync,"desync")
    }
    if(flags & (1 << 2)){
        var height = 1-Entity.GetProp(local, "DT_CSPlayer", "m_flDuckAmount")
        addFlag(height, "height")
    }
    if(flags & (1 << 3)){
        var extend = UI.GetValue("Misc", "GENERAL", "Miscellaneous", "Extended backtracking")
        addFlag(extend ? 1 : 0, "extend")
    }
    finishRender()
}
Cheat.RegisterCallback("Draw", "onDraw11")

//region api
const global = [], globals = [], sound = [], cheat = [], local = [], world = [], input = [], render = [], ui = [], convar = [], event = [], entity = [], trace = [], usercmd = [], antiaim = [], exploit = [], ragebot = [], material = []; global.print = Global.Print, global.print_chat = Global.PrintChat, global.print_color = Global.PrintColor, global.register_callback = Global.RegisterCallback, global.execute_command = Global.ExecuteCommand, global.frame_stage = Global.FrameStage, global.tickcount = Global.Tickcount, global.tickrate = Global.Tickrate, global.tick_interval = Global.TickInterval, global.curtime = Global.Curtime, global.realtime = Global.Realtime, global.frametime = Global.Frametime, global.latency = Global.Latency, global.get_view_angles = Global.GetViewAngles, global.set_view_angles = Global.SetViewAngles, global.get_map_name = Global.GetMapName, global.is_key_pressed = Global.IsKeyPressed, global.get_screen_size = Global.GetScreenSize, global.get_cursor_position = Global.GetCursorPosition, global.play_sound = Global.PlaySound, global.play_microphone = Global.PlayMicrophone, global.stop_microphone = Global.StopMicrophone, global.get_username = Global.GetUsername, global.set_clan_tag = Global.SetClanTag, globals.tickcount = Globals.Tickcount, globals.tickrate = Globals.Tickrate, globals.tick_interval = Globals.TickInterval, globals.curtime = Globals.Curtime, globals.realtime = Globals.Realtime, globals.frametime = Globals.Frametime, sound.play = Sound.Play, sound.play_microphone = Sound.PlayMicrophone, sound.stop_microphone = Sound.StopMicrophone, cheat.get_username = Cheat.GetUsername, cheat.register_callback = function(c, f) { switch (c) { case 'create_move': Cheat.RegisterCallback("CreateMove", f); break; case 'paint': Cheat.RegisterCallback("Draw", f); break; case 'fsn': Cheat.RegisterCallback("FrameStageNotify", f); break; case 'shutdown': Cheat.RegisterCallback("Unload", f); break; default: Cheat.RegisterCallback(c, f); break; } }, cheat.execute_command = Cheat.ExecuteCommand, cheat.frame_stage = Cheat.FrameStage, cheat.print = Cheat.Print, cheat.print_chat = Cheat.PrintChat, cheat.print_color = Cheat.PrintColor, local.latency = Local.Latency, local.get_view_angles = Local.GetViewAngles, local.set_view_angles = Local.SetViewAngles, local.set_clan_tag = Local.SetClanTag, local.get_real_yaw = Local.GetRealYaw, local.get_fake_yaw = Local.GetFakeYaw, local.get_spread = Local.GetSpread, local.get_inaccuracy = Local.GetInaccuracy, world.get_map_name = World.GetMapName, world.get_server_string = World.GetServerString, input.get_cursor_position = Input.GetCursorPosition, input.is_key_pressed = Input.IsKeyPressed, render.string = Render.String, render.text_size = Render.TextSize, render.line = Render.Line, render.rect = Render.Rect, render.filled_rect = Render.FilledRect, render.gradient_rect = Render.GradientRect, render.circle = Render.Circle, render.filled_circle = Render.FilledCircle, render.polygon = Render.Polygon, render.world_to_screen = Render.WorldToScreen, render.add_font = Render.AddFont, render.find_font = Render.FindFont, render.string_custom = Render.StringCustom, render.textured_rect = Render.TexturedRect, render.add_texture = Render.AddTexture, render.text_size_custom = Render.TextSizeCustom, render.get_screen_size = Render.GetScreenSize, ui.get_value = UI.GetValue, ui.set_value = UI.SetValue, ui.add_checkbox = UI.AddCheckbox, ui.add_slider_int = UI.AddSliderInt, ui.add_slider_float = UI.AddSliderFloat, ui.add_hotkey = UI.AddHotkey, ui.add_label = UI.AddLabel, ui.add_dropdown = UI.AddDropdown, ui.add_multi_dropdown = UI.AddMultiDropdown, ui.add_color_picker = UI.AddColorPicker, ui.add_textbox = UI.AddTextbox, ui.set_enabled = UI.SetEnabled, ui.get_string = UI.GetString, ui.get_color = UI.GetColor, ui.set_color = UI.SetColor, ui.is_hotkey_active = UI.IsHotkeyActive, ui.toggle_hotkey = UI.ToggleHotkey, ui.is_menu_open = UI.IsMenuOpen, convar.get_int = Convar.GetInt, convar.set_int = Convar.SetInt, convar.get_float = Convar.GetFloat, convar.set_float = Convar.SetFloat, convar.get_string = Convar.GetString, convar.set_string = Convar.SetString, event.get_int = Event.GetInt, event.get_float = Event.GetFloat, event.get_string = Event.GetString, entity.get_entities = Entity.GetEntities, entity.get_entities_by_class_i_d = Entity.GetEntitiesByClassID, entity.get_players = Entity.GetPlayers, entity.get_enemies = Entity.GetEnemies, entity.get_teammates = Entity.GetTeammates, entity.get_local_player = Entity.GetLocalPlayer, entity.get_game_rules_proxy = Entity.GetGameRulesProxy, entity.get_entity_from_user_i_d = Entity.GetEntityFromUserID, entity.is_teammate = Entity.IsTeammate, entity.is_enemy = Entity.IsEnemy, entity.is_bot = Entity.IsBot, entity.is_local_player = Entity.IsLocalPlayer, entity.is_valid = Entity.IsValid, entity.is_alive = Entity.IsAlive, entity.is_dormant = Entity.IsDormant, entity.get_class_i_d = Entity.GetClassID, entity.get_class_name = Entity.GetClassName, entity.get_name = Entity.GetName, entity.get_weapon = Entity.GetWeapon, entity.get_weapons = Entity.GetWeapons, entity.get_render_origin = Entity.GetRenderOrigin, entity.get_render_box = Entity.GetRenderBox, entity.get_prop = Entity.GetProp, entity.set_prop = Entity.SetProp, entity.get_hitbox_position = Entity.GetHitboxPosition, entity.get_eye_position = Entity.GetEyePosition, trace.line = Trace.Line, trace.bullet = Trace.Bullet, usercmd.set_movement = UserCMD.SetMovement, usercmd.get_movement = UserCMD.GetMovement, usercmd.set_angles = UserCMD.SetAngles, usercmd.force_jump = UserCMD.ForceJump, usercmd.force_crouch = UserCMD.ForceCrouch, antiaim.get_override = AntiAim.GetOverride, antiaim.set_override = AntiAim.SetOverride, antiaim.set_real_offset = AntiAim.SetRealOffset, antiaim.set_fake_offset = AntiAim.SetFakeOffset, antiaim.set_l_b_y_offset = AntiAim.SetLBYOffset, exploit.get_charge = Exploit.GetCharge, exploit.recharge = Exploit.Recharge, exploit.disable_recharge = Exploit.DisableRecharge, exploit.enable_recharge = Exploit.EnableRecharge, ragebot.get_target = Ragebot.GetTarget, ragebot.ignore_target = Ragebot.IgnoreTarget, ragebot.force_target = Ragebot.ForceTarget, ragebot.force_target_safety = Ragebot.ForceTargetSafety, ragebot.force_target_hitchance = Ragebot.ForceTargetHitchance, ragebot.force_target_minimum_damage = Ragebot.ForceTargetMinimumDamage, ragebot.force_hitbox_safety = Ragebot.ForceHitboxSafety, material.create = Material.Create, material.destroy = Material.Destroy, material.get = Material.Get, material.set_key_value = Material.SetKeyValue, material.refresh = Material.Refresh
//endregion

//region dependencies

/**
 * @title BetterUI
 * @version 2.0.1
 * @description A better UI system for Onetap
 */

var menu = {
    _class: 'BetterUI'
};
const menu_spacer = "                                                                                  ";

/**
 * Concats two elements into an array without increasing the array length.
 * Prevents the memory leak in 2.0.0 from happening
 * 
 * @param a {array}
 * @param b {any}
 */
menu.concat = function(a, b)
{
    // Creates a new array.
    var arr = [];

    // Push all items from the array 'a' into our array.
    for (var c in a)
    {
        arr.push(a[c]);
    }

    // Push the value 'b' into our array.
    arr.push(b);

    // Return the new array.
    return arr;
}

/**
 * Creates a new menu label
 *
 * @param label {string}
 */
menu.label = function(label)
{
    // Creates the label
    UI.AddLabel(label);
};

/**
 * Creates a new menu element
 *
 * @param func {function}
 * @param name {string}
 * @param label {string},
 * @param properties {array}
 */
menu.call = function(func, name, label, properties)
{
    // Get properties
    const final_name = name + menu_spacer + label;
    var final_props = [final_name];
    const element_info_t = {
        path: ["Misc", "JAVASCRIPT", "Script Items", final_name]
    };

    // If our properties aren't null, then pack them together.
    if (properties != null)
    {
        for (var i = 0; i < properties.length; i++)
        {
            final_props.push(properties[i]);
        }
    }

    // Create our menu element and return properties
    func.apply(null, final_props);
    return element_info_t;
};

/**
 * Creates a new menu reference
 *
 * @param path {array}
 */
menu.reference = function(path)
{
    const element_info_t = {
        path: path
    };

    return element_info_t;
};

/**
 * Gets the value of a menu element
 *
 * @param elem {array}
 * @return {*}
 */
menu.get = function(elem)
{
    // If the element doesn't exist
    if (!(elem.path))
        throw new Error("[Menu] This element doesn't exist!");

    // Returns the element's value
    return UI.GetValue.apply(null, elem.path);
};

/**
 * Gets the value of a menu element
 *
 * @param elem {array}
 * @return {*}
 */
menu.get_hotkey = function(elem)
{
    // If the label doesn't exist
    if (!(elem.path))
        throw new Error("[Menu] This element doesn't exist!");

    // Returns the element's value
    return UI.IsHotkeyActive.apply(null, elem.path);
};

/**
 * Gets the value of a menu element
 *
 * @param elem {array}
 * @return {*}
 */
menu.get_color = function(elem)
{
    // If the label doesn't exist
    if (!(elem.path))
        throw new Error("[Menu] This element doesn't exist!");

    // Returns the element's value
    return UI.GetColor.apply(null, elem.path);
};

/**
 * Sets the value of a menu element
 *
 * @param elem {array}
 * @param value {*}
 */
menu.set = function(elem, value)
{
    // If the label doesn't exist
    if (!(elem.path))
        throw new Error("[Menu] This element doesn't exist!");

    // Get properties
    const properties = elem;

    // Set the element's value
    UI.SetValue.apply(null, this.concat(properties.path, value));
};

/**
 * Sets the value of a color picker
 *
 * @param elem {array}
 * @param color {array|Color}
 */
menu.set_color = function(elem, color)
{
    // If the label doesn't exist
    if (!(elem.path))
        throw new Error("[Menu] This element doesn't exist!");

    // Get properties
    const properties = elem;

    // Set the element's value
    UI.SetColor.apply(null, this.concat(properties.path, color));
};

/**
 * Toggles a hotkey
 *
 * @param elem {array}
 */
menu.toggle = function(elem)
{
    // If the label doesn't exist
    if (!(elem.path))
        throw new Error("[Menu] This element doesn't exist!");

    // Set the element's value
    UI.ToggleHotkey.apply(null, elem.path);
};

/**
 * Changes the visibility of a menu elements
 *
 * @param elem {array}
 * @param visible {boolean}
 */
menu.visibility = function(elem, visible)
{
    // If the label doesn't exist
    if (!(elem.path))
        throw new Error("[Menu] This element doesn't exist!");

    // Get properties
    const properties = elem;

    // Change the element's visibility
    UI.SetEnabled.apply(null, this.concat(properties.path, visible));
};

const distance_in_ft = function(origin, destination)
{
    const sub = [destination[0] - origin[0], destination[1] - origin[1], destination[2] - origin[2]];
    return Math.round(Math.sqrt(sub[0] ** 2 + sub[1] ** 2 + sub[2] ** 2) / 12);
}

const clamp = function(v, f, c)
{
    return Math.min(Math.max(v, f), c);
}

render.arc = function(x, y, r1, r2, s, d, col)
{
    for (var i = s; i < s + d; i++)
    {

        const rad = i * Math.PI / 180;

        render.line(x + Math.cos(rad) * r1, y + Math.sin(rad) * r1, x + Math.cos(rad) * r2, y + Math.sin(rad) * r2, col);
    }
}

const is_inside_screen = function(vec)
{
    const screen_size = render.get_screen_size();
    return vec[0] > 0 && vec[1] > 0 && vec[0] < screen_size[0] && vec[1] < screen_size[1];
}

//endregion

//region globals

var positions = [];

//endregion

//region menu


    




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_dropdown_value = function(value, index){
    const mask = 1 << index;
    return value & mask ? true : false;
}

var shots = [];

const is_bidlo = function(value){
    for(var i in shots){
        if(shots[i].tickcount == value)
            return true;
    }
    return false;
}

const text = function(outline, x, y, a, text, color, font)
{
    if(outline){
        Render.StringCustom(x + 1, y, a, text, [0, 0, 0, color[3]], font);
        Render.StringCustom(x - 1, y, a, text, [0, 0, 0, color[3]], font);
        Render.StringCustom(x, y + 1, a, text, [0, 0, 0, color[3]], font);
        Render.StringCustom(x, y - 1, a, text, [0, 0, 0, color[3]], font);
    }
    Render.StringCustom(x, y, a, text, color, font);
}

const cross = function(x,y,size,color,type){
    switch(type){
        case 0:
            Render.Line(x - size, y - size, x + size, y + size, color);
            Render.Line(x - size, y + size, x + size, y - size, color);
        break;

        case 1:
            Render.Line(x + size, y + size, x + (size / 3), y + (size / 3), color);
            Render.Line(x + size, y - size, x + (size / 3), y - (size / 3), color);
            Render.Line(x - size, y - size, x - (size / 3), y - (size / 3), color);
            Render.Line(x - size, y + size, x - (size / 3), y + (size / 3), color);
        break;

        case 2:
            Render.Line(x - size, y, x + size, y, color);
            Render.Line(x, y + size, x, y - size, color);
        break;

        case 3:
            Render.Line(x + size, y, x + (size / 3), y, color);
            Render.Line(x, y - size, x, y - (size / 3), color);
            Render.Line(x - size, y, x - (size / 3), y, color);
            Render.Line(x, y + size, x, y + (size / 3), color);
        break;

        case 4:
            Render.Line(x + size, y + size, x + (size / 4), y + (size / 4), color);
            Render.Line(x + size, y - size, x + (size / 4), y - (size / 4), color);
            Render.Line(x - size, y - size, x - (size / 4), y - (size / 4), color);
            Render.Line(x - size, y + size, x - (size / 4), y + (size / 4), color);
            Render.Circle(x,y,size/1.5,color);
        break;
    }
}

const screen_size = Render.GetScreenSize();



if( !getval("Disable sounds") ) Cheat.ExecuteCommand("play music\\kill_03"); // lmao

const main = function(){
    const font = Render.AddFont("Verdana", 8, 600);
    const values = {cross_size: getval("Cross size"), cross_color: getcol("Cross & lines color"), animated: getval("Animated"), animation_speed: getval("Animation speed"), delay: getval("Erase time"), lines: getval("Lines from screen center"), damage: getval("Damage"), damage_color: getcol("Damage color"), damage_fly: getval("Damage fly up"), damage_fly_speed: getval("Damage fly up speed"), damage_outline: getval("Damage outline")};
    for(var i in shots){
        const s = shots[i];
        if(s.didhit){
            if(s.alpha<255 && s.erase_time == values.delay) s.alpha+=values.animation_speed;
            if(s.alpha>=255 && s.erase_time > 0) s.erase_time -= 0.5; else if(s.erase_time <= 0) s.alpha-=values.animation_speed;
            if(s.alpha <= 0 && s.erase_time <= 0) shots.splice(i, 1);

            const w2s = Render.WorldToScreen(s.pos);
            const color = [values.cross_color[0],values.cross_color[1],values.cross_color[2],values.animated ? (s.alpha > 255 ? 255 : s.alpha) : values.cross_color[3]];
            const color_dmg = [values.damage_color[0],values.damage_color[1],values.damage_color[2],values.animated ? (s.alpha > 255 ? 255 : s.alpha) : values.damage_color[3]];
            cross(w2s[0], w2s[1], values.cross_size, color, s.cross_type);
            if(values.damage) text(values.damage_outline, w2s[0],w2s[1] - 30 - s.damage_fly,1,s.damage.toString(),color_dmg,font);
            if(values.damage_fly) s.damage_fly += values.damage_fly_speed;
            if(values.lines && (w2s[1] < screen_size[1] && w2s[1] > 0)) Render.Line(screen_size[0] / 2, screen_size[1] / 2, w2s[0], w2s[1], color);
        }
    }
}

const hitgroup_to_hitbox = {1: 0, 2: 5, 3: 2, 4: 13, 5: 14, 6: 12, 7: 11};
const bullet_impact = function(){
    if(shots.length > 25) shots.shift();
    const uid = Entity.GetEntityFromUserID(Event.GetInt("userid"));
    if(Entity.IsLocalPlayer(uid) && !is_bidlo(Globals.Tickcount()))
        if(getval("Cross position"))
            shots.push({pos: [Event.GetFloat("x"),Event.GetFloat("y"),Event.GetFloat("z")], didhit: 0, tickcount: Globals.Tickcount(), cross_type: getval("Cross type"), alpha: getval("Animated") ? 0 : 255, erase_time: getval("Erase time"), damage: 0, damage_fly: 0});
}

const player_hurt = function(){
    const uid = Entity.GetEntityFromUserID(Event.GetInt("userid"));
    const attacker = Entity.GetEntityFromUserID(Event.GetInt("attacker"));
    if(Entity.IsLocalPlayer(attacker) && uid != attacker){
        if(!getval("Cross position")) shots.push({pos: Entity.GetHitboxPosition(uid, hitgroup_to_hitbox[Event.GetInt("hitgroup")] != undefined ? hitgroup_to_hitbox[Event.GetInt("hitgroup")] : 3), didhit: 1, tickcount: Globals.Tickcount(), cross_type: getval("Cross type"), alpha: getval("Animated") ? 0 : 255, erase_time: getval("Erase time"), damage: Event.GetInt("dmg_health"), damage_fly: 0}); else {
            for (var i in shots){
                if(shots[i].tickcount == Globals.Tickcount() && !shots[i].didhit){
                    shots[i].didhit = true;
                    shots[i].damage = Event.GetInt("dmg_health");
                }
            }
        }
    }
}

Cheat.RegisterCallback("Draw", "main");
Cheat.RegisterCallback("bullet_impact", "bullet_impact");
Cheat.RegisterCallback("player_hurt", "player_hurt");
//endregion
UI.AddSliderInt("", 0, 0);

function rect(x, y, w, h, dir, color1, color2) {
    Render.GradientRect(x - Math.round(w/2), y - Math.round(h/2), w, h, dir, color1, color2);
}
function md5(string){
                function md5_RotateLeft(lValue, iShiftBits) {
                        return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
                }
                function md5_AddUnsigned(lX,lY){
                        var lX4,lY4,lX8,lY8,lResult;
                        lX8 = (lX & 0x80000000);
                        lY8 = (lY & 0x80000000);
                        lX4 = (lX & 0x40000000);
                        lY4 = (lY & 0x40000000);
                        lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
                        if (lX4 & lY4) {
                                return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
                        }
                        if (lX4 | lY4) {
                                if (lResult & 0x40000000) {
                                        return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
                                } else {
                                        return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
                                }
                        } else {
                                return (lResult ^ lX8 ^ lY8);
                        }
                }         
                function md5_F(x,y,z){
                        return (x & y) | ((~x) & z);
                }
                function md5_G(x,y,z){
                        return (x & z) | (y & (~z));
                }
                function md5_H(x,y,z){
                        return (x ^ y ^ z);
                }
                function md5_I(x,y,z){
                        return (y ^ (x | (~z)));
                }
                function md5_FF(a,b,c,d,x,s,ac){
                        a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_F(b, c, d), x), ac));
                        return md5_AddUnsigned(md5_RotateLeft(a, s), b);
                };
                function md5_GG(a,b,c,d,x,s,ac){
                        a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_G(b, c, d), x), ac));
                        return md5_AddUnsigned(md5_RotateLeft(a, s), b);
                };
                function md5_HH(a,b,c,d,x,s,ac){
                        a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_H(b, c, d), x), ac));
                        return md5_AddUnsigned(md5_RotateLeft(a, s), b);
                };
                function md5_II(a,b,c,d,x,s,ac){
                        a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_I(b, c, d), x), ac));
                        return md5_AddUnsigned(md5_RotateLeft(a, s), b);
                };
                function md5_ConvertToWordArray(string) {
                        var lWordCount;
                        var lMessageLength = string.length;
                        var lNumberOfWords_temp1=lMessageLength + 8;
                        var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64;
                        var lNumberOfWords = (lNumberOfWords_temp2+1)*16;
                        var lWordArray=Array(lNumberOfWords-1);
                        var lBytePosition = 0;
                        var lByteCount = 0;
                        while ( lByteCount < lMessageLength ) {
                                lWordCount = (lByteCount-(lByteCount % 4))/4;
                                lBytePosition = (lByteCount % 4)*8;
                                lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<<lBytePosition));
                                lByteCount++;
                        }
                        lWordCount = (lByteCount-(lByteCount % 4))/4;
                        lBytePosition = (lByteCount % 4)*8;
                        lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition);
                        lWordArray[lNumberOfWords-2] = lMessageLength<<3;
                        lWordArray[lNumberOfWords-1] = lMessageLength>>>29;
                        return lWordArray;
                };
                function md5_WordToHex(lValue){
                        var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;
                        for(lCount = 0;lCount<=3;lCount++){
                                lByte = (lValue>>>(lCount*8)) & 255;
                                WordToHexValue_temp = "0" + lByte.toString(16);
                                WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);
                        }
                        return WordToHexValue;
                };
                function md5_Utf8Encode(string){
                        string = string.replace(/\r\n/g,"\n");
                        var utftext = "";
                        for (var n = 0; n < string.length; n++) {
                                var c = string.charCodeAt(n);
                                if (c < 128) {
                                        utftext += String.fromCharCode(c);
                                }else if((c > 127) && (c < 2048)) {
                                        utftext += String.fromCharCode((c >> 6) | 192);
                                        utftext += String.fromCharCode((c & 63) | 128);
                                } else {
                                        utftext += String.fromCharCode((c >> 12) | 224);
                                        utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                                        utftext += String.fromCharCode((c & 63) | 128);
                                }
                        }
                        return utftext;
                };
                var x=Array();
                var k,AA,BB,CC,DD,a,b,c,d;
                var S11=7, S12=12, S13=17, S14=22;
                var S21=5, S22=9 , S23=14, S24=20;
                var S31=4, S32=11, S33=16, S34=23;
                var S41=6, S42=10, S43=15, S44=21;
                string = md5_Utf8Encode(string);
                x = md5_ConvertToWordArray(string);
                a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
                for (k=0;k<x.length;k+=16) {
                        AA=a; BB=b; CC=c; DD=d;
                        a=md5_FF(a,b,c,d,x[k+0], S11,0xD76AA478);
                        d=md5_FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
                        c=md5_FF(c,d,a,b,x[k+2], S13,0x242070DB);
                        b=md5_FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
                        a=md5_FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
                        d=md5_FF(d,a,b,c,x[k+5], S12,0x4787C62A);
                        c=md5_FF(c,d,a,b,x[k+6], S13,0xA8304613);
                        b=md5_FF(b,c,d,a,x[k+7], S14,0xFD469501);
                        a=md5_FF(a,b,c,d,x[k+8], S11,0x698098D8);
                        d=md5_FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
                        c=md5_FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
                        b=md5_FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
                        a=md5_FF(a,b,c,d,x[k+12],S11,0x6B901122);
                        d=md5_FF(d,a,b,c,x[k+13],S12,0xFD987193);
                        c=md5_FF(c,d,a,b,x[k+14],S13,0xA679438E);
                        b=md5_FF(b,c,d,a,x[k+15],S14,0x49B40821);
                        a=md5_GG(a,b,c,d,x[k+1], S21,0xF61E2562);
                        d=md5_GG(d,a,b,c,x[k+6], S22,0xC040B340);
                        c=md5_GG(c,d,a,b,x[k+11],S23,0x265E5A51);
                        b=md5_GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
                        a=md5_GG(a,b,c,d,x[k+5], S21,0xD62F105D);
                        d=md5_GG(d,a,b,c,x[k+10],S22,0x2441453);
                        c=md5_GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
                        b=md5_GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
                        a=md5_GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
                        d=md5_GG(d,a,b,c,x[k+14],S22,0xC33707D6);
                        c=md5_GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
                        b=md5_GG(b,c,d,a,x[k+8], S24,0x455A14ED);
                        a=md5_GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
                        d=md5_GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
                        c=md5_GG(c,d,a,b,x[k+7], S23,0x676F02D9);
                        b=md5_GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
                        a=md5_HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
                        d=md5_HH(d,a,b,c,x[k+8], S32,0x8771F681);
                        c=md5_HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
                        b=md5_HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
                        a=md5_HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
                        d=md5_HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
                        c=md5_HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
                        b=md5_HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
                        a=md5_HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
                        d=md5_HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
                        c=md5_HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
                        b=md5_HH(b,c,d,a,x[k+6], S34,0x4881D05);
                        a=md5_HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
                        d=md5_HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
                        c=md5_HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
                        b=md5_HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
                        a=md5_II(a,b,c,d,x[k+0], S41,0xF4292244);
                        d=md5_II(d,a,b,c,x[k+7], S42,0x432AFF97);
                        c=md5_II(c,d,a,b,x[k+14],S43,0xAB9423A7);
                        b=md5_II(b,c,d,a,x[k+5], S44,0xFC93A039);
                        a=md5_II(a,b,c,d,x[k+12],S41,0x655B59C3);
                        d=md5_II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
                        c=md5_II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
                        b=md5_II(b,c,d,a,x[k+1], S44,0x85845DD1);
                        a=md5_II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
                        d=md5_II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
                        c=md5_II(c,d,a,b,x[k+6], S43,0xA3014314);
                        b=md5_II(b,c,d,a,x[k+13],S44,0x4E0811A1);
                        a=md5_II(a,b,c,d,x[k+4], S41,0xF7537E82);
                        d=md5_II(d,a,b,c,x[k+11],S42,0xBD3AF235);
                        c=md5_II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
                        b=md5_II(b,c,d,a,x[k+9], S44,0xEB86D391);
                        a=md5_AddUnsigned(a,AA);
                        b=md5_AddUnsigned(b,BB);
                        c=md5_AddUnsigned(c,CC);
                        d=md5_AddUnsigned(d,DD);
                }
        return (md5_WordToHex(a)+md5_WordToHex(b)+md5_WordToHex(c)+md5_WordToHex(d)).toLowerCase();
}


var screen_size = Global.GetScreenSize();
var last=false;
var startX = screen_size[0]/2;
var startY = screen_size[1]/2;


function HSV2RGB(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)
    };
}
var lasttick=false;




function run() {
	if(World.GetServerString() == ""){
		return;
	}
    
    var sizeX = 350;
	var sizeX2 = 25;
    var sizeY = 2;
    var off = sizeX /2+20;
	var off2 = sizeX2 / 2 + 5;
    if(tick_end!=0 && tick_end>=Globals.Tickcount()){
		var c2 = [255, 100, 100, 255];
	}else{
		var c2 = [150, 200, 255, 255];
	}
	//colors = HSV2RGB(Global.Realtime() * 0.5, 1, 1);
	if (Entity.GetProp(Entity.GetLocalPlayer(), "CCSPlayer", "m_bIsScoped")) {
		realBorderColor=[100, 180, 255, 75];
	fakeBorderColor=[255,255, 255, 75];
	circleColor=[255, 255, 255, 20];
	}else{
	realBorderColor=[ 23, 124, 255, 255];
	fakeBorderColor=[255,255, 255, 255];
	circleColor=[255, 255, 255, 40];
	}
	negativeColor=[100, 180, 255, 255];
	positiveColor=[255,100,100,255];
	if(Entity.IsAlive(Entity.GetLocalPlayer())){
	//Render.Circle(screen_size[0] / 2, screen_size[1] / 2, 24, circleColor);
    //Render.Circle(screen_size[0] / 2, screen_size[1] / 2, 25, circleColor);
    //Render.Circle(screen_size[0] / 2, screen_size[1] / 2, 21, circleColor);
    //Render.Circle(screen_size[0] / 2, screen_size[1] / 2, 22, circleColor);
    //Render.Circle(screen_size[0] / 2, screen_size[1] / 2, 23, circleColor);


    desyncSize = Math.abs(normalizeYaw(Local.GetRealYaw() - Local.GetFakeYaw()));
    desyncSize = (desyncSize > 120) ? 120 : desyncSize;
    var finalll =  ((desyncSize / 60) * 360) + 14;
    if(desyncSize < 2 && finalll > 2)
    {
            finalll = 0;
    }


	viewYaw = Local.GetViewAngles()[1] - 180;
	fake = adjustAngle(Local.GetFakeYaw()-viewYaw);
	real = adjustAngle(Local.GetRealYaw()-viewYaw);
    if(getmultidrop(getvalue("Indicators"), 0))
    {
	drawArc(screen_size[0]/2,screen_size[1]/2,35,real - (50 * 0.5),30,3,realBorderColor);
	drawArc(screen_size[0]/2,screen_size[1]/2,35,fake - (50 * 0.5),30,3,fakeBorderColor);
    
		
        
		Render.String(screen_size[0]/2,screen_size[1]/2+45,1,desyncSize.toFixed(0)+"",[255,255,255,150],10);
		desyncSize60=desyncSize = (desyncSize > 60) ? 60 : desyncSize;
		//if(normalizeYaw(Local.GetRealYaw() - Local.GetFakeYaw())>0){
		//	Render.GradientRect(screen_size[0]/2-Math.floor(120*(desyncSize60/60)),screen_size[1]/2+65,Math.floor(120*(desyncSize60/60)),5,1,[positiveColor[0],positiveColor[1],positiveColor[2],0],positiveColor);
		//	Render.GradientRect(screen_size[0]/2,screen_size[1]/2+65,Math.floor(120*(desyncSize60/60)),5,1,positiveColor,[positiveColor[0],positiveColor[1],positiveColor[2],0]);
		//}else{
    }
		//}
	//c2=[color.r,color.b,colors.b,255];
	}
    var c1 = [200,0, 150, 0];
    

}
var tick_end=0;

function onPlayerHurt(){
	if(Entity.GetEntityFromUserID(Event.GetInt("attacker"))==Entity.GetLocalPlayer()){
		tick_end=Globals.Tickcount()+16;
	}
}
function onPlayerDeath(){
	if(Entity.GetEntityFromUserID(Event.GetInt("userid"))==Entity.GetLocalPlayer()){
		tick_end=0;
	}
}

function onPlayerJoin(){
	tick_end=0;
}

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