var Utilities = {}
var Jitter = {}
var Customaa = {}
var Afakelag = {}
Utilities.Get = function(name){
    return UI.GetValue ("Script Items",name)
}
Utilities.Set = function(name1,name,name3,val){
    UI.SetValue(name1,name,name3,val)
}
Utilities.Add = function(type,name,min,max){
    if(type == 1)
    {
        UI.AddCheckbox(name)
    }
    if(type == 2)
    {
        UI.AddSliderInt(name, min,max)
    }
}
Utilities.tick = function(){
    return Globals.Tickcount()
}
function doUI(){
  
    Utilities.Add(1,"AEnable")
    Utilities.Add(2,"Choke limit",0,16)
    Utilities.Add(2, "Send limit", 0, 16)


    Utilities.Add(1, "Custom desync")
    Utilities.Add(2,"Real offset",-60,90)
    Utilities.Add(2, "Lby offset", -90,90)
}
var tick2 = 0
var swap2 = false
Afakelag.onCreateMove = function(){
    var curTick = Utilities.tick()
    if(!Utilities.Get("AEnable")){
        return
    }
    Utilities.Set("Anti-Aim","Fake-Lag","Limit",Utilities.Get("Choke limit"))
    if(curTick > tick2 + Utilities.Get("Choke limit") && !swap2)
    {
        Utilities.Set("Anti-Aim","Fake-Lag","Enabled",false)
        tick2 = curTick
        swap2 = true
        return
    }
    if(curTick > tick2 + Utilities.Get("Send limit") && swap2)
    {
        Utilities.Set("Anti-Aim","Fake-Lag","Enabled",true)
        tick2 = curTick
        swap2 = false
        return
    }
}
Customaa.onCreateMove = function () {
    AntiAim.SetOverride(Utilities.Get("Custom desync"))
    if (!UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter")) {
        AntiAim.SetFakeOffset(Utilities.Get("Fake offset"))
        AntiAim.SetRealOffset(Utilities.Get("Real offset"))
        AntiAim.SetLBYOffset(Utilities.Get("Lby offset"))
    }
    else {
        AntiAim.SetFakeOffset(-Utilities.Get("Fake offset"))
        AntiAim.SetRealOffset(-Utilities.Get("Real offset"))
        AntiAim.SetLBYOffset(-Utilities.Get("Lby offset"))
    }
}








var swap = 0
var tick = 0









function main(){
    doUI()
    Cheat.RegisterCallback("CreateMove","Customaa.onCreateMove")
    Cheat.RegisterCallback("CreateMove","Afakelag.onCreateMove")
}
main()