Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › MultiPlayer Game Hacks & Cheats › Other Semi-Popular First Person Shooter Hacks › Mission Against Terror Hacks & Cheats › dBased Auto Aim C++ source code from Mat Automaton.

PostdBased Auto Aim C++ source code from Mat Automaton.

Posts 1–15 of 22 · Page 1 of 2
samnang18
samnang18
dBased Auto Aim C++ source code from Mat Automaton.
Hi EveryBody this is y second post, Do you miss automaton and dBased(Automaton Creator)
especially the auto aim. I have found a source code from mat auto maton and i hope it help you.
I'm suck at Visual Basic, so who made it don't forget to release it. here it is:
AutoAim:

Code:
#
#  Project: MAT Automaton
#
#  Aiming & utilities
#  - Copyright (C) 2011 dB. All rights reserved.
#

# Python imports
import os
import json

# Automaton imports
from Automaton.System import Register
from Automaton.Outputs import Logger
from Automaton import AntTweakBar
from Automaton import Keys

# Unreal imports
from Unreal.Core   import Vector, Rotator, Color
from Unreal.Core   import Object  as ObjectClass
from Unreal.Engine import Actor   as ActorClass
from Unreal.Engine import Pawn    as PawnClass
from Unreal.Engine import Texture as TextureClass
from Unreal.Engine import Weapon  as WeaponClass

# Fetch important functions
DynamicLoadObject = FindFunction ( ObjectClass, 'DynamicLoadObject' )

# Physics constants
(PHYS_None,         PHYS_Walking,
 PHYS_Falling,      PHYS_Swimming,
 PHYS_Flying,       PHYS_Rotating,
 PHYS_Projectile,   PHYS_Interpolating,
 PHYS_MovingBrush,  PHYS_Spider,
 PHYS_Trailer,      PHYS_Ladder,
 PHYS_RootMotion,   PHYS_Karma,
 PHYS_KarmaRagDoll, PHYS_Hovering) = range ( 16 )

 # Pawn bit constants
(EPB_UseItem,        EPB_God,
 EPB_Dance,          EPB_Speedup,
 EPB_AutoAim,        EPB_Mini,
 EPB_Talking,        EPB_7,
 EPB_FilterBadState, EPB_Hide,
 EPB_Second,         EPB_Third,
 EPB_12,             EPB_13,
 EPB_14,             EPB_15,
 EPB_MagicChange,    EPB_Frozen,
 EPB_Chaos,          EPB_Speeddown,
 EPB_LightingStrike, EPB_Vertigo,
 EPB_CorpseChange,   EPB_EvilPigChange,
 EPB_Terminator,     EPB_25,
 EPB_26,             EPB_27,
 EPB_28,             EPB_29,
 EPB_30,             EPB_Max) = range ( 32 )

# Bone constants
(BONE_Head, BONE_Root) = range ( 2 )

# Team constants
(TEAM_Blue, TEAM_Red) = range ( 2 )

# Aiming modes
(AIMING_Health, AIMING_Distance, AIMING_Key) = range ( 3 )

# Exploits modes
(EXPLOITS_Full, EXPLOITS_Shieldable, EXPLOITS_None) = range ( 3 )

class Aiming(object):
    def __init__(self):
        # Defaults
        self.Wireframe         = False
        self.Wallhack          = False
        self.AlwaysDraw        = False
        self.AutoAim           = False
        self.AutoFire          = False
        self.FriendlyFire      = False
        self.LatencyCorrection = False
        self.SecondaryFire     = False
        self.AimKey            = Keys.Shift
        self.AimMode           = AIMING_Health
        self.AimAngle          = 180.0
        self.BonePrecedence    = BONE_Head
        # Initialization
        self.KeyDown           = False
        self.Viewport          = None
        self.WhiteTexture      = None
        self.AimingModes       = {
            AIMING_Health   : self.__best_byhealth,
            AIMING_Distance : self.__best_bydistance,
            AIMING_Key      : self.__best_bycrosshair
        }

    # Aiming mode comperators
    def __best_byhealth(self, current, other):
        return other.Health < current.Health
    def __best_bydistance(self, current, other):
        CameraLocation  = self.Viewport.Actor.CalcViewLocation
        CurrentDistance = abs ( current.Location - CameraLocation )
        OtherDistance   = abs ( other.Location - CameraLocation )
        return OtherDistance < CurrentDistance
    def __best_bycrosshair(self, current, other):
        CameraLocation  = self.Viewport.Actor.CalcViewLocation
        CameraRotation  = self.Viewport.Actor.CalcViewRotation
        desired         = CameraRotation.Vector ()
        dotCurrent      = desired | ( current.Location - CameraLocation ).Normal ()
        dotOther        = desired | ( other.Location   - CameraLocation ).Normal ()
        return dotOther > dotCurrent

    # Compare two pawns
    def Compare(self, pawn, other):
        return self.AimingModes [ self.AimMode ] ( pawn, other )

    def Tick(self, deltatime):
        if ( self.Viewport and self.Viewport.Actor ):
            # Get our player controller
            PC = self.Viewport.Actor

            # Fetch camera information
            CameraLocation = PC.CalcViewLocation
            CameraRotation = PC.CalcViewRotation

            # Setup configuration data
            FireMode = int ( self.SecondaryFire )
            AutoAim  = self.AutoAim and ( self.AimMode != AIMING_Key or self.KeyDown )

            # If we are auto aiming
            if ( AutoAim and PC.Pawn ):
                # Look for the best target
                BestPawn     = None
                BestLocation = None
                for Pawn in PC.DynamicActors ( PawnClass, PC ):
                    # Check if the pawn is valid
                    if ( Pawn == PC.Pawn or not self.Damagable ( Pawn ) ): continue

                    # If it is a team game make sure we are on a different team
                    if ( not self.FriendlyFire and self.SameTeam ( Pawn ) ): continue

                    # Setup bones list
                    BoneList = ( self.BonePrecedence == BONE_Root ) \
                        and [Pawn****otBone, Pawn.HeadBone] \
                        or  [Pawn.HeadBone, Pawn****otBone]

                    # Find a visible bone
                    for bone in BoneList:
                        # Fetch the bone coords
                        BoneCoords = Pawn.GetBoneCoords ( bone )

                        # Calculate the location
                        BoneLocation = BoneCoords.Origin + BoneCoords.XAxis + BoneCoords.YAxis + BoneCoords.ZAxis

                        # Conditionally apply latency correction
                        if ( self.LatencyCorrection ):
                            BoneLocation += self.Correction ( PC, Pawn, deltatime )

                        # Adjust according to projectile physics
                        if ( PC.Pawn.Weapon and PC.Pawn.Weapon.FireMode [ FireMode ] and PC.Pawn.Weapon.FireMode [ FireMode ].ProjectileClass ):
                            Projectile = PC.Pawn.Weapon.FireMode [ FireMode ].ProjectileClass.Default
                            if ( Projectile and Projectile.Speed != 0 and Projectile.Physics != PHYS_Falling ):
                                BoneLocation += Pawn.Velocity * ( abs ( BoneLocation - CameraLocation ) / Projectile.Speed )

                        # Calculate angle
                        Angle = ( CameraRotation.Vector () | ( BoneLocation - CameraLocation ).Normal () ) + 1.0
                        Angle = ( 1.0 - ( Angle / 2.0 ) ) * 180.0

                        # Do the check
                        if ( Angle <= self.AimAngle and Pawn.FastTrace ( BoneLocation, CameraLocation ) ):
                            # Is this the best one?
                            if ( not BestPawn or self.Compare ( BestPawn, Pawn ) ):
                                BestPawn     = Pawn
                                BestLocation = BoneLocation
                            break
                if ( BestPawn ):
                    # We've found a valid target, so lets set the rotation and fire as required
                    PC.ClientSetRotation ( ( BestLocation - CameraLocation )****tation () )
                    if ( self.AutoFire and PC.Pawn.Weapon ): PC.Pawn.Weapon.ClientStartFire ( FireMode )

    def Render(self, canvas):
        if ( self.Viewport and self.Viewport.Actor ):
            # Get our player controller and canvs
            Canvas = canvas
            PC     = self.Viewport.Actor

            # Fetch game information
            TeamGame = PC.GameReplicationInfo and PC.GameReplicationInfo.bTeamGame

            # Fetch camera information
            CameraLocation = PC.CalcViewLocation
            CameraRotation = PC.CalcViewRotation

            # Get required textures
            self.WhiteTexture = DynamicLoadObject ( 'Engine.WhiteTexture', TextureClass )

            # Do our drawing for list of pawns
            for Pawn in PC.DynamicActors ( PawnClass, PC ):
                # Skip our own pawn and dead pawns
                if ( Pawn == PC.Pawn or Pawn.Health <= 0 ): continue

                # Deal with wireframe wallhack
                if ( self.Wireframe and ( self.AlwaysDraw or self.Invisible ( Pawn ) or not PC.FastTrace ( Pawn.Location, CameraLocation ) ) ):
                    Canvas.DrawActor ( Pawn, True, True, PC.FovAngle )

                # Deal with indicator wallhack
                if ( self.Wallhack and self.WhiteTexture ):
                    HeadCoords = Pawn.GetBoneCoords ( Pawn.HeadBone )

                    # Raise the indicator above the head
                    HeadCoords.Origin.Z += 40

                    # Indicator location
                    IndicatorLocation = HeadCoords.Origin + HeadCoords.XAxis + HeadCoords.YAxis + HeadCoords.ZAxis

                    # Get the indicator position on screen
                    IndicatorPosition = Canvas.WorldToScreen ( IndicatorLocation )

                    # See if the indicator is within screen area
                    if ( IndicatorPosition.X >= 0 and IndicatorPosition.X <= Canvas.ClipX and
                         IndicatorPosition.Y >= 0 and IndicatorPosition.Y <= Canvas.ClipY and
                         CameraRotation.Vector () | ( IndicatorLocation - CameraLocation ).Normal () > 0 ):
                        # Set the proper colors
                        colors      = {TEAM_Blue: Color ( 0, 0, 255 ), TEAM_Red: Color ( 255, 0, 0 )}
                        TeamColor   = colors [ self.GetTeam ( Pawn ) ]
                        HealthColor = Color ( 0, 255, 0 )

                        # Set the health color
                        if ( not self.Damagable ( Pawn ) ):
                            # Yellow is used for pawns with god mode
                            HealthColor = Color ( 255, 255, 0 )
                        else:
                            # Change health indicator to reflect current health
                            HealthColor.G = int ( Pawn.Health / Pawn.HealthMax * HealthColor.G ) % 256
                            HealthColor.R = 255 - HealthColor.G

                        # Reset the canvas
                        Canvas.Reset ()
                        Canvas.KFXFontAlias = 'lightsmall'

                        # Draw the player name
                        Canvas.DrawColor = TeamColor
                        if ( Pawn.PlayerReplicationInfo and ( not TeamGame or not self.SameTeam ( Pawn ) ) ):
                            Canvas.SetPos ( IndicatorPosition.X + 15, IndicatorPosition.Y - 15 )
                            Canvas.KFXDrawStr ( Pawn.PlayerReplicationInfo.PlayerName )

                        # Draw the team part of the indicator
                        Canvas.SetPos ( IndicatorPosition.X - 10, IndicatorPosition.Y - 4 )
                        Canvas.DrawTile ( self.WhiteTexture, 20.0, 8.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )
                        Canvas.SetPos ( IndicatorPosition.X - 4, IndicatorPosition.Y - 10 )
                        Canvas.DrawTile ( self.WhiteTexture, 8.0, 20.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )

                        # Draw the health part of the indicator
                        Canvas.DrawColor = HealthColor
                        Canvas.SetPos ( IndicatorPosition.X - 8, IndicatorPosition.Y - 2 )
                        Canvas.DrawTile ( self.WhiteTexture, 16.0, 4.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )
                        Canvas.SetPos ( IndicatorPosition.X - 2, IndicatorPosition.Y - 8 )
                        Canvas.DrawTile ( self.WhiteTexture, 4.0, 16.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )

    # Helpers
    def GetTeam(self, pawn):
        PRI = pawn and pawn.PlayerReplicationInfo
        if ( PRI and hasattr ( PRI, 'IsCorpsePlayer' ) ):
            return TEAM_Red if PRI.IsCorpsePlayer () else TEAM_Blue
        return PRI and PRI.Team and PRI.Team.TeamIndex or TEAM_Blue
    def Invisible(self, actor):
        PC = self.Viewport and self.Viewport.Actor
        return PC and PC.GameReplicationInfo \
                  and PC.GameReplicationInfo.GameClass == 'KFXGame.KFXGhostGame' \
                  and actor.PlayerReplicationInfo and actor.PlayerReplicationInfo.Team \
                  and actor.PlayerReplicationInfo.Team.TeamIndex == TEAM_Red
    def SameTeam(self, pawn):
        PC = self.Viewport and self.Viewport.Actor
        PRI = pawn and pawn.PlayerReplicationInfo
        if ( PRI and hasattr ( PRI, 'IsCorpsePlayer' ) and hasattr ( PC, 'IsCorpsePlayer' ) ):
            return PC.IsCorpsePlayer () == PRI.IsCorpsePlayer ()
        return PC and PC.GameReplicationInfo and PC.GameReplicationInfo.bTeamGame \
                  and PC.PlayerReplicationInfo and pawn.PlayerReplicationInfo \
                  and PC.PlayerReplicationInfo.Team == pawn.PlayerReplicationInfo.Team
    def Damagable(self, pawn):
        if ( pawn.Health <= 0 ): return False
        if ( hasattr ( pawn, 'KFXIsGodMode' ) ):
            return not pawn.KFXIsGodMode ()
        else: return True
    def Gravity(self, actor):
        # Make sure the actor is valid
        if ( not actor or not actor.PhysicsVolume ): return Vector ()
        # Fetch the zone gravity and add the supplementary pawn gravity
        Acceleration = actor.PhysicsVolume.Gravity
        if ( hasattr ( actor, 'ConstantAcceleration' ) ):
            Acceleration += actor.ConstantAcceleration
        return Acceleration
    def Adjustment(self, actor, time):
        # Make sure its a valid actor
        if ( not actor ): return Vector ()
        # Perform the time correction
        if ( hasattr ( actor, 'Physics' ) and actor.Physics == PHYS_Falling ):
            return self.Gravity ( actor ) * 0.5 * ( time * time ) + actor.Velocity * time
        else: return actor.Velocity * time
    def Correction(self, pc, actor, deltatime):
        # Adjust for latency and player velocity
        if ( not pc ): return Vector ( 0, 0, 0 );
        return self.Adjustment ( actor, pc.ExactPing + deltatime ) - \
               self.Adjustment ( pc.Pawn, deltatime )

    # Event handlers
    def OnTick(self, deltatime):
        self.Tick ( deltatime )
    def OnPostRender(self, canvas):
        self.Viewport = canvas.Viewport
        self.Render ( canvas )
    def OnKeyDown(self, keycode, repeats, prevstate):
        if ( keycode == self.AimKey ): self.KeyDown = True
    def OnKeyUp(self, keycode):
        if ( keycode == self.AimKey ): self.KeyDown = False

class Naming(object):
    def __init__(self):
        # Set some defaults
        self.Interval = 1
        self.Enabled  = False
        # Initialization
        self.Viewport = None
        self.Time     = 0
        self.Count    = 0
    def Enable(self, enabled = True):
        self.Enabled = enabled
        self.Count   = 0
        self.Time    = 0
    def OnTick(self, deltatime):
        if ( not self.Enabled ): return
        self.Time += deltatime
        if ( self.Time > self.Interval ):
            self.Time = 0
            if ( self.Viewport and self.Viewport.Actor ):
                value = self.Count % 256
                name  = ''.join ( reversed ( [ str((value >> bit) & 1) for bit in range ( 8 ) ] ) )
                self.Viewport.Actor.ChangeName ( name )
                self.Count += 1
    def OnPostRender(self, canvas):
        if ( canvas and canvas.Viewport ):
            self.Viewport = canvas.Viewport

class Configuration(object):
    # Internal settings
    __config_layout = {
        'Aiming'   : [('aiming', [ 'AimKey', 'AimMode', 'AutoAim', 'AutoFire', 'AimAngle', 'FriendlyFire', 'LatencyCorrection', 'SecondaryFire', 'BonePrecedence' ])],
        'Info'     : [('aiming', [ 'AlwaysDraw', 'Wireframe', 'Wallhack' ])],
        'Naming'   : [('configuration', [ 'ChangedName' ]), ( 'naming', [ 'Enabled' ] )],
        'Exploits' : [('configuration', [ 'Shield', 'PlayerScale' ])]
    }

    # Init/exit routines
    def __init__(self):
        # Globals for load/save
        global configuration
        configuration = self
        # Set some defaults
        aiming.AutoAim           = True
        aiming.AutoFire          = True
        aiming.LatencyCorrection = True
        aiming.Wireframe         = True
        aiming.Wallhack          = True
        self.Shield              = False
        self.ChangedName         = None
        self.PlayerScale         = 1.0
        self.SaveInterval        = 30
        # Initialization
        self.LastSave            = 0
        self.MenuOpen            = False
        self.Exploits            = self.__checkexploits ()
        # Load settings and setup menu
        self.__loadsettings ()
        self.__setup_antweakbar ()

    # Check exploits mode
    def __checkexploits(self):
        return EXPLOITS_Shieldable

    # Configuration presistence
    def __loadsettings(self):
        # Load and parse the settings file
        filename = os.path.expandvars ( '%AppData%\\MAT Automaton\\settings.json' )
        try:
            infile = None
            infile = open ( filename, 'r' )
            settings = json.load ( infile )
        except: return
        finally: infile and infile.close ()
        # Traverse configuration layout
        for seclayout in self.__config_layout.items ():
            # Fetch section object & data
            try: section = settings [ seclayout [ 0 ] ]
            except: continue
            # Set settings from data
            for objcfg in seclayout [ 1 ]:
                obj = globals () [ objcfg [ 0 ] ]
                for x in objcfg [ 1 ]: x in section and setattr ( obj, x, section [ x ] )
    def __savesettings(self):
        # Setup directory and file
        dir = os.path.expandvars ( '%AppData%\\MAT Automaton' )
        if ( not os.path.exists ( dir ) ): os.mkdir ( dir )
        filename = os.path.join ( dir, 'settings.json' )
        try: outfile = open ( filename, 'w' )
        except: return
        # Build the settings dictionary
        settings = {}
        for seclayout in self.__config_layout.items ():
            section = {}
            for objcfg in seclayout [ 1 ]:
                obj = globals () [ objcfg [ 0 ] ]
                section.update ( dict ( map ( lambda x: (x, getattr ( obj, x )), objcfg [ 1 ] ) ) )
            settings [ seclayout [ 0 ] ] = section
        # Save settings to json settings file
        json.dump ( settings, outfile, indent = 4 )
        outfile.close ()

    def __setup_antweakbar(self):
        mainbar = AntTweakBar.TwGetBarByName ( "MATAutomaton" )
        if ( mainbar ): AntTweakBar.TwDeleteBar ( mainbar )
        try: mainbar = AntTweakBar.TwNewBar ( "MATAutomaton" )
        except: return # Unknown AntTweakBar error
        AntTweakBar.TwDefine ( " MATAutomaton label='MAT Automaton' color='212 0 0' fontSize='3' size='330 450' position='16 16' " )
        AntTweakBar.TwAddVar ( mainbar, 'Key', AntTweakBar.TwDefineEnum ( 'EKey', [(k[1], k[0]) for k in Keys.dictionary.items ()] ), lambda : aiming.AimKey, lambda x : setattr ( aiming, 'AimKey', x ), " group='Aiming' label='Key' " )
        AntTweakBar.TwAddVar ( mainbar, 'Mode', AntTweakBar.TwDefineEnum ( 'EAimModes', [(AIMING_Health, 'Health'), (AIMING_Distance, 'Distance'), (AIMING_Key, 'Key')] ), lambda : aiming.AimMode, lambda x : setattr ( aiming, 'AimMode', x ), " group='Aiming' label='Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'AutoAim', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AutoAim, lambda x : setattr ( aiming, 'AutoAim', x ), " group='Aiming' label='Auto Aim' " )        
        AntTweakBar.TwAddVar ( mainbar, 'AutoFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AutoFire, lambda x : setattr ( aiming, 'AutoFire', x ), " group='Aiming' label='Auto Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'BonePrecedence', AntTweakBar.TwDefineEnum ( 'EBones', [(BONE_Head, 'Head'), (BONE_Root, 'Root')] ), lambda : aiming.BonePrecedence, lambda x : setattr ( aiming, 'BonePrecedence', x ), " group='Aiming' label='Bone Precedence' " )
        AntTweakBar.TwAddVar ( mainbar, 'SecondaryFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.SecondaryFire, lambda x : setattr ( aiming, 'SecondaryFire', x ), " group='Aiming' label='Secondary Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'FriendlyFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.FriendlyFire, lambda x : setattr ( aiming, 'FriendlyFire', x ), " group='Aiming' label='Friendly Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'LatencyCorrection', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.LatencyCorrection, lambda x : setattr ( aiming, 'LatencyCorrection', x ), " group='Aiming' label='Latency Correction' " )
        AntTweakBar.TwAddVar ( mainbar, 'AlwaysDraw', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AlwaysDraw, lambda x : setattr ( aiming, 'AlwaysDraw', x ), " group='Information' label='Always Draw' " )
        AntTweakBar.TwAddVar ( mainbar, 'Wireframe', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.Wireframe, lambda x : setattr ( aiming, 'Wireframe', x ), " group='Information' label='Wireframe' " )
        AntTweakBar.TwAddVar ( mainbar, 'Wallhack', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.Wallhack, lambda x : setattr ( aiming, 'Wallhack', x ), " group='Information' label='Wallhack' " )
        AntTweakBar.TwAddButton ( mainbar, 'SwitchTeam', self.__switchteam, " group='Tools' label='Switch Team' " )
        AntTweakBar.TwAddButton ( mainbar, 'CommitSuicide', self.__suicide, " group='Tools' label='Commit Suicide' " )
        AntTweakBar.TwAddButton ( mainbar, 'OpenConsole', self.__openconsole, " group='Tools' label='Open Console' " )        
        AntTweakBar.TwAddVar ( mainbar, 'BehindView', AntTweakBar.TW_TYPE_BOOL32, self.__getbehindview, self.__setbehindview, " group='Tools' label='Behind View' " )
        AntTweakBar.TwAddVar ( mainbar, 'RandomName', AntTweakBar.TW_TYPE_BOOL32, lambda : naming.Enabled, lambda x : naming.Enable ( x ), " group='Tools' label='Random Name' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerName', AntTweakBar.TW_TYPE_CDSTRING, self.__getplayername, self.__changeplayername, " group='Tools' label='Player Name' " )
        AntTweakBar.TwAddButton ( mainbar, 'GodMode', self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerScale', AntTweakBar.TW_TYPE_FLOAT, lambda : self.PlayerScale, lambda x : setattr ( self, 'PlayerScale', x ), " group='Exploits' label='Player Scale' step=0.1 " )
        AntTweakBar.TwAddButton ( mainbar, 'SetScale', self.__setscale, " group='Exploits' label='Set Scale' " )
        AntTweakBar.TwAddVar ( mainbar, 'Gravity', AntTweakBar.TW_TYPE_FLOAT, self.__getgravity, self.__setgravity, " group='Tools' label='Gravity' step=0.1 " )

       # Shieldable exploits mode
        if ( self.Exploits == EXPLOITS_Shieldable ):
            AntTweakBar.TwAddVar ( mainbar, 'Shield', AntTweakBar.TW_TYPE_BOOL32, lambda : self.Shield, lambda x : setattr ( self, 'Shield', x ), " group='Exploits' label='Shield' " )
        # Full exploits mode
        if ( self.Exploits == EXPLOITS_Full ):
        AntTweakBar.TwAddVar ( mainbar, 'GodMode', AntTweakBar.TW_TYPE_BOOL32, self.__getpawnbit ( EPB_God ), self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerScale', AntTweakBar.TW_TYPE_FLOAT, lambda : self.PlayerScale, lambda x : setattr ( self, 'PlayerScale', x ), " group='Exploits' label='Player Scale' step=0.1 " )
        AntTweakBar.TwAddButton ( mainbar, 'SetScale', self.__setscale, " group='Exploits' label='Set Scale' " )
        AntTweakBar.TwAddButton ( mainbar, 'GodMode', self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
    
    # Tool routines
    def __getbehindview(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        return PC****ehindView if ( PC ) else False
    def __setbehindview(self, value):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.BehindView ( value )
    def __getplayername(self):
        PC  = aiming.Viewport and aiming.Viewport.Actor
        PRI = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.PlayerReplicationInfo
        ChangedName = not naming.Enabled and self.ChangedName or None
        if ( PC and PRI and ChangedName and ChangedName != PRI.PlayerName ):
            PC.ChangeName ( ChangedName )
        return ChangedName or ( PRI and PRI.PlayerName ) or 'None'    
    def __changeplayername(self, value):
        self.ChangedName = value.replace ( ' ', '_' )
    def __suicide(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.Suicide ()    
    def __switchteam(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.SwitchTeam ()        
    def __openconsole(self):
        Console = aiming.Viewport and aiming.Viewpor*****nsole
        if ( Console ): Console.ConsoleOpen ()
    def __getgravity(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        return PC.PhysicsVolume.Gravity.Z if PC.PhysicsVolume else 0
    def __setgravity(self, x):
        PC = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor
        if ( PC and PC.PhysicsVolume ): PC.PhysicsVolume.Gravity.Z = x
    def __checkshield(self):
        Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
        if ( not Pawn or self.Exploits != EXPLOITS_Shieldable ): return
        if ( self.Shield and not Pawn.KFXIsBitStateOn ( EPB_God ) ):
            Pawn.KFXSetPB ( EPB_God, 5 )
    def __setGodMode(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.GodMode()    
    
    # Exploit routines
    def __setpawnbit(self, pawnbit):
        def function():
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            if ( Pawn ): Pawn.KFXSetPB ( pawnbit )
        return function
    def __setscale(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.ServreSetOwnScale ( self.PlayerScale )
        
    # Event handling
    def OnTick(self, deltatime):
        self.LastSave += deltatime
        if ( self.LastSave > self.SaveInterval ):
            self.LastSave = 0
            self.__savesettings ()
    def OnKeyDown(self, keycode, repeats, prevstate):
        if ( keycode == Keys.Numpad0 ):
            aiming.AutoAim = not aiming.AutoAim
            Logger.Log ( 'Auto aiming is now %s!' % ( aiming.AutoAim and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad1 ):
            aiming.Wallhack = not aiming.Wallhack
            Logger.Log ( 'Wallhack is now %s!' % ( aiming.Wallhack and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad2 ):
            aiming.Wireframe = not aiming.Wireframe
            Logger.Log ( 'Wireframe is now %s!' % ( aiming.Wireframe and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad3 ):
            aiming.AutoFire = not aiming.AutoFire
            Logger.Log ( 'Auto firing is now %s!' % ( aiming.AutoFire and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad5 ):
            aiming.SecondaryFire = not aiming.SecondaryFire
            Logger.Log ( 'Secondary firing is now %s!' % ( aiming.SecondaryFire and 'on' or 'off' ) )
        elif ( keycode == Keys.Delete ):
            if ( aiming.Viewport and aiming.Viewpor*****nsole ):
                aiming.Viewpor*****nsole.ConsoleOpen ()
    def OnMenuShow(self):        
        PC = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and aiming.Viewport.Actor.Player and aiming.Viewport.Actor.Player.GUIController        
        if ( GUI ):
            GUI.OperateMsgs [ 99 ] = 'M.A.T By: Daniel Averinaldo Hacker site Mpgh.net.'
            GUI.OpenModeDialogue ( 99 )
    def OnMenuHide(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and aiming.Viewport.Actor.Player and aiming.Viewport.Actor.Player.GUIController
        if ( GUI ):
            GUI.CloseModeDialogue ()
            if ( not GUI.MenuStack ):
                GUI.bActive = False
                GUI.bVisible = False
                try: GUI.ViewportOwner.bShowWindowsMouse = False
                except: pass

class Startup(object):
    def __init__(self):
        self.started = False
        
    def Startup(self):
        # Mark aiming/configuration as globals
        global aiming, naming, configuration
        
        # Instantiate and register
        aiming = Aiming ()
        naming = Naming ()
        configuration = Configuration ()
        Register ( aiming )
        Register ( naming )
        Register ( configuration )

    def OnTick(self, deltatime):    
        # Check status
        if ( self.started ): return
        self.Startup ()
        self.started = True

# Instantiate startup handler
Register ( Startup () )

















Aiming 2(Don't Know):
#
#  Project: MAT Automaton
#
#  Aiming & utilities
#  - Copyright (C) 2011 dB. All rights reserved.
#

# Python imports
import os
import json

# Automaton imports
from Automaton.System import Register
from Automaton.Outputs import Logger
from Automaton import AntTweakBar
from Automaton import Keys

# Unreal imports
from Unreal.Core   import Vector, Rotator, Color
from Unreal.Core   import Object  as ObjectClass
from Unreal.Engine import Actor   as ActorClass
from Unreal.Engine import Pawn    as PawnClass
from Unreal.Engine import Texture as TextureClass
from Unreal.Engine import Weapon  as WeaponClass

# Fetch important functions
DynamicLoadObject = FindFunction ( ObjectClass, 'DynamicLoadObject' )

# Physics constants
(PHYS_None,         PHYS_Walking,
 PHYS_Falling,      PHYS_Swimming,
 PHYS_Flying,       PHYS_Rotating,
 PHYS_Projectile,   PHYS_Interpolating,
 PHYS_MovingBrush,  PHYS_Spider,
 PHYS_Trailer,      PHYS_Ladder,
 PHYS_RootMotion,   PHYS_Karma,
 PHYS_KarmaRagDoll, PHYS_Hovering) = range ( 16 )

 # Pawn bit constants
(EPB_UseItem,        EPB_God,
 EPB_Dance,          EPB_Speedup,
 EPB_AutoAim,        EPB_Mini,
 EPB_Talking,        EPB_7,
 EPB_FilterBadState, EPB_Hide,
 EPB_Second,         EPB_Third,
 EPB_12,             EPB_13,
 EPB_14,             EPB_15,
 EPB_MagicChange,    EPB_Frozen,
 EPB_Chaos,          EPB_Speeddown,
 EPB_LightingStrike, EPB_Vertigo,
 EPB_CorpseChange,   EPB_EvilPigChange,
 EPB_Terminator,     EPB_25,
 EPB_26,             EPB_27,
 EPB_28,             EPB_29,
 EPB_30,             EPB_Max) = range ( 32 )

# Bone constants
(BONE_Head, BONE_Root) = range ( 2 )

# Team constants
(TEAM_Blue, TEAM_Red) = range ( 2 )

# Aiming modes
(AIMING_Health, AIMING_Distance, AIMING_Key) = range ( 3 )

# Exploits modes
(EXPLOITS_Full, EXPLOITS_Shieldable, EXPLOITS_None) = range ( 3 )

class Aiming(object):
    def __init__(self):
        # Defaults
        self.Wireframe         = False
        self.Wallhack          = False
        self.AlwaysDraw        = False
        self.AutoAim           = False
        self.AutoFire          = False
        self.FriendlyFire      = False
        self.LatencyCorrection = False
        self.SecondaryFire     = False
        self.AimKey            = Keys.Shift
        self.AimMode           = AIMING_Health
        self.AimAngle          = 180.0
        self.BonePrecedence    = BONE_Head
        # Initialization
        self.KeyDown           = False
        self.Viewport          = None
        self.WhiteTexture      = None
        self.AimingModes       = {
            AIMING_Health   : self.__best_byhealth,
            AIMING_Distance : self.__best_bydistance,
            AIMING_Key      : self.__best_bycrosshair
        }

    # Aiming mode comperators
    def __best_byhealth(self, current, other):
        return other.Health < current.Health
    def __best_bydistance(self, current, other):
        CameraLocation  = self.Viewport.Actor.CalcViewLocation
        CurrentDistance = abs ( current.Location - CameraLocation )
        OtherDistance   = abs ( other.Location - CameraLocation )
        return OtherDistance < CurrentDistance
    def __best_bycrosshair(self, current, other):
        CameraLocation  = self.Viewport.Actor.CalcViewLocation
        CameraRotation  = self.Viewport.Actor.CalcViewRotation
        desired         = CameraRotation.Vector ()
        dotCurrent      = desired | ( current.Location - CameraLocation ).Normal ()
        dotOther        = desired | ( other.Location   - CameraLocation ).Normal ()
        return dotOther > dotCurrent

    # Compare two pawns
    def Compare(self, pawn, other):
        return self.AimingModes [ self.AimMode ] ( pawn, other )

    def Tick(self, deltatime):
        if ( self.Viewport and self.Viewport.Actor ):
            # Get our player controller
            PC = self.Viewport.Actor

            # Fetch camera information
            CameraLocation = PC.CalcViewLocation
            CameraRotation = PC.CalcViewRotation

            # Setup configuration data
            FireMode = int ( self.SecondaryFire )
            AutoAim  = self.AutoAim and ( self.AimMode != AIMING_Key or self.KeyDown )

            # If we are auto aiming
            if ( AutoAim and PC.Pawn ):
                # Look for the best target
                BestPawn     = None
                BestLocation = None
                for Pawn in PC.DynamicActors ( PawnClass, PC ):
                    # Check if the pawn is valid
                    if ( Pawn == PC.Pawn or not self.Damagable ( Pawn ) ): continue

                    # If it is a team game make sure we are on a different team
                    if ( not self.FriendlyFire and self.SameTeam ( Pawn ) ): continue

                    # Setup bones list
                    BoneList = ( self.BonePrecedence == BONE_Root ) \
                        and [Pawn****otBone, Pawn.HeadBone] \
                        or  [Pawn.HeadBone, Pawn****otBone]

                    # Find a visible bone
                    for bone in BoneList:
                        # Fetch the bone coords
                        BoneCoords = Pawn.GetBoneCoords ( bone )

                        # Calculate the location
                        BoneLocation = BoneCoords.Origin + BoneCoords.XAxis + BoneCoords.YAxis + BoneCoords.ZAxis

                        # Conditionally apply latency correction
                        if ( self.LatencyCorrection ):
                            BoneLocation += self.Correction ( PC, Pawn, deltatime )

                        # Adjust according to projectile physics
                        if ( PC.Pawn.Weapon and PC.Pawn.Weapon.FireMode [ FireMode ] and PC.Pawn.Weapon.FireMode [ FireMode ].ProjectileClass ):
                            Projectile = PC.Pawn.Weapon.FireMode [ FireMode ].ProjectileClass.Default
                            if ( Projectile and Projectile.Speed != 0 and Projectile.Physics != PHYS_Falling ):
                                BoneLocation += Pawn.Velocity * ( abs ( BoneLocation - CameraLocation ) / Projectile.Speed )

                        # Calculate angle
                        Angle = ( CameraRotation.Vector () | ( BoneLocation - CameraLocation ).Normal () ) + 1.0
                        Angle = ( 1.0 - ( Angle / 2.0 ) ) * 180.0

                        # Do the check
                        if ( Angle <= self.AimAngle and Pawn.FastTrace ( BoneLocation, CameraLocation ) ):
                            # Is this the best one?
                            if ( not BestPawn or self.Compare ( BestPawn, Pawn ) ):
                                BestPawn     = Pawn
                                BestLocation = BoneLocation
                            break
                if ( BestPawn ):
                    # We've found a valid target, so lets set the rotation and fire as required
                    PC.ClientSetRotation ( ( BestLocation - CameraLocation )****tation () )
                    if ( self.AutoFire and PC.Pawn.Weapon ): PC.Pawn.Weapon.ClientStartFire ( FireMode )

    def Render(self, canvas):
        if ( self.Viewport and self.Viewport.Actor ):
            # Get our player controller and canvs
            Canvas = canvas
            PC     = self.Viewport.Actor

            # Fetch game information
            TeamGame = PC.GameReplicationInfo and PC.GameReplicationInfo.bTeamGame

            # Fetch camera information
            CameraLocation = PC.CalcViewLocation
            CameraRotation = PC.CalcViewRotation

            # Get required textures
            self.WhiteTexture = DynamicLoadObject ( 'Engine.WhiteTexture', TextureClass )

            # Do our drawing for list of pawns
            for Pawn in PC.DynamicActors ( PawnClass, PC ):
                # Skip our own pawn and dead pawns
                if ( Pawn == PC.Pawn or Pawn.Health <= 0 ): continue

                # Deal with wireframe wallhack
                if ( self.Wireframe and ( self.AlwaysDraw or self.Invisible ( Pawn ) or not PC.FastTrace ( Pawn.Location, CameraLocation ) ) ):
                    Canvas.DrawActor ( Pawn, True, True, PC.FovAngle )

                # Deal with indicator wallhack
                if ( self.Wallhack and self.WhiteTexture ):
                    HeadCoords = Pawn.GetBoneCoords ( Pawn.HeadBone )

                    # Raise the indicator above the head
                    HeadCoords.Origin.Z += 40

                    # Indicator location
                    IndicatorLocation = HeadCoords.Origin + HeadCoords.XAxis + HeadCoords.YAxis + HeadCoords.ZAxis

                    # Get the indicator position on screen
                    IndicatorPosition = Canvas.WorldToScreen ( IndicatorLocation )

                    # See if the indicator is within screen area
                    if ( IndicatorPosition.X >= 0 and IndicatorPosition.X <= Canvas.ClipX and
                         IndicatorPosition.Y >= 0 and IndicatorPosition.Y <= Canvas.ClipY and
                         CameraRotation.Vector () | ( IndicatorLocation - CameraLocation ).Normal () > 0 ):
                        # Set the proper colors
                        colors      = {TEAM_Blue: Color ( 0, 0, 255 ), TEAM_Red: Color ( 255, 0, 0 )}
                        TeamColor   = colors [ self.GetTeam ( Pawn ) ]
                        HealthColor = Color ( 0, 255, 0 )

                        # Set the health color
                        if ( not self.Damagable ( Pawn ) ):
                            # Yellow is used for pawns with god mode
                            HealthColor = Color ( 255, 255, 0 )
                        else:
                            # Change health indicator to reflect current health
                            HealthColor.G = int ( Pawn.Health / Pawn.HealthMax * HealthColor.G ) % 256
                            HealthColor.R = 255 - HealthColor.G

                        # Reset the canvas
                        Canvas.Reset ()
                        Canvas.KFXFontAlias = 'lightsmall'

                        # Draw the player name
                        Canvas.DrawColor = TeamColor
                        if ( Pawn.PlayerReplicationInfo and ( not TeamGame or not self.SameTeam ( Pawn ) ) ):
                            Canvas.SetPos ( IndicatorPosition.X + 15, IndicatorPosition.Y - 15 )
                            Canvas.KFXDrawStr ( Pawn.PlayerReplicationInfo.PlayerName )

                        # Draw the team part of the indicator
                        Canvas.SetPos ( IndicatorPosition.X - 10, IndicatorPosition.Y - 4 )
                        Canvas.DrawTile ( self.WhiteTexture, 20.0, 8.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )
                        Canvas.SetPos ( IndicatorPosition.X - 4, IndicatorPosition.Y - 10 )
                        Canvas.DrawTile ( self.WhiteTexture, 8.0, 20.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )

                        # Draw the health part of the indicator
                        Canvas.DrawColor = HealthColor
                        Canvas.SetPos ( IndicatorPosition.X - 8, IndicatorPosition.Y - 2 )
                        Canvas.DrawTile ( self.WhiteTexture, 16.0, 4.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )
                        Canvas.SetPos ( IndicatorPosition.X - 2, IndicatorPosition.Y - 8 )
                        Canvas.DrawTile ( self.WhiteTexture, 4.0, 16.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )

    # Helpers
    def GetTeam(self, pawn):
        PRI = pawn and pawn.PlayerReplicationInfo
        if ( PRI and hasattr ( PRI, 'IsCorpsePlayer' ) ):
            return TEAM_Red if PRI.IsCorpsePlayer () else TEAM_Blue
        return PRI and PRI.Team and PRI.Team.TeamIndex or TEAM_Blue
    def Invisible(self, actor):
        PC = self.Viewport and self.Viewport.Actor
        return PC and PC.GameReplicationInfo \
                  and PC.GameReplicationInfo.GameClass == 'KFXGame.KFXGhostGame' \
                  and actor.PlayerReplicationInfo and actor.PlayerReplicationInfo.Team \
                  and actor.PlayerReplicationInfo.Team.TeamIndex == TEAM_Red
    def SameTeam(self, pawn):
        PC = self.Viewport and self.Viewport.Actor
        PRI = pawn and pawn.PlayerReplicationInfo
        if ( PRI and hasattr ( PRI, 'IsCorpsePlayer' ) and hasattr ( PC, 'IsCorpsePlayer' ) ):
            return PC.IsCorpsePlayer () == PRI.IsCorpsePlayer ()
        return PC and PC.GameReplicationInfo and PC.GameReplicationInfo.bTeamGame \
                  and PC.PlayerReplicationInfo and pawn.PlayerReplicationInfo \
                  and PC.PlayerReplicationInfo.Team == pawn.PlayerReplicationInfo.Team
    def Damagable(self, pawn):
        if ( pawn.Health <= 0 ): return False
        if ( hasattr ( pawn, 'KFXIsGodMode' ) ):
            return not pawn.KFXIsGodMode ()
        else: return True
    def Gravity(self, actor):
        # Make sure the actor is valid
        if ( not actor or not actor.PhysicsVolume ): return Vector ()
        # Fetch the zone gravity and add the supplementary pawn gravity
        Acceleration = actor.PhysicsVolume.Gravity
        if ( hasattr ( actor, 'ConstantAcceleration' ) ):
            Acceleration += actor.ConstantAcceleration
        return Acceleration
    def Adjustment(self, actor, time):
        # Make sure its a valid actor
        if ( not actor ): return Vector ()
        # Perform the time correction
        if ( hasattr ( actor, 'Physics' ) and actor.Physics == PHYS_Falling ):
            return self.Gravity ( actor ) * 0.5 * ( time * time ) + actor.Velocity * time
        else: return actor.Velocity * time
    def Correction(self, pc, actor, deltatime):
        # Adjust for latency and player velocity
        if ( not pc ): return Vector ( 0, 0, 0 );
        return self.Adjustment ( actor, pc.ExactPing + deltatime ) - \
               self.Adjustment ( pc.Pawn, deltatime )

    # Event handlers
    def OnTick(self, deltatime):
        self.Tick ( deltatime )
    def OnPostRender(self, canvas):
        self.Viewport = canvas.Viewport
        self.Render ( canvas )
    def OnKeyDown(self, keycode, repeats, prevstate):
        if ( keycode == self.AimKey ): self.KeyDown = True
    def OnKeyUp(self, keycode):
        if ( keycode == self.AimKey ): self.KeyDown = False

class Naming(object):
    def __init__(self):
        # Set some defaults
        self.Interval = 1
        self.Enabled  = False
        # Initialization
        self.Viewport = None
        self.Time     = 0
        self.Count    = 0
    def Enable(self, enabled = True):
        self.Enabled = enabled
        self.Count   = 0
        self.Time    = 0
    def OnTick(self, deltatime):
        if ( not self.Enabled ): return
        self.Time += deltatime
        if ( self.Time > self.Interval ):
            self.Time = 0
            if ( self.Viewport and self.Viewport.Actor ):
                value = self.Count % 256
                name  = ''.join ( reversed ( [ str((value >> bit) & 1) for bit in range ( 8 ) ] ) )
                self.Viewport.Actor.ChangeName ( name )
                self.Count += 1
    def OnPostRender(self, canvas):
        if ( canvas and canvas.Viewport ):
            self.Viewport = canvas.Viewport

class Configuration(object):
    # Internal settings
    __config_layout = {
        'Aiming'   : [('aiming', [ 'AimKey', 'AimMode', 'AutoAim', 'AutoFire', 'AimAngle', 'FriendlyFire', 'LatencyCorrection', 'SecondaryFire', 'BonePrecedence' ])],
        'Info'     : [('aiming', [ 'AlwaysDraw', 'Wireframe', 'Wallhack' ])],
        'Naming'   : [('configuration', [ 'ChangedName' ]), ( 'naming', [ 'Enabled' ] )],
        'Exploits' : [('configuration', [ 'Shield', 'PlayerScale' ])]
    }

    # Init/exit routines
    def __init__(self):
        # Globals for load/save
        global configuration
        configuration = self
        # Set some defaults
        aiming.AutoAim           = True
        aiming.AutoFire          = True
        aiming.LatencyCorrection = True
        aiming.Wireframe         = True
        aiming.Wallhack          = True
        self.Shield              = False
        self.ChangedName         = None
        self.PlayerScale         = 1.0
        self.SaveInterval        = 30
        # Initialization
        self.LastSave            = 0
        self.MenuOpen            = False
        self.Exploits            = self.__checkexploits ()
        # Load settings and setup menu
        self.__loadsettings ()
        self.__setup_antweakbar ()

    # Check exploits mode
    def __checkexploits(self):
        return EXPLOITS_Shieldable

    # Configuration presistence
    def __loadsettings(self):
        # Load and parse the settings file
        filename = os.path.expandvars ( '%AppData%\\MAT Automaton\\settings.json' )
        try:
            infile = None
            infile = open ( filename, 'r' )
            settings = json.load ( infile )
        except: return
        finally: infile and infile.close ()
        # Traverse configuration layout
        for seclayout in self.__config_layout.items ():
            # Fetch section object & data
            try: section = settings [ seclayout [ 0 ] ]
            except: continue
            # Set settings from data
            for objcfg in seclayout [ 1 ]:
                obj = globals () [ objcfg [ 0 ] ]
                for x in objcfg [ 1 ]: x in section and setattr ( obj, x, section [ x ] )
    def __savesettings(self):
        # Setup directory and file
        dir = os.path.expandvars ( '%AppData%\\MAT Automaton' )
        if ( not os.path.exists ( dir ) ): os.mkdir ( dir )
        filename = os.path.join ( dir, 'settings.json' )
        try: outfile = open ( filename, 'w' )
        except: return
        # Build the settings dictionary
        settings = {}
        for seclayout in self.__config_layout.items ():
            section = {}
            for objcfg in seclayout [ 1 ]:
                obj = globals () [ objcfg [ 0 ] ]
                section.update ( dict ( map ( lambda x: (x, getattr ( obj, x )), objcfg [ 1 ] ) ) )
            settings [ seclayout [ 0 ] ] = section
        # Save settings to json settings file
        json.dump ( settings, outfile, indent = 4 )
        outfile.close ()

    def __setup_antweakbar(self):
        mainbar = AntTweakBar.TwGetBarByName ( "MATAutomaton" )
        if ( mainbar ): AntTweakBar.TwDeleteBar ( mainbar )
        try: mainbar = AntTweakBar.TwNewBar ( "MATAutomaton" )
        except: return # Unknown AntTweakBar error
        AntTweakBar.TwDefine ( " MATAutomaton label='MAT Automaton' color='135 0 0' fontSize='3' size='330 450' position='16 16' " )
        AntTweakBar.TwAddVar ( mainbar, 'Key', AntTweakBar.TwDefineEnum ( 'EKey', [(k[1], k[0]) for k in Keys.dictionary.items ()] ), lambda : aiming.AimKey, lambda x : setattr ( aiming, 'AimKey', x ), " group='Aiming' label='Key' " )
        AntTweakBar.TwAddVar ( mainbar, 'Mode', AntTweakBar.TwDefineEnum ( 'EAimModes', [(AIMING_Health, 'Health'), (AIMING_Distance, 'Distance'), (AIMING_Key, 'Key')] ), lambda : aiming.AimMode, lambda x : setattr ( aiming, 'AimMode', x ), " group='Aiming' label='Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'AutoAim', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AutoAim, lambda x : setattr ( aiming, 'AutoAim', x ), " group='Aiming' label='Auto Aim' " )        
        AntTweakBar.TwAddVar ( mainbar, 'AutoFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AutoFire, lambda x : setattr ( aiming, 'AutoFire', x ), " group='Aiming' label='Auto Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'BonePrecedence', AntTweakBar.TwDefineEnum ( 'EBones', [(BONE_Head, 'Head'), (BONE_Root, 'Root')] ), lambda : aiming.BonePrecedence, lambda x : setattr ( aiming, 'BonePrecedence', x ), " group='Aiming' label='Bone Precedence' " )
        AntTweakBar.TwAddVar ( mainbar, 'SecondaryFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.SecondaryFire, lambda x : setattr ( aiming, 'SecondaryFire', x ), " group='Aiming' label='Secondary Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'FriendlyFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.FriendlyFire, lambda x : setattr ( aiming, 'FriendlyFire', x ), " group='Aiming' label='Friendly Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'LatencyCorrection', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.LatencyCorrection, lambda x : setattr ( aiming, 'LatencyCorrection', x ), " group='Aiming' label='Latency Correction' " )
        AntTweakBar.TwAddVar ( mainbar, 'AlwaysDraw', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AlwaysDraw, lambda x : setattr ( aiming, 'AlwaysDraw', x ), " group='Information' label='Always Draw' " )
        AntTweakBar.TwAddVar ( mainbar, 'Wireframe', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.Wireframe, lambda x : setattr ( aiming, 'Wireframe', x ), " group='Information' label='Wireframe' " )
        AntTweakBar.TwAddVar ( mainbar, 'Wallhack', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.Wallhack, lambda x : setattr ( aiming, 'Wallhack', x ), " group='Information' label='Wallhack' " )
        AntTweakBar.TwAddButton ( mainbar, 'SwitchTeam', self.__switchteam, " group='Tools' label='Switch Team' " )
        AntTweakBar.TwAddButton ( mainbar, 'CommitSuicide', self.__suicide, " group='Tools' label='Commit Suicide' " )
        AntTweakBar.TwAddButton ( mainbar, 'OpenConsole', self.__openconsole, " group='Tools' label='Open Console' " )        
        AntTweakBar.TwAddVar ( mainbar, 'BehindView', AntTweakBar.TW_TYPE_BOOL32, self.__getbehindview, self.__setbehindview, " group='Tools' label='Behind View' " )
        AntTweakBar.TwAddVar ( mainbar, 'RandomName', AntTweakBar.TW_TYPE_BOOL32, lambda : naming.Enabled, lambda x : naming.Enable ( x ), " group='Tools' label='Random Name' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerName', AntTweakBar.TW_TYPE_CDSTRING, self.__getplayername, self.__changeplayername, " group='Tools' label='Player Name' " )
        AntTweakBar.TwAddButton ( mainbar, 'GodMode', self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerScale', AntTweakBar.TW_TYPE_FLOAT, lambda : self.PlayerScale, lambda x : setattr ( self, 'PlayerScale', x ), " group='Exploits' label='Player Scale' step=0.1 " )
        AntTweakBar.TwAddButton ( mainbar, 'SetScale', self.__setscale, " group='Exploits' label='Set Scale' " )
        AntTweakBar.TwAddVar ( mainbar, 'Gravity', AntTweakBar.TW_TYPE_FLOAT, self.__getgravity, self.__setgravity, " group='Tools' label='Gravity' step=0.1 " )
        # Shieldable exploits mode
        if ( self.Exploits == EXPLOITS_Shieldable ):
            AntTweakBar.TwAddVar ( mainbar, 'Shield', AntTweakBar.TW_TYPE_BOOL32, lambda : self.Shield, lambda x : setattr ( self, 'Shield', x ), " group='Exploits' label='Shield' " )
        # Full exploits mode
        if ( self.Exploits == EXPLOITS_Full ):
            AntTweakBar.TwAddVar ( mainbar, 'GodMode', AntTweakBar.TW_TYPE_BOOL32, self.__getpawnbit ( EPB_God ), self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
            AntTweakBar.TwAddVar ( mainbar, 'PlayerScale', AntTweakBar.TW_TYPE_FLOAT, lambda : self.PlayerScale, lambda x : setattr ( self, 'PlayerScale', x ), " group='Exploits' label='Player Scale' step=0.1 " )
            AntTweakBar.TwAddButton ( mainbar, 'SetScale', self.__setscale, " group='Exploits' label='Set Scale' " )

    # Tool routines
    def __getbehindview(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        return PC****ehindView if ( PC ) else False
    def __setbehindview(self, value):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.BehindView ( value )
    def __getplayername(self):
        PC  = aiming.Viewport and aiming.Viewport.Actor
        PRI = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.PlayerReplicationInfo
        ChangedName = not naming.Enabled and self.ChangedName or None
        if ( PC and PRI and ChangedName and ChangedName != PRI.PlayerName ):
            PC.ChangeName ( ChangedName )
        return ChangedName or ( PRI and PRI.PlayerName ) or 'None'    
    def __changeplayername(self, value):
        self.ChangedName = value.replace ( ' ', '_' )
    def __suicide(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.Suicide ()    
    def __switchteam(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.SwitchTeam ()        
    def __openconsole(self):
        Console = aiming.Viewport and aiming.Viewpor*****nsole
        if ( Console ): Console.ConsoleOpen ()
    def __setGodMode(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.GodMode()   
    def __getgravity(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        return PC.PhysicsVolume.Gravity.Z if PC.PhysicsVolume else 0
    def __setgravity(self, x):
        PC = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor
        if ( PC and PC.PhysicsVolume ): PC.PhysicsVolume.Gravity.Z = x
    def __checkshield(self):
        Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
        if ( not Pawn or self.Exploits != EXPLOITS_Shieldable ): return
        if ( self.Shield and not Pawn.KFXIsBitStateOn ( EPB_God ) ):
            Pawn.KFXSetPB ( EPB_God, 5 ) 
    
    # Exploit routines
    def __getpawnbit(self, pawnbit):
        def function():
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            return bool ( Pawn ) and Pawn.KFXIsBitStateOn ( pawnbit )
        return function
    def __setpawnbit(self, pawnbit):
        def function(x):
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            if ( Pawn ): Pawn.KFXSetPB ( pawnbit, 0 if x else 0.1 )
        return function
    def __setscale(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.ServreSetOwnScale ( self.PlayerScale )


        
    # Exploit routines
    def __getpawnbit(self, pawnbit):
        def function():
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            return bool ( Pawn ) and Pawn.KFXIsBitStateOn ( pawnbit )
        return function
    def __setpawnbit(self, pawnbit):
        def function(x):
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            if ( Pawn ): Pawn.KFXSetPB ( pawnbit, 0 if x else 0.1 )
        return function
    def __setscale(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.ServreSetOwnScale ( self.PlayerScale )

    # Event handling
    def OnTick(self, deltatime):
        PC  = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and PC.Player and PC.Player.GUIController
        if ( GUI and self.MenuOpen ): GUI.OperateTime = 0
        self.__checkshield ()
        self.__getplayername ()
        self.LastSave += deltatime
        if ( self.LastSave > self.SaveInterval ):
            self.LastSave = 0
            self.__savesettings ()
    def OnKeyDown(self, keycode, repeats, prevstate):
        if ( keycode == Keys.Numpad0 ):
            aiming.AutoAim = not aiming.AutoAim
            Logger.Log ( 'Auto aiming is now %s!' % ( aiming.AutoAim and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad1 ):
            aiming.Wallhack = not aiming.Wallhack
            Logger.Log ( 'Wallhack is now %s!' % ( aiming.Wallhack and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad2 ):
            aiming.Wireframe = not aiming.Wireframe
            Logger.Log ( 'Wireframe is now %s!' % ( aiming.Wireframe and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad3 ):
            aiming.AutoFire = not aiming.AutoFire
            Logger.Log ( 'Auto firing is now %s!' % ( aiming.AutoFire and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad5 ):
            aiming.SecondaryFire = not aiming.SecondaryFire
            Logger.Log ( 'Secondary firing is now %s!' % ( aiming.SecondaryFire and 'on' or 'off' ) )
        elif ( keycode == Keys.Delete ):
            if ( aiming.Viewport and aiming.Viewpor*****nsole ):
                aiming.Viewpor*****nsole.ConsoleOpen ()
    def OnMenuShow(self):
        self.MenuOpen = True
        PC  = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and PC.Player and PC.Player.GUIController
        if ( GUI ):
            GUI.OperateMsgs [ 99 ] = 'M.A.T. Auto BY: DANIEL PlAy FoR FuN d^_^b.'
            GUI.OpenModeDialogue ( 99 )
    def OnMenuHide(self):
        self.MenuOpen = False
        PC  = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and PC.Player and PC.Player.GUIController
        if ( GUI ):
            GUI.CloseModeDialogue ()
            if ( not GUI.MenuStack ):
                GUI.bActive = False
                GUI.bVisible = False
                try: GUI.ViewportOwner.bShowWindowsMouse = False
                except: pass

class Startup(object):
    def __init__(self):
        self.started = False

    def Startup(self):
        # Mark aiming/configuration as globals
        global aiming, naming, configuration

        # Instantiate and register
        aiming = Aiming ()
        naming = Naming ()
        configuration = Configuration ()
        Register ( aiming )
        Register ( naming )
        Register ( configuration )

    def OnTick(self, deltatime):
        # Check status
        if ( self.started ): return
        self.Startup ()
        self.started = True

# Instantiate startup handler
Register ( Startup () )
Hope It work.
Sorry For Bad Language
#1 · edited 13y ago · 13y ago
astron51
astron51
Quote Originally Posted by samnang18 View Post
Hi EveryBody this is y second post, Do you miss automaton and dBased(Automaton Creator)
especially the auto aim. I have found a source code from mat auto maton and i hope it help you.
I'm suck at Visual Basic, so who made it don't forget to release it. here it is:
AutoAim:


Code:
#
#  Project: MAT Automaton
#
#  Aiming & utilities
#  - Copyright (C) 2011 dB. All rights reserved.
#

# Python imports
import os
import json

# Automaton imports
from Automaton.System import Register
from Automaton.Outputs import Logger
from Automaton import AntTweakBar
from Automaton import Keys

# Unreal imports
from Unreal.Core   import Vector, Rotator, Color
from Unreal.Core   import Object  as ObjectClass
from Unreal.Engine import Actor   as ActorClass
from Unreal.Engine import Pawn    as PawnClass
from Unreal.Engine import Texture as TextureClass
from Unreal.Engine import Weapon  as WeaponClass

# Fetch important functions
DynamicLoadObject = FindFunction ( ObjectClass, 'DynamicLoadObject' )

# Physics constants
(PHYS_None,         PHYS_Walking,
 PHYS_Falling,      PHYS_Swimming,
 PHYS_Flying,       PHYS_Rotating,
 PHYS_Projectile,   PHYS_Interpolating,
 PHYS_MovingBrush,  PHYS_Spider,
 PHYS_Trailer,      PHYS_Ladder,
 PHYS_RootMotion,   PHYS_Karma,
 PHYS_KarmaRagDoll, PHYS_Hovering) = range ( 16 )

 # Pawn bit constants
(EPB_UseItem,        EPB_God,
 EPB_Dance,          EPB_Speedup,
 EPB_AutoAim,        EPB_Mini,
 EPB_Talking,        EPB_7,
 EPB_FilterBadState, EPB_Hide,
 EPB_Second,         EPB_Third,
 EPB_12,             EPB_13,
 EPB_14,             EPB_15,
 EPB_MagicChange,    EPB_Frozen,
 EPB_Chaos,          EPB_Speeddown,
 EPB_LightingStrike, EPB_Vertigo,
 EPB_CorpseChange,   EPB_EvilPigChange,
 EPB_Terminator,     EPB_25,
 EPB_26,             EPB_27,
 EPB_28,             EPB_29,
 EPB_30,             EPB_Max) = range ( 32 )

# Bone constants
(BONE_Head, BONE_Root) = range ( 2 )

# Team constants
(TEAM_Blue, TEAM_Red) = range ( 2 )

# Aiming modes
(AIMING_Health, AIMING_Distance, AIMING_Key) = range ( 3 )

# Exploits modes
(EXPLOITS_Full, EXPLOITS_Shieldable, EXPLOITS_None) = range ( 3 )

class Aiming(object):
    def __init__(self):
        # Defaults
        self.Wireframe         = False
        self.Wallhack          = False
        self.AlwaysDraw        = False
        self.AutoAim           = False
        self.AutoFire          = False
        self.FriendlyFire      = False
        self.LatencyCorrection = False
        self.SecondaryFire     = False
        self.AimKey            = Keys.Shift
        self.AimMode           = AIMING_Health
        self.AimAngle          = 180.0
        self.BonePrecedence    = BONE_Head
        # Initialization
        self.KeyDown           = False
        self.Viewport          = None
        self.WhiteTexture      = None
        self.AimingModes       = {
            AIMING_Health   : self.__best_byhealth,
            AIMING_Distance : self.__best_bydistance,
            AIMING_Key      : self.__best_bycrosshair
        }

    # Aiming mode comperators
    def __best_byhealth(self, current, other):
        return other.Health < current.Health
    def __best_bydistance(self, current, other):
        CameraLocation  = self.Viewport.Actor.CalcViewLocation
        CurrentDistance = abs ( current.Location - CameraLocation )
        OtherDistance   = abs ( other.Location - CameraLocation )
        return OtherDistance < CurrentDistance
    def __best_bycrosshair(self, current, other):
        CameraLocation  = self.Viewport.Actor.CalcViewLocation
        CameraRotation  = self.Viewport.Actor.CalcViewRotation
        desired         = CameraRotation.Vector ()
        dotCurrent      = desired | ( current.Location - CameraLocation ).Normal ()
        dotOther        = desired | ( other.Location   - CameraLocation ).Normal ()
        return dotOther > dotCurrent

    # Compare two pawns
    def Compare(self, pawn, other):
        return self.AimingModes [ self.AimMode ] ( pawn, other )

    def Tick(self, deltatime):
        if ( self.Viewport and self.Viewport.Actor ):
            # Get our player controller
            PC = self.Viewport.Actor

            # Fetch camera information
            CameraLocation = PC.CalcViewLocation
            CameraRotation = PC.CalcViewRotation

            # Setup configuration data
            FireMode = int ( self.SecondaryFire )
            AutoAim  = self.AutoAim and ( self.AimMode != AIMING_Key or self.KeyDown )

            # If we are auto aiming
            if ( AutoAim and PC.Pawn ):
                # Look for the best target
                BestPawn     = None
                BestLocation = None
                for Pawn in PC.DynamicActors ( PawnClass, PC ):
                    # Check if the pawn is valid
                    if ( Pawn == PC.Pawn or not self.Damagable ( Pawn ) ): continue

                    # If it is a team game make sure we are on a different team
                    if ( not self.FriendlyFire and self.SameTeam ( Pawn ) ): continue

                    # Setup bones list
                    BoneList = ( self.BonePrecedence == BONE_Root ) \
                        and [Pawn****otBone, Pawn.HeadBone] \
                        or  [Pawn.HeadBone, Pawn****otBone]

                    # Find a visible bone
                    for bone in BoneList:
                        # Fetch the bone coords
                        BoneCoords = Pawn.GetBoneCoords ( bone )

                        # Calculate the location
                        BoneLocation = BoneCoords.Origin + BoneCoords.XAxis + BoneCoords.YAxis + BoneCoords.ZAxis

                        # Conditionally apply latency correction
                        if ( self.LatencyCorrection ):
                            BoneLocation += self.Correction ( PC, Pawn, deltatime )

                        # Adjust according to projectile physics
                        if ( PC.Pawn.Weapon and PC.Pawn.Weapon.FireMode [ FireMode ] and PC.Pawn.Weapon.FireMode [ FireMode ].ProjectileClass ):
                            Projectile = PC.Pawn.Weapon.FireMode [ FireMode ].ProjectileClass.Default
                            if ( Projectile and Projectile.Speed != 0 and Projectile.Physics != PHYS_Falling ):
                                BoneLocation += Pawn.Velocity * ( abs ( BoneLocation - CameraLocation ) / Projectile.Speed )

                        # Calculate angle
                        Angle = ( CameraRotation.Vector () | ( BoneLocation - CameraLocation ).Normal () ) + 1.0
                        Angle = ( 1.0 - ( Angle / 2.0 ) ) * 180.0

                        # Do the check
                        if ( Angle <= self.AimAngle and Pawn.FastTrace ( BoneLocation, CameraLocation ) ):
                            # Is this the best one?
                            if ( not BestPawn or self.Compare ( BestPawn, Pawn ) ):
                                BestPawn     = Pawn
                                BestLocation = BoneLocation
                            break
                if ( BestPawn ):
                    # We've found a valid target, so lets set the rotation and fire as required
                    PC.ClientSetRotation ( ( BestLocation - CameraLocation )****tation () )
                    if ( self.AutoFire and PC.Pawn.Weapon ): PC.Pawn.Weapon.ClientStartFire ( FireMode )

    def Render(self, canvas):
        if ( self.Viewport and self.Viewport.Actor ):
            # Get our player controller and canvs
            Canvas = canvas
            PC     = self.Viewport.Actor

            # Fetch game information
            TeamGame = PC.GameReplicationInfo and PC.GameReplicationInfo.bTeamGame

            # Fetch camera information
            CameraLocation = PC.CalcViewLocation
            CameraRotation = PC.CalcViewRotation

            # Get required textures
            self.WhiteTexture = DynamicLoadObject ( 'Engine.WhiteTexture', TextureClass )

            # Do our drawing for list of pawns
            for Pawn in PC.DynamicActors ( PawnClass, PC ):
                # Skip our own pawn and dead pawns
                if ( Pawn == PC.Pawn or Pawn.Health <= 0 ): continue

                # Deal with wireframe wallhack
                if ( self.Wireframe and ( self.AlwaysDraw or self.Invisible ( Pawn ) or not PC.FastTrace ( Pawn.Location, CameraLocation ) ) ):
                    Canvas.DrawActor ( Pawn, True, True, PC.FovAngle )

                # Deal with indicator wallhack
                if ( self.Wallhack and self.WhiteTexture ):
                    HeadCoords = Pawn.GetBoneCoords ( Pawn.HeadBone )

                    # Raise the indicator above the head
                    HeadCoords.Origin.Z += 40

                    # Indicator location
                    IndicatorLocation = HeadCoords.Origin + HeadCoords.XAxis + HeadCoords.YAxis + HeadCoords.ZAxis

                    # Get the indicator position on screen
                    IndicatorPosition = Canvas.WorldToScreen ( IndicatorLocation )

                    # See if the indicator is within screen area
                    if ( IndicatorPosition.X >= 0 and IndicatorPosition.X <= Canvas.ClipX and
                         IndicatorPosition.Y >= 0 and IndicatorPosition.Y <= Canvas.ClipY and
                         CameraRotation.Vector () | ( IndicatorLocation - CameraLocation ).Normal () > 0 ):
                        # Set the proper colors
                        colors      = {TEAM_Blue: Color ( 0, 0, 255 ), TEAM_Red: Color ( 255, 0, 0 )}
                        TeamColor   = colors [ self.GetTeam ( Pawn ) ]
                        HealthColor = Color ( 0, 255, 0 )

                        # Set the health color
                        if ( not self.Damagable ( Pawn ) ):
                            # Yellow is used for pawns with god mode
                            HealthColor = Color ( 255, 255, 0 )
                        else:
                            # Change health indicator to reflect current health
                            HealthColor.G = int ( Pawn.Health / Pawn.HealthMax * HealthColor.G ) % 256
                            HealthColor.R = 255 - HealthColor.G

                        # Reset the canvas
                        Canvas.Reset ()
                        Canvas.KFXFontAlias = 'lightsmall'

                        # Draw the player name
                        Canvas.DrawColor = TeamColor
                        if ( Pawn.PlayerReplicationInfo and ( not TeamGame or not self.SameTeam ( Pawn ) ) ):
                            Canvas.SetPos ( IndicatorPosition.X + 15, IndicatorPosition.Y - 15 )
                            Canvas.KFXDrawStr ( Pawn.PlayerReplicationInfo.PlayerName )

                        # Draw the team part of the indicator
                        Canvas.SetPos ( IndicatorPosition.X - 10, IndicatorPosition.Y - 4 )
                        Canvas.DrawTile ( self.WhiteTexture, 20.0, 8.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )
                        Canvas.SetPos ( IndicatorPosition.X - 4, IndicatorPosition.Y - 10 )
                        Canvas.DrawTile ( self.WhiteTexture, 8.0, 20.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )

                        # Draw the health part of the indicator
                        Canvas.DrawColor = HealthColor
                        Canvas.SetPos ( IndicatorPosition.X - 8, IndicatorPosition.Y - 2 )
                        Canvas.DrawTile ( self.WhiteTexture, 16.0, 4.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )
                        Canvas.SetPos ( IndicatorPosition.X - 2, IndicatorPosition.Y - 8 )
                        Canvas.DrawTile ( self.WhiteTexture, 4.0, 16.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )

    # Helpers
    def GetTeam(self, pawn):
        PRI = pawn and pawn.PlayerReplicationInfo
        if ( PRI and hasattr ( PRI, 'IsCorpsePlayer' ) ):
            return TEAM_Red if PRI.IsCorpsePlayer () else TEAM_Blue
        return PRI and PRI.Team and PRI.Team.TeamIndex or TEAM_Blue
    def Invisible(self, actor):
        PC = self.Viewport and self.Viewport.Actor
        return PC and PC.GameReplicationInfo \
                  and PC.GameReplicationInfo.GameClass == 'KFXGame.KFXGhostGame' \
                  and actor.PlayerReplicationInfo and actor.PlayerReplicationInfo.Team \
                  and actor.PlayerReplicationInfo.Team.TeamIndex == TEAM_Red
    def SameTeam(self, pawn):
        PC = self.Viewport and self.Viewport.Actor
        PRI = pawn and pawn.PlayerReplicationInfo
        if ( PRI and hasattr ( PRI, 'IsCorpsePlayer' ) and hasattr ( PC, 'IsCorpsePlayer' ) ):
            return PC.IsCorpsePlayer () == PRI.IsCorpsePlayer ()
        return PC and PC.GameReplicationInfo and PC.GameReplicationInfo.bTeamGame \
                  and PC.PlayerReplicationInfo and pawn.PlayerReplicationInfo \
                  and PC.PlayerReplicationInfo.Team == pawn.PlayerReplicationInfo.Team
    def Damagable(self, pawn):
        if ( pawn.Health <= 0 ): return False
        if ( hasattr ( pawn, 'KFXIsGodMode' ) ):
            return not pawn.KFXIsGodMode ()
        else: return True
    def Gravity(self, actor):
        # Make sure the actor is valid
        if ( not actor or not actor.PhysicsVolume ): return Vector ()
        # Fetch the zone gravity and add the supplementary pawn gravity
        Acceleration = actor.PhysicsVolume.Gravity
        if ( hasattr ( actor, 'ConstantAcceleration' ) ):
            Acceleration += actor.ConstantAcceleration
        return Acceleration
    def Adjustment(self, actor, time):
        # Make sure its a valid actor
        if ( not actor ): return Vector ()
        # Perform the time correction
        if ( hasattr ( actor, 'Physics' ) and actor.Physics == PHYS_Falling ):
            return self.Gravity ( actor ) * 0.5 * ( time * time ) + actor.Velocity * time
        else: return actor.Velocity * time
    def Correction(self, pc, actor, deltatime):
        # Adjust for latency and player velocity
        if ( not pc ): return Vector ( 0, 0, 0 );
        return self.Adjustment ( actor, pc.ExactPing + deltatime ) - \
               self.Adjustment ( pc.Pawn, deltatime )

    # Event handlers
    def OnTick(self, deltatime):
        self.Tick ( deltatime )
    def OnPostRender(self, canvas):
        self.Viewport = canvas.Viewport
        self.Render ( canvas )
    def OnKeyDown(self, keycode, repeats, prevstate):
        if ( keycode == self.AimKey ): self.KeyDown = True
    def OnKeyUp(self, keycode):
        if ( keycode == self.AimKey ): self.KeyDown = False

class Naming(object):
    def __init__(self):
        # Set some defaults
        self.Interval = 1
        self.Enabled  = False
        # Initialization
        self.Viewport = None
        self.Time     = 0
        self.Count    = 0
    def Enable(self, enabled = True):
        self.Enabled = enabled
        self.Count   = 0
        self.Time    = 0
    def OnTick(self, deltatime):
        if ( not self.Enabled ): return
        self.Time += deltatime
        if ( self.Time > self.Interval ):
            self.Time = 0
            if ( self.Viewport and self.Viewport.Actor ):
                value = self.Count % 256
                name  = ''.join ( reversed ( [ str((value >> bit) & 1) for bit in range ( 8 ) ] ) )
                self.Viewport.Actor.ChangeName ( name )
                self.Count += 1
    def OnPostRender(self, canvas):
        if ( canvas and canvas.Viewport ):
            self.Viewport = canvas.Viewport

class Configuration(object):
    # Internal settings
    __config_layout = {
        'Aiming'   : [('aiming', [ 'AimKey', 'AimMode', 'AutoAim', 'AutoFire', 'AimAngle', 'FriendlyFire', 'LatencyCorrection', 'SecondaryFire', 'BonePrecedence' ])],
        'Info'     : [('aiming', [ 'AlwaysDraw', 'Wireframe', 'Wallhack' ])],
        'Naming'   : [('configuration', [ 'ChangedName' ]), ( 'naming', [ 'Enabled' ] )],
        'Exploits' : [('configuration', [ 'Shield', 'PlayerScale' ])]
    }

    # Init/exit routines
    def __init__(self):
        # Globals for load/save
        global configuration
        configuration = self
        # Set some defaults
        aiming.AutoAim           = True
        aiming.AutoFire          = True
        aiming.LatencyCorrection = True
        aiming.Wireframe         = True
        aiming.Wallhack          = True
        self.Shield              = False
        self.ChangedName         = None
        self.PlayerScale         = 1.0
        self.SaveInterval        = 30
        # Initialization
        self.LastSave            = 0
        self.MenuOpen            = False
        self.Exploits            = self.__checkexploits ()
        # Load settings and setup menu
        self.__loadsettings ()
        self.__setup_antweakbar ()

    # Check exploits mode
    def __checkexploits(self):
        return EXPLOITS_Shieldable

    # Configuration presistence
    def __loadsettings(self):
        # Load and parse the settings file
        filename = os.path.expandvars ( '%AppData%\\MAT Automaton\\settings.json' )
        try:
            infile = None
            infile = open ( filename, 'r' )
            settings = json.load ( infile )
        except: return
        finally: infile and infile.close ()
        # Traverse configuration layout
        for seclayout in self.__config_layout.items ():
            # Fetch section object & data
            try: section = settings [ seclayout [ 0 ] ]
            except: continue
            # Set settings from data
            for objcfg in seclayout [ 1 ]:
                obj = globals () [ objcfg [ 0 ] ]
                for x in objcfg [ 1 ]: x in section and setattr ( obj, x, section [ x ] )
    def __savesettings(self):
        # Setup directory and file
        dir = os.path.expandvars ( '%AppData%\\MAT Automaton' )
        if ( not os.path.exists ( dir ) ): os.mkdir ( dir )
        filename = os.path.join ( dir, 'settings.json' )
        try: outfile = open ( filename, 'w' )
        except: return
        # Build the settings dictionary
        settings = {}
        for seclayout in self.__config_layout.items ():
            section = {}
            for objcfg in seclayout [ 1 ]:
                obj = globals () [ objcfg [ 0 ] ]
                section.update ( dict ( map ( lambda x: (x, getattr ( obj, x )), objcfg [ 1 ] ) ) )
            settings [ seclayout [ 0 ] ] = section
        # Save settings to json settings file
        json.dump ( settings, outfile, indent = 4 )
        outfile.close ()

    def __setup_antweakbar(self):
        mainbar = AntTweakBar.TwGetBarByName ( "MATAutomaton" )
        if ( mainbar ): AntTweakBar.TwDeleteBar ( mainbar )
        try: mainbar = AntTweakBar.TwNewBar ( "MATAutomaton" )
        except: return # Unknown AntTweakBar error
        AntTweakBar.TwDefine ( " MATAutomaton label='MAT Automaton' color='212 0 0' fontSize='3' size='330 450' position='16 16' " )
        AntTweakBar.TwAddVar ( mainbar, 'Key', AntTweakBar.TwDefineEnum ( 'EKey', [(k[1], k[0]) for k in Keys.dictionary.items ()] ), lambda : aiming.AimKey, lambda x : setattr ( aiming, 'AimKey', x ), " group='Aiming' label='Key' " )
        AntTweakBar.TwAddVar ( mainbar, 'Mode', AntTweakBar.TwDefineEnum ( 'EAimModes', [(AIMING_Health, 'Health'), (AIMING_Distance, 'Distance'), (AIMING_Key, 'Key')] ), lambda : aiming.AimMode, lambda x : setattr ( aiming, 'AimMode', x ), " group='Aiming' label='Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'AutoAim', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AutoAim, lambda x : setattr ( aiming, 'AutoAim', x ), " group='Aiming' label='Auto Aim' " )        
        AntTweakBar.TwAddVar ( mainbar, 'AutoFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AutoFire, lambda x : setattr ( aiming, 'AutoFire', x ), " group='Aiming' label='Auto Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'BonePrecedence', AntTweakBar.TwDefineEnum ( 'EBones', [(BONE_Head, 'Head'), (BONE_Root, 'Root')] ), lambda : aiming.BonePrecedence, lambda x : setattr ( aiming, 'BonePrecedence', x ), " group='Aiming' label='Bone Precedence' " )
        AntTweakBar.TwAddVar ( mainbar, 'SecondaryFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.SecondaryFire, lambda x : setattr ( aiming, 'SecondaryFire', x ), " group='Aiming' label='Secondary Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'FriendlyFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.FriendlyFire, lambda x : setattr ( aiming, 'FriendlyFire', x ), " group='Aiming' label='Friendly Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'LatencyCorrection', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.LatencyCorrection, lambda x : setattr ( aiming, 'LatencyCorrection', x ), " group='Aiming' label='Latency Correction' " )
        AntTweakBar.TwAddVar ( mainbar, 'AlwaysDraw', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AlwaysDraw, lambda x : setattr ( aiming, 'AlwaysDraw', x ), " group='Information' label='Always Draw' " )
        AntTweakBar.TwAddVar ( mainbar, 'Wireframe', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.Wireframe, lambda x : setattr ( aiming, 'Wireframe', x ), " group='Information' label='Wireframe' " )
        AntTweakBar.TwAddVar ( mainbar, 'Wallhack', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.Wallhack, lambda x : setattr ( aiming, 'Wallhack', x ), " group='Information' label='Wallhack' " )
        AntTweakBar.TwAddButton ( mainbar, 'SwitchTeam', self.__switchteam, " group='Tools' label='Switch Team' " )
        AntTweakBar.TwAddButton ( mainbar, 'CommitSuicide', self.__suicide, " group='Tools' label='Commit Suicide' " )
        AntTweakBar.TwAddButton ( mainbar, 'OpenConsole', self.__openconsole, " group='Tools' label='Open Console' " )        
        AntTweakBar.TwAddVar ( mainbar, 'BehindView', AntTweakBar.TW_TYPE_BOOL32, self.__getbehindview, self.__setbehindview, " group='Tools' label='Behind View' " )
        AntTweakBar.TwAddVar ( mainbar, 'RandomName', AntTweakBar.TW_TYPE_BOOL32, lambda : naming.Enabled, lambda x : naming.Enable ( x ), " group='Tools' label='Random Name' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerName', AntTweakBar.TW_TYPE_CDSTRING, self.__getplayername, self.__changeplayername, " group='Tools' label='Player Name' " )
        AntTweakBar.TwAddButton ( mainbar, 'GodMode', self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerScale', AntTweakBar.TW_TYPE_FLOAT, lambda : self.PlayerScale, lambda x : setattr ( self, 'PlayerScale', x ), " group='Exploits' label='Player Scale' step=0.1 " )
        AntTweakBar.TwAddButton ( mainbar, 'SetScale', self.__setscale, " group='Exploits' label='Set Scale' " )
        AntTweakBar.TwAddVar ( mainbar, 'Gravity', AntTweakBar.TW_TYPE_FLOAT, self.__getgravity, self.__setgravity, " group='Tools' label='Gravity' step=0.1 " )

       # Shieldable exploits mode
        if ( self.Exploits == EXPLOITS_Shieldable ):
            AntTweakBar.TwAddVar ( mainbar, 'Shield', AntTweakBar.TW_TYPE_BOOL32, lambda : self.Shield, lambda x : setattr ( self, 'Shield', x ), " group='Exploits' label='Shield' " )
        # Full exploits mode
        if ( self.Exploits == EXPLOITS_Full ):
        AntTweakBar.TwAddVar ( mainbar, 'GodMode', AntTweakBar.TW_TYPE_BOOL32, self.__getpawnbit ( EPB_God ), self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerScale', AntTweakBar.TW_TYPE_FLOAT, lambda : self.PlayerScale, lambda x : setattr ( self, 'PlayerScale', x ), " group='Exploits' label='Player Scale' step=0.1 " )
        AntTweakBar.TwAddButton ( mainbar, 'SetScale', self.__setscale, " group='Exploits' label='Set Scale' " )
        AntTweakBar.TwAddButton ( mainbar, 'GodMode', self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
    
    # Tool routines
    def __getbehindview(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        return PC****ehindView if ( PC ) else False
    def __setbehindview(self, value):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.BehindView ( value )
    def __getplayername(self):
        PC  = aiming.Viewport and aiming.Viewport.Actor
        PRI = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.PlayerReplicationInfo
        ChangedName = not naming.Enabled and self.ChangedName or None
        if ( PC and PRI and ChangedName and ChangedName != PRI.PlayerName ):
            PC.ChangeName ( ChangedName )
        return ChangedName or ( PRI and PRI.PlayerName ) or 'None'    
    def __changeplayername(self, value):
        self.ChangedName = value.replace ( ' ', '_' )
    def __suicide(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.Suicide ()    
    def __switchteam(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.SwitchTeam ()        
    def __openconsole(self):
        Console = aiming.Viewport and aiming.Viewpor*****nsole
        if ( Console ): Console.ConsoleOpen ()
    def __getgravity(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        return PC.PhysicsVolume.Gravity.Z if PC.PhysicsVolume else 0
    def __setgravity(self, x):
        PC = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor
        if ( PC and PC.PhysicsVolume ): PC.PhysicsVolume.Gravity.Z = x
    def __checkshield(self):
        Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
        if ( not Pawn or self.Exploits != EXPLOITS_Shieldable ): return
        if ( self.Shield and not Pawn.KFXIsBitStateOn ( EPB_God ) ):
            Pawn.KFXSetPB ( EPB_God, 5 )
    def __setGodMode(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.GodMode()    
    
    # Exploit routines
    def __setpawnbit(self, pawnbit):
        def function():
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            if ( Pawn ): Pawn.KFXSetPB ( pawnbit )
        return function
    def __setscale(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.ServreSetOwnScale ( self.PlayerScale )
        
    # Event handling
    def OnTick(self, deltatime):
        self.LastSave += deltatime
        if ( self.LastSave > self.SaveInterval ):
            self.LastSave = 0
            self.__savesettings ()
    def OnKeyDown(self, keycode, repeats, prevstate):
        if ( keycode == Keys.Numpad0 ):
            aiming.AutoAim = not aiming.AutoAim
            Logger.Log ( 'Auto aiming is now %s!' % ( aiming.AutoAim and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad1 ):
            aiming.Wallhack = not aiming.Wallhack
            Logger.Log ( 'Wallhack is now %s!' % ( aiming.Wallhack and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad2 ):
            aiming.Wireframe = not aiming.Wireframe
            Logger.Log ( 'Wireframe is now %s!' % ( aiming.Wireframe and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad3 ):
            aiming.AutoFire = not aiming.AutoFire
            Logger.Log ( 'Auto firing is now %s!' % ( aiming.AutoFire and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad5 ):
            aiming.SecondaryFire = not aiming.SecondaryFire
            Logger.Log ( 'Secondary firing is now %s!' % ( aiming.SecondaryFire and 'on' or 'off' ) )
        elif ( keycode == Keys.Delete ):
            if ( aiming.Viewport and aiming.Viewpor*****nsole ):
                aiming.Viewpor*****nsole.ConsoleOpen ()
    def OnMenuShow(self):        
        PC = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and aiming.Viewport.Actor.Player and aiming.Viewport.Actor.Player.GUIController        
        if ( GUI ):
            GUI.OperateMsgs [ 99 ] = 'M.A.T By: Daniel Averinaldo Hacker site Mpgh.net.'
            GUI.OpenModeDialogue ( 99 )
    def OnMenuHide(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and aiming.Viewport.Actor.Player and aiming.Viewport.Actor.Player.GUIController
        if ( GUI ):
            GUI.CloseModeDialogue ()
            if ( not GUI.MenuStack ):
                GUI.bActive = False
                GUI.bVisible = False
                try: GUI.ViewportOwner.bShowWindowsMouse = False
                except: pass

class Startup(object):
    def __init__(self):
        self.started = False
        
    def Startup(self):
        # Mark aiming/configuration as globals
        global aiming, naming, configuration
        
        # Instantiate and register
        aiming = Aiming ()
        naming = Naming ()
        configuration = Configuration ()
        Register ( aiming )
        Register ( naming )
        Register ( configuration )

    def OnTick(self, deltatime):    
        # Check status
        if ( self.started ): return
        self.Startup ()
        self.started = True

# Instantiate startup handler
Register ( Startup () )

















Aiming 2(Don't Know):
#
#  Project: MAT Automaton
#
#  Aiming & utilities
#  - Copyright (C) 2011 dB. All rights reserved.
#

# Python imports
import os
import json

# Automaton imports
from Automaton.System import Register
from Automaton.Outputs import Logger
from Automaton import AntTweakBar
from Automaton import Keys

# Unreal imports
from Unreal.Core   import Vector, Rotator, Color
from Unreal.Core   import Object  as ObjectClass
from Unreal.Engine import Actor   as ActorClass
from Unreal.Engine import Pawn    as PawnClass
from Unreal.Engine import Texture as TextureClass
from Unreal.Engine import Weapon  as WeaponClass

# Fetch important functions
DynamicLoadObject = FindFunction ( ObjectClass, 'DynamicLoadObject' )

# Physics constants
(PHYS_None,         PHYS_Walking,
 PHYS_Falling,      PHYS_Swimming,
 PHYS_Flying,       PHYS_Rotating,
 PHYS_Projectile,   PHYS_Interpolating,
 PHYS_MovingBrush,  PHYS_Spider,
 PHYS_Trailer,      PHYS_Ladder,
 PHYS_RootMotion,   PHYS_Karma,
 PHYS_KarmaRagDoll, PHYS_Hovering) = range ( 16 )

 # Pawn bit constants
(EPB_UseItem,        EPB_God,
 EPB_Dance,          EPB_Speedup,
 EPB_AutoAim,        EPB_Mini,
 EPB_Talking,        EPB_7,
 EPB_FilterBadState, EPB_Hide,
 EPB_Second,         EPB_Third,
 EPB_12,             EPB_13,
 EPB_14,             EPB_15,
 EPB_MagicChange,    EPB_Frozen,
 EPB_Chaos,          EPB_Speeddown,
 EPB_LightingStrike, EPB_Vertigo,
 EPB_CorpseChange,   EPB_EvilPigChange,
 EPB_Terminator,     EPB_25,
 EPB_26,             EPB_27,
 EPB_28,             EPB_29,
 EPB_30,             EPB_Max) = range ( 32 )

# Bone constants
(BONE_Head, BONE_Root) = range ( 2 )

# Team constants
(TEAM_Blue, TEAM_Red) = range ( 2 )

# Aiming modes
(AIMING_Health, AIMING_Distance, AIMING_Key) = range ( 3 )

# Exploits modes
(EXPLOITS_Full, EXPLOITS_Shieldable, EXPLOITS_None) = range ( 3 )

class Aiming(object):
    def __init__(self):
        # Defaults
        self.Wireframe         = False
        self.Wallhack          = False
        self.AlwaysDraw        = False
        self.AutoAim           = False
        self.AutoFire          = False
        self.FriendlyFire      = False
        self.LatencyCorrection = False
        self.SecondaryFire     = False
        self.AimKey            = Keys.Shift
        self.AimMode           = AIMING_Health
        self.AimAngle          = 180.0
        self.BonePrecedence    = BONE_Head
        # Initialization
        self.KeyDown           = False
        self.Viewport          = None
        self.WhiteTexture      = None
        self.AimingModes       = {
            AIMING_Health   : self.__best_byhealth,
            AIMING_Distance : self.__best_bydistance,
            AIMING_Key      : self.__best_bycrosshair
        }

    # Aiming mode comperators
    def __best_byhealth(self, current, other):
        return other.Health < current.Health
    def __best_bydistance(self, current, other):
        CameraLocation  = self.Viewport.Actor.CalcViewLocation
        CurrentDistance = abs ( current.Location - CameraLocation )
        OtherDistance   = abs ( other.Location - CameraLocation )
        return OtherDistance < CurrentDistance
    def __best_bycrosshair(self, current, other):
        CameraLocation  = self.Viewport.Actor.CalcViewLocation
        CameraRotation  = self.Viewport.Actor.CalcViewRotation
        desired         = CameraRotation.Vector ()
        dotCurrent      = desired | ( current.Location - CameraLocation ).Normal ()
        dotOther        = desired | ( other.Location   - CameraLocation ).Normal ()
        return dotOther > dotCurrent

    # Compare two pawns
    def Compare(self, pawn, other):
        return self.AimingModes [ self.AimMode ] ( pawn, other )

    def Tick(self, deltatime):
        if ( self.Viewport and self.Viewport.Actor ):
            # Get our player controller
            PC = self.Viewport.Actor

            # Fetch camera information
            CameraLocation = PC.CalcViewLocation
            CameraRotation = PC.CalcViewRotation

            # Setup configuration data
            FireMode = int ( self.SecondaryFire )
            AutoAim  = self.AutoAim and ( self.AimMode != AIMING_Key or self.KeyDown )

            # If we are auto aiming
            if ( AutoAim and PC.Pawn ):
                # Look for the best target
                BestPawn     = None
                BestLocation = None
                for Pawn in PC.DynamicActors ( PawnClass, PC ):
                    # Check if the pawn is valid
                    if ( Pawn == PC.Pawn or not self.Damagable ( Pawn ) ): continue

                    # If it is a team game make sure we are on a different team
                    if ( not self.FriendlyFire and self.SameTeam ( Pawn ) ): continue

                    # Setup bones list
                    BoneList = ( self.BonePrecedence == BONE_Root ) \
                        and [Pawn****otBone, Pawn.HeadBone] \
                        or  [Pawn.HeadBone, Pawn****otBone]

                    # Find a visible bone
                    for bone in BoneList:
                        # Fetch the bone coords
                        BoneCoords = Pawn.GetBoneCoords ( bone )

                        # Calculate the location
                        BoneLocation = BoneCoords.Origin + BoneCoords.XAxis + BoneCoords.YAxis + BoneCoords.ZAxis

                        # Conditionally apply latency correction
                        if ( self.LatencyCorrection ):
                            BoneLocation += self.Correction ( PC, Pawn, deltatime )

                        # Adjust according to projectile physics
                        if ( PC.Pawn.Weapon and PC.Pawn.Weapon.FireMode [ FireMode ] and PC.Pawn.Weapon.FireMode [ FireMode ].ProjectileClass ):
                            Projectile = PC.Pawn.Weapon.FireMode [ FireMode ].ProjectileClass.Default
                            if ( Projectile and Projectile.Speed != 0 and Projectile.Physics != PHYS_Falling ):
                                BoneLocation += Pawn.Velocity * ( abs ( BoneLocation - CameraLocation ) / Projectile.Speed )

                        # Calculate angle
                        Angle = ( CameraRotation.Vector () | ( BoneLocation - CameraLocation ).Normal () ) + 1.0
                        Angle = ( 1.0 - ( Angle / 2.0 ) ) * 180.0

                        # Do the check
                        if ( Angle <= self.AimAngle and Pawn.FastTrace ( BoneLocation, CameraLocation ) ):
                            # Is this the best one?
                            if ( not BestPawn or self.Compare ( BestPawn, Pawn ) ):
                                BestPawn     = Pawn
                                BestLocation = BoneLocation
                            break
                if ( BestPawn ):
                    # We've found a valid target, so lets set the rotation and fire as required
                    PC.ClientSetRotation ( ( BestLocation - CameraLocation )****tation () )
                    if ( self.AutoFire and PC.Pawn.Weapon ): PC.Pawn.Weapon.ClientStartFire ( FireMode )

    def Render(self, canvas):
        if ( self.Viewport and self.Viewport.Actor ):
            # Get our player controller and canvs
            Canvas = canvas
            PC     = self.Viewport.Actor

            # Fetch game information
            TeamGame = PC.GameReplicationInfo and PC.GameReplicationInfo.bTeamGame

            # Fetch camera information
            CameraLocation = PC.CalcViewLocation
            CameraRotation = PC.CalcViewRotation

            # Get required textures
            self.WhiteTexture = DynamicLoadObject ( 'Engine.WhiteTexture', TextureClass )

            # Do our drawing for list of pawns
            for Pawn in PC.DynamicActors ( PawnClass, PC ):
                # Skip our own pawn and dead pawns
                if ( Pawn == PC.Pawn or Pawn.Health <= 0 ): continue

                # Deal with wireframe wallhack
                if ( self.Wireframe and ( self.AlwaysDraw or self.Invisible ( Pawn ) or not PC.FastTrace ( Pawn.Location, CameraLocation ) ) ):
                    Canvas.DrawActor ( Pawn, True, True, PC.FovAngle )

                # Deal with indicator wallhack
                if ( self.Wallhack and self.WhiteTexture ):
                    HeadCoords = Pawn.GetBoneCoords ( Pawn.HeadBone )

                    # Raise the indicator above the head
                    HeadCoords.Origin.Z += 40

                    # Indicator location
                    IndicatorLocation = HeadCoords.Origin + HeadCoords.XAxis + HeadCoords.YAxis + HeadCoords.ZAxis

                    # Get the indicator position on screen
                    IndicatorPosition = Canvas.WorldToScreen ( IndicatorLocation )

                    # See if the indicator is within screen area
                    if ( IndicatorPosition.X >= 0 and IndicatorPosition.X <= Canvas.ClipX and
                         IndicatorPosition.Y >= 0 and IndicatorPosition.Y <= Canvas.ClipY and
                         CameraRotation.Vector () | ( IndicatorLocation - CameraLocation ).Normal () > 0 ):
                        # Set the proper colors
                        colors      = {TEAM_Blue: Color ( 0, 0, 255 ), TEAM_Red: Color ( 255, 0, 0 )}
                        TeamColor   = colors [ self.GetTeam ( Pawn ) ]
                        HealthColor = Color ( 0, 255, 0 )

                        # Set the health color
                        if ( not self.Damagable ( Pawn ) ):
                            # Yellow is used for pawns with god mode
                            HealthColor = Color ( 255, 255, 0 )
                        else:
                            # Change health indicator to reflect current health
                            HealthColor.G = int ( Pawn.Health / Pawn.HealthMax * HealthColor.G ) % 256
                            HealthColor.R = 255 - HealthColor.G

                        # Reset the canvas
                        Canvas.Reset ()
                        Canvas.KFXFontAlias = 'lightsmall'

                        # Draw the player name
                        Canvas.DrawColor = TeamColor
                        if ( Pawn.PlayerReplicationInfo and ( not TeamGame or not self.SameTeam ( Pawn ) ) ):
                            Canvas.SetPos ( IndicatorPosition.X + 15, IndicatorPosition.Y - 15 )
                            Canvas.KFXDrawStr ( Pawn.PlayerReplicationInfo.PlayerName )

                        # Draw the team part of the indicator
                        Canvas.SetPos ( IndicatorPosition.X - 10, IndicatorPosition.Y - 4 )
                        Canvas.DrawTile ( self.WhiteTexture, 20.0, 8.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )
                        Canvas.SetPos ( IndicatorPosition.X - 4, IndicatorPosition.Y - 10 )
                        Canvas.DrawTile ( self.WhiteTexture, 8.0, 20.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )

                        # Draw the health part of the indicator
                        Canvas.DrawColor = HealthColor
                        Canvas.SetPos ( IndicatorPosition.X - 8, IndicatorPosition.Y - 2 )
                        Canvas.DrawTile ( self.WhiteTexture, 16.0, 4.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )
                        Canvas.SetPos ( IndicatorPosition.X - 2, IndicatorPosition.Y - 8 )
                        Canvas.DrawTile ( self.WhiteTexture, 4.0, 16.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )

    # Helpers
    def GetTeam(self, pawn):
        PRI = pawn and pawn.PlayerReplicationInfo
        if ( PRI and hasattr ( PRI, 'IsCorpsePlayer' ) ):
            return TEAM_Red if PRI.IsCorpsePlayer () else TEAM_Blue
        return PRI and PRI.Team and PRI.Team.TeamIndex or TEAM_Blue
    def Invisible(self, actor):
        PC = self.Viewport and self.Viewport.Actor
        return PC and PC.GameReplicationInfo \
                  and PC.GameReplicationInfo.GameClass == 'KFXGame.KFXGhostGame' \
                  and actor.PlayerReplicationInfo and actor.PlayerReplicationInfo.Team \
                  and actor.PlayerReplicationInfo.Team.TeamIndex == TEAM_Red
    def SameTeam(self, pawn):
        PC = self.Viewport and self.Viewport.Actor
        PRI = pawn and pawn.PlayerReplicationInfo
        if ( PRI and hasattr ( PRI, 'IsCorpsePlayer' ) and hasattr ( PC, 'IsCorpsePlayer' ) ):
            return PC.IsCorpsePlayer () == PRI.IsCorpsePlayer ()
        return PC and PC.GameReplicationInfo and PC.GameReplicationInfo.bTeamGame \
                  and PC.PlayerReplicationInfo and pawn.PlayerReplicationInfo \
                  and PC.PlayerReplicationInfo.Team == pawn.PlayerReplicationInfo.Team
    def Damagable(self, pawn):
        if ( pawn.Health <= 0 ): return False
        if ( hasattr ( pawn, 'KFXIsGodMode' ) ):
            return not pawn.KFXIsGodMode ()
        else: return True
    def Gravity(self, actor):
        # Make sure the actor is valid
        if ( not actor or not actor.PhysicsVolume ): return Vector ()
        # Fetch the zone gravity and add the supplementary pawn gravity
        Acceleration = actor.PhysicsVolume.Gravity
        if ( hasattr ( actor, 'ConstantAcceleration' ) ):
            Acceleration += actor.ConstantAcceleration
        return Acceleration
    def Adjustment(self, actor, time):
        # Make sure its a valid actor
        if ( not actor ): return Vector ()
        # Perform the time correction
        if ( hasattr ( actor, 'Physics' ) and actor.Physics == PHYS_Falling ):
            return self.Gravity ( actor ) * 0.5 * ( time * time ) + actor.Velocity * time
        else: return actor.Velocity * time
    def Correction(self, pc, actor, deltatime):
        # Adjust for latency and player velocity
        if ( not pc ): return Vector ( 0, 0, 0 );
        return self.Adjustment ( actor, pc.ExactPing + deltatime ) - \
               self.Adjustment ( pc.Pawn, deltatime )

    # Event handlers
    def OnTick(self, deltatime):
        self.Tick ( deltatime )
    def OnPostRender(self, canvas):
        self.Viewport = canvas.Viewport
        self.Render ( canvas )
    def OnKeyDown(self, keycode, repeats, prevstate):
        if ( keycode == self.AimKey ): self.KeyDown = True
    def OnKeyUp(self, keycode):
        if ( keycode == self.AimKey ): self.KeyDown = False

class Naming(object):
    def __init__(self):
        # Set some defaults
        self.Interval = 1
        self.Enabled  = False
        # Initialization
        self.Viewport = None
        self.Time     = 0
        self.Count    = 0
    def Enable(self, enabled = True):
        self.Enabled = enabled
        self.Count   = 0
        self.Time    = 0
    def OnTick(self, deltatime):
        if ( not self.Enabled ): return
        self.Time += deltatime
        if ( self.Time > self.Interval ):
            self.Time = 0
            if ( self.Viewport and self.Viewport.Actor ):
                value = self.Count % 256
                name  = ''.join ( reversed ( [ str((value >> bit) & 1) for bit in range ( 8 ) ] ) )
                self.Viewport.Actor.ChangeName ( name )
                self.Count += 1
    def OnPostRender(self, canvas):
        if ( canvas and canvas.Viewport ):
            self.Viewport = canvas.Viewport

class Configuration(object):
    # Internal settings
    __config_layout = {
        'Aiming'   : [('aiming', [ 'AimKey', 'AimMode', 'AutoAim', 'AutoFire', 'AimAngle', 'FriendlyFire', 'LatencyCorrection', 'SecondaryFire', 'BonePrecedence' ])],
        'Info'     : [('aiming', [ 'AlwaysDraw', 'Wireframe', 'Wallhack' ])],
        'Naming'   : [('configuration', [ 'ChangedName' ]), ( 'naming', [ 'Enabled' ] )],
        'Exploits' : [('configuration', [ 'Shield', 'PlayerScale' ])]
    }

    # Init/exit routines
    def __init__(self):
        # Globals for load/save
        global configuration
        configuration = self
        # Set some defaults
        aiming.AutoAim           = True
        aiming.AutoFire          = True
        aiming.LatencyCorrection = True
        aiming.Wireframe         = True
        aiming.Wallhack          = True
        self.Shield              = False
        self.ChangedName         = None
        self.PlayerScale         = 1.0
        self.SaveInterval        = 30
        # Initialization
        self.LastSave            = 0
        self.MenuOpen            = False
        self.Exploits            = self.__checkexploits ()
        # Load settings and setup menu
        self.__loadsettings ()
        self.__setup_antweakbar ()

    # Check exploits mode
    def __checkexploits(self):
        return EXPLOITS_Shieldable

    # Configuration presistence
    def __loadsettings(self):
        # Load and parse the settings file
        filename = os.path.expandvars ( '%AppData%\\MAT Automaton\\settings.json' )
        try:
            infile = None
            infile = open ( filename, 'r' )
            settings = json.load ( infile )
        except: return
        finally: infile and infile.close ()
        # Traverse configuration layout
        for seclayout in self.__config_layout.items ():
            # Fetch section object & data
            try: section = settings [ seclayout [ 0 ] ]
            except: continue
            # Set settings from data
            for objcfg in seclayout [ 1 ]:
                obj = globals () [ objcfg [ 0 ] ]
                for x in objcfg [ 1 ]: x in section and setattr ( obj, x, section [ x ] )
    def __savesettings(self):
        # Setup directory and file
        dir = os.path.expandvars ( '%AppData%\\MAT Automaton' )
        if ( not os.path.exists ( dir ) ): os.mkdir ( dir )
        filename = os.path.join ( dir, 'settings.json' )
        try: outfile = open ( filename, 'w' )
        except: return
        # Build the settings dictionary
        settings = {}
        for seclayout in self.__config_layout.items ():
            section = {}
            for objcfg in seclayout [ 1 ]:
                obj = globals () [ objcfg [ 0 ] ]
                section.update ( dict ( map ( lambda x: (x, getattr ( obj, x )), objcfg [ 1 ] ) ) )
            settings [ seclayout [ 0 ] ] = section
        # Save settings to json settings file
        json.dump ( settings, outfile, indent = 4 )
        outfile.close ()

    def __setup_antweakbar(self):
        mainbar = AntTweakBar.TwGetBarByName ( "MATAutomaton" )
        if ( mainbar ): AntTweakBar.TwDeleteBar ( mainbar )
        try: mainbar = AntTweakBar.TwNewBar ( "MATAutomaton" )
        except: return # Unknown AntTweakBar error
        AntTweakBar.TwDefine ( " MATAutomaton label='MAT Automaton' color='135 0 0' fontSize='3' size='330 450' position='16 16' " )
        AntTweakBar.TwAddVar ( mainbar, 'Key', AntTweakBar.TwDefineEnum ( 'EKey', [(k[1], k[0]) for k in Keys.dictionary.items ()] ), lambda : aiming.AimKey, lambda x : setattr ( aiming, 'AimKey', x ), " group='Aiming' label='Key' " )
        AntTweakBar.TwAddVar ( mainbar, 'Mode', AntTweakBar.TwDefineEnum ( 'EAimModes', [(AIMING_Health, 'Health'), (AIMING_Distance, 'Distance'), (AIMING_Key, 'Key')] ), lambda : aiming.AimMode, lambda x : setattr ( aiming, 'AimMode', x ), " group='Aiming' label='Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'AutoAim', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AutoAim, lambda x : setattr ( aiming, 'AutoAim', x ), " group='Aiming' label='Auto Aim' " )        
        AntTweakBar.TwAddVar ( mainbar, 'AutoFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AutoFire, lambda x : setattr ( aiming, 'AutoFire', x ), " group='Aiming' label='Auto Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'BonePrecedence', AntTweakBar.TwDefineEnum ( 'EBones', [(BONE_Head, 'Head'), (BONE_Root, 'Root')] ), lambda : aiming.BonePrecedence, lambda x : setattr ( aiming, 'BonePrecedence', x ), " group='Aiming' label='Bone Precedence' " )
        AntTweakBar.TwAddVar ( mainbar, 'SecondaryFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.SecondaryFire, lambda x : setattr ( aiming, 'SecondaryFire', x ), " group='Aiming' label='Secondary Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'FriendlyFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.FriendlyFire, lambda x : setattr ( aiming, 'FriendlyFire', x ), " group='Aiming' label='Friendly Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'LatencyCorrection', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.LatencyCorrection, lambda x : setattr ( aiming, 'LatencyCorrection', x ), " group='Aiming' label='Latency Correction' " )
        AntTweakBar.TwAddVar ( mainbar, 'AlwaysDraw', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AlwaysDraw, lambda x : setattr ( aiming, 'AlwaysDraw', x ), " group='Information' label='Always Draw' " )
        AntTweakBar.TwAddVar ( mainbar, 'Wireframe', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.Wireframe, lambda x : setattr ( aiming, 'Wireframe', x ), " group='Information' label='Wireframe' " )
        AntTweakBar.TwAddVar ( mainbar, 'Wallhack', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.Wallhack, lambda x : setattr ( aiming, 'Wallhack', x ), " group='Information' label='Wallhack' " )
        AntTweakBar.TwAddButton ( mainbar, 'SwitchTeam', self.__switchteam, " group='Tools' label='Switch Team' " )
        AntTweakBar.TwAddButton ( mainbar, 'CommitSuicide', self.__suicide, " group='Tools' label='Commit Suicide' " )
        AntTweakBar.TwAddButton ( mainbar, 'OpenConsole', self.__openconsole, " group='Tools' label='Open Console' " )        
        AntTweakBar.TwAddVar ( mainbar, 'BehindView', AntTweakBar.TW_TYPE_BOOL32, self.__getbehindview, self.__setbehindview, " group='Tools' label='Behind View' " )
        AntTweakBar.TwAddVar ( mainbar, 'RandomName', AntTweakBar.TW_TYPE_BOOL32, lambda : naming.Enabled, lambda x : naming.Enable ( x ), " group='Tools' label='Random Name' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerName', AntTweakBar.TW_TYPE_CDSTRING, self.__getplayername, self.__changeplayername, " group='Tools' label='Player Name' " )
        AntTweakBar.TwAddButton ( mainbar, 'GodMode', self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerScale', AntTweakBar.TW_TYPE_FLOAT, lambda : self.PlayerScale, lambda x : setattr ( self, 'PlayerScale', x ), " group='Exploits' label='Player Scale' step=0.1 " )
        AntTweakBar.TwAddButton ( mainbar, 'SetScale', self.__setscale, " group='Exploits' label='Set Scale' " )
        AntTweakBar.TwAddVar ( mainbar, 'Gravity', AntTweakBar.TW_TYPE_FLOAT, self.__getgravity, self.__setgravity, " group='Tools' label='Gravity' step=0.1 " )
        # Shieldable exploits mode
        if ( self.Exploits == EXPLOITS_Shieldable ):
            AntTweakBar.TwAddVar ( mainbar, 'Shield', AntTweakBar.TW_TYPE_BOOL32, lambda : self.Shield, lambda x : setattr ( self, 'Shield', x ), " group='Exploits' label='Shield' " )
        # Full exploits mode
        if ( self.Exploits == EXPLOITS_Full ):
            AntTweakBar.TwAddVar ( mainbar, 'GodMode', AntTweakBar.TW_TYPE_BOOL32, self.__getpawnbit ( EPB_God ), self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
            AntTweakBar.TwAddVar ( mainbar, 'PlayerScale', AntTweakBar.TW_TYPE_FLOAT, lambda : self.PlayerScale, lambda x : setattr ( self, 'PlayerScale', x ), " group='Exploits' label='Player Scale' step=0.1 " )
            AntTweakBar.TwAddButton ( mainbar, 'SetScale', self.__setscale, " group='Exploits' label='Set Scale' " )

    # Tool routines
    def __getbehindview(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        return PC****ehindView if ( PC ) else False
    def __setbehindview(self, value):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.BehindView ( value )
    def __getplayername(self):
        PC  = aiming.Viewport and aiming.Viewport.Actor
        PRI = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.PlayerReplicationInfo
        ChangedName = not naming.Enabled and self.ChangedName or None
        if ( PC and PRI and ChangedName and ChangedName != PRI.PlayerName ):
            PC.ChangeName ( ChangedName )
        return ChangedName or ( PRI and PRI.PlayerName ) or 'None'    
    def __changeplayername(self, value):
        self.ChangedName = value.replace ( ' ', '_' )
    def __suicide(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.Suicide ()    
    def __switchteam(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.SwitchTeam ()        
    def __openconsole(self):
        Console = aiming.Viewport and aiming.Viewpor*****nsole
        if ( Console ): Console.ConsoleOpen ()
    def __setGodMode(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.GodMode()   
    def __getgravity(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        return PC.PhysicsVolume.Gravity.Z if PC.PhysicsVolume else 0
    def __setgravity(self, x):
        PC = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor
        if ( PC and PC.PhysicsVolume ): PC.PhysicsVolume.Gravity.Z = x
    def __checkshield(self):
        Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
        if ( not Pawn or self.Exploits != EXPLOITS_Shieldable ): return
        if ( self.Shield and not Pawn.KFXIsBitStateOn ( EPB_God ) ):
            Pawn.KFXSetPB ( EPB_God, 5 ) 
    
    # Exploit routines
    def __getpawnbit(self, pawnbit):
        def function():
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            return bool ( Pawn ) and Pawn.KFXIsBitStateOn ( pawnbit )
        return function
    def __setpawnbit(self, pawnbit):
        def function(x):
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            if ( Pawn ): Pawn.KFXSetPB ( pawnbit, 0 if x else 0.1 )
        return function
    def __setscale(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.ServreSetOwnScale ( self.PlayerScale )


        
    # Exploit routines
    def __getpawnbit(self, pawnbit):
        def function():
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            return bool ( Pawn ) and Pawn.KFXIsBitStateOn ( pawnbit )
        return function
    def __setpawnbit(self, pawnbit):
        def function(x):
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            if ( Pawn ): Pawn.KFXSetPB ( pawnbit, 0 if x else 0.1 )
        return function
    def __setscale(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.ServreSetOwnScale ( self.PlayerScale )

    # Event handling
    def OnTick(self, deltatime):
        PC  = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and PC.Player and PC.Player.GUIController
        if ( GUI and self.MenuOpen ): GUI.OperateTime = 0
        self.__checkshield ()
        self.__getplayername ()
        self.LastSave += deltatime
        if ( self.LastSave > self.SaveInterval ):
            self.LastSave = 0
            self.__savesettings ()
    def OnKeyDown(self, keycode, repeats, prevstate):
        if ( keycode == Keys.Numpad0 ):
            aiming.AutoAim = not aiming.AutoAim
            Logger.Log ( 'Auto aiming is now %s!' % ( aiming.AutoAim and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad1 ):
            aiming.Wallhack = not aiming.Wallhack
            Logger.Log ( 'Wallhack is now %s!' % ( aiming.Wallhack and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad2 ):
            aiming.Wireframe = not aiming.Wireframe
            Logger.Log ( 'Wireframe is now %s!' % ( aiming.Wireframe and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad3 ):
            aiming.AutoFire = not aiming.AutoFire
            Logger.Log ( 'Auto firing is now %s!' % ( aiming.AutoFire and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad5 ):
            aiming.SecondaryFire = not aiming.SecondaryFire
            Logger.Log ( 'Secondary firing is now %s!' % ( aiming.SecondaryFire and 'on' or 'off' ) )
        elif ( keycode == Keys.Delete ):
            if ( aiming.Viewport and aiming.Viewpor*****nsole ):
                aiming.Viewpor*****nsole.ConsoleOpen ()
    def OnMenuShow(self):
        self.MenuOpen = True
        PC  = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and PC.Player and PC.Player.GUIController
        if ( GUI ):
            GUI.OperateMsgs [ 99 ] = 'M.A.T. Auto BY: DANIEL PlAy FoR FuN d^_^b.'
            GUI.OpenModeDialogue ( 99 )
    def OnMenuHide(self):
        self.MenuOpen = False
        PC  = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and PC.Player and PC.Player.GUIController
        if ( GUI ):
            GUI.CloseModeDialogue ()
            if ( not GUI.MenuStack ):
                GUI.bActive = False
                GUI.bVisible = False
                try: GUI.ViewportOwner.bShowWindowsMouse = False
                except: pass

class Startup(object):
    def __init__(self):
        self.started = False

    def Startup(self):
        # Mark aiming/configuration as globals
        global aiming, naming, configuration

        # Instantiate and register
        aiming = Aiming ()
        naming = Naming ()
        configuration = Configuration ()
        Register ( aiming )
        Register ( naming )
        Register ( configuration )

    def OnTick(self, deltatime):
        # Check status
        if ( self.started ): return
        self.Startup ()
        self.started = True

# Instantiate startup handler
Register ( Startup () )
Hope It work.
Sorry For Bad Language
These are useless now or u know how to code it
#2 · edited 13y ago · 13y ago
CO
Codex+
Quote Originally Posted by astron51 View Post
These are useless now or u know how to code it
These are not useless. If you Can see "KFXsetpb" etc. Actually these Code are Patched . If you Know how to Unload the Apex and Change the current Console code.
you will make it works
#3 · 13y ago
XI
Xiao@
Quote Originally Posted by Codex+ View Post
These are not useless. If you Can see "KFXsetpb" etc. Actually these Code are Patched . If you Know how to Unload the Apex and Change the current Console code.
you will make it works
U know how to unload Apex protection?
#4 · 13y ago
Janitor
Janitor
Use [code] tags next time.
Fixed it.
#5 · 13y ago
Athenaa
Athenaa
hmmm how to use it, my head is spinning
#6 · 13y ago
COD3RIN
COD3RIN
hard to compile this code
#7 · 13y ago
samnang18
samnang18
Ok xD Me Newbie so There are mistake.
#8 · 13y ago
PC
pc117
Quote Originally Posted by samnang18 View Post
Hi EveryBody this is y second post, Do you miss automaton and dBased(Automaton Creator)
especially the auto aim. I have found a source code from mat auto maton and i hope it help you.
I'm suck at Visual Basic, so who made it don't forget to release it. here it is:
AutoAim:

Code:
#
#  Project: MAT Automaton
#
#  Aiming & utilities
#  - Copyright (C) 2011 dB. All rights reserved.
#

# Python imports
import os
import json

# Automaton imports
from Automaton.System import Register
from Automaton.Outputs import Logger
from Automaton import AntTweakBar
from Automaton import Keys

# Unreal imports
from Unreal.Core   import Vector, Rotator, Color
from Unreal.Core   import Object  as ObjectClass
from Unreal.Engine import Actor   as ActorClass
from Unreal.Engine import Pawn    as PawnClass
from Unreal.Engine import Texture as TextureClass
from Unreal.Engine import Weapon  as WeaponClass

# Fetch important functions
DynamicLoadObject = FindFunction ( ObjectClass, 'DynamicLoadObject' )

# Physics constants
(PHYS_None,         PHYS_Walking,
 PHYS_Falling,      PHYS_Swimming,
 PHYS_Flying,       PHYS_Rotating,
 PHYS_Projectile,   PHYS_Interpolating,
 PHYS_MovingBrush,  PHYS_Spider,
 PHYS_Trailer,      PHYS_Ladder,
 PHYS_RootMotion,   PHYS_Karma,
 PHYS_KarmaRagDoll, PHYS_Hovering) = range ( 16 )

 # Pawn bit constants
(EPB_UseItem,        EPB_God,
 EPB_Dance,          EPB_Speedup,
 EPB_AutoAim,        EPB_Mini,
 EPB_Talking,        EPB_7,
 EPB_FilterBadState, EPB_Hide,
 EPB_Second,         EPB_Third,
 EPB_12,             EPB_13,
 EPB_14,             EPB_15,
 EPB_MagicChange,    EPB_Frozen,
 EPB_Chaos,          EPB_Speeddown,
 EPB_LightingStrike, EPB_Vertigo,
 EPB_CorpseChange,   EPB_EvilPigChange,
 EPB_Terminator,     EPB_25,
 EPB_26,             EPB_27,
 EPB_28,             EPB_29,
 EPB_30,             EPB_Max) = range ( 32 )

# Bone constants
(BONE_Head, BONE_Root) = range ( 2 )

# Team constants
(TEAM_Blue, TEAM_Red) = range ( 2 )

# Aiming modes
(AIMING_Health, AIMING_Distance, AIMING_Key) = range ( 3 )

# Exploits modes
(EXPLOITS_Full, EXPLOITS_Shieldable, EXPLOITS_None) = range ( 3 )

class Aiming(object):
    def __init__(self):
        # Defaults
        self.Wireframe         = False
        self.Wallhack          = False
        self.AlwaysDraw        = False
        self.AutoAim           = False
        self.AutoFire          = False
        self.FriendlyFire      = False
        self.LatencyCorrection = False
        self.SecondaryFire     = False
        self.AimKey            = Keys.Shift
        self.AimMode           = AIMING_Health
        self.AimAngle          = 180.0
        self.BonePrecedence    = BONE_Head
        # Initialization
        self.KeyDown           = False
        self.Viewport          = None
        self.WhiteTexture      = None
        self.AimingModes       = {
            AIMING_Health   : self.__best_byhealth,
            AIMING_Distance : self.__best_bydistance,
            AIMING_Key      : self.__best_bycrosshair
        }

    # Aiming mode comperators
    def __best_byhealth(self, current, other):
        return other.Health < current.Health
    def __best_bydistance(self, current, other):
        CameraLocation  = self.Viewport.Actor.CalcViewLocation
        CurrentDistance = abs ( current.Location - CameraLocation )
        OtherDistance   = abs ( other.Location - CameraLocation )
        return OtherDistance < CurrentDistance
    def __best_bycrosshair(self, current, other):
        CameraLocation  = self.Viewport.Actor.CalcViewLocation
        CameraRotation  = self.Viewport.Actor.CalcViewRotation
        desired         = CameraRotation.Vector ()
        dotCurrent      = desired | ( current.Location - CameraLocation ).Normal ()
        dotOther        = desired | ( other.Location   - CameraLocation ).Normal ()
        return dotOther > dotCurrent

    # Compare two pawns
    def Compare(self, pawn, other):
        return self.AimingModes [ self.AimMode ] ( pawn, other )

    def Tick(self, deltatime):
        if ( self.Viewport and self.Viewport.Actor ):
            # Get our player controller
            PC = self.Viewport.Actor

            # Fetch camera information
            CameraLocation = PC.CalcViewLocation
            CameraRotation = PC.CalcViewRotation

            # Setup configuration data
            FireMode = int ( self.SecondaryFire )
            AutoAim  = self.AutoAim and ( self.AimMode != AIMING_Key or self.KeyDown )

            # If we are auto aiming
            if ( AutoAim and PC.Pawn ):
                # Look for the best target
                BestPawn     = None
                BestLocation = None
                for Pawn in PC.DynamicActors ( PawnClass, PC ):
                    # Check if the pawn is valid
                    if ( Pawn == PC.Pawn or not self.Damagable ( Pawn ) ): continue

                    # If it is a team game make sure we are on a different team
                    if ( not self.FriendlyFire and self.SameTeam ( Pawn ) ): continue

                    # Setup bones list
                    BoneList = ( self.BonePrecedence == BONE_Root ) \
                        and [Pawn****otBone, Pawn.HeadBone] \
                        or  [Pawn.HeadBone, Pawn****otBone]

                    # Find a visible bone
                    for bone in BoneList:
                        # Fetch the bone coords
                        BoneCoords = Pawn.GetBoneCoords ( bone )

                        # Calculate the location
                        BoneLocation = BoneCoords.Origin + BoneCoords.XAxis + BoneCoords.YAxis + BoneCoords.ZAxis

                        # Conditionally apply latency correction
                        if ( self.LatencyCorrection ):
                            BoneLocation += self.Correction ( PC, Pawn, deltatime )

                        # Adjust according to projectile physics
                        if ( PC.Pawn.Weapon and PC.Pawn.Weapon.FireMode [ FireMode ] and PC.Pawn.Weapon.FireMode [ FireMode ].ProjectileClass ):
                            Projectile = PC.Pawn.Weapon.FireMode [ FireMode ].ProjectileClass.Default
                            if ( Projectile and Projectile.Speed != 0 and Projectile.Physics != PHYS_Falling ):
                                BoneLocation += Pawn.Velocity * ( abs ( BoneLocation - CameraLocation ) / Projectile.Speed )

                        # Calculate angle
                        Angle = ( CameraRotation.Vector () | ( BoneLocation - CameraLocation ).Normal () ) + 1.0
                        Angle = ( 1.0 - ( Angle / 2.0 ) ) * 180.0

                        # Do the check
                        if ( Angle <= self.AimAngle and Pawn.FastTrace ( BoneLocation, CameraLocation ) ):
                            # Is this the best one?
                            if ( not BestPawn or self.Compare ( BestPawn, Pawn ) ):
                                BestPawn     = Pawn
                                BestLocation = BoneLocation
                            break
                if ( BestPawn ):
                    # We've found a valid target, so lets set the rotation and fire as required
                    PC.ClientSetRotation ( ( BestLocation - CameraLocation )****tation () )
                    if ( self.AutoFire and PC.Pawn.Weapon ): PC.Pawn.Weapon.ClientStartFire ( FireMode )

    def Render(self, canvas):
        if ( self.Viewport and self.Viewport.Actor ):
            # Get our player controller and canvs
            Canvas = canvas
            PC     = self.Viewport.Actor

            # Fetch game information
            TeamGame = PC.GameReplicationInfo and PC.GameReplicationInfo.bTeamGame

            # Fetch camera information
            CameraLocation = PC.CalcViewLocation
            CameraRotation = PC.CalcViewRotation

            # Get required textures
            self.WhiteTexture = DynamicLoadObject ( 'Engine.WhiteTexture', TextureClass )

            # Do our drawing for list of pawns
            for Pawn in PC.DynamicActors ( PawnClass, PC ):
                # Skip our own pawn and dead pawns
                if ( Pawn == PC.Pawn or Pawn.Health <= 0 ): continue

                # Deal with wireframe wallhack
                if ( self.Wireframe and ( self.AlwaysDraw or self.Invisible ( Pawn ) or not PC.FastTrace ( Pawn.Location, CameraLocation ) ) ):
                    Canvas.DrawActor ( Pawn, True, True, PC.FovAngle )

                # Deal with indicator wallhack
                if ( self.Wallhack and self.WhiteTexture ):
                    HeadCoords = Pawn.GetBoneCoords ( Pawn.HeadBone )

                    # Raise the indicator above the head
                    HeadCoords.Origin.Z += 40

                    # Indicator location
                    IndicatorLocation = HeadCoords.Origin + HeadCoords.XAxis + HeadCoords.YAxis + HeadCoords.ZAxis

                    # Get the indicator position on screen
                    IndicatorPosition = Canvas.WorldToScreen ( IndicatorLocation )

                    # See if the indicator is within screen area
                    if ( IndicatorPosition.X >= 0 and IndicatorPosition.X <= Canvas.ClipX and
                         IndicatorPosition.Y >= 0 and IndicatorPosition.Y <= Canvas.ClipY and
                         CameraRotation.Vector () | ( IndicatorLocation - CameraLocation ).Normal () > 0 ):
                        # Set the proper colors
                        colors      = {TEAM_Blue: Color ( 0, 0, 255 ), TEAM_Red: Color ( 255, 0, 0 )}
                        TeamColor   = colors [ self.GetTeam ( Pawn ) ]
                        HealthColor = Color ( 0, 255, 0 )

                        # Set the health color
                        if ( not self.Damagable ( Pawn ) ):
                            # Yellow is used for pawns with god mode
                            HealthColor = Color ( 255, 255, 0 )
                        else:
                            # Change health indicator to reflect current health
                            HealthColor.G = int ( Pawn.Health / Pawn.HealthMax * HealthColor.G ) % 256
                            HealthColor.R = 255 - HealthColor.G

                        # Reset the canvas
                        Canvas.Reset ()
                        Canvas.KFXFontAlias = 'lightsmall'

                        # Draw the player name
                        Canvas.DrawColor = TeamColor
                        if ( Pawn.PlayerReplicationInfo and ( not TeamGame or not self.SameTeam ( Pawn ) ) ):
                            Canvas.SetPos ( IndicatorPosition.X + 15, IndicatorPosition.Y - 15 )
                            Canvas.KFXDrawStr ( Pawn.PlayerReplicationInfo.PlayerName )

                        # Draw the team part of the indicator
                        Canvas.SetPos ( IndicatorPosition.X - 10, IndicatorPosition.Y - 4 )
                        Canvas.DrawTile ( self.WhiteTexture, 20.0, 8.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )
                        Canvas.SetPos ( IndicatorPosition.X - 4, IndicatorPosition.Y - 10 )
                        Canvas.DrawTile ( self.WhiteTexture, 8.0, 20.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )

                        # Draw the health part of the indicator
                        Canvas.DrawColor = HealthColor
                        Canvas.SetPos ( IndicatorPosition.X - 8, IndicatorPosition.Y - 2 )
                        Canvas.DrawTile ( self.WhiteTexture, 16.0, 4.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )
                        Canvas.SetPos ( IndicatorPosition.X - 2, IndicatorPosition.Y - 8 )
                        Canvas.DrawTile ( self.WhiteTexture, 4.0, 16.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )

    # Helpers
    def GetTeam(self, pawn):
        PRI = pawn and pawn.PlayerReplicationInfo
        if ( PRI and hasattr ( PRI, 'IsCorpsePlayer' ) ):
            return TEAM_Red if PRI.IsCorpsePlayer () else TEAM_Blue
        return PRI and PRI.Team and PRI.Team.TeamIndex or TEAM_Blue
    def Invisible(self, actor):
        PC = self.Viewport and self.Viewport.Actor
        return PC and PC.GameReplicationInfo \
                  and PC.GameReplicationInfo.GameClass == 'KFXGame.KFXGhostGame' \
                  and actor.PlayerReplicationInfo and actor.PlayerReplicationInfo.Team \
                  and actor.PlayerReplicationInfo.Team.TeamIndex == TEAM_Red
    def SameTeam(self, pawn):
        PC = self.Viewport and self.Viewport.Actor
        PRI = pawn and pawn.PlayerReplicationInfo
        if ( PRI and hasattr ( PRI, 'IsCorpsePlayer' ) and hasattr ( PC, 'IsCorpsePlayer' ) ):
            return PC.IsCorpsePlayer () == PRI.IsCorpsePlayer ()
        return PC and PC.GameReplicationInfo and PC.GameReplicationInfo.bTeamGame \
                  and PC.PlayerReplicationInfo and pawn.PlayerReplicationInfo \
                  and PC.PlayerReplicationInfo.Team == pawn.PlayerReplicationInfo.Team
    def Damagable(self, pawn):
        if ( pawn.Health <= 0 ): return False
        if ( hasattr ( pawn, 'KFXIsGodMode' ) ):
            return not pawn.KFXIsGodMode ()
        else: return True
    def Gravity(self, actor):
        # Make sure the actor is valid
        if ( not actor or not actor.PhysicsVolume ): return Vector ()
        # Fetch the zone gravity and add the supplementary pawn gravity
        Acceleration = actor.PhysicsVolume.Gravity
        if ( hasattr ( actor, 'ConstantAcceleration' ) ):
            Acceleration += actor.ConstantAcceleration
        return Acceleration
    def Adjustment(self, actor, time):
        # Make sure its a valid actor
        if ( not actor ): return Vector ()
        # Perform the time correction
        if ( hasattr ( actor, 'Physics' ) and actor.Physics == PHYS_Falling ):
            return self.Gravity ( actor ) * 0.5 * ( time * time ) + actor.Velocity * time
        else: return actor.Velocity * time
    def Correction(self, pc, actor, deltatime):
        # Adjust for latency and player velocity
        if ( not pc ): return Vector ( 0, 0, 0 );
        return self.Adjustment ( actor, pc.ExactPing + deltatime ) - \
               self.Adjustment ( pc.Pawn, deltatime )

    # Event handlers
    def OnTick(self, deltatime):
        self.Tick ( deltatime )
    def OnPostRender(self, canvas):
        self.Viewport = canvas.Viewport
        self.Render ( canvas )
    def OnKeyDown(self, keycode, repeats, prevstate):
        if ( keycode == self.AimKey ): self.KeyDown = True
    def OnKeyUp(self, keycode):
        if ( keycode == self.AimKey ): self.KeyDown = False

class Naming(object):
    def __init__(self):
        # Set some defaults
        self.Interval = 1
        self.Enabled  = False
        # Initialization
        self.Viewport = None
        self.Time     = 0
        self.Count    = 0
    def Enable(self, enabled = True):
        self.Enabled = enabled
        self.Count   = 0
        self.Time    = 0
    def OnTick(self, deltatime):
        if ( not self.Enabled ): return
        self.Time += deltatime
        if ( self.Time > self.Interval ):
            self.Time = 0
            if ( self.Viewport and self.Viewport.Actor ):
                value = self.Count % 256
                name  = ''.join ( reversed ( [ str((value >> bit) & 1) for bit in range ( 8 ) ] ) )
                self.Viewport.Actor.ChangeName ( name )
                self.Count += 1
    def OnPostRender(self, canvas):
        if ( canvas and canvas.Viewport ):
            self.Viewport = canvas.Viewport

class Configuration(object):
    # Internal settings
    __config_layout = {
        'Aiming'   : [('aiming', [ 'AimKey', 'AimMode', 'AutoAim', 'AutoFire', 'AimAngle', 'FriendlyFire', 'LatencyCorrection', 'SecondaryFire', 'BonePrecedence' ])],
        'Info'     : [('aiming', [ 'AlwaysDraw', 'Wireframe', 'Wallhack' ])],
        'Naming'   : [('configuration', [ 'ChangedName' ]), ( 'naming', [ 'Enabled' ] )],
        'Exploits' : [('configuration', [ 'Shield', 'PlayerScale' ])]
    }

    # Init/exit routines
    def __init__(self):
        # Globals for load/save
        global configuration
        configuration = self
        # Set some defaults
        aiming.AutoAim           = True
        aiming.AutoFire          = True
        aiming.LatencyCorrection = True
        aiming.Wireframe         = True
        aiming.Wallhack          = True
        self.Shield              = False
        self.ChangedName         = None
        self.PlayerScale         = 1.0
        self.SaveInterval        = 30
        # Initialization
        self.LastSave            = 0
        self.MenuOpen            = False
        self.Exploits            = self.__checkexploits ()
        # Load settings and setup menu
        self.__loadsettings ()
        self.__setup_antweakbar ()

    # Check exploits mode
    def __checkexploits(self):
        return EXPLOITS_Shieldable

    # Configuration presistence
    def __loadsettings(self):
        # Load and parse the settings file
        filename = os.path.expandvars ( '%AppData%\\MAT Automaton\\settings.json' )
        try:
            infile = None
            infile = open ( filename, 'r' )
            settings = json.load ( infile )
        except: return
        finally: infile and infile.close ()
        # Traverse configuration layout
        for seclayout in self.__config_layout.items ():
            # Fetch section object & data
            try: section = settings [ seclayout [ 0 ] ]
            except: continue
            # Set settings from data
            for objcfg in seclayout [ 1 ]:
                obj = globals () [ objcfg [ 0 ] ]
                for x in objcfg [ 1 ]: x in section and setattr ( obj, x, section [ x ] )
    def __savesettings(self):
        # Setup directory and file
        dir = os.path.expandvars ( '%AppData%\\MAT Automaton' )
        if ( not os.path.exists ( dir ) ): os.mkdir ( dir )
        filename = os.path.join ( dir, 'settings.json' )
        try: outfile = open ( filename, 'w' )
        except: return
        # Build the settings dictionary
        settings = {}
        for seclayout in self.__config_layout.items ():
            section = {}
            for objcfg in seclayout [ 1 ]:
                obj = globals () [ objcfg [ 0 ] ]
                section.update ( dict ( map ( lambda x: (x, getattr ( obj, x )), objcfg [ 1 ] ) ) )
            settings [ seclayout [ 0 ] ] = section
        # Save settings to json settings file
        json.dump ( settings, outfile, indent = 4 )
        outfile.close ()

    def __setup_antweakbar(self):
        mainbar = AntTweakBar.TwGetBarByName ( "MATAutomaton" )
        if ( mainbar ): AntTweakBar.TwDeleteBar ( mainbar )
        try: mainbar = AntTweakBar.TwNewBar ( "MATAutomaton" )
        except: return # Unknown AntTweakBar error
        AntTweakBar.TwDefine ( " MATAutomaton label='MAT Automaton' color='212 0 0' fontSize='3' size='330 450' position='16 16' " )
        AntTweakBar.TwAddVar ( mainbar, 'Key', AntTweakBar.TwDefineEnum ( 'EKey', [(k[1], k[0]) for k in Keys.dictionary.items ()] ), lambda : aiming.AimKey, lambda x : setattr ( aiming, 'AimKey', x ), " group='Aiming' label='Key' " )
        AntTweakBar.TwAddVar ( mainbar, 'Mode', AntTweakBar.TwDefineEnum ( 'EAimModes', [(AIMING_Health, 'Health'), (AIMING_Distance, 'Distance'), (AIMING_Key, 'Key')] ), lambda : aiming.AimMode, lambda x : setattr ( aiming, 'AimMode', x ), " group='Aiming' label='Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'AutoAim', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AutoAim, lambda x : setattr ( aiming, 'AutoAim', x ), " group='Aiming' label='Auto Aim' " )        
        AntTweakBar.TwAddVar ( mainbar, 'AutoFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AutoFire, lambda x : setattr ( aiming, 'AutoFire', x ), " group='Aiming' label='Auto Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'BonePrecedence', AntTweakBar.TwDefineEnum ( 'EBones', [(BONE_Head, 'Head'), (BONE_Root, 'Root')] ), lambda : aiming.BonePrecedence, lambda x : setattr ( aiming, 'BonePrecedence', x ), " group='Aiming' label='Bone Precedence' " )
        AntTweakBar.TwAddVar ( mainbar, 'SecondaryFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.SecondaryFire, lambda x : setattr ( aiming, 'SecondaryFire', x ), " group='Aiming' label='Secondary Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'FriendlyFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.FriendlyFire, lambda x : setattr ( aiming, 'FriendlyFire', x ), " group='Aiming' label='Friendly Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'LatencyCorrection', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.LatencyCorrection, lambda x : setattr ( aiming, 'LatencyCorrection', x ), " group='Aiming' label='Latency Correction' " )
        AntTweakBar.TwAddVar ( mainbar, 'AlwaysDraw', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AlwaysDraw, lambda x : setattr ( aiming, 'AlwaysDraw', x ), " group='Information' label='Always Draw' " )
        AntTweakBar.TwAddVar ( mainbar, 'Wireframe', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.Wireframe, lambda x : setattr ( aiming, 'Wireframe', x ), " group='Information' label='Wireframe' " )
        AntTweakBar.TwAddVar ( mainbar, 'Wallhack', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.Wallhack, lambda x : setattr ( aiming, 'Wallhack', x ), " group='Information' label='Wallhack' " )
        AntTweakBar.TwAddButton ( mainbar, 'SwitchTeam', self.__switchteam, " group='Tools' label='Switch Team' " )
        AntTweakBar.TwAddButton ( mainbar, 'CommitSuicide', self.__suicide, " group='Tools' label='Commit Suicide' " )
        AntTweakBar.TwAddButton ( mainbar, 'OpenConsole', self.__openconsole, " group='Tools' label='Open Console' " )        
        AntTweakBar.TwAddVar ( mainbar, 'BehindView', AntTweakBar.TW_TYPE_BOOL32, self.__getbehindview, self.__setbehindview, " group='Tools' label='Behind View' " )
        AntTweakBar.TwAddVar ( mainbar, 'RandomName', AntTweakBar.TW_TYPE_BOOL32, lambda : naming.Enabled, lambda x : naming.Enable ( x ), " group='Tools' label='Random Name' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerName', AntTweakBar.TW_TYPE_CDSTRING, self.__getplayername, self.__changeplayername, " group='Tools' label='Player Name' " )
        AntTweakBar.TwAddButton ( mainbar, 'GodMode', self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerScale', AntTweakBar.TW_TYPE_FLOAT, lambda : self.PlayerScale, lambda x : setattr ( self, 'PlayerScale', x ), " group='Exploits' label='Player Scale' step=0.1 " )
        AntTweakBar.TwAddButton ( mainbar, 'SetScale', self.__setscale, " group='Exploits' label='Set Scale' " )
        AntTweakBar.TwAddVar ( mainbar, 'Gravity', AntTweakBar.TW_TYPE_FLOAT, self.__getgravity, self.__setgravity, " group='Tools' label='Gravity' step=0.1 " )

       # Shieldable exploits mode
        if ( self.Exploits == EXPLOITS_Shieldable ):
            AntTweakBar.TwAddVar ( mainbar, 'Shield', AntTweakBar.TW_TYPE_BOOL32, lambda : self.Shield, lambda x : setattr ( self, 'Shield', x ), " group='Exploits' label='Shield' " )
        # Full exploits mode
        if ( self.Exploits == EXPLOITS_Full ):
        AntTweakBar.TwAddVar ( mainbar, 'GodMode', AntTweakBar.TW_TYPE_BOOL32, self.__getpawnbit ( EPB_God ), self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerScale', AntTweakBar.TW_TYPE_FLOAT, lambda : self.PlayerScale, lambda x : setattr ( self, 'PlayerScale', x ), " group='Exploits' label='Player Scale' step=0.1 " )
        AntTweakBar.TwAddButton ( mainbar, 'SetScale', self.__setscale, " group='Exploits' label='Set Scale' " )
        AntTweakBar.TwAddButton ( mainbar, 'GodMode', self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
    
    # Tool routines
    def __getbehindview(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        return PC****ehindView if ( PC ) else False
    def __setbehindview(self, value):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.BehindView ( value )
    def __getplayername(self):
        PC  = aiming.Viewport and aiming.Viewport.Actor
        PRI = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.PlayerReplicationInfo
        ChangedName = not naming.Enabled and self.ChangedName or None
        if ( PC and PRI and ChangedName and ChangedName != PRI.PlayerName ):
            PC.ChangeName ( ChangedName )
        return ChangedName or ( PRI and PRI.PlayerName ) or 'None'    
    def __changeplayername(self, value):
        self.ChangedName = value.replace ( ' ', '_' )
    def __suicide(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.Suicide ()    
    def __switchteam(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.SwitchTeam ()        
    def __openconsole(self):
        Console = aiming.Viewport and aiming.Viewpor*****nsole
        if ( Console ): Console.ConsoleOpen ()
    def __getgravity(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        return PC.PhysicsVolume.Gravity.Z if PC.PhysicsVolume else 0
    def __setgravity(self, x):
        PC = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor
        if ( PC and PC.PhysicsVolume ): PC.PhysicsVolume.Gravity.Z = x
    def __checkshield(self):
        Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
        if ( not Pawn or self.Exploits != EXPLOITS_Shieldable ): return
        if ( self.Shield and not Pawn.KFXIsBitStateOn ( EPB_God ) ):
            Pawn.KFXSetPB ( EPB_God, 5 )
    def __setGodMode(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.GodMode()    
    
    # Exploit routines
    def __setpawnbit(self, pawnbit):
        def function():
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            if ( Pawn ): Pawn.KFXSetPB ( pawnbit )
        return function
    def __setscale(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.ServreSetOwnScale ( self.PlayerScale )
        
    # Event handling
    def OnTick(self, deltatime):
        self.LastSave += deltatime
        if ( self.LastSave > self.SaveInterval ):
            self.LastSave = 0
            self.__savesettings ()
    def OnKeyDown(self, keycode, repeats, prevstate):
        if ( keycode == Keys.Numpad0 ):
            aiming.AutoAim = not aiming.AutoAim
            Logger.Log ( 'Auto aiming is now %s!' % ( aiming.AutoAim and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad1 ):
            aiming.Wallhack = not aiming.Wallhack
            Logger.Log ( 'Wallhack is now %s!' % ( aiming.Wallhack and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad2 ):
            aiming.Wireframe = not aiming.Wireframe
            Logger.Log ( 'Wireframe is now %s!' % ( aiming.Wireframe and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad3 ):
            aiming.AutoFire = not aiming.AutoFire
            Logger.Log ( 'Auto firing is now %s!' % ( aiming.AutoFire and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad5 ):
            aiming.SecondaryFire = not aiming.SecondaryFire
            Logger.Log ( 'Secondary firing is now %s!' % ( aiming.SecondaryFire and 'on' or 'off' ) )
        elif ( keycode == Keys.Delete ):
            if ( aiming.Viewport and aiming.Viewpor*****nsole ):
                aiming.Viewpor*****nsole.ConsoleOpen ()
    def OnMenuShow(self):        
        PC = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and aiming.Viewport.Actor.Player and aiming.Viewport.Actor.Player.GUIController        
        if ( GUI ):
            GUI.OperateMsgs [ 99 ] = 'M.A.T By: Daniel Averinaldo Hacker site Mpgh.net.'
            GUI.OpenModeDialogue ( 99 )
    def OnMenuHide(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and aiming.Viewport.Actor.Player and aiming.Viewport.Actor.Player.GUIController
        if ( GUI ):
            GUI.CloseModeDialogue ()
            if ( not GUI.MenuStack ):
                GUI.bActive = False
                GUI.bVisible = False
                try: GUI.ViewportOwner.bShowWindowsMouse = False
                except: pass

class Startup(object):
    def __init__(self):
        self.started = False
        
    def Startup(self):
        # Mark aiming/configuration as globals
        global aiming, naming, configuration
        
        # Instantiate and register
        aiming = Aiming ()
        naming = Naming ()
        configuration = Configuration ()
        Register ( aiming )
        Register ( naming )
        Register ( configuration )

    def OnTick(self, deltatime):    
        # Check status
        if ( self.started ): return
        self.Startup ()
        self.started = True

# Instantiate startup handler
Register ( Startup () )

















Aiming 2(Don't Know):
#
#  Project: MAT Automaton
#
#  Aiming & utilities
#  - Copyright (C) 2011 dB. All rights reserved.
#

# Python imports
import os
import json

# Automaton imports
from Automaton.System import Register
from Automaton.Outputs import Logger
from Automaton import AntTweakBar
from Automaton import Keys

# Unreal imports
from Unreal.Core   import Vector, Rotator, Color
from Unreal.Core   import Object  as ObjectClass
from Unreal.Engine import Actor   as ActorClass
from Unreal.Engine import Pawn    as PawnClass
from Unreal.Engine import Texture as TextureClass
from Unreal.Engine import Weapon  as WeaponClass

# Fetch important functions
DynamicLoadObject = FindFunction ( ObjectClass, 'DynamicLoadObject' )

# Physics constants
(PHYS_None,         PHYS_Walking,
 PHYS_Falling,      PHYS_Swimming,
 PHYS_Flying,       PHYS_Rotating,
 PHYS_Projectile,   PHYS_Interpolating,
 PHYS_MovingBrush,  PHYS_Spider,
 PHYS_Trailer,      PHYS_Ladder,
 PHYS_RootMotion,   PHYS_Karma,
 PHYS_KarmaRagDoll, PHYS_Hovering) = range ( 16 )

 # Pawn bit constants
(EPB_UseItem,        EPB_God,
 EPB_Dance,          EPB_Speedup,
 EPB_AutoAim,        EPB_Mini,
 EPB_Talking,        EPB_7,
 EPB_FilterBadState, EPB_Hide,
 EPB_Second,         EPB_Third,
 EPB_12,             EPB_13,
 EPB_14,             EPB_15,
 EPB_MagicChange,    EPB_Frozen,
 EPB_Chaos,          EPB_Speeddown,
 EPB_LightingStrike, EPB_Vertigo,
 EPB_CorpseChange,   EPB_EvilPigChange,
 EPB_Terminator,     EPB_25,
 EPB_26,             EPB_27,
 EPB_28,             EPB_29,
 EPB_30,             EPB_Max) = range ( 32 )

# Bone constants
(BONE_Head, BONE_Root) = range ( 2 )

# Team constants
(TEAM_Blue, TEAM_Red) = range ( 2 )

# Aiming modes
(AIMING_Health, AIMING_Distance, AIMING_Key) = range ( 3 )

# Exploits modes
(EXPLOITS_Full, EXPLOITS_Shieldable, EXPLOITS_None) = range ( 3 )

class Aiming(object):
    def __init__(self):
        # Defaults
        self.Wireframe         = False
        self.Wallhack          = False
        self.AlwaysDraw        = False
        self.AutoAim           = False
        self.AutoFire          = False
        self.FriendlyFire      = False
        self.LatencyCorrection = False
        self.SecondaryFire     = False
        self.AimKey            = Keys.Shift
        self.AimMode           = AIMING_Health
        self.AimAngle          = 180.0
        self.BonePrecedence    = BONE_Head
        # Initialization
        self.KeyDown           = False
        self.Viewport          = None
        self.WhiteTexture      = None
        self.AimingModes       = {
            AIMING_Health   : self.__best_byhealth,
            AIMING_Distance : self.__best_bydistance,
            AIMING_Key      : self.__best_bycrosshair
        }

    # Aiming mode comperators
    def __best_byhealth(self, current, other):
        return other.Health < current.Health
    def __best_bydistance(self, current, other):
        CameraLocation  = self.Viewport.Actor.CalcViewLocation
        CurrentDistance = abs ( current.Location - CameraLocation )
        OtherDistance   = abs ( other.Location - CameraLocation )
        return OtherDistance < CurrentDistance
    def __best_bycrosshair(self, current, other):
        CameraLocation  = self.Viewport.Actor.CalcViewLocation
        CameraRotation  = self.Viewport.Actor.CalcViewRotation
        desired         = CameraRotation.Vector ()
        dotCurrent      = desired | ( current.Location - CameraLocation ).Normal ()
        dotOther        = desired | ( other.Location   - CameraLocation ).Normal ()
        return dotOther > dotCurrent

    # Compare two pawns
    def Compare(self, pawn, other):
        return self.AimingModes [ self.AimMode ] ( pawn, other )

    def Tick(self, deltatime):
        if ( self.Viewport and self.Viewport.Actor ):
            # Get our player controller
            PC = self.Viewport.Actor

            # Fetch camera information
            CameraLocation = PC.CalcViewLocation
            CameraRotation = PC.CalcViewRotation

            # Setup configuration data
            FireMode = int ( self.SecondaryFire )
            AutoAim  = self.AutoAim and ( self.AimMode != AIMING_Key or self.KeyDown )

            # If we are auto aiming
            if ( AutoAim and PC.Pawn ):
                # Look for the best target
                BestPawn     = None
                BestLocation = None
                for Pawn in PC.DynamicActors ( PawnClass, PC ):
                    # Check if the pawn is valid
                    if ( Pawn == PC.Pawn or not self.Damagable ( Pawn ) ): continue

                    # If it is a team game make sure we are on a different team
                    if ( not self.FriendlyFire and self.SameTeam ( Pawn ) ): continue

                    # Setup bones list
                    BoneList = ( self.BonePrecedence == BONE_Root ) \
                        and [Pawn****otBone, Pawn.HeadBone] \
                        or  [Pawn.HeadBone, Pawn****otBone]

                    # Find a visible bone
                    for bone in BoneList:
                        # Fetch the bone coords
                        BoneCoords = Pawn.GetBoneCoords ( bone )

                        # Calculate the location
                        BoneLocation = BoneCoords.Origin + BoneCoords.XAxis + BoneCoords.YAxis + BoneCoords.ZAxis

                        # Conditionally apply latency correction
                        if ( self.LatencyCorrection ):
                            BoneLocation += self.Correction ( PC, Pawn, deltatime )

                        # Adjust according to projectile physics
                        if ( PC.Pawn.Weapon and PC.Pawn.Weapon.FireMode [ FireMode ] and PC.Pawn.Weapon.FireMode [ FireMode ].ProjectileClass ):
                            Projectile = PC.Pawn.Weapon.FireMode [ FireMode ].ProjectileClass.Default
                            if ( Projectile and Projectile.Speed != 0 and Projectile.Physics != PHYS_Falling ):
                                BoneLocation += Pawn.Velocity * ( abs ( BoneLocation - CameraLocation ) / Projectile.Speed )

                        # Calculate angle
                        Angle = ( CameraRotation.Vector () | ( BoneLocation - CameraLocation ).Normal () ) + 1.0
                        Angle = ( 1.0 - ( Angle / 2.0 ) ) * 180.0

                        # Do the check
                        if ( Angle <= self.AimAngle and Pawn.FastTrace ( BoneLocation, CameraLocation ) ):
                            # Is this the best one?
                            if ( not BestPawn or self.Compare ( BestPawn, Pawn ) ):
                                BestPawn     = Pawn
                                BestLocation = BoneLocation
                            break
                if ( BestPawn ):
                    # We've found a valid target, so lets set the rotation and fire as required
                    PC.ClientSetRotation ( ( BestLocation - CameraLocation )****tation () )
                    if ( self.AutoFire and PC.Pawn.Weapon ): PC.Pawn.Weapon.ClientStartFire ( FireMode )

    def Render(self, canvas):
        if ( self.Viewport and self.Viewport.Actor ):
            # Get our player controller and canvs
            Canvas = canvas
            PC     = self.Viewport.Actor

            # Fetch game information
            TeamGame = PC.GameReplicationInfo and PC.GameReplicationInfo.bTeamGame

            # Fetch camera information
            CameraLocation = PC.CalcViewLocation
            CameraRotation = PC.CalcViewRotation

            # Get required textures
            self.WhiteTexture = DynamicLoadObject ( 'Engine.WhiteTexture', TextureClass )

            # Do our drawing for list of pawns
            for Pawn in PC.DynamicActors ( PawnClass, PC ):
                # Skip our own pawn and dead pawns
                if ( Pawn == PC.Pawn or Pawn.Health <= 0 ): continue

                # Deal with wireframe wallhack
                if ( self.Wireframe and ( self.AlwaysDraw or self.Invisible ( Pawn ) or not PC.FastTrace ( Pawn.Location, CameraLocation ) ) ):
                    Canvas.DrawActor ( Pawn, True, True, PC.FovAngle )

                # Deal with indicator wallhack
                if ( self.Wallhack and self.WhiteTexture ):
                    HeadCoords = Pawn.GetBoneCoords ( Pawn.HeadBone )

                    # Raise the indicator above the head
                    HeadCoords.Origin.Z += 40

                    # Indicator location
                    IndicatorLocation = HeadCoords.Origin + HeadCoords.XAxis + HeadCoords.YAxis + HeadCoords.ZAxis

                    # Get the indicator position on screen
                    IndicatorPosition = Canvas.WorldToScreen ( IndicatorLocation )

                    # See if the indicator is within screen area
                    if ( IndicatorPosition.X >= 0 and IndicatorPosition.X <= Canvas.ClipX and
                         IndicatorPosition.Y >= 0 and IndicatorPosition.Y <= Canvas.ClipY and
                         CameraRotation.Vector () | ( IndicatorLocation - CameraLocation ).Normal () > 0 ):
                        # Set the proper colors
                        colors      = {TEAM_Blue: Color ( 0, 0, 255 ), TEAM_Red: Color ( 255, 0, 0 )}
                        TeamColor   = colors [ self.GetTeam ( Pawn ) ]
                        HealthColor = Color ( 0, 255, 0 )

                        # Set the health color
                        if ( not self.Damagable ( Pawn ) ):
                            # Yellow is used for pawns with god mode
                            HealthColor = Color ( 255, 255, 0 )
                        else:
                            # Change health indicator to reflect current health
                            HealthColor.G = int ( Pawn.Health / Pawn.HealthMax * HealthColor.G ) % 256
                            HealthColor.R = 255 - HealthColor.G

                        # Reset the canvas
                        Canvas.Reset ()
                        Canvas.KFXFontAlias = 'lightsmall'

                        # Draw the player name
                        Canvas.DrawColor = TeamColor
                        if ( Pawn.PlayerReplicationInfo and ( not TeamGame or not self.SameTeam ( Pawn ) ) ):
                            Canvas.SetPos ( IndicatorPosition.X + 15, IndicatorPosition.Y - 15 )
                            Canvas.KFXDrawStr ( Pawn.PlayerReplicationInfo.PlayerName )

                        # Draw the team part of the indicator
                        Canvas.SetPos ( IndicatorPosition.X - 10, IndicatorPosition.Y - 4 )
                        Canvas.DrawTile ( self.WhiteTexture, 20.0, 8.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )
                        Canvas.SetPos ( IndicatorPosition.X - 4, IndicatorPosition.Y - 10 )
                        Canvas.DrawTile ( self.WhiteTexture, 8.0, 20.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )

                        # Draw the health part of the indicator
                        Canvas.DrawColor = HealthColor
                        Canvas.SetPos ( IndicatorPosition.X - 8, IndicatorPosition.Y - 2 )
                        Canvas.DrawTile ( self.WhiteTexture, 16.0, 4.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )
                        Canvas.SetPos ( IndicatorPosition.X - 2, IndicatorPosition.Y - 8 )
                        Canvas.DrawTile ( self.WhiteTexture, 4.0, 16.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )

    # Helpers
    def GetTeam(self, pawn):
        PRI = pawn and pawn.PlayerReplicationInfo
        if ( PRI and hasattr ( PRI, 'IsCorpsePlayer' ) ):
            return TEAM_Red if PRI.IsCorpsePlayer () else TEAM_Blue
        return PRI and PRI.Team and PRI.Team.TeamIndex or TEAM_Blue
    def Invisible(self, actor):
        PC = self.Viewport and self.Viewport.Actor
        return PC and PC.GameReplicationInfo \
                  and PC.GameReplicationInfo.GameClass == 'KFXGame.KFXGhostGame' \
                  and actor.PlayerReplicationInfo and actor.PlayerReplicationInfo.Team \
                  and actor.PlayerReplicationInfo.Team.TeamIndex == TEAM_Red
    def SameTeam(self, pawn):
        PC = self.Viewport and self.Viewport.Actor
        PRI = pawn and pawn.PlayerReplicationInfo
        if ( PRI and hasattr ( PRI, 'IsCorpsePlayer' ) and hasattr ( PC, 'IsCorpsePlayer' ) ):
            return PC.IsCorpsePlayer () == PRI.IsCorpsePlayer ()
        return PC and PC.GameReplicationInfo and PC.GameReplicationInfo.bTeamGame \
                  and PC.PlayerReplicationInfo and pawn.PlayerReplicationInfo \
                  and PC.PlayerReplicationInfo.Team == pawn.PlayerReplicationInfo.Team
    def Damagable(self, pawn):
        if ( pawn.Health <= 0 ): return False
        if ( hasattr ( pawn, 'KFXIsGodMode' ) ):
            return not pawn.KFXIsGodMode ()
        else: return True
    def Gravity(self, actor):
        # Make sure the actor is valid
        if ( not actor or not actor.PhysicsVolume ): return Vector ()
        # Fetch the zone gravity and add the supplementary pawn gravity
        Acceleration = actor.PhysicsVolume.Gravity
        if ( hasattr ( actor, 'ConstantAcceleration' ) ):
            Acceleration += actor.ConstantAcceleration
        return Acceleration
    def Adjustment(self, actor, time):
        # Make sure its a valid actor
        if ( not actor ): return Vector ()
        # Perform the time correction
        if ( hasattr ( actor, 'Physics' ) and actor.Physics == PHYS_Falling ):
            return self.Gravity ( actor ) * 0.5 * ( time * time ) + actor.Velocity * time
        else: return actor.Velocity * time
    def Correction(self, pc, actor, deltatime):
        # Adjust for latency and player velocity
        if ( not pc ): return Vector ( 0, 0, 0 );
        return self.Adjustment ( actor, pc.ExactPing + deltatime ) - \
               self.Adjustment ( pc.Pawn, deltatime )

    # Event handlers
    def OnTick(self, deltatime):
        self.Tick ( deltatime )
    def OnPostRender(self, canvas):
        self.Viewport = canvas.Viewport
        self.Render ( canvas )
    def OnKeyDown(self, keycode, repeats, prevstate):
        if ( keycode == self.AimKey ): self.KeyDown = True
    def OnKeyUp(self, keycode):
        if ( keycode == self.AimKey ): self.KeyDown = False

class Naming(object):
    def __init__(self):
        # Set some defaults
        self.Interval = 1
        self.Enabled  = False
        # Initialization
        self.Viewport = None
        self.Time     = 0
        self.Count    = 0
    def Enable(self, enabled = True):
        self.Enabled = enabled
        self.Count   = 0
        self.Time    = 0
    def OnTick(self, deltatime):
        if ( not self.Enabled ): return
        self.Time += deltatime
        if ( self.Time > self.Interval ):
            self.Time = 0
            if ( self.Viewport and self.Viewport.Actor ):
                value = self.Count % 256
                name  = ''.join ( reversed ( [ str((value >> bit) & 1) for bit in range ( 8 ) ] ) )
                self.Viewport.Actor.ChangeName ( name )
                self.Count += 1
    def OnPostRender(self, canvas):
        if ( canvas and canvas.Viewport ):
            self.Viewport = canvas.Viewport

class Configuration(object):
    # Internal settings
    __config_layout = {
        'Aiming'   : [('aiming', [ 'AimKey', 'AimMode', 'AutoAim', 'AutoFire', 'AimAngle', 'FriendlyFire', 'LatencyCorrection', 'SecondaryFire', 'BonePrecedence' ])],
        'Info'     : [('aiming', [ 'AlwaysDraw', 'Wireframe', 'Wallhack' ])],
        'Naming'   : [('configuration', [ 'ChangedName' ]), ( 'naming', [ 'Enabled' ] )],
        'Exploits' : [('configuration', [ 'Shield', 'PlayerScale' ])]
    }

    # Init/exit routines
    def __init__(self):
        # Globals for load/save
        global configuration
        configuration = self
        # Set some defaults
        aiming.AutoAim           = True
        aiming.AutoFire          = True
        aiming.LatencyCorrection = True
        aiming.Wireframe         = True
        aiming.Wallhack          = True
        self.Shield              = False
        self.ChangedName         = None
        self.PlayerScale         = 1.0
        self.SaveInterval        = 30
        # Initialization
        self.LastSave            = 0
        self.MenuOpen            = False
        self.Exploits            = self.__checkexploits ()
        # Load settings and setup menu
        self.__loadsettings ()
        self.__setup_antweakbar ()

    # Check exploits mode
    def __checkexploits(self):
        return EXPLOITS_Shieldable

    # Configuration presistence
    def __loadsettings(self):
        # Load and parse the settings file
        filename = os.path.expandvars ( '%AppData%\\MAT Automaton\\settings.json' )
        try:
            infile = None
            infile = open ( filename, 'r' )
            settings = json.load ( infile )
        except: return
        finally: infile and infile.close ()
        # Traverse configuration layout
        for seclayout in self.__config_layout.items ():
            # Fetch section object & data
            try: section = settings [ seclayout [ 0 ] ]
            except: continue
            # Set settings from data
            for objcfg in seclayout [ 1 ]:
                obj = globals () [ objcfg [ 0 ] ]
                for x in objcfg [ 1 ]: x in section and setattr ( obj, x, section [ x ] )
    def __savesettings(self):
        # Setup directory and file
        dir = os.path.expandvars ( '%AppData%\\MAT Automaton' )
        if ( not os.path.exists ( dir ) ): os.mkdir ( dir )
        filename = os.path.join ( dir, 'settings.json' )
        try: outfile = open ( filename, 'w' )
        except: return
        # Build the settings dictionary
        settings = {}
        for seclayout in self.__config_layout.items ():
            section = {}
            for objcfg in seclayout [ 1 ]:
                obj = globals () [ objcfg [ 0 ] ]
                section.update ( dict ( map ( lambda x: (x, getattr ( obj, x )), objcfg [ 1 ] ) ) )
            settings [ seclayout [ 0 ] ] = section
        # Save settings to json settings file
        json.dump ( settings, outfile, indent = 4 )
        outfile.close ()

    def __setup_antweakbar(self):
        mainbar = AntTweakBar.TwGetBarByName ( "MATAutomaton" )
        if ( mainbar ): AntTweakBar.TwDeleteBar ( mainbar )
        try: mainbar = AntTweakBar.TwNewBar ( "MATAutomaton" )
        except: return # Unknown AntTweakBar error
        AntTweakBar.TwDefine ( " MATAutomaton label='MAT Automaton' color='135 0 0' fontSize='3' size='330 450' position='16 16' " )
        AntTweakBar.TwAddVar ( mainbar, 'Key', AntTweakBar.TwDefineEnum ( 'EKey', [(k[1], k[0]) for k in Keys.dictionary.items ()] ), lambda : aiming.AimKey, lambda x : setattr ( aiming, 'AimKey', x ), " group='Aiming' label='Key' " )
        AntTweakBar.TwAddVar ( mainbar, 'Mode', AntTweakBar.TwDefineEnum ( 'EAimModes', [(AIMING_Health, 'Health'), (AIMING_Distance, 'Distance'), (AIMING_Key, 'Key')] ), lambda : aiming.AimMode, lambda x : setattr ( aiming, 'AimMode', x ), " group='Aiming' label='Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'AutoAim', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AutoAim, lambda x : setattr ( aiming, 'AutoAim', x ), " group='Aiming' label='Auto Aim' " )        
        AntTweakBar.TwAddVar ( mainbar, 'AutoFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AutoFire, lambda x : setattr ( aiming, 'AutoFire', x ), " group='Aiming' label='Auto Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'BonePrecedence', AntTweakBar.TwDefineEnum ( 'EBones', [(BONE_Head, 'Head'), (BONE_Root, 'Root')] ), lambda : aiming.BonePrecedence, lambda x : setattr ( aiming, 'BonePrecedence', x ), " group='Aiming' label='Bone Precedence' " )
        AntTweakBar.TwAddVar ( mainbar, 'SecondaryFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.SecondaryFire, lambda x : setattr ( aiming, 'SecondaryFire', x ), " group='Aiming' label='Secondary Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'FriendlyFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.FriendlyFire, lambda x : setattr ( aiming, 'FriendlyFire', x ), " group='Aiming' label='Friendly Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'LatencyCorrection', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.LatencyCorrection, lambda x : setattr ( aiming, 'LatencyCorrection', x ), " group='Aiming' label='Latency Correction' " )
        AntTweakBar.TwAddVar ( mainbar, 'AlwaysDraw', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AlwaysDraw, lambda x : setattr ( aiming, 'AlwaysDraw', x ), " group='Information' label='Always Draw' " )
        AntTweakBar.TwAddVar ( mainbar, 'Wireframe', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.Wireframe, lambda x : setattr ( aiming, 'Wireframe', x ), " group='Information' label='Wireframe' " )
        AntTweakBar.TwAddVar ( mainbar, 'Wallhack', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.Wallhack, lambda x : setattr ( aiming, 'Wallhack', x ), " group='Information' label='Wallhack' " )
        AntTweakBar.TwAddButton ( mainbar, 'SwitchTeam', self.__switchteam, " group='Tools' label='Switch Team' " )
        AntTweakBar.TwAddButton ( mainbar, 'CommitSuicide', self.__suicide, " group='Tools' label='Commit Suicide' " )
        AntTweakBar.TwAddButton ( mainbar, 'OpenConsole', self.__openconsole, " group='Tools' label='Open Console' " )        
        AntTweakBar.TwAddVar ( mainbar, 'BehindView', AntTweakBar.TW_TYPE_BOOL32, self.__getbehindview, self.__setbehindview, " group='Tools' label='Behind View' " )
        AntTweakBar.TwAddVar ( mainbar, 'RandomName', AntTweakBar.TW_TYPE_BOOL32, lambda : naming.Enabled, lambda x : naming.Enable ( x ), " group='Tools' label='Random Name' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerName', AntTweakBar.TW_TYPE_CDSTRING, self.__getplayername, self.__changeplayername, " group='Tools' label='Player Name' " )
        AntTweakBar.TwAddButton ( mainbar, 'GodMode', self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerScale', AntTweakBar.TW_TYPE_FLOAT, lambda : self.PlayerScale, lambda x : setattr ( self, 'PlayerScale', x ), " group='Exploits' label='Player Scale' step=0.1 " )
        AntTweakBar.TwAddButton ( mainbar, 'SetScale', self.__setscale, " group='Exploits' label='Set Scale' " )
        AntTweakBar.TwAddVar ( mainbar, 'Gravity', AntTweakBar.TW_TYPE_FLOAT, self.__getgravity, self.__setgravity, " group='Tools' label='Gravity' step=0.1 " )
        # Shieldable exploits mode
        if ( self.Exploits == EXPLOITS_Shieldable ):
            AntTweakBar.TwAddVar ( mainbar, 'Shield', AntTweakBar.TW_TYPE_BOOL32, lambda : self.Shield, lambda x : setattr ( self, 'Shield', x ), " group='Exploits' label='Shield' " )
        # Full exploits mode
        if ( self.Exploits == EXPLOITS_Full ):
            AntTweakBar.TwAddVar ( mainbar, 'GodMode', AntTweakBar.TW_TYPE_BOOL32, self.__getpawnbit ( EPB_God ), self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
            AntTweakBar.TwAddVar ( mainbar, 'PlayerScale', AntTweakBar.TW_TYPE_FLOAT, lambda : self.PlayerScale, lambda x : setattr ( self, 'PlayerScale', x ), " group='Exploits' label='Player Scale' step=0.1 " )
            AntTweakBar.TwAddButton ( mainbar, 'SetScale', self.__setscale, " group='Exploits' label='Set Scale' " )

    # Tool routines
    def __getbehindview(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        return PC****ehindView if ( PC ) else False
    def __setbehindview(self, value):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.BehindView ( value )
    def __getplayername(self):
        PC  = aiming.Viewport and aiming.Viewport.Actor
        PRI = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.PlayerReplicationInfo
        ChangedName = not naming.Enabled and self.ChangedName or None
        if ( PC and PRI and ChangedName and ChangedName != PRI.PlayerName ):
            PC.ChangeName ( ChangedName )
        return ChangedName or ( PRI and PRI.PlayerName ) or 'None'    
    def __changeplayername(self, value):
        self.ChangedName = value.replace ( ' ', '_' )
    def __suicide(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.Suicide ()    
    def __switchteam(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.SwitchTeam ()        
    def __openconsole(self):
        Console = aiming.Viewport and aiming.Viewpor*****nsole
        if ( Console ): Console.ConsoleOpen ()
    def __setGodMode(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.GodMode()   
    def __getgravity(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        return PC.PhysicsVolume.Gravity.Z if PC.PhysicsVolume else 0
    def __setgravity(self, x):
        PC = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor
        if ( PC and PC.PhysicsVolume ): PC.PhysicsVolume.Gravity.Z = x
    def __checkshield(self):
        Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
        if ( not Pawn or self.Exploits != EXPLOITS_Shieldable ): return
        if ( self.Shield and not Pawn.KFXIsBitStateOn ( EPB_God ) ):
            Pawn.KFXSetPB ( EPB_God, 5 ) 
    
    # Exploit routines
    def __getpawnbit(self, pawnbit):
        def function():
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            return bool ( Pawn ) and Pawn.KFXIsBitStateOn ( pawnbit )
        return function
    def __setpawnbit(self, pawnbit):
        def function(x):
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            if ( Pawn ): Pawn.KFXSetPB ( pawnbit, 0 if x else 0.1 )
        return function
    def __setscale(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.ServreSetOwnScale ( self.PlayerScale )


        
    # Exploit routines
    def __getpawnbit(self, pawnbit):
        def function():
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            return bool ( Pawn ) and Pawn.KFXIsBitStateOn ( pawnbit )
        return function
    def __setpawnbit(self, pawnbit):
        def function(x):
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            if ( Pawn ): Pawn.KFXSetPB ( pawnbit, 0 if x else 0.1 )
        return function
    def __setscale(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.ServreSetOwnScale ( self.PlayerScale )

    # Event handling
    def OnTick(self, deltatime):
        PC  = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and PC.Player and PC.Player.GUIController
        if ( GUI and self.MenuOpen ): GUI.OperateTime = 0
        self.__checkshield ()
        self.__getplayername ()
        self.LastSave += deltatime
        if ( self.LastSave > self.SaveInterval ):
            self.LastSave = 0
            self.__savesettings ()
    def OnKeyDown(self, keycode, repeats, prevstate):
        if ( keycode == Keys.Numpad0 ):
            aiming.AutoAim = not aiming.AutoAim
            Logger.Log ( 'Auto aiming is now %s!' % ( aiming.AutoAim and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad1 ):
            aiming.Wallhack = not aiming.Wallhack
            Logger.Log ( 'Wallhack is now %s!' % ( aiming.Wallhack and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad2 ):
            aiming.Wireframe = not aiming.Wireframe
            Logger.Log ( 'Wireframe is now %s!' % ( aiming.Wireframe and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad3 ):
            aiming.AutoFire = not aiming.AutoFire
            Logger.Log ( 'Auto firing is now %s!' % ( aiming.AutoFire and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad5 ):
            aiming.SecondaryFire = not aiming.SecondaryFire
            Logger.Log ( 'Secondary firing is now %s!' % ( aiming.SecondaryFire and 'on' or 'off' ) )
        elif ( keycode == Keys.Delete ):
            if ( aiming.Viewport and aiming.Viewpor*****nsole ):
                aiming.Viewpor*****nsole.ConsoleOpen ()
    def OnMenuShow(self):
        self.MenuOpen = True
        PC  = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and PC.Player and PC.Player.GUIController
        if ( GUI ):
            GUI.OperateMsgs [ 99 ] = 'M.A.T. Auto BY: DANIEL PlAy FoR FuN d^_^b.'
            GUI.OpenModeDialogue ( 99 )
    def OnMenuHide(self):
        self.MenuOpen = False
        PC  = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and PC.Player and PC.Player.GUIController
        if ( GUI ):
            GUI.CloseModeDialogue ()
            if ( not GUI.MenuStack ):
                GUI.bActive = False
                GUI.bVisible = False
                try: GUI.ViewportOwner.bShowWindowsMouse = False
                except: pass

class Startup(object):
    def __init__(self):
        self.started = False

    def Startup(self):
        # Mark aiming/configuration as globals
        global aiming, naming, configuration

        # Instantiate and register
        aiming = Aiming ()
        naming = Naming ()
        configuration = Configuration ()
        Register ( aiming )
        Register ( naming )
        Register ( configuration )

    def OnTick(self, deltatime):
        # Check status
        if ( self.started ): return
        self.Startup ()
        self.started = True

# Instantiate startup handler
Register ( Startup () )
Hope It work.
Sorry For Bad Language
This Is old Scripts If You Wan Make it Tell The @dBased
#9 · 13y ago
Invader-Zim
Invader-Zim
Quote Originally Posted by pc117 View Post
This Is old Scripts If You Wan Make it Tell The @dBased
Lol, the code was detect.
#10 · 13y ago
loped
loped
Quote Originally Posted by samnang18 View Post
Hi EveryBody this is y second post, Do you miss automaton and dBased(Automaton Creator)
especially the auto aim. I have found a source code from mat auto maton and i hope it help you.
I'm suck at Visual Basic, so who made it don't forget to release it. here it is:
AutoAim:

Code:
#
#  Project: MAT Automaton
#
#  Aiming & utilities
#  - Copyright (C) 2011 dB. All rights reserved.
#

# Python imports
import os
import json

# Automaton imports
from Automaton.System import Register
from Automaton.Outputs import Logger
from Automaton import AntTweakBar
from Automaton import Keys

# Unreal imports
from Unreal.Core   import Vector, Rotator, Color
from Unreal.Core   import Object  as ObjectClass
from Unreal.Engine import Actor   as ActorClass
from Unreal.Engine import Pawn    as PawnClass
from Unreal.Engine import Texture as TextureClass
from Unreal.Engine import Weapon  as WeaponClass

# Fetch important functions
DynamicLoadObject = FindFunction ( ObjectClass, 'DynamicLoadObject' )

# Physics constants
(PHYS_None,         PHYS_Walking,
 PHYS_Falling,      PHYS_Swimming,
 PHYS_Flying,       PHYS_Rotating,
 PHYS_Projectile,   PHYS_Interpolating,
 PHYS_MovingBrush,  PHYS_Spider,
 PHYS_Trailer,      PHYS_Ladder,
 PHYS_RootMotion,   PHYS_Karma,
 PHYS_KarmaRagDoll, PHYS_Hovering) = range ( 16 )

 # Pawn bit constants
(EPB_UseItem,        EPB_God,
 EPB_Dance,          EPB_Speedup,
 EPB_AutoAim,        EPB_Mini,
 EPB_Talking,        EPB_7,
 EPB_FilterBadState, EPB_Hide,
 EPB_Second,         EPB_Third,
 EPB_12,             EPB_13,
 EPB_14,             EPB_15,
 EPB_MagicChange,    EPB_Frozen,
 EPB_Chaos,          EPB_Speeddown,
 EPB_LightingStrike, EPB_Vertigo,
 EPB_CorpseChange,   EPB_EvilPigChange,
 EPB_Terminator,     EPB_25,
 EPB_26,             EPB_27,
 EPB_28,             EPB_29,
 EPB_30,             EPB_Max) = range ( 32 )

# Bone constants
(BONE_Head, BONE_Root) = range ( 2 )

# Team constants
(TEAM_Blue, TEAM_Red) = range ( 2 )

# Aiming modes
(AIMING_Health, AIMING_Distance, AIMING_Key) = range ( 3 )

# Exploits modes
(EXPLOITS_Full, EXPLOITS_Shieldable, EXPLOITS_None) = range ( 3 )

class Aiming(object):
    def __init__(self):
        # Defaults
        self.Wireframe         = False
        self.Wallhack          = False
        self.AlwaysDraw        = False
        self.AutoAim           = False
        self.AutoFire          = False
        self.FriendlyFire      = False
        self.LatencyCorrection = False
        self.SecondaryFire     = False
        self.AimKey            = Keys.Shift
        self.AimMode           = AIMING_Health
        self.AimAngle          = 180.0
        self.BonePrecedence    = BONE_Head
        # Initialization
        self.KeyDown           = False
        self.Viewport          = None
        self.WhiteTexture      = None
        self.AimingModes       = {
            AIMING_Health   : self.__best_byhealth,
            AIMING_Distance : self.__best_bydistance,
            AIMING_Key      : self.__best_bycrosshair
        }

    # Aiming mode comperators
    def __best_byhealth(self, current, other):
        return other.Health < current.Health
    def __best_bydistance(self, current, other):
        CameraLocation  = self.Viewport.Actor.CalcViewLocation
        CurrentDistance = abs ( current.Location - CameraLocation )
        OtherDistance   = abs ( other.Location - CameraLocation )
        return OtherDistance < CurrentDistance
    def __best_bycrosshair(self, current, other):
        CameraLocation  = self.Viewport.Actor.CalcViewLocation
        CameraRotation  = self.Viewport.Actor.CalcViewRotation
        desired         = CameraRotation.Vector ()
        dotCurrent      = desired | ( current.Location - CameraLocation ).Normal ()
        dotOther        = desired | ( other.Location   - CameraLocation ).Normal ()
        return dotOther > dotCurrent

    # Compare two pawns
    def Compare(self, pawn, other):
        return self.AimingModes [ self.AimMode ] ( pawn, other )

    def Tick(self, deltatime):
        if ( self.Viewport and self.Viewport.Actor ):
            # Get our player controller
            PC = self.Viewport.Actor

            # Fetch camera information
            CameraLocation = PC.CalcViewLocation
            CameraRotation = PC.CalcViewRotation

            # Setup configuration data
            FireMode = int ( self.SecondaryFire )
            AutoAim  = self.AutoAim and ( self.AimMode != AIMING_Key or self.KeyDown )

            # If we are auto aiming
            if ( AutoAim and PC.Pawn ):
                # Look for the best target
                BestPawn     = None
                BestLocation = None
                for Pawn in PC.DynamicActors ( PawnClass, PC ):
                    # Check if the pawn is valid
                    if ( Pawn == PC.Pawn or not self.Damagable ( Pawn ) ): continue

                    # If it is a team game make sure we are on a different team
                    if ( not self.FriendlyFire and self.SameTeam ( Pawn ) ): continue

                    # Setup bones list
                    BoneList = ( self.BonePrecedence == BONE_Root ) \
                        and [Pawn****otBone, Pawn.HeadBone] \
                        or  [Pawn.HeadBone, Pawn****otBone]

                    # Find a visible bone
                    for bone in BoneList:
                        # Fetch the bone coords
                        BoneCoords = Pawn.GetBoneCoords ( bone )

                        # Calculate the location
                        BoneLocation = BoneCoords.Origin + BoneCoords.XAxis + BoneCoords.YAxis + BoneCoords.ZAxis

                        # Conditionally apply latency correction
                        if ( self.LatencyCorrection ):
                            BoneLocation += self.Correction ( PC, Pawn, deltatime )

                        # Adjust according to projectile physics
                        if ( PC.Pawn.Weapon and PC.Pawn.Weapon.FireMode [ FireMode ] and PC.Pawn.Weapon.FireMode [ FireMode ].ProjectileClass ):
                            Projectile = PC.Pawn.Weapon.FireMode [ FireMode ].ProjectileClass.Default
                            if ( Projectile and Projectile.Speed != 0 and Projectile.Physics != PHYS_Falling ):
                                BoneLocation += Pawn.Velocity * ( abs ( BoneLocation - CameraLocation ) / Projectile.Speed )

                        # Calculate angle
                        Angle = ( CameraRotation.Vector () | ( BoneLocation - CameraLocation ).Normal () ) + 1.0
                        Angle = ( 1.0 - ( Angle / 2.0 ) ) * 180.0

                        # Do the check
                        if ( Angle <= self.AimAngle and Pawn.FastTrace ( BoneLocation, CameraLocation ) ):
                            # Is this the best one?
                            if ( not BestPawn or self.Compare ( BestPawn, Pawn ) ):
                                BestPawn     = Pawn
                                BestLocation = BoneLocation
                            break
                if ( BestPawn ):
                    # We've found a valid target, so lets set the rotation and fire as required
                    PC.ClientSetRotation ( ( BestLocation - CameraLocation )****tation () )
                    if ( self.AutoFire and PC.Pawn.Weapon ): PC.Pawn.Weapon.ClientStartFire ( FireMode )

    def Render(self, canvas):
        if ( self.Viewport and self.Viewport.Actor ):
            # Get our player controller and canvs
            Canvas = canvas
            PC     = self.Viewport.Actor

            # Fetch game information
            TeamGame = PC.GameReplicationInfo and PC.GameReplicationInfo.bTeamGame

            # Fetch camera information
            CameraLocation = PC.CalcViewLocation
            CameraRotation = PC.CalcViewRotation

            # Get required textures
            self.WhiteTexture = DynamicLoadObject ( 'Engine.WhiteTexture', TextureClass )

            # Do our drawing for list of pawns
            for Pawn in PC.DynamicActors ( PawnClass, PC ):
                # Skip our own pawn and dead pawns
                if ( Pawn == PC.Pawn or Pawn.Health <= 0 ): continue

                # Deal with wireframe wallhack
                if ( self.Wireframe and ( self.AlwaysDraw or self.Invisible ( Pawn ) or not PC.FastTrace ( Pawn.Location, CameraLocation ) ) ):
                    Canvas.DrawActor ( Pawn, True, True, PC.FovAngle )

                # Deal with indicator wallhack
                if ( self.Wallhack and self.WhiteTexture ):
                    HeadCoords = Pawn.GetBoneCoords ( Pawn.HeadBone )

                    # Raise the indicator above the head
                    HeadCoords.Origin.Z += 40

                    # Indicator location
                    IndicatorLocation = HeadCoords.Origin + HeadCoords.XAxis + HeadCoords.YAxis + HeadCoords.ZAxis

                    # Get the indicator position on screen
                    IndicatorPosition = Canvas.WorldToScreen ( IndicatorLocation )

                    # See if the indicator is within screen area
                    if ( IndicatorPosition.X >= 0 and IndicatorPosition.X <= Canvas.ClipX and
                         IndicatorPosition.Y >= 0 and IndicatorPosition.Y <= Canvas.ClipY and
                         CameraRotation.Vector () | ( IndicatorLocation - CameraLocation ).Normal () > 0 ):
                        # Set the proper colors
                        colors      = {TEAM_Blue: Color ( 0, 0, 255 ), TEAM_Red: Color ( 255, 0, 0 )}
                        TeamColor   = colors [ self.GetTeam ( Pawn ) ]
                        HealthColor = Color ( 0, 255, 0 )

                        # Set the health color
                        if ( not self.Damagable ( Pawn ) ):
                            # Yellow is used for pawns with god mode
                            HealthColor = Color ( 255, 255, 0 )
                        else:
                            # Change health indicator to reflect current health
                            HealthColor.G = int ( Pawn.Health / Pawn.HealthMax * HealthColor.G ) % 256
                            HealthColor.R = 255 - HealthColor.G

                        # Reset the canvas
                        Canvas.Reset ()
                        Canvas.KFXFontAlias = 'lightsmall'

                        # Draw the player name
                        Canvas.DrawColor = TeamColor
                        if ( Pawn.PlayerReplicationInfo and ( not TeamGame or not self.SameTeam ( Pawn ) ) ):
                            Canvas.SetPos ( IndicatorPosition.X + 15, IndicatorPosition.Y - 15 )
                            Canvas.KFXDrawStr ( Pawn.PlayerReplicationInfo.PlayerName )

                        # Draw the team part of the indicator
                        Canvas.SetPos ( IndicatorPosition.X - 10, IndicatorPosition.Y - 4 )
                        Canvas.DrawTile ( self.WhiteTexture, 20.0, 8.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )
                        Canvas.SetPos ( IndicatorPosition.X - 4, IndicatorPosition.Y - 10 )
                        Canvas.DrawTile ( self.WhiteTexture, 8.0, 20.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )

                        # Draw the health part of the indicator
                        Canvas.DrawColor = HealthColor
                        Canvas.SetPos ( IndicatorPosition.X - 8, IndicatorPosition.Y - 2 )
                        Canvas.DrawTile ( self.WhiteTexture, 16.0, 4.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )
                        Canvas.SetPos ( IndicatorPosition.X - 2, IndicatorPosition.Y - 8 )
                        Canvas.DrawTile ( self.WhiteTexture, 4.0, 16.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )

    # Helpers
    def GetTeam(self, pawn):
        PRI = pawn and pawn.PlayerReplicationInfo
        if ( PRI and hasattr ( PRI, 'IsCorpsePlayer' ) ):
            return TEAM_Red if PRI.IsCorpsePlayer () else TEAM_Blue
        return PRI and PRI.Team and PRI.Team.TeamIndex or TEAM_Blue
    def Invisible(self, actor):
        PC = self.Viewport and self.Viewport.Actor
        return PC and PC.GameReplicationInfo \
                  and PC.GameReplicationInfo.GameClass == 'KFXGame.KFXGhostGame' \
                  and actor.PlayerReplicationInfo and actor.PlayerReplicationInfo.Team \
                  and actor.PlayerReplicationInfo.Team.TeamIndex == TEAM_Red
    def SameTeam(self, pawn):
        PC = self.Viewport and self.Viewport.Actor
        PRI = pawn and pawn.PlayerReplicationInfo
        if ( PRI and hasattr ( PRI, 'IsCorpsePlayer' ) and hasattr ( PC, 'IsCorpsePlayer' ) ):
            return PC.IsCorpsePlayer () == PRI.IsCorpsePlayer ()
        return PC and PC.GameReplicationInfo and PC.GameReplicationInfo.bTeamGame \
                  and PC.PlayerReplicationInfo and pawn.PlayerReplicationInfo \
                  and PC.PlayerReplicationInfo.Team == pawn.PlayerReplicationInfo.Team
    def Damagable(self, pawn):
        if ( pawn.Health <= 0 ): return False
        if ( hasattr ( pawn, 'KFXIsGodMode' ) ):
            return not pawn.KFXIsGodMode ()
        else: return True
    def Gravity(self, actor):
        # Make sure the actor is valid
        if ( not actor or not actor.PhysicsVolume ): return Vector ()
        # Fetch the zone gravity and add the supplementary pawn gravity
        Acceleration = actor.PhysicsVolume.Gravity
        if ( hasattr ( actor, 'ConstantAcceleration' ) ):
            Acceleration += actor.ConstantAcceleration
        return Acceleration
    def Adjustment(self, actor, time):
        # Make sure its a valid actor
        if ( not actor ): return Vector ()
        # Perform the time correction
        if ( hasattr ( actor, 'Physics' ) and actor.Physics == PHYS_Falling ):
            return self.Gravity ( actor ) * 0.5 * ( time * time ) + actor.Velocity * time
        else: return actor.Velocity * time
    def Correction(self, pc, actor, deltatime):
        # Adjust for latency and player velocity
        if ( not pc ): return Vector ( 0, 0, 0 );
        return self.Adjustment ( actor, pc.ExactPing + deltatime ) - \
               self.Adjustment ( pc.Pawn, deltatime )

    # Event handlers
    def OnTick(self, deltatime):
        self.Tick ( deltatime )
    def OnPostRender(self, canvas):
        self.Viewport = canvas.Viewport
        self.Render ( canvas )
    def OnKeyDown(self, keycode, repeats, prevstate):
        if ( keycode == self.AimKey ): self.KeyDown = True
    def OnKeyUp(self, keycode):
        if ( keycode == self.AimKey ): self.KeyDown = False

class Naming(object):
    def __init__(self):
        # Set some defaults
        self.Interval = 1
        self.Enabled  = False
        # Initialization
        self.Viewport = None
        self.Time     = 0
        self.Count    = 0
    def Enable(self, enabled = True):
        self.Enabled = enabled
        self.Count   = 0
        self.Time    = 0
    def OnTick(self, deltatime):
        if ( not self.Enabled ): return
        self.Time += deltatime
        if ( self.Time > self.Interval ):
            self.Time = 0
            if ( self.Viewport and self.Viewport.Actor ):
                value = self.Count % 256
                name  = ''.join ( reversed ( [ str((value >> bit) & 1) for bit in range ( 8 ) ] ) )
                self.Viewport.Actor.ChangeName ( name )
                self.Count += 1
    def OnPostRender(self, canvas):
        if ( canvas and canvas.Viewport ):
            self.Viewport = canvas.Viewport

class Configuration(object):
    # Internal settings
    __config_layout = {
        'Aiming'   : [('aiming', [ 'AimKey', 'AimMode', 'AutoAim', 'AutoFire', 'AimAngle', 'FriendlyFire', 'LatencyCorrection', 'SecondaryFire', 'BonePrecedence' ])],
        'Info'     : [('aiming', [ 'AlwaysDraw', 'Wireframe', 'Wallhack' ])],
        'Naming'   : [('configuration', [ 'ChangedName' ]), ( 'naming', [ 'Enabled' ] )],
        'Exploits' : [('configuration', [ 'Shield', 'PlayerScale' ])]
    }

    # Init/exit routines
    def __init__(self):
        # Globals for load/save
        global configuration
        configuration = self
        # Set some defaults
        aiming.AutoAim           = True
        aiming.AutoFire          = True
        aiming.LatencyCorrection = True
        aiming.Wireframe         = True
        aiming.Wallhack          = True
        self.Shield              = False
        self.ChangedName         = None
        self.PlayerScale         = 1.0
        self.SaveInterval        = 30
        # Initialization
        self.LastSave            = 0
        self.MenuOpen            = False
        self.Exploits            = self.__checkexploits ()
        # Load settings and setup menu
        self.__loadsettings ()
        self.__setup_antweakbar ()

    # Check exploits mode
    def __checkexploits(self):
        return EXPLOITS_Shieldable

    # Configuration presistence
    def __loadsettings(self):
        # Load and parse the settings file
        filename = os.path.expandvars ( '%AppData%\\MAT Automaton\\settings.json' )
        try:
            infile = None
            infile = open ( filename, 'r' )
            settings = json.load ( infile )
        except: return
        finally: infile and infile.close ()
        # Traverse configuration layout
        for seclayout in self.__config_layout.items ():
            # Fetch section object & data
            try: section = settings [ seclayout [ 0 ] ]
            except: continue
            # Set settings from data
            for objcfg in seclayout [ 1 ]:
                obj = globals () [ objcfg [ 0 ] ]
                for x in objcfg [ 1 ]: x in section and setattr ( obj, x, section [ x ] )
    def __savesettings(self):
        # Setup directory and file
        dir = os.path.expandvars ( '%AppData%\\MAT Automaton' )
        if ( not os.path.exists ( dir ) ): os.mkdir ( dir )
        filename = os.path.join ( dir, 'settings.json' )
        try: outfile = open ( filename, 'w' )
        except: return
        # Build the settings dictionary
        settings = {}
        for seclayout in self.__config_layout.items ():
            section = {}
            for objcfg in seclayout [ 1 ]:
                obj = globals () [ objcfg [ 0 ] ]
                section.update ( dict ( map ( lambda x: (x, getattr ( obj, x )), objcfg [ 1 ] ) ) )
            settings [ seclayout [ 0 ] ] = section
        # Save settings to json settings file
        json.dump ( settings, outfile, indent = 4 )
        outfile.close ()

    def __setup_antweakbar(self):
        mainbar = AntTweakBar.TwGetBarByName ( "MATAutomaton" )
        if ( mainbar ): AntTweakBar.TwDeleteBar ( mainbar )
        try: mainbar = AntTweakBar.TwNewBar ( "MATAutomaton" )
        except: return # Unknown AntTweakBar error
        AntTweakBar.TwDefine ( " MATAutomaton label='MAT Automaton' color='212 0 0' fontSize='3' size='330 450' position='16 16' " )
        AntTweakBar.TwAddVar ( mainbar, 'Key', AntTweakBar.TwDefineEnum ( 'EKey', [(k[1], k[0]) for k in Keys.dictionary.items ()] ), lambda : aiming.AimKey, lambda x : setattr ( aiming, 'AimKey', x ), " group='Aiming' label='Key' " )
        AntTweakBar.TwAddVar ( mainbar, 'Mode', AntTweakBar.TwDefineEnum ( 'EAimModes', [(AIMING_Health, 'Health'), (AIMING_Distance, 'Distance'), (AIMING_Key, 'Key')] ), lambda : aiming.AimMode, lambda x : setattr ( aiming, 'AimMode', x ), " group='Aiming' label='Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'AutoAim', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AutoAim, lambda x : setattr ( aiming, 'AutoAim', x ), " group='Aiming' label='Auto Aim' " )        
        AntTweakBar.TwAddVar ( mainbar, 'AutoFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AutoFire, lambda x : setattr ( aiming, 'AutoFire', x ), " group='Aiming' label='Auto Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'BonePrecedence', AntTweakBar.TwDefineEnum ( 'EBones', [(BONE_Head, 'Head'), (BONE_Root, 'Root')] ), lambda : aiming.BonePrecedence, lambda x : setattr ( aiming, 'BonePrecedence', x ), " group='Aiming' label='Bone Precedence' " )
        AntTweakBar.TwAddVar ( mainbar, 'SecondaryFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.SecondaryFire, lambda x : setattr ( aiming, 'SecondaryFire', x ), " group='Aiming' label='Secondary Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'FriendlyFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.FriendlyFire, lambda x : setattr ( aiming, 'FriendlyFire', x ), " group='Aiming' label='Friendly Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'LatencyCorrection', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.LatencyCorrection, lambda x : setattr ( aiming, 'LatencyCorrection', x ), " group='Aiming' label='Latency Correction' " )
        AntTweakBar.TwAddVar ( mainbar, 'AlwaysDraw', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AlwaysDraw, lambda x : setattr ( aiming, 'AlwaysDraw', x ), " group='Information' label='Always Draw' " )
        AntTweakBar.TwAddVar ( mainbar, 'Wireframe', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.Wireframe, lambda x : setattr ( aiming, 'Wireframe', x ), " group='Information' label='Wireframe' " )
        AntTweakBar.TwAddVar ( mainbar, 'Wallhack', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.Wallhack, lambda x : setattr ( aiming, 'Wallhack', x ), " group='Information' label='Wallhack' " )
        AntTweakBar.TwAddButton ( mainbar, 'SwitchTeam', self.__switchteam, " group='Tools' label='Switch Team' " )
        AntTweakBar.TwAddButton ( mainbar, 'CommitSuicide', self.__suicide, " group='Tools' label='Commit Suicide' " )
        AntTweakBar.TwAddButton ( mainbar, 'OpenConsole', self.__openconsole, " group='Tools' label='Open Console' " )        
        AntTweakBar.TwAddVar ( mainbar, 'BehindView', AntTweakBar.TW_TYPE_BOOL32, self.__getbehindview, self.__setbehindview, " group='Tools' label='Behind View' " )
        AntTweakBar.TwAddVar ( mainbar, 'RandomName', AntTweakBar.TW_TYPE_BOOL32, lambda : naming.Enabled, lambda x : naming.Enable ( x ), " group='Tools' label='Random Name' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerName', AntTweakBar.TW_TYPE_CDSTRING, self.__getplayername, self.__changeplayername, " group='Tools' label='Player Name' " )
        AntTweakBar.TwAddButton ( mainbar, 'GodMode', self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerScale', AntTweakBar.TW_TYPE_FLOAT, lambda : self.PlayerScale, lambda x : setattr ( self, 'PlayerScale', x ), " group='Exploits' label='Player Scale' step=0.1 " )
        AntTweakBar.TwAddButton ( mainbar, 'SetScale', self.__setscale, " group='Exploits' label='Set Scale' " )
        AntTweakBar.TwAddVar ( mainbar, 'Gravity', AntTweakBar.TW_TYPE_FLOAT, self.__getgravity, self.__setgravity, " group='Tools' label='Gravity' step=0.1 " )

       # Shieldable exploits mode
        if ( self.Exploits == EXPLOITS_Shieldable ):
            AntTweakBar.TwAddVar ( mainbar, 'Shield', AntTweakBar.TW_TYPE_BOOL32, lambda : self.Shield, lambda x : setattr ( self, 'Shield', x ), " group='Exploits' label='Shield' " )
        # Full exploits mode
        if ( self.Exploits == EXPLOITS_Full ):
        AntTweakBar.TwAddVar ( mainbar, 'GodMode', AntTweakBar.TW_TYPE_BOOL32, self.__getpawnbit ( EPB_God ), self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerScale', AntTweakBar.TW_TYPE_FLOAT, lambda : self.PlayerScale, lambda x : setattr ( self, 'PlayerScale', x ), " group='Exploits' label='Player Scale' step=0.1 " )
        AntTweakBar.TwAddButton ( mainbar, 'SetScale', self.__setscale, " group='Exploits' label='Set Scale' " )
        AntTweakBar.TwAddButton ( mainbar, 'GodMode', self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
    
    # Tool routines
    def __getbehindview(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        return PC****ehindView if ( PC ) else False
    def __setbehindview(self, value):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.BehindView ( value )
    def __getplayername(self):
        PC  = aiming.Viewport and aiming.Viewport.Actor
        PRI = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.PlayerReplicationInfo
        ChangedName = not naming.Enabled and self.ChangedName or None
        if ( PC and PRI and ChangedName and ChangedName != PRI.PlayerName ):
            PC.ChangeName ( ChangedName )
        return ChangedName or ( PRI and PRI.PlayerName ) or 'None'    
    def __changeplayername(self, value):
        self.ChangedName = value.replace ( ' ', '_' )
    def __suicide(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.Suicide ()    
    def __switchteam(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.SwitchTeam ()        
    def __openconsole(self):
        Console = aiming.Viewport and aiming.Viewpor*****nsole
        if ( Console ): Console.ConsoleOpen ()
    def __getgravity(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        return PC.PhysicsVolume.Gravity.Z if PC.PhysicsVolume else 0
    def __setgravity(self, x):
        PC = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor
        if ( PC and PC.PhysicsVolume ): PC.PhysicsVolume.Gravity.Z = x
    def __checkshield(self):
        Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
        if ( not Pawn or self.Exploits != EXPLOITS_Shieldable ): return
        if ( self.Shield and not Pawn.KFXIsBitStateOn ( EPB_God ) ):
            Pawn.KFXSetPB ( EPB_God, 5 )
    def __setGodMode(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.GodMode()    
    
    # Exploit routines
    def __setpawnbit(self, pawnbit):
        def function():
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            if ( Pawn ): Pawn.KFXSetPB ( pawnbit )
        return function
    def __setscale(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.ServreSetOwnScale ( self.PlayerScale )
        
    # Event handling
    def OnTick(self, deltatime):
        self.LastSave += deltatime
        if ( self.LastSave > self.SaveInterval ):
            self.LastSave = 0
            self.__savesettings ()
    def OnKeyDown(self, keycode, repeats, prevstate):
        if ( keycode == Keys.Numpad0 ):
            aiming.AutoAim = not aiming.AutoAim
            Logger.Log ( 'Auto aiming is now %s!' % ( aiming.AutoAim and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad1 ):
            aiming.Wallhack = not aiming.Wallhack
            Logger.Log ( 'Wallhack is now %s!' % ( aiming.Wallhack and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad2 ):
            aiming.Wireframe = not aiming.Wireframe
            Logger.Log ( 'Wireframe is now %s!' % ( aiming.Wireframe and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad3 ):
            aiming.AutoFire = not aiming.AutoFire
            Logger.Log ( 'Auto firing is now %s!' % ( aiming.AutoFire and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad5 ):
            aiming.SecondaryFire = not aiming.SecondaryFire
            Logger.Log ( 'Secondary firing is now %s!' % ( aiming.SecondaryFire and 'on' or 'off' ) )
        elif ( keycode == Keys.Delete ):
            if ( aiming.Viewport and aiming.Viewpor*****nsole ):
                aiming.Viewpor*****nsole.ConsoleOpen ()
    def OnMenuShow(self):        
        PC = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and aiming.Viewport.Actor.Player and aiming.Viewport.Actor.Player.GUIController        
        if ( GUI ):
            GUI.OperateMsgs [ 99 ] = 'M.A.T By: Daniel Averinaldo Hacker site Mpgh.net.'
            GUI.OpenModeDialogue ( 99 )
    def OnMenuHide(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and aiming.Viewport.Actor.Player and aiming.Viewport.Actor.Player.GUIController
        if ( GUI ):
            GUI.CloseModeDialogue ()
            if ( not GUI.MenuStack ):
                GUI.bActive = False
                GUI.bVisible = False
                try: GUI.ViewportOwner.bShowWindowsMouse = False
                except: pass

class Startup(object):
    def __init__(self):
        self.started = False
        
    def Startup(self):
        # Mark aiming/configuration as globals
        global aiming, naming, configuration
        
        # Instantiate and register
        aiming = Aiming ()
        naming = Naming ()
        configuration = Configuration ()
        Register ( aiming )
        Register ( naming )
        Register ( configuration )

    def OnTick(self, deltatime):    
        # Check status
        if ( self.started ): return
        self.Startup ()
        self.started = True

# Instantiate startup handler
Register ( Startup () )

















Aiming 2(Don't Know):
#
#  Project: MAT Automaton
#
#  Aiming & utilities
#  - Copyright (C) 2011 dB. All rights reserved.
#

# Python imports
import os
import json

# Automaton imports
from Automaton.System import Register
from Automaton.Outputs import Logger
from Automaton import AntTweakBar
from Automaton import Keys

# Unreal imports
from Unreal.Core   import Vector, Rotator, Color
from Unreal.Core   import Object  as ObjectClass
from Unreal.Engine import Actor   as ActorClass
from Unreal.Engine import Pawn    as PawnClass
from Unreal.Engine import Texture as TextureClass
from Unreal.Engine import Weapon  as WeaponClass

# Fetch important functions
DynamicLoadObject = FindFunction ( ObjectClass, 'DynamicLoadObject' )

# Physics constants
(PHYS_None,         PHYS_Walking,
 PHYS_Falling,      PHYS_Swimming,
 PHYS_Flying,       PHYS_Rotating,
 PHYS_Projectile,   PHYS_Interpolating,
 PHYS_MovingBrush,  PHYS_Spider,
 PHYS_Trailer,      PHYS_Ladder,
 PHYS_RootMotion,   PHYS_Karma,
 PHYS_KarmaRagDoll, PHYS_Hovering) = range ( 16 )

 # Pawn bit constants
(EPB_UseItem,        EPB_God,
 EPB_Dance,          EPB_Speedup,
 EPB_AutoAim,        EPB_Mini,
 EPB_Talking,        EPB_7,
 EPB_FilterBadState, EPB_Hide,
 EPB_Second,         EPB_Third,
 EPB_12,             EPB_13,
 EPB_14,             EPB_15,
 EPB_MagicChange,    EPB_Frozen,
 EPB_Chaos,          EPB_Speeddown,
 EPB_LightingStrike, EPB_Vertigo,
 EPB_CorpseChange,   EPB_EvilPigChange,
 EPB_Terminator,     EPB_25,
 EPB_26,             EPB_27,
 EPB_28,             EPB_29,
 EPB_30,             EPB_Max) = range ( 32 )

# Bone constants
(BONE_Head, BONE_Root) = range ( 2 )

# Team constants
(TEAM_Blue, TEAM_Red) = range ( 2 )

# Aiming modes
(AIMING_Health, AIMING_Distance, AIMING_Key) = range ( 3 )

# Exploits modes
(EXPLOITS_Full, EXPLOITS_Shieldable, EXPLOITS_None) = range ( 3 )

class Aiming(object):
    def __init__(self):
        # Defaults
        self.Wireframe         = False
        self.Wallhack          = False
        self.AlwaysDraw        = False
        self.AutoAim           = False
        self.AutoFire          = False
        self.FriendlyFire      = False
        self.LatencyCorrection = False
        self.SecondaryFire     = False
        self.AimKey            = Keys.Shift
        self.AimMode           = AIMING_Health
        self.AimAngle          = 180.0
        self.BonePrecedence    = BONE_Head
        # Initialization
        self.KeyDown           = False
        self.Viewport          = None
        self.WhiteTexture      = None
        self.AimingModes       = {
            AIMING_Health   : self.__best_byhealth,
            AIMING_Distance : self.__best_bydistance,
            AIMING_Key      : self.__best_bycrosshair
        }

    # Aiming mode comperators
    def __best_byhealth(self, current, other):
        return other.Health < current.Health
    def __best_bydistance(self, current, other):
        CameraLocation  = self.Viewport.Actor.CalcViewLocation
        CurrentDistance = abs ( current.Location - CameraLocation )
        OtherDistance   = abs ( other.Location - CameraLocation )
        return OtherDistance < CurrentDistance
    def __best_bycrosshair(self, current, other):
        CameraLocation  = self.Viewport.Actor.CalcViewLocation
        CameraRotation  = self.Viewport.Actor.CalcViewRotation
        desired         = CameraRotation.Vector ()
        dotCurrent      = desired | ( current.Location - CameraLocation ).Normal ()
        dotOther        = desired | ( other.Location   - CameraLocation ).Normal ()
        return dotOther > dotCurrent

    # Compare two pawns
    def Compare(self, pawn, other):
        return self.AimingModes [ self.AimMode ] ( pawn, other )

    def Tick(self, deltatime):
        if ( self.Viewport and self.Viewport.Actor ):
            # Get our player controller
            PC = self.Viewport.Actor

            # Fetch camera information
            CameraLocation = PC.CalcViewLocation
            CameraRotation = PC.CalcViewRotation

            # Setup configuration data
            FireMode = int ( self.SecondaryFire )
            AutoAim  = self.AutoAim and ( self.AimMode != AIMING_Key or self.KeyDown )

            # If we are auto aiming
            if ( AutoAim and PC.Pawn ):
                # Look for the best target
                BestPawn     = None
                BestLocation = None
                for Pawn in PC.DynamicActors ( PawnClass, PC ):
                    # Check if the pawn is valid
                    if ( Pawn == PC.Pawn or not self.Damagable ( Pawn ) ): continue

                    # If it is a team game make sure we are on a different team
                    if ( not self.FriendlyFire and self.SameTeam ( Pawn ) ): continue

                    # Setup bones list
                    BoneList = ( self.BonePrecedence == BONE_Root ) \
                        and [Pawn****otBone, Pawn.HeadBone] \
                        or  [Pawn.HeadBone, Pawn****otBone]

                    # Find a visible bone
                    for bone in BoneList:
                        # Fetch the bone coords
                        BoneCoords = Pawn.GetBoneCoords ( bone )

                        # Calculate the location
                        BoneLocation = BoneCoords.Origin + BoneCoords.XAxis + BoneCoords.YAxis + BoneCoords.ZAxis

                        # Conditionally apply latency correction
                        if ( self.LatencyCorrection ):
                            BoneLocation += self.Correction ( PC, Pawn, deltatime )

                        # Adjust according to projectile physics
                        if ( PC.Pawn.Weapon and PC.Pawn.Weapon.FireMode [ FireMode ] and PC.Pawn.Weapon.FireMode [ FireMode ].ProjectileClass ):
                            Projectile = PC.Pawn.Weapon.FireMode [ FireMode ].ProjectileClass.Default
                            if ( Projectile and Projectile.Speed != 0 and Projectile.Physics != PHYS_Falling ):
                                BoneLocation += Pawn.Velocity * ( abs ( BoneLocation - CameraLocation ) / Projectile.Speed )

                        # Calculate angle
                        Angle = ( CameraRotation.Vector () | ( BoneLocation - CameraLocation ).Normal () ) + 1.0
                        Angle = ( 1.0 - ( Angle / 2.0 ) ) * 180.0

                        # Do the check
                        if ( Angle <= self.AimAngle and Pawn.FastTrace ( BoneLocation, CameraLocation ) ):
                            # Is this the best one?
                            if ( not BestPawn or self.Compare ( BestPawn, Pawn ) ):
                                BestPawn     = Pawn
                                BestLocation = BoneLocation
                            break
                if ( BestPawn ):
                    # We've found a valid target, so lets set the rotation and fire as required
                    PC.ClientSetRotation ( ( BestLocation - CameraLocation )****tation () )
                    if ( self.AutoFire and PC.Pawn.Weapon ): PC.Pawn.Weapon.ClientStartFire ( FireMode )

    def Render(self, canvas):
        if ( self.Viewport and self.Viewport.Actor ):
            # Get our player controller and canvs
            Canvas = canvas
            PC     = self.Viewport.Actor

            # Fetch game information
            TeamGame = PC.GameReplicationInfo and PC.GameReplicationInfo.bTeamGame

            # Fetch camera information
            CameraLocation = PC.CalcViewLocation
            CameraRotation = PC.CalcViewRotation

            # Get required textures
            self.WhiteTexture = DynamicLoadObject ( 'Engine.WhiteTexture', TextureClass )

            # Do our drawing for list of pawns
            for Pawn in PC.DynamicActors ( PawnClass, PC ):
                # Skip our own pawn and dead pawns
                if ( Pawn == PC.Pawn or Pawn.Health <= 0 ): continue

                # Deal with wireframe wallhack
                if ( self.Wireframe and ( self.AlwaysDraw or self.Invisible ( Pawn ) or not PC.FastTrace ( Pawn.Location, CameraLocation ) ) ):
                    Canvas.DrawActor ( Pawn, True, True, PC.FovAngle )

                # Deal with indicator wallhack
                if ( self.Wallhack and self.WhiteTexture ):
                    HeadCoords = Pawn.GetBoneCoords ( Pawn.HeadBone )

                    # Raise the indicator above the head
                    HeadCoords.Origin.Z += 40

                    # Indicator location
                    IndicatorLocation = HeadCoords.Origin + HeadCoords.XAxis + HeadCoords.YAxis + HeadCoords.ZAxis

                    # Get the indicator position on screen
                    IndicatorPosition = Canvas.WorldToScreen ( IndicatorLocation )

                    # See if the indicator is within screen area
                    if ( IndicatorPosition.X >= 0 and IndicatorPosition.X <= Canvas.ClipX and
                         IndicatorPosition.Y >= 0 and IndicatorPosition.Y <= Canvas.ClipY and
                         CameraRotation.Vector () | ( IndicatorLocation - CameraLocation ).Normal () > 0 ):
                        # Set the proper colors
                        colors      = {TEAM_Blue: Color ( 0, 0, 255 ), TEAM_Red: Color ( 255, 0, 0 )}
                        TeamColor   = colors [ self.GetTeam ( Pawn ) ]
                        HealthColor = Color ( 0, 255, 0 )

                        # Set the health color
                        if ( not self.Damagable ( Pawn ) ):
                            # Yellow is used for pawns with god mode
                            HealthColor = Color ( 255, 255, 0 )
                        else:
                            # Change health indicator to reflect current health
                            HealthColor.G = int ( Pawn.Health / Pawn.HealthMax * HealthColor.G ) % 256
                            HealthColor.R = 255 - HealthColor.G

                        # Reset the canvas
                        Canvas.Reset ()
                        Canvas.KFXFontAlias = 'lightsmall'

                        # Draw the player name
                        Canvas.DrawColor = TeamColor
                        if ( Pawn.PlayerReplicationInfo and ( not TeamGame or not self.SameTeam ( Pawn ) ) ):
                            Canvas.SetPos ( IndicatorPosition.X + 15, IndicatorPosition.Y - 15 )
                            Canvas.KFXDrawStr ( Pawn.PlayerReplicationInfo.PlayerName )

                        # Draw the team part of the indicator
                        Canvas.SetPos ( IndicatorPosition.X - 10, IndicatorPosition.Y - 4 )
                        Canvas.DrawTile ( self.WhiteTexture, 20.0, 8.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )
                        Canvas.SetPos ( IndicatorPosition.X - 4, IndicatorPosition.Y - 10 )
                        Canvas.DrawTile ( self.WhiteTexture, 8.0, 20.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )

                        # Draw the health part of the indicator
                        Canvas.DrawColor = HealthColor
                        Canvas.SetPos ( IndicatorPosition.X - 8, IndicatorPosition.Y - 2 )
                        Canvas.DrawTile ( self.WhiteTexture, 16.0, 4.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )
                        Canvas.SetPos ( IndicatorPosition.X - 2, IndicatorPosition.Y - 8 )
                        Canvas.DrawTile ( self.WhiteTexture, 4.0, 16.0, 0, 0, self.WhiteTexture.USize, self.WhiteTexture.VSize )

    # Helpers
    def GetTeam(self, pawn):
        PRI = pawn and pawn.PlayerReplicationInfo
        if ( PRI and hasattr ( PRI, 'IsCorpsePlayer' ) ):
            return TEAM_Red if PRI.IsCorpsePlayer () else TEAM_Blue
        return PRI and PRI.Team and PRI.Team.TeamIndex or TEAM_Blue
    def Invisible(self, actor):
        PC = self.Viewport and self.Viewport.Actor
        return PC and PC.GameReplicationInfo \
                  and PC.GameReplicationInfo.GameClass == 'KFXGame.KFXGhostGame' \
                  and actor.PlayerReplicationInfo and actor.PlayerReplicationInfo.Team \
                  and actor.PlayerReplicationInfo.Team.TeamIndex == TEAM_Red
    def SameTeam(self, pawn):
        PC = self.Viewport and self.Viewport.Actor
        PRI = pawn and pawn.PlayerReplicationInfo
        if ( PRI and hasattr ( PRI, 'IsCorpsePlayer' ) and hasattr ( PC, 'IsCorpsePlayer' ) ):
            return PC.IsCorpsePlayer () == PRI.IsCorpsePlayer ()
        return PC and PC.GameReplicationInfo and PC.GameReplicationInfo.bTeamGame \
                  and PC.PlayerReplicationInfo and pawn.PlayerReplicationInfo \
                  and PC.PlayerReplicationInfo.Team == pawn.PlayerReplicationInfo.Team
    def Damagable(self, pawn):
        if ( pawn.Health <= 0 ): return False
        if ( hasattr ( pawn, 'KFXIsGodMode' ) ):
            return not pawn.KFXIsGodMode ()
        else: return True
    def Gravity(self, actor):
        # Make sure the actor is valid
        if ( not actor or not actor.PhysicsVolume ): return Vector ()
        # Fetch the zone gravity and add the supplementary pawn gravity
        Acceleration = actor.PhysicsVolume.Gravity
        if ( hasattr ( actor, 'ConstantAcceleration' ) ):
            Acceleration += actor.ConstantAcceleration
        return Acceleration
    def Adjustment(self, actor, time):
        # Make sure its a valid actor
        if ( not actor ): return Vector ()
        # Perform the time correction
        if ( hasattr ( actor, 'Physics' ) and actor.Physics == PHYS_Falling ):
            return self.Gravity ( actor ) * 0.5 * ( time * time ) + actor.Velocity * time
        else: return actor.Velocity * time
    def Correction(self, pc, actor, deltatime):
        # Adjust for latency and player velocity
        if ( not pc ): return Vector ( 0, 0, 0 );
        return self.Adjustment ( actor, pc.ExactPing + deltatime ) - \
               self.Adjustment ( pc.Pawn, deltatime )

    # Event handlers
    def OnTick(self, deltatime):
        self.Tick ( deltatime )
    def OnPostRender(self, canvas):
        self.Viewport = canvas.Viewport
        self.Render ( canvas )
    def OnKeyDown(self, keycode, repeats, prevstate):
        if ( keycode == self.AimKey ): self.KeyDown = True
    def OnKeyUp(self, keycode):
        if ( keycode == self.AimKey ): self.KeyDown = False

class Naming(object):
    def __init__(self):
        # Set some defaults
        self.Interval = 1
        self.Enabled  = False
        # Initialization
        self.Viewport = None
        self.Time     = 0
        self.Count    = 0
    def Enable(self, enabled = True):
        self.Enabled = enabled
        self.Count   = 0
        self.Time    = 0
    def OnTick(self, deltatime):
        if ( not self.Enabled ): return
        self.Time += deltatime
        if ( self.Time > self.Interval ):
            self.Time = 0
            if ( self.Viewport and self.Viewport.Actor ):
                value = self.Count % 256
                name  = ''.join ( reversed ( [ str((value >> bit) & 1) for bit in range ( 8 ) ] ) )
                self.Viewport.Actor.ChangeName ( name )
                self.Count += 1
    def OnPostRender(self, canvas):
        if ( canvas and canvas.Viewport ):
            self.Viewport = canvas.Viewport

class Configuration(object):
    # Internal settings
    __config_layout = {
        'Aiming'   : [('aiming', [ 'AimKey', 'AimMode', 'AutoAim', 'AutoFire', 'AimAngle', 'FriendlyFire', 'LatencyCorrection', 'SecondaryFire', 'BonePrecedence' ])],
        'Info'     : [('aiming', [ 'AlwaysDraw', 'Wireframe', 'Wallhack' ])],
        'Naming'   : [('configuration', [ 'ChangedName' ]), ( 'naming', [ 'Enabled' ] )],
        'Exploits' : [('configuration', [ 'Shield', 'PlayerScale' ])]
    }

    # Init/exit routines
    def __init__(self):
        # Globals for load/save
        global configuration
        configuration = self
        # Set some defaults
        aiming.AutoAim           = True
        aiming.AutoFire          = True
        aiming.LatencyCorrection = True
        aiming.Wireframe         = True
        aiming.Wallhack          = True
        self.Shield              = False
        self.ChangedName         = None
        self.PlayerScale         = 1.0
        self.SaveInterval        = 30
        # Initialization
        self.LastSave            = 0
        self.MenuOpen            = False
        self.Exploits            = self.__checkexploits ()
        # Load settings and setup menu
        self.__loadsettings ()
        self.__setup_antweakbar ()

    # Check exploits mode
    def __checkexploits(self):
        return EXPLOITS_Shieldable

    # Configuration presistence
    def __loadsettings(self):
        # Load and parse the settings file
        filename = os.path.expandvars ( '%AppData%\\MAT Automaton\\settings.json' )
        try:
            infile = None
            infile = open ( filename, 'r' )
            settings = json.load ( infile )
        except: return
        finally: infile and infile.close ()
        # Traverse configuration layout
        for seclayout in self.__config_layout.items ():
            # Fetch section object & data
            try: section = settings [ seclayout [ 0 ] ]
            except: continue
            # Set settings from data
            for objcfg in seclayout [ 1 ]:
                obj = globals () [ objcfg [ 0 ] ]
                for x in objcfg [ 1 ]: x in section and setattr ( obj, x, section [ x ] )
    def __savesettings(self):
        # Setup directory and file
        dir = os.path.expandvars ( '%AppData%\\MAT Automaton' )
        if ( not os.path.exists ( dir ) ): os.mkdir ( dir )
        filename = os.path.join ( dir, 'settings.json' )
        try: outfile = open ( filename, 'w' )
        except: return
        # Build the settings dictionary
        settings = {}
        for seclayout in self.__config_layout.items ():
            section = {}
            for objcfg in seclayout [ 1 ]:
                obj = globals () [ objcfg [ 0 ] ]
                section.update ( dict ( map ( lambda x: (x, getattr ( obj, x )), objcfg [ 1 ] ) ) )
            settings [ seclayout [ 0 ] ] = section
        # Save settings to json settings file
        json.dump ( settings, outfile, indent = 4 )
        outfile.close ()

    def __setup_antweakbar(self):
        mainbar = AntTweakBar.TwGetBarByName ( "MATAutomaton" )
        if ( mainbar ): AntTweakBar.TwDeleteBar ( mainbar )
        try: mainbar = AntTweakBar.TwNewBar ( "MATAutomaton" )
        except: return # Unknown AntTweakBar error
        AntTweakBar.TwDefine ( " MATAutomaton label='MAT Automaton' color='135 0 0' fontSize='3' size='330 450' position='16 16' " )
        AntTweakBar.TwAddVar ( mainbar, 'Key', AntTweakBar.TwDefineEnum ( 'EKey', [(k[1], k[0]) for k in Keys.dictionary.items ()] ), lambda : aiming.AimKey, lambda x : setattr ( aiming, 'AimKey', x ), " group='Aiming' label='Key' " )
        AntTweakBar.TwAddVar ( mainbar, 'Mode', AntTweakBar.TwDefineEnum ( 'EAimModes', [(AIMING_Health, 'Health'), (AIMING_Distance, 'Distance'), (AIMING_Key, 'Key')] ), lambda : aiming.AimMode, lambda x : setattr ( aiming, 'AimMode', x ), " group='Aiming' label='Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'AutoAim', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AutoAim, lambda x : setattr ( aiming, 'AutoAim', x ), " group='Aiming' label='Auto Aim' " )        
        AntTweakBar.TwAddVar ( mainbar, 'AutoFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AutoFire, lambda x : setattr ( aiming, 'AutoFire', x ), " group='Aiming' label='Auto Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'BonePrecedence', AntTweakBar.TwDefineEnum ( 'EBones', [(BONE_Head, 'Head'), (BONE_Root, 'Root')] ), lambda : aiming.BonePrecedence, lambda x : setattr ( aiming, 'BonePrecedence', x ), " group='Aiming' label='Bone Precedence' " )
        AntTweakBar.TwAddVar ( mainbar, 'SecondaryFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.SecondaryFire, lambda x : setattr ( aiming, 'SecondaryFire', x ), " group='Aiming' label='Secondary Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'FriendlyFire', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.FriendlyFire, lambda x : setattr ( aiming, 'FriendlyFire', x ), " group='Aiming' label='Friendly Fire' " )
        AntTweakBar.TwAddVar ( mainbar, 'LatencyCorrection', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.LatencyCorrection, lambda x : setattr ( aiming, 'LatencyCorrection', x ), " group='Aiming' label='Latency Correction' " )
        AntTweakBar.TwAddVar ( mainbar, 'AlwaysDraw', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.AlwaysDraw, lambda x : setattr ( aiming, 'AlwaysDraw', x ), " group='Information' label='Always Draw' " )
        AntTweakBar.TwAddVar ( mainbar, 'Wireframe', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.Wireframe, lambda x : setattr ( aiming, 'Wireframe', x ), " group='Information' label='Wireframe' " )
        AntTweakBar.TwAddVar ( mainbar, 'Wallhack', AntTweakBar.TW_TYPE_BOOL32, lambda : aiming.Wallhack, lambda x : setattr ( aiming, 'Wallhack', x ), " group='Information' label='Wallhack' " )
        AntTweakBar.TwAddButton ( mainbar, 'SwitchTeam', self.__switchteam, " group='Tools' label='Switch Team' " )
        AntTweakBar.TwAddButton ( mainbar, 'CommitSuicide', self.__suicide, " group='Tools' label='Commit Suicide' " )
        AntTweakBar.TwAddButton ( mainbar, 'OpenConsole', self.__openconsole, " group='Tools' label='Open Console' " )        
        AntTweakBar.TwAddVar ( mainbar, 'BehindView', AntTweakBar.TW_TYPE_BOOL32, self.__getbehindview, self.__setbehindview, " group='Tools' label='Behind View' " )
        AntTweakBar.TwAddVar ( mainbar, 'RandomName', AntTweakBar.TW_TYPE_BOOL32, lambda : naming.Enabled, lambda x : naming.Enable ( x ), " group='Tools' label='Random Name' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerName', AntTweakBar.TW_TYPE_CDSTRING, self.__getplayername, self.__changeplayername, " group='Tools' label='Player Name' " )
        AntTweakBar.TwAddButton ( mainbar, 'GodMode', self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
        AntTweakBar.TwAddVar ( mainbar, 'PlayerScale', AntTweakBar.TW_TYPE_FLOAT, lambda : self.PlayerScale, lambda x : setattr ( self, 'PlayerScale', x ), " group='Exploits' label='Player Scale' step=0.1 " )
        AntTweakBar.TwAddButton ( mainbar, 'SetScale', self.__setscale, " group='Exploits' label='Set Scale' " )
        AntTweakBar.TwAddVar ( mainbar, 'Gravity', AntTweakBar.TW_TYPE_FLOAT, self.__getgravity, self.__setgravity, " group='Tools' label='Gravity' step=0.1 " )
        # Shieldable exploits mode
        if ( self.Exploits == EXPLOITS_Shieldable ):
            AntTweakBar.TwAddVar ( mainbar, 'Shield', AntTweakBar.TW_TYPE_BOOL32, lambda : self.Shield, lambda x : setattr ( self, 'Shield', x ), " group='Exploits' label='Shield' " )
        # Full exploits mode
        if ( self.Exploits == EXPLOITS_Full ):
            AntTweakBar.TwAddVar ( mainbar, 'GodMode', AntTweakBar.TW_TYPE_BOOL32, self.__getpawnbit ( EPB_God ), self.__setpawnbit ( EPB_God ), " group='Exploits' label='God Mode' " )
            AntTweakBar.TwAddVar ( mainbar, 'PlayerScale', AntTweakBar.TW_TYPE_FLOAT, lambda : self.PlayerScale, lambda x : setattr ( self, 'PlayerScale', x ), " group='Exploits' label='Player Scale' step=0.1 " )
            AntTweakBar.TwAddButton ( mainbar, 'SetScale', self.__setscale, " group='Exploits' label='Set Scale' " )

    # Tool routines
    def __getbehindview(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        return PC****ehindView if ( PC ) else False
    def __setbehindview(self, value):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.BehindView ( value )
    def __getplayername(self):
        PC  = aiming.Viewport and aiming.Viewport.Actor
        PRI = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.PlayerReplicationInfo
        ChangedName = not naming.Enabled and self.ChangedName or None
        if ( PC and PRI and ChangedName and ChangedName != PRI.PlayerName ):
            PC.ChangeName ( ChangedName )
        return ChangedName or ( PRI and PRI.PlayerName ) or 'None'    
    def __changeplayername(self, value):
        self.ChangedName = value.replace ( ' ', '_' )
    def __suicide(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.Suicide ()    
    def __switchteam(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.SwitchTeam ()        
    def __openconsole(self):
        Console = aiming.Viewport and aiming.Viewpor*****nsole
        if ( Console ): Console.ConsoleOpen ()
    def __setGodMode(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.GodMode()   
    def __getgravity(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        return PC.PhysicsVolume.Gravity.Z if PC.PhysicsVolume else 0
    def __setgravity(self, x):
        PC = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor
        if ( PC and PC.PhysicsVolume ): PC.PhysicsVolume.Gravity.Z = x
    def __checkshield(self):
        Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
        if ( not Pawn or self.Exploits != EXPLOITS_Shieldable ): return
        if ( self.Shield and not Pawn.KFXIsBitStateOn ( EPB_God ) ):
            Pawn.KFXSetPB ( EPB_God, 5 ) 
    
    # Exploit routines
    def __getpawnbit(self, pawnbit):
        def function():
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            return bool ( Pawn ) and Pawn.KFXIsBitStateOn ( pawnbit )
        return function
    def __setpawnbit(self, pawnbit):
        def function(x):
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            if ( Pawn ): Pawn.KFXSetPB ( pawnbit, 0 if x else 0.1 )
        return function
    def __setscale(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.ServreSetOwnScale ( self.PlayerScale )


        
    # Exploit routines
    def __getpawnbit(self, pawnbit):
        def function():
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            return bool ( Pawn ) and Pawn.KFXIsBitStateOn ( pawnbit )
        return function
    def __setpawnbit(self, pawnbit):
        def function(x):
            Pawn = aiming.Viewport and aiming.Viewport.Actor and aiming.Viewport.Actor.Pawn
            if ( Pawn ): Pawn.KFXSetPB ( pawnbit, 0 if x else 0.1 )
        return function
    def __setscale(self):
        PC = aiming.Viewport and aiming.Viewport.Actor
        if ( PC ): PC.ServreSetOwnScale ( self.PlayerScale )

    # Event handling
    def OnTick(self, deltatime):
        PC  = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and PC.Player and PC.Player.GUIController
        if ( GUI and self.MenuOpen ): GUI.OperateTime = 0
        self.__checkshield ()
        self.__getplayername ()
        self.LastSave += deltatime
        if ( self.LastSave > self.SaveInterval ):
            self.LastSave = 0
            self.__savesettings ()
    def OnKeyDown(self, keycode, repeats, prevstate):
        if ( keycode == Keys.Numpad0 ):
            aiming.AutoAim = not aiming.AutoAim
            Logger.Log ( 'Auto aiming is now %s!' % ( aiming.AutoAim and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad1 ):
            aiming.Wallhack = not aiming.Wallhack
            Logger.Log ( 'Wallhack is now %s!' % ( aiming.Wallhack and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad2 ):
            aiming.Wireframe = not aiming.Wireframe
            Logger.Log ( 'Wireframe is now %s!' % ( aiming.Wireframe and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad3 ):
            aiming.AutoFire = not aiming.AutoFire
            Logger.Log ( 'Auto firing is now %s!' % ( aiming.AutoFire and 'on' or 'off' ) )
        elif ( keycode == Keys.Numpad5 ):
            aiming.SecondaryFire = not aiming.SecondaryFire
            Logger.Log ( 'Secondary firing is now %s!' % ( aiming.SecondaryFire and 'on' or 'off' ) )
        elif ( keycode == Keys.Delete ):
            if ( aiming.Viewport and aiming.Viewpor*****nsole ):
                aiming.Viewpor*****nsole.ConsoleOpen ()
    def OnMenuShow(self):
        self.MenuOpen = True
        PC  = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and PC.Player and PC.Player.GUIController
        if ( GUI ):
            GUI.OperateMsgs [ 99 ] = 'M.A.T. Auto BY: DANIEL PlAy FoR FuN d^_^b.'
            GUI.OpenModeDialogue ( 99 )
    def OnMenuHide(self):
        self.MenuOpen = False
        PC  = aiming.Viewport and aiming.Viewport.Actor
        GUI = PC and PC.Player and PC.Player.GUIController
        if ( GUI ):
            GUI.CloseModeDialogue ()
            if ( not GUI.MenuStack ):
                GUI.bActive = False
                GUI.bVisible = False
                try: GUI.ViewportOwner.bShowWindowsMouse = False
                except: pass

class Startup(object):
    def __init__(self):
        self.started = False

    def Startup(self):
        # Mark aiming/configuration as globals
        global aiming, naming, configuration

        # Instantiate and register
        aiming = Aiming ()
        naming = Naming ()
        configuration = Configuration ()
        Register ( aiming )
        Register ( naming )
        Register ( configuration )

    def OnTick(self, deltatime):
        # Check status
        if ( self.started ): return
        self.Startup ()
        self.started = True

# Instantiate startup handler
Register ( Startup () )
Hope It work.
Sorry For Bad Language
u cant compile it to Visual Basic or etc,its a lua script.dBased just chg to .atpy for automaton.
MAT Automaton is only the injector of that script.If u can create injector that can load that script,u can create new version MAT AUTOMATON with your creativity !
Thats only i understand about MAT Automaton
Thanks me if I helped
#11 · 13y ago
DO
DouljaKing
What Am I Suppose To Do With This?
wtf.jpg
#12 · 13y ago
hochantola
hochantola
Use with Dev C++?
#13 · 13y ago
anuarstarz
anuarstarz
Can U post exe,dll or something that i can open it
#14 · 13y ago
astron51
astron51
Quote Originally Posted by Codex+ View Post
These are not useless. If you Can see "KFXsetpb" etc. Actually these Code are Patched . If you Know how to Unload the Apex and Change the current Console code.
you will make it works
well.i can get access to the old console by wongjeffry.And the Console command(All of Them) in MAT is changed.

---------- Post added at 05:22 PM ---------- Previous post was at 05:20 PM ----------

Quote Originally Posted by astron51 View Post
well.i can get access to the old console by wongjeffry.And the Console command(All of Them) in MAT is changed.
Now i have 2 console command.Ghost box and mummy invincible
#15 · 13y ago
Posts 1–15 of 22 · Page 1 of 2

Post a Reply

Similar Threads

  • My Source Code from Box Hack GeneratorBy uzinato in CrossFire Hack Coding / Programming / Source Code
    13Last post 15y ago
  • Auto Close Injector Source CodeBy Karla857 in Visual Basic Programming
    6Last post 13y ago
  • How to edit a dll files or reflect to get the source code from itBy testingid123456 in Sudden Attack General
    1Last post 15y ago
  • question about hack source codes from other Lithtech gamesBy supercarz1991 in Combat Arms Coding Help & Discussion
    2Last post 14y ago

Tags for this Thread

None