//Created by Misnik
UI.AddLabel("               By Misnik");
UI.AddLabel("            CFGFORUM.RU");
UI.AddLabel("                                             v 1.4");
UI.AddSliderInt(" ", 0, 0);
UI.AddCheckbox("AA Settings");

UI.AddDropdown("Conditions", ["Stand", "Slow walk", "Move", "Air"]);
UI.AddDropdown("Stand", ["Low Delta", "Sway", "Jitter","Switch"]);
UI.AddDropdown("Slow walk", ["Low Delta", "Sway", "Jitter", "Switch"]);
UI.AddDropdown("Move", ["Low Delta", "Sway", "Jitter", "Switch"]);
UI.AddDropdown("Air", ["Low Delta", "Sway", "Jitter", "Switch"]);

UI.AddCheckbox("Settings for AA modes");
UI.AddDropdown("Builder settings", ["Left", "Right", "LegitAA", "Sway", "Jitter", "Jitter yaw","On-Shit aa"]);
UI.AddDropdown("Moving conditions L", ["Standing", "Moving",]);
UI.AddDropdown("Moving conditions R", ["Standing", "Moving",]);
//UI.AddSliderInt("Fake yaw",-180, 180);
UI.AddSliderInt("Offset L", -180, 180);
UI.AddSliderInt("Real Delta L", -60, 90);
UI.AddSliderInt("Fake LBY Delta L", -60, 90)

UI.AddSliderInt("MOffset L", -180, 180);
UI.AddSliderInt("MReal Delta L", -60, 60);


UI.AddSliderInt("Offset R", -180, 180);
UI.AddSliderInt("Real Delta R", -60, 60);
UI.AddSliderInt("Fake LBY Delta R", -60, 60);

UI.AddSliderInt("MOffset R", -180, 180);
UI.AddSliderInt("MReal Delta R", -60, 60);


UI.AddSliderInt("Legit Offset L", -180, 180);
UI.AddSliderInt("Legit Real Delta L", 0, 60);
UI.AddSliderInt("Legit Fake LBY Delta L", 0, 60);

UI.AddSliderInt("Legit Offset R", -180, 180);
UI.AddSliderInt("Legit Real Delta R", 0, 60);
UI.AddSliderInt("Legit Fake LBY Delta R", 0, 60);

UI.AddDropdown("Sway Type", ["1", "2",])
UI.AddDropdown("Sway conditions", ["Standing", "Moving",]);
UI.AddCheckbox("Avoid Overlap in move");
UI.AddSliderInt("Sway stand", 0, 100);
UI.AddSliderInt("Sway move", 0, 50);

UI.AddSliderInt("Sway standing start", -60, 60);
UI.AddSliderInt("Sway standing end", -60, 60);
UI.AddSliderInt("Sway standing speed", 0, 5);

UI.AddSliderInt("Sway slowwalk start", -60, 60);
UI.AddSliderInt("Sway slowwalk end", -60, 60);
UI.AddSliderInt("Sway slowwalk speed", 0, 5);

UI.AddSliderInt("Desync delta", -60, 60);
UI.AddSliderInt("Jitter delta", 0, 60);
UI.AddSliderInt("Jitteryaw delta", -180, 180);
UI.AddMultiDropdown("Jitteryaw conditions", ["stand", "slowwalk", "move", "air"]);

UI.AddCheckbox("On-shot Switch");


UI.AddLabel("               Keybinds");
UI.AddHotkey("LegitAA");
UI.AddCheckbox("Clantag(sync)");
UI.AddLabel(" ");
UI.AddLabel("If you don't want configurate this js ");
UI.AddLabel("       click on Premade settings ");
UI.AddCheckbox("Premade settings");


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



var scriptitems = ["Misc", "JAVASCRIPT", "Script Items"];

function menu_cb() {
	//visability for dropbox
	var enabled = UI.GetValue(scriptitems, "AA Settings");
	UI.SetEnabled(scriptitems, "Settings for AA modes", enabled);
	UI.SetEnabled(scriptitems, "               Keybinds", enabled);
	UI.SetEnabled(scriptitems, "If you don't want configurate this js ", enabled);
	UI.SetEnabled(scriptitems, "       click on Premade settings ", enabled);
	var se_enabled = UI.GetValue(scriptitems, "Settings for AA modes");
	UI.SetEnabled(scriptitems, "Builder settings", se_enabled && enabled);
	UI.SetEnabled(scriptitems, "Conditions", enabled);

	var l_enabled = UI.GetValue(scriptitems, "Builder settings") == 0 && se_enabled && enabled;
	UI.SetEnabled(scriptitems, "Moving conditions L", l_enabled);

	var lstand_enabled = UI.GetValue(scriptitems, "Moving conditions L") == 0 && se_enabled;
	UI.SetEnabled(scriptitems, "Offset L", lstand_enabled && l_enabled);
	UI.SetEnabled(scriptitems, "Real Delta L", lstand_enabled && l_enabled);
	UI.SetEnabled(scriptitems, "Fake LBY Delta L", lstand_enabled && l_enabled);

	var lmove_enabled = UI.GetValue(scriptitems, "Moving conditions L") == 1 && se_enabled;
	UI.SetEnabled(scriptitems, "MOffset L", lmove_enabled && l_enabled);
	UI.SetEnabled(scriptitems, "MReal Delta L", lmove_enabled && l_enabled);

	var r_enabled = UI.GetValue(scriptitems, "Builder settings") == 1 && se_enabled && enabled;
	UI.SetEnabled(scriptitems, "Moving conditions R", r_enabled);

	var rstand_enabled = UI.GetValue(scriptitems, "Moving conditions R") == 0 && se_enabled;
	UI.SetEnabled(scriptitems, "Offset R", rstand_enabled && r_enabled);
	UI.SetEnabled(scriptitems, "Real Delta R", rstand_enabled && r_enabled);
	UI.SetEnabled(scriptitems, "Fake LBY Delta R", rstand_enabled && r_enabled);
	var rmove_enabled = UI.GetValue(scriptitems, "Moving conditions R") == 1 && se_enabled;
	UI.SetEnabled(scriptitems, "MOffset R", rmove_enabled && r_enabled);
	UI.SetEnabled(scriptitems, "MReal Delta R", rmove_enabled && r_enabled);

	var ol_enabled = UI.GetValue(scriptitems, "Builder settings") == 2 && se_enabled && enabled;
	UI.SetEnabled(scriptitems, "Legit Offset L", ol_enabled);
	UI.SetEnabled(scriptitems, "Legit Real Delta L", ol_enabled);
	UI.SetEnabled(scriptitems, "Legit Fake LBY Delta L", ol_enabled);
	UI.SetEnabled(scriptitems, "Legit Offset R", ol_enabled);
	UI.SetEnabled(scriptitems, "Legit Real Delta R", ol_enabled);
	UI.SetEnabled(scriptitems, "Legit Fake LBY Delta R", ol_enabled);
	UI.SetEnabled(scriptitems, "LegitAA", enabled);

	var oi_enabled = UI.GetValue(scriptitems, "Builder settings") == 3 && se_enabled && enabled;
	UI.SetEnabled(scriptitems, "Sway Type", oi_enabled);

	var swaytypeone_enabled = UI.GetValue(scriptitems, "Sway Type") == 1 && se_enabled && oi_enabled;
	UI.SetEnabled(scriptitems, "Sway stand", swaytypeone_enabled);
	UI.SetEnabled(scriptitems, "Sway move", swaytypeone_enabled);

	var swaytypetwo_enabled = UI.GetValue(scriptitems, "Sway Type") == 0 && se_enabled && oi_enabled;
	UI.SetEnabled(scriptitems, "Sway conditions", swaytypetwo_enabled);
	UI.SetEnabled(scriptitems, "Avoid Overlap in move", swaytypetwo_enabled)
	var swaytypetwocons_enabled = UI.GetValue(scriptitems, "Sway conditions") == 0 && se_enabled && oi_enabled && swaytypetwo_enabled;
	UI.SetEnabled(scriptitems, "Sway standing start", swaytypetwocons_enabled);
	UI.SetEnabled(scriptitems, "Sway standing end", swaytypetwocons_enabled);
	UI.SetEnabled(scriptitems, "Sway standing speed", swaytypetwocons_enabled);
	UI.SetEnabled(scriptitems, "Desync delta", swaytypetwo_enabled);
	var swaytypetwoconm_enabled = UI.GetValue(scriptitems, "Sway conditions") == 1 && se_enabled && oi_enabled && swaytypetwo_enabled;
	UI.SetEnabled(scriptitems, "Sway slowwalk start", swaytypetwoconm_enabled);
	UI.SetEnabled(scriptitems, "Sway slowwalk end", swaytypetwoconm_enabled);
	UI.SetEnabled(scriptitems, "Sway slowwalk speed", swaytypetwoconm_enabled);
	var op_enabled = UI.GetValue(scriptitems, "Builder settings") == 4 && se_enabled && enabled;
	UI.SetEnabled(scriptitems, "Jitter delta", op_enabled);

	var oo_enabled = UI.GetValue(scriptitems, "Builder settings") == 5 && se_enabled && enabled;
	UI.SetEnabled(scriptitems, "Jitteryaw delta", oo_enabled);
	UI.SetEnabled(scriptitems, "Jitteryaw conditions", oo_enabled);
	ooo_enabled = UI.GetValue(scriptitems, "Builder settings") == 6 && se_enabled && enabled; 
	UI.SetEnabled(scriptitems, "On-shot Switch", ooo_enabled);

	UI.SetEnabled(scriptitems, "Clantag(sync)", enabled);
	UI.SetEnabled(scriptitems, "Premade settings", enabled);

	var st_enabled = UI.GetValue(scriptitems, "Conditions") == 0 && enabled;
	UI.SetEnabled(scriptitems, "Stand", st_enabled);
	var sw_enabled = UI.GetValue(scriptitems, "Conditions") == 1 && enabled;
	UI.SetEnabled(scriptitems, "Slow walk", sw_enabled);
	var mv_enabled = UI.GetValue(scriptitems, "Conditions") == 2 && enabled;
	UI.SetEnabled(scriptitems, "Move", mv_enabled);
	var ar_enabled = UI.GetValue(scriptitems, "Conditions") == 3 && enabled;
	UI.SetEnabled(scriptitems, "Air", ar_enabled);
}

function draw_custom_aa() {
	if (UI.IsMenuOpen()) {
		menu_cb();
	}

}



var flip2 = true
var last = 0

function autoflip() {
	if (legitaa) {
		return
	}

	
	UI.SetValue("Anti-Aim", "Extra", "Pitch", 1)
	UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", 0)
	AntiAim.SetOverride(1); // 0
	var sim = Globals.Curtime() * 10
	if(sim - last < 0.5) //0.2	
	return;
	flip2 = !flip2
		UI.ToggleHotkey("Anti-Aim", "Fake angles", "Inverter",flip2)
		last = sim
	if(inverter == true){AntiAim.SetLBYOffset(0)} else {AntiAim.SetLBYOffset(0)}
	if(inverter == true){AntiAim.SetRealOffset(-60)} else {AntiAim.SetRealOffset(60)}
	
}

function legit() {
	UI.SetValue("Misc", "PERFORMANCE & INFORMATION", "Restrictions", 0)
	UI.SetValue("Anti-Aim", "Extra", "Pitch", 3)
	UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", lastLOff)
	AntiAim.SetRealOffset(inverter ? -LRealDelta : LRealDelta)
	AntiAim.SetLBYOffset(inverter ? LLBYOff : -LLBYOff)

}

function lowdelta() {
	UI.SetValue("Anti-Aim", "Extra", "Pitch", 1)
	if (legitaa) { } else {
		if (velocity <= 10) {
			UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", Off)
			AntiAim.SetRealOffset(inverter ? RealDelta : -RealDelta)
			AntiAim.SetLBYOffset(inverter ? -LBYOff : LBYOff)
		} else {
			UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", MOff)
			AntiAim.SetRealOffset(inverter ? MRealDelta : -MRealDelta)
		}
	}
}

new_sway = 0

function sway() {
	if (legitaa) {
		return
	}
	UI.SetValue("Anti-Aim", "Extra", "Pitch", 1)
	UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", 0)
	if (typesway == 1) {
		if (velocity < 5) {
			speedsw = Swed
			real_yaw = inverter ? 40 : -40
		} else {
			speedsw = Swsp;
			real_yaw = inverter ? 45 : -45
		}
		var sine = ((Math.sin(Globals.Curtime() * 5) - 1) / 2) * speedsw
		var new_yaw = inverter ? real_yaw + sine : real_yaw - sine
		AntiAim.SetRealOffset(new_yaw)
		AntiAim.SetLBYOffset(inverter ? -60 : 60)
	} else {
		swaystart = (velocity < 5 ? (UI.GetValue(scriptitems, "Sway standing start")) : (UI.GetValue(scriptitems, "Sway slowwalk start")))
		swayend = (velocity < 5 ? (UI.GetValue(scriptitems, "Sway standing end")) : (UI.GetValue(scriptitems, "Sway slowwalk end")))
		swayspeed = (velocity < 5 ? (UI.GetValue(scriptitems, "Sway standing speed")) : (UI.GetValue(scriptitems, "Sway slowwalk speed")))
		swaydesync = UI.GetValue(scriptitems, "Desync delta")
		AntiAim.SetLBYOffset(inverter ? -swaydesync : swaydesync)

		if (swaystart < swayend) {
			new_sway = new_sway + swayspeed
		}

		if (((new_sway == -24 || new_sway == -23 || new_sway == -22 || new_sway == -21) && velocity > 10) && UI.GetValue("Avoid Overlap in move")) {
			new_sway = new_sway + 34
		}
		if (swayend < new_sway) {
			new_sway = swaystart
		}
		AntiAim.SetRealOffset(inverter ? new_sway : -new_sway)

	}

}
shotstatus = true
function OnshotAA()
{
if(!UI.GetValue("On-shot Switch"))
return;
shotstatus = !shotstatus
UI.SetValue("Anti-Aim","Fake angles","Desync on shot",shotstatus)
}

function jitter() {
	UI.SetValue("Anti-Aim", "Extra", "Pitch", 1)
	UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Yaw offset", 0)
	var jit_yaw = Math.random() * (Jitterleg - -50) + -50;
	AntiAim.SetLBYOffset(inverter ? -60 : 60);
	AntiAim.SetRealOffset(inverter ? -jit_yaw : jit_yaw)

}

function jitteryaw() {
	UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Jitter offset", Jitteryawleg);
	isjitter = 0;
}

currentTick = 0;
lastTick = 0;
buffer = 0
function clantag() {

	if (UI.GetValue("Clantag(sync)") && !World.GetServerString() == "") {

		currentTick = parseInt(Globals.Curtime() * 1000);

		if ((currentTick - 100) >= lastTick) {

			switch (Math.round(Globals.Curtime() % 14)) {

				default:
				case 0: buffer = ""; 			 break;
				case 1: buffer = "S"; 			 break;
				case 2: buffer = "Sw"; 			 break;
				case 3: buffer = "Swa";	 	     break;
				case 4: buffer = "Sway";		 break;
				case 5: buffer = "Sway ";	 	 break;
				case 6: buffer = "Sway A"; 		 break;
				case 7: buffer = "Sway Ab";      break;
				case 8: buffer = "Sway Abu";	 break;
				case 9: buffer = "Sway Abus"; 	 break;
				case 10: buffer = "Sway Abuse";  break;
				case 11: buffer = "Sway Abuser"; break;
				case 12: buffer = "#### Abuser"; break;
				case 13: buffer = "#### ######"; break;
				case 14: buffer = "";            break;

			}

			Local.SetClanTag(buffer)
			lastTick = currentTick;

		} else if (currentTick < 5000) {

			lastTick = 0;

		}

	}

}



function aa() {

	AntiAim.SetOverride(1);
	//AntiAim.SetFakeOffset(UI.GetValue("Fake yaw"));
	player = Entity.GetLocalPlayer();
	localplayer = Entity.GetProp(player, "CBasePlayer", "m_vecVelocity[0]");
	velocity = Math.sqrt(localplayer[0] * localplayer[0] + localplayer[1] * localplayer[1]);


	legitaa = UI.IsHotkeyActive(scriptitems, "LegitAA")
	inverter = UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter")
	if (inverter) {
		var inverterstatus = " L"
	} else {
		inverterstatus = " R"
	}
	Jitterleg = UI.GetValue(scriptitems, "Jitter delta")
	Jitteryawleg = UI.GetValue(scriptitems, "Jitteryaw delta")
	isjitter = 1
	jitterlegit = 0

	Off = UI.GetValue("scriptitems", "Offset" + inverterstatus)
	RealDelta = UI.GetValue("scriptitems", "Real Delta" + inverterstatus)
	LBYOff = UI.GetValue("scriptitems", "Fake LBY Delta" + inverterstatus)

	MOff = UI.GetValue("scriptitems", "MOffset" + inverterstatus)
	MRealDelta = UI.GetValue("scriptitems", "MReal Delta" + inverterstatus)
	ispreset = UI.GetValue("Premade settings")
	LOff = UI.GetValue("scriptitems", "Legit Offset" + inverterstatus)
	LRealDelta = UI.GetValue("scriptitems", "Legit Real Delta" + inverterstatus)
	LLBYOff = UI.GetValue("scriptitems", "Legit Fake LBY Delta" + inverterstatus)
	lastLOff = 180 - LOff

	typesway = UI.GetValue(scriptitems, "Sway Type")

	Swed = UI.GetValue(scriptitems, "Sway stand")
	Swsp = UI.GetValue(scriptitems, "Sway move")


	stand = UI.GetValue(scriptitems, "Stand")
	slowwalk = UI.GetValue(scriptitems, "Slow walk")
	move = UI.GetValue(scriptitems, "Move")
	air = UI.GetValue(scriptitems, "Air")
	jittercondition = UI.GetValue(scriptitems, "Jitteryaw conditions")
	airinfo = Entity.GetProp(player, "CBasePlayer", "m_hGroundEntity");
	if (ispreset) {
		preset();
	}
	if (isjitter) {
		UI.SetValue("Anti-Aim", "Rage Anti-Aim", "Jitter offset", 0)
	}

	if (velocity < 5 && airinfo == 0) {
		if (jittercondition == 1 || jittercondition == 3 || jittercondition == 5 || jittercondition == 7 || jittercondition == 9 || jittercondition == 11 || jittercondition == 13 || jittercondition == 15) {
			jitteryaw()
		}
		switch (stand) {
			case 0:
				lowdelta();
				break
			case 1:
				sway();
				break
			case 2:
				jitter();
				break
			case 3:
				autoflip();
				break
		}
	}

	if (velocity >= 10 && velocity < 100 && airinfo == 0) {
		if (jittercondition == 2 || jittercondition == 3 || jittercondition == 6 || jittercondition == 7 || jittercondition == 10 || jittercondition == 11 || jittercondition == 14 || jittercondition == 15) {
			jitteryaw()
		}
		switch (slowwalk) {
			case 0:
				lowdelta();
				break
			case 1:
				sway();
				break
			case 2:
				jitter();
				break
			case 3:
				autoflip();
				break
		}
	}

	if (velocity > 100 && airinfo == 0) {
		if (jittercondition == 4 || jittercondition == 5 || jittercondition == 6 || jittercondition == 7 || jittercondition == 12 || jittercondition == 13 || jittercondition == 14 || jittercondition == 15) {
			jitteryaw()
		}
		switch (move) {
			case 0:
				lowdelta();
				break
			case 1:
				sway();
				break
			case 2:
				jitter();
				break
			case 3:
				autoflip();
				break
		}
	}

	if (airinfo != 0) {
		if (jittercondition == 8 || jittercondition == 9 || jittercondition == 10 || jittercondition == 12 || jittercondition == 13 || jittercondition == 14 || jittercondition == 15) {
			jitteryaw()
		}
		switch (air) {
			case 0:
				lowdelta();
				break
			case 1:
				sway();
				break
			case 2:
				jitter();
				break
			case 3:
				autoflip();
				break
		}
	}

	
	

	if (legitaa) {
		legit()
	}

}

function preset() {
	UI.SetValue(scriptitems, "Stand", 1);
	UI.SetValue(scriptitems, "Slow walk", 1);
	UI.SetValue(scriptitems, "Move", 3);
	UI.SetValue(scriptitems, "Air", 3);

	UI.SetValue(scriptitems, "Offset L", 0);
	UI.SetValue(scriptitems, "Real Delta L", 10);
	UI.SetValue(scriptitems, "Fake LBY Delta L", 60);

	UI.SetValue(scriptitems, "MOffset L", 1);
	UI.SetValue(scriptitems, "MReal Delta L", 21);

	UI.SetValue(scriptitems, "Offset R", 1);
	UI.SetValue(scriptitems, "Real Delta R", 30);
	UI.SetValue(scriptitems, "Fake LBY Delta R", 60);

	UI.SetValue(scriptitems, "MOffset R", 0);
	UI.SetValue(scriptitems, "MReal Delta R", 15);

	UI.SetValue(scriptitems, "Sway type", 1);
	UI.SetValue(scriptitems, "Sway standing start", -40);
	UI.SetValue(scriptitems, "Sway standing end", 35);
	UI.SetValue(scriptitems, "Sway standing speed", 3);
	UI.SetValue(scriptitems, "Sway slowwalk start", -60);
	UI.SetValue(scriptitems, "Sway slowwalk end", 60);
	UI.SetValue(scriptitems, "Sway slowwalk speed", 3);
	UI.SetValue(scriptitems, "Desync delta", 60);

	UI.SetValue(scriptitems, "Jitter delta", 40);

	UI.SetValue(scriptitems, "Jitteryaw delta", 0);
	UI.SetValue(scriptitems, "Jitteryaw conditions", 0);

	UI.SetValue(scriptitems, "Legit Offset L", 0);
	UI.SetValue(scriptitems, "Legit Real Delta L", 60);
	UI.SetValue(scriptitems, "Legit Fake LBY Delta L", 60);
	UI.SetValue(scriptitems, "Legit Offset R", 0);
	UI.SetValue(scriptitems, "Legit Real Delta R", 60);
	UI.SetValue(scriptitems, "Legit Fake LBY Delta R", 60);
	UI.SetValue(scriptitems, "Premade settings", 0)
}


function unload() {
	//disable override aa on unload js
	Local.SetClanTag(" ")
	AntiAim.SetOverride(0);
}

Cheat.RegisterCallback("Unload", "unload")
Cheat.RegisterCallback("Draw", "draw_custom_aa");
Cheat.RegisterCallback("CreateMove", "aa")
Cheat.RegisterCallback("Draw", "clantag");
Cheat.RegisterCallback("ragebot_fire","OnshotAA")