Latest Aiming.atpy

Posts 1–10 of 10 · Page 1 of 1
Latest Aiming.atpy
Can someone post or upload their Aiming.atpy from the latest version of MAT Automaton? I want to learn from it, modify and write my own based on that and the next time the MAT Automaton is back, I could use my own.

Thank you.
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 )

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.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 )

                        # Do the check
                        if ( 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', 'FriendlyFire', 'LatencyCorrection', 'SecondaryFire', 'BonePrecedence' ])],
        'Info'     : [('aiming', [ 'AlwaysDraw', 'Wireframe', 'Wallhack' ])],
        'Naming'   : [('configuration', [ 'ChangedName' ]), ( 'naming', [ 'Enabled' ] )],
        'Exploits' : [('configuration', [ '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.ChangedName         = None
        self.PlayerScale         = 1.0
        self.SaveInterval        = 30
        # Initialization
        self.LastSave            = 0
        self.MenuOpen            = False
        # Load settings and setup menu
        self.__loadsettings ()
        self.__setup_antweakbar ()

    # Configuration presistence
    def __loadsettings(self):
        # Load and parse the settings file
        filename = os.path.expandvars ( '%AppData%\\MAT Automaton\\settings.json' )
        try: settings = json.load ( open ( filename, 'r' ) )
        except: return
        # 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 )

    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='255 0 0' fontSize='3' size='330 460' 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, '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.TwAddVar ( mainbar, 'Gravity', AntTweakBar.TW_TYPE_FLOAT, self.__getgravity, self.__setgravity, " group='Tools' label='Gravity' step=0.1 " )
        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 __getplayername(self):
        PC  = aiming.Viewport and aiming.Viewport.Actor
        PRI = PC and PC.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.Viewport.Console
        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

    # 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.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.Viewport.Console ):
                aiming.Viewport.Console.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. Automaton is freeware. If you paid for it, ask for a refund.'
            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 () )
Aiming.rarattachment deleted · 251 downloads before removal
Quote Originally Posted by dBased View Post
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 )

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.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 )

                        # Do the check
                        if ( 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', 'FriendlyFire', 'LatencyCorrection', 'SecondaryFire', 'BonePrecedence' ])],
        'Info'     : [('aiming', [ 'AlwaysDraw', 'Wireframe', 'Wallhack' ])],
        'Naming'   : [('configuration', [ 'ChangedName' ]), ( 'naming', [ 'Enabled' ] )],
        'Exploits' : [('configuration', [ '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.ChangedName         = None
        self.PlayerScale         = 1.0
        self.SaveInterval        = 30
        # Initialization
        self.LastSave            = 0
        self.MenuOpen            = False
        # Load settings and setup menu
        self.__loadsettings ()
        self.__setup_antweakbar ()

    # Configuration presistence
    def __loadsettings(self):
        # Load and parse the settings file
        filename = os.path.expandvars ( '%AppData%\\MAT Automaton\\settings.json' )
        try: settings = json.load ( open ( filename, 'r' ) )
        except: return
        # 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 )

    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='255 0 0' fontSize='3' size='330 460' 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, '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.TwAddVar ( mainbar, 'Gravity', AntTweakBar.TW_TYPE_FLOAT, self.__getgravity, self.__setgravity, " group='Tools' label='Gravity' step=0.1 " )
        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 __getplayername(self):
        PC  = aiming.Viewport and aiming.Viewport.Actor
        PRI = PC and PC.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.Viewport.Console
        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

    # 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.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.Viewport.Console ):
                aiming.Viewport.Console.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. Automaton is freeware. If you paid for it, ask for a refund.'
            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 () )
How to use this mr.dbase
dbased hack mat automaton can use ?
He give the Aiming code for someone need to make their MAT hack of Aiming.
Thanks dBased for, You know i miss you so much, why you make us miss dbased? Becoz you hard work of hack, right?
friend, could you tell me how to use this hack?
Quote Originally Posted by ketupan View Post
friend, could you tell me how to use this hack?
This hack can't use anymore coz it suspended. But wait for dBased come back again.
he make hack 4 good but some off us too ****** then use it illegally = =!!! i hope u will be back Dbased
Can u give the font support for this code? I need it... Thanks you very much my best friend dbased.
.............................
...................................
Posts 1–10 of 10 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us