ViolLua.Ragebot = { 
    Optimizations = ViolLua.Optimizations,
    Records       = ViolLua.Records,
    Require       = ViolLua.Require,
    Overlay       = ViolLua.Overlay,
    Config        = ViolLua.Config,
    Client        = ViolLua.Client,
    Hooks         = ViolLua.Hooks,
    Shots         = ViolLua.Shots,
    Menu          = ViolLua.Menu,
    
    Bots = ViolLua.Bots,

    Hitboxes = {
        [ HITGROUP_GENERIC ] = 'aimbot_hitboxes_generic',
        [ HITGROUP_HEAD ] = 'aimbot_hitboxes_head',
        [ HITGROUP_CHEST ] = 'aimbot_hitboxes_chest',
        [ HITGROUP_STOMACH ] = 'aimbot_hitboxes_stomach',
        [ HITGROUP_LEFTARM ] = 'aimbot_hitboxes_arms',
        [ HITGROUP_RIGHTARM ] = 'aimbot_hitboxes_arms',
        [ HITGROUP_LEFTLEG ] = 'aimbot_hitboxes_feet',
        [ HITGROUP_RIGHTLEG ] = 'aimbot_hitboxes_feet'
    },

    Indexes = { },
    Cones   = { },

    isManipulating = false,

    Yaw = GetConVar( 'm_yaw' ),
    Pitch = GetConVar( 'm_pitch' ),

    Fake   = angle_zero,
    Real   = angle_zero,
    Silent = angle_zero
}

ViolLua:LoadFile( 'lua/ViolLua/modules/ragebot/resolver/handler.lua' )

ViolLua:LoadFile( 'lua/ViolLua/modules/ragebot/aimbot/handler.lua' )

ViolLua:LoadFile( 'lua/ViolLua/modules/ragebot/antiaim/handler.lua' )

ViolLua:LoadFile( 'lua/ViolLua/modules/ragebot/packs/hl2.lua' )
ViolLua:LoadFile( 'lua/ViolLua/modules/ragebot/packs/m9k.lua' )

ViolLua:LoadFile( 'lua/ViolLua/modules/ragebot/helpers/pack.lua' )
ViolLua:LoadFile( 'lua/ViolLua/modules/ragebot/helpers/silent.lua' )
ViolLua:LoadFile( 'lua/ViolLua/modules/ragebot/helpers/angles.lua' )
ViolLua:LoadFile( 'lua/ViolLua/modules/ragebot/helpers/targeter.lua' )
ViolLua:LoadFile( 'lua/ViolLua/modules/ragebot/helpers/grenades.lua' )
ViolLua:LoadFile( 'lua/ViolLua/modules/ragebot/helpers/hitbox_parser.lua' )

function ViolLua.Ragebot:PrePredicted( Stage, CUserCMD )
    if ( Stage != MOVE_PRE_PREDICTED ) then 
        return
    end

    if ( not self.Client.Local ) then 
        return
    end

    self:SetPack( self.Client.Weapon )
    self:SetupSilent( CUserCMD )
    
    self.Records:Cleanup( )

    if ( CUserCMD:CommandNumber( ) == 0 ) then 
        return
    end

    self.Packet = true
    self.isManipulating = false
    self.currentAngle = false
end

function ViolLua.Ragebot:Predicted( Stage, CUserCMD )
    if ( Stage != MOVE_PREDICTED ) then 
        return
    end

    if ( CUserCMD:CommandNumber( ) == 0 ) then 
        return
    end

    self:Speedhack( CUserCMD )
    self:Lagswitch( CUserCMD )
    self:Networking( CUserCMD )

    self:AntiAim( CUserCMD )

    self:Fakelag( CUserCMD )

    self:Aimbot( CUserCMD )

    self:AdjustGrenades( CUserCMD )

    self.Hooks:Call( 'CreateMoveEx', MOVE_PRE_MOVEMENT, CUserCMD )

    self:SetupMovement( CUserCMD )

    self.Hooks:Call( 'CreateMoveEx', MOVE_POST_MOVEMENT, CUserCMD )

    self:BreakAnimations( CUserCMD )
    
    if ( not self.Packet ) then 
        self.Choked = self.Choked + 1
    else
        self.Choked = 0
    end
    
    self.Require:BSendPacket( self.Packet )
end

ViolLua.Hooks:New( 'CreateMoveEx', ViolLua.Ragebot.Predicted, ViolLua.Ragebot )
ViolLua.Hooks:New( 'CreateMoveEx', ViolLua.Ragebot.PrePredicted, ViolLua.Ragebot )