Learning Uscript
You are new at Hacking ?
And you wanna know HOW you can hack, too ?!
Here is a great and free Tutorial by [ELF]helioS :
=====================================================================================
Project : HelioS Aimbot Tutorial (UT2003 Edition)
Version : 2.0
Coder : [ELF]HelioS
Site :
http://users.skynet.be/HelioS/Main
Note : This Aimbot will NOT
work online
=====================================================================================
Setting
up your project
1)
Go to the UT2003 Root directory and make a new directory named
"MyAimbot"
2)
In that directory make 2 more direcotry's named "Classes" and
"Textures"
Now your directory structure should look
like this
UT2003
+ Cache
+ Editor
+ Help
+ Logs
+ Maps
+ Music
+ MyAimbot
+ Classes
+ Textures
+ Sounds
+ System
+ Textures
+ Web
3)
Open the "UT2003.ini" located in the "UT2003\System"
directory
4)
Search for "Console=XInterface.extendedconsole" and replace it with
"Console=MyAimbot.MyConsole"
5)
Now search for "EditPackages=" and add
"EditPackages=MyAimbot" at the end of the list
You should have
EditPackages=Core
EditPackages=Engine
EditPackages=Fire
EditPackages=Editor
EditPackages=UnrealEd
EditPackages=IpDrv
EditPackages=UWeb
EditPackages=GamePlay
EditPackages=UnrealGame
EditPackages=XGame_rc
EditPackages=XEffects
EditPackages=XWeapons_rc
EditPackages=XPickups_rc
EditPackages=XPickups
EditPackages=XGame
EditPackages=XWeapons
EditPackages=XInterface
EditPackages=XAdmin
EditPackages=XWebAdmin
EditPackages=MyAimbot
6)
Save the .ini file and go back to the "UT2003\MyAimbot" directory
8)
In that directory create a new .bat file named "CompileMyAimbot.bat"
This will make compiling the Aimbot easier
later on
Edit the new .bat file and write
cd..
cd System
Del MyAimbot.u
UCC.exe Make
Pause
7)
Go to the "UT2003\MyAimbot\Classes" directory and create 2 new empty
text files
and name them "MyConsole.uc" and
"MyInteraction.uc"
8)
Open the "MyConsole.uc" and "MyInteraction.uc" file with
any text editor you like
NotePad or WordPad should work fine
Now we can start the actual
Programming/Scripting
Programming
a simple Aimbot
You
should have "MyConsole.uc" open by now
The
Actual Bot code
//=====================================================================================
// BOT START.
//=====================================================================================
class
MyConsole extends ExtendedConsole Config(MyAimbot);
// MyConsole : This must match the filename you are programming in
// ExtendedConsole : This is the Class your script extends
// Config(MyAimbot) : Your bot settings will be saved in the
"MyAimbot.ini" file
#exec
Texture Import File=Textures\MyCross.bmp Name=MyCross
#exec
Texture Import File=Textures\MyLogo.bmp
Name=MyLogo
// #exec lines are used to tell the compiler it should Import a
texture or sound
// In this case you will Import the file "MyCross.bmp"
and give it the variable name "MyCross"
// The same goes for MyLogo.bmp
// if a config statement is before the variable, you will be able
to save the variable into "MyAimbot.ini"
var
config bool bBotActive;
var
config bool bAutoAim;
var
config bool bAutoFire;
var
config bool bDrawRadar;
// These vars will not be saved to the .ini file but are needed to
make the Aimbot function like it should
var
Pawn Me;
var
PlayerController MyController;
var
MyInteraction MyInteraction;
var
bool bBotIsShooting;
// This is a tricky part
// Hook into the Tick event so we can create an Interaction
// The Interaction is used to get Canvas acces later on because
the Console doesn't support PostRender events
// If you have Canvas acces you are able to write and show stuff
onto your Screen
event
Tick (float Delta)
{
Super.Tick(Delta);
// This will execute
all the code that is located into the "Tick" event we have just
overwritten
// Don't forget this
MyController = ViewportOwner.Actor;
// We give the
Variable "MyController" the value "ViewportOwner.Actor"
//
"MyController" now holds the Base of our own Player
if ( MyInteraction == None ) // Check to see if we already created the Interaction
needed for Canvas acces
{
// We
didn't create the Interaction so lets create it
MyInteraction =
MyInteraction(MyController.Player.InteractionMaster.AddInteraction("MyAimbot.MyInteraction",
MyController.Player));
MyInteraction.MyConsole = self; // Pass on our Console so the Interaction can send the
Canvas back to us
}
}
//================================================================================
// MAIN BOT.
//================================================================================
// This is where the magic happens :P
// It is the start of our own Aimbot code
function
MyPostRender (Canvas Canvas)
{
MyController = ViewportOwner.Actor;
// We give the
Variable "MyController" the value "ViewportOwner.Actor"
//
"MyController" now holds the Base of our own Player
Me = MyController.Pawn;
// We give the Variable
"Me" the value "MyController.Pawn"
// "Me" now
holds our own Player
// This is a check if
we activated our Aimbot
// And we check if the
variables MyController and Me are NOT None
// You must be carefull
that a variable you use is not None because
// it can lead to
enormous errors and even a crash of UT
if (!bBotActive || MyController == None ||
Me == None || Me.PlayerReplicationInfo == None)
{
Return;
// If we didn't
activate our aimbot or the Me variable is None
// we stop this
function with the "Return" statement
}
// Now execute our Code
that is located in the Function below and give them all Canvas acces
DrawMyLogo(Canvas);
DrawMySettings(Canvas);
PawnRelated(Canvas);
}
// Let us draw a nice bot logo on screen so you can show off your
newly created aimbot to your friends :P
function
DrawMyLogo (Canvas Canvas)
{
Canvas.Style = 3;
// set the Canvas Style
to transparant
Canvas.bCenter = False;
// we don't want it in
the center of the screen
Canvas.bNoSmooth = True;
// Divide the screen
height by 3
Canvas.SetPos(20, Canvas.ClipY / 3);
// set the DrawColor to
White
Canvas.DrawColor.R = 229;
Canvas.DrawColor.G = 229;
Canvas.DrawColor.B = 229;
Canvas.DrawColor.A = 0;
// Draw our 1337 Logo
:P
Canvas.DrawIcon(Texture'MyLogo', 0.7);
}
// It is allways usefull to show on screen what features of the
Aimbot are On/Off
function
DrawMySettings (Canvas Canvas)
{
// set the Font to
small so we don't fill up an entire screen by just writing some settings
Canvas.Font = Canvas.SmallFont;
Canvas.SetPos(20, Canvas.ClipY / 2);
Canvas.DrawText("[MyAimbot]");
Canvas.SetPos(20, Canvas.ClipY / 2 + 10 );
Canvas.DrawText("----------");
Canvas.SetPos(20, Canvas.ClipY / 2 + 20);
Canvas.DrawText("AutoAim : " $ String(bAutoAim));
Canvas.SetPos(20, Canvas.ClipY / 2 + 30);
Canvas.DrawText("AutoFire : " $
String(bAutoFire));
Canvas.SetPos(20, Canvas.ClipY / 2 + 40);
Canvas.DrawText("Radar : " $ String(bDrawRadar));
}
// This function holds the code that will cycle through all
Players on the Map
function
PawnRelated(Canvas Canvas)
{
local Pawn Target;
local Pawn BestTarget;
// Cycle through all
players (Pawns) on the Map and store them in a temporarry variable
"Target"
foreach Me.Level.AllActors(Class'Pawn',
Target)
{
// Check if this
Target is Valid, we don't want to be Aiming at spectator or people that are
allready dead :P
if ( ValidTarget(Target) )
{
// Check if
the feature "DrawRadar" is active
if ( bDrawRadar )
{
DrawPlayerOnRadar(Target,
Canvas);
//
execute the code that will draw this Target in our 3D Radar
}
// Check if
the feature "AutoAim" is active
if ( bAutoAim )
{
//
Check to see that this Target should be considered as a target to aim at
if ( GoodWeapon()
&& IsEnemy(Target) && PlayerVisible(Target) )
{
BestTarget =
GetBestTarget(BestTarget, Target);
// The "GetBestTarget" function
will return the BestTarget we have so far
//
So lets store it in the variable "BestTarget"
//
Notice that "BestTarget" can change when we progress through our
Player Cycle
}
}
}
}
// Check to see if the
bot managed to get a Target to Aim at
if ( BestTarget != None )
{
SetMyRotation(BestTarget);
// execute the
code that will set our Rotation so we look directly at the
"BestTarget"
// Check if the
feature "AutoFire" is active
if ( bAutoFire )
{
FireMyWeapon();
// execute
the code that will make our Weapon Fire
}
}
else
{
StopMyWeapon();
// If we don't
have a Target to Aim at we should stop our weapon from shooting
}
}
// This function gets called from the "PawnRelated"
function to see if a Target is Valid
function
bool ValidTarget (Pawn Target)
{
if (
(Target != None) && // Target variable is Not Empty
(!Target.bHidden) && // Target is Not hidden
(Target.Health > 0) && // Target is still alive
(!Target.IsInState('Dying'))
&& // Target is Not Dying
(!Target.IsA('StaticPawn'))
&& // Target is Not a Static Box or Crate
(Target.PlayerReplicationInfo !=
None) && // Target has Replication info
(!Target.PlayerReplicationInfo.bIsSpectator)
&& // Target is Not a spectator
(!Target.PlayerReplicationInfo.bWaitingPlayer)
&&// Target is Not somebody that is pending
to get into the game
(Target.PlayerReplicationInfo !=
Me.PlayerReplicationInfo) // Target is Not ower own
Player
)
{
Return True;
// If all the
above condition are met we return True else we return False
}
else
{
Return False;
}
}
// This function gets called from the "PawnRelated"
function to see if a Target is the Opposit Team
function
bool IsEnemy (Pawn Target)
{
// Check to see if the
Target is part of a Team
// If not we are Not
playing a TeamGame
if ( Target.PlayerReplicationInfo.Team !=
None )
{
// Check
to see if the Target is on our Team
if (
Target.PlayerReplicationInfo.Team.TeamIndex != Me.PlayerReplicationInfo.Team.TeamIndex
)
{
Return True;
}
else
{
Return False;
}
}
else
{
Return True;
// It's not a TeamGame so lets return True
}
}
// This function gets called from the "PawnRelated"
function to see if we are holding a Good Weapon
function
bool GoodWeapon ()
{
local float MaxAmmo;
local float CurAmmo;
if ( Me.Weapon != None ) // Our Weapon in Not None
{
MaxAmmo = 1; // Initialize the MaxAmmo and CurAmmo to 1
CurAmmo = 1;
Me.Weapon.GetAmmoCount(MaxAmmo,
CurAmmo);
if( (CurAmmo / MaxAmmo) > 0 )
{
return True; // We Still have Ammo left in our weapon so lets return
True
}
}
Return False; //
Our Weapon is None or we don't have any ammo left in our Weapon so lets return
False
}
// This function gets called from the "PawnRelated"
function to see which Target is better
function
Pawn GetBestTarget (Pawn BestTarget, Pawn Target)
{
local float BestDistance;
local float CurrentDistance;
if ( BestTarget == None )
{
Return Target;
// If we
don't have a BestTarget Yet we return the current Target
}
else
{
// We allready
have a BestTarget, so let's see if our new Target is closer
// Store the
Distance of both Targets is 2 variables
BestDistance =
VSize(BestTarget.Location - Me.Location);
CurrentDistance =
VSize(Target.Location - Me.Location);
if ( CurrentDistance <
BestDistance )
{
Return Target;
// Our new
Target is Closer so lets return the new Target to become the BestTarget
}
else
{
Return BestTarget;
// Our BestTarget
is still closer so just return the same BestTarget
}
}
}
// This function gets called from the "PawnRelated"
function to see if a Target is Visible
function
bool PlayerVisible (Pawn Target)
{
local vector HisLocation;
local vector MyLocation;
// Store our location
in a vector and add our EyeHeight to it
// so we have a vector
that holds the place of our Eyes
MyLocation = Me.Location;
MyLocation.Z += Me.BaseEyeHeight;
// Store the Target's
location in a vector
// We can't add their
EyeHeight to it because the Server doesn't send the correct value to Client
HisLocation = Target.Location;
HisLocation.Z += Target.CollisionHeight *
0.7;
// Lets do a Trace from
our location to his location
// The Trace will return
true if there is no object blocking the path between both Vectors
// Notice that Tracing
takes up CPU power and a lot of Traces will cause UT to run slow or lag
if ( Me.FastTrace(HisLocation, MyLocation)
)
{
Return True;
}
else
{
Return False;
}
}
// This function gets called from the "PawnRelated"
function to set our View direclty to the BestTarget
function
SetMyRotation (Pawn BestTarget)
{
local vector AimLocation;
local rotator AimRotation;
local vector MyLocation;
// Same stuff we did
before
MyLocation = Me.Location;
MyLocation.Z += Me.BaseEyeHeight;
// Same stuff we did
before
AimLocation = BestTarget.Location;
AimLocation.Z +=
BestTarget.CollisionHeight * 0.7;
// Store the needed
Rotation we have to make to aim at the BestTarget
AimRotation = Normalize( rotator(
AimLocation - MyLocation ) );
// Do the Actual
Rotation
Me.SetRotation(AimRotation);
Me.ClientSetLocation(Me.Location,AimRotation);
}
// This function gets called from the "PawnRelated"
function to Start Fireing
function
FireMyWeapon ()
{
// set BotIsShooting to
true so we can use this variable later to check if the bot is shooting or we
shot manually
bBotIsShooting = True;
// Turn on Primary Fire
an Simulate that we are pressing the Fire Button
MyController.bFire=1;
MyController.bAltFire=0;
MyController.Fire();
}
// This function gets called from the "PawnRelated"
function to Stop our weapon
function
StopMyWeapon ()
{
// Check to see if the
bot turned on fire or we shot manually
if ( bBotIsShooting )
{
// The bot
stopped shooting so lets set BotIsShooting
to false
bBotIsShooting = False;
// Deactivate all
fire modes
MyController.bFire=0;
MyController.bAltFire=0;
}
}
// This function gets called from the "PawnRelated"
function to Draw a Player in the 3D Radar
function
DrawPlayerOnRadar (Pawn Target, Canvas Canvas)
{
local vector MyLocation;
local vector TargetLocation;
local vector DiffLocation;
local vector X,Y,Z;
local float ScreenPosX;
local float ScreenPosY;
local string DistanceInfo;
local string HealthInfo;
local string NameInfo;
// I think you know
this by now :P
MyLocation = Me.Location;
MyLocation.Z += Me.EyeHeight;
// And again
TargetLocation = Target.Location;
TargetLocation.Z += Target.CollisionHeight
/ 2;
// Substract both
locations and store it in a variable
DiffLocation = TargetLocation -
MyLocation;
// This is a bit more
complicated
// We have to devide
our own ViewRotation into different axels
GetAxes(Normalize(Me.GetViewRotation()),X,Y,Z);
// Check to see if the
Player is Not behind us
// If we didn't do this
check we should draw players on the radar that are behind us
if (DiffLocation Dot X > 0.70)
{
// This is even
more complicated
// It converts a
vector in a 3D space to a 2D Screen
// It takes into
acount the Screen Resolution and the Zoom level that you are currently using
ScreenPosX = (Canvas.ClipX / 2) + (
(DiffLocation Dot Y)) * ((Canvas.ClipX / 2) / Tan(MyController.FovAngle *
Pi/360)) / (DiffLocation Dot X);
ScreenPosY = (Canvas.ClipY / 2) +
(-(DiffLocation Dot Z)) * ((Canvas.ClipX / 2) / Tan(MyController.FovAngle *
Pi/360)) / (DiffLocation Dot X);
// Set the
position or on Screen so we can draw a cross at that position
Canvas.SetPos(ScreenPosX - 8,
ScreenPosY - 8);
// Set the
DrawColor to match the TeamColor of the Target
GetTeamColor(Canvas, Target);
// Draw the
actual Cross on Screen
Canvas.DrawIcon(Texture'MyCross',
0.5);
// A cross on a
screen doesn't hold much info so lets draw some extra info next to it
NameInfo = Target.PlayerReplicationInfo.PlayerName;
HealthInfo = "H: " $ String(Target.Health);
DistanceInfo = "D: " $
String(Int(VSize(DiffLocation) / 48));
// Set the Font
of your text to small so we don't fill up an entire screen
Canvas.Font = Canvas.SmallFont;
// Draw the Extra
Info next to then Cross
Canvas.SetPos(ScreenPosX + 10,
ScreenPosY - 8 );
Canvas.DrawText(NameInfo);
Canvas.SetPos(ScreenPosX + 10,
ScreenPosY );
Canvas.DrawText(HealthInfo);
Canvas.SetPos(ScreenPosX + 10,
ScreenPosY + 8);
Canvas.DrawText(DistanceInfo);
}
}
// This function gets called from the
"DrawPlayerOnRadar" function to determine the TeamColor of a Target
function
GetTeamColor (Canvas Canvas, Pawn Target)
{
if ( Target.PlayerReplicationInfo.Team !=
None ) // Target is Part of a Team
{
switch( Target.PlayerReplicationInfo.Team.TeamIndex
)
{
Case 0: // Red Team
Canvas.SetDrawColor(229,60,60);
Break;
Case 1: // Blue Team
Canvas.SetDrawColor(90,160,229);
Break;
Default: // Green or Default Team
Canvas.SetDrawColor(60,229,60);
Break;
}
}
else
{
Canvas.SetDrawColor(60,229,60); // Green or Default Team
}
}
// function to make it easier to show some Extra Info
function
Msg (string Message)
{
if ( Me != None )
{
Me.ClientMessage(Message);
// Add this Message to the Console and HUD
}
}
//================================================================================
// BOT COMMANDS.
//================================================================================
// Function that start with "exec" can be called from
within the Console Menu
// All functions below are used to Toggle the Aimbot Featurs
// Bot Commands are "doActive" "doAutoAim"
"doAutoFire" "doRadar" "doSave"
exec
function doActive ()
{
bBotActive = !bBotActive;
Msg("Aimbot Active = " $
string(bBotActive));
}
exec
function doAutoAim ()
{
bAutoAim = !bAutoAim;
Msg("AutoAim = " $
string(bAutoAim));
}
exec
function doAutoFire ()
{
bAutoFire = !bAutoFire;
Msg("AutoFire = " $
string(bAutoFire));
}
exec
function doRadar ()
{
bDrawRadar = !bDrawRadar;
Msg("Radar = " $
string(bDrawRadar));
}
exec
function doSave ()
{
// We want to save some
settings to the "MyAimbot.ini" file so lets call a Native function to
do that
SaveConfig();
StaticSaveConfig();
Msg("Settings Saved");
}
//================================================================================
// DEFAULTS.
//================================================================================
defaultproperties
{
// The variables will
hold these values from the start
// Do NOT use
Spaces here
bBotActive=True;
bAutoAim=True;
bAutoFire=True;
bDrawRadar=True;
}
//=====================================================================================
// BOT END.
//=====================================================================================
You
should have "MyInteraction.uc" open by now
The
Actual Interaction code
//=====================================================================================
// INTERACTION START.
//=====================================================================================
Class
MyInteraction extends Interaction;
// MyInteraction : This must match the filename you are
programming in
// Interaction : This is the Class your script extends
// Needed varialbe so we can pass on Canvas acces
var
MyConsole MyConsole;
// Hook into "PostRender" event so we get Canvas acces
// There is no need to call Super.PostRender(Canvas) because there
is no real code in the Super Class
function
PostRender (Canvas Canvas)
{
if ( MyConsole != None ) // Check to see is MyConsole is set
{
MyConsole.MyPostRender(Canvas); // Pass on Canvas acces to our own Console so we can Draw
on Screen
}
}
defaultproperties
{
// The variables will
hold these values from the start
// Do NOT use
Spaces here
bVisible=True;
// This tells UT that our Interaction wants a PostRender event for Canvas acces
bActive=True; //
This tells UT that our Interaction is Active
}
//=====================================================================================
// INTERACTION END.
//=====================================================================================
How
to Compile the Aimbot
Just
DoubleClick on the "CompileMyAimbot.bat" file
If
all went like planned there will be "MyAimbot.u" in your
"UT2003\System" Directory
Aimbot
Commands
Type
these commands in Console while you are playing
doActive
: to toggle the full Aimbot on/off
doAutoAim
: to toggle AutoAim on/off
doAutoFire : to toggle AutoFire on/off
doRadar
: to toggle 3D Player Radar on/off
doSave
: to save all bot settings
Extra
Stuff you need to know
You
can find a precoded Aimbot source in the Tutorial
But
without all the extra comment
This
Aimbot will NOT work online !!!
Please
give me credit if you use this Tutorial as a base for your working Aimbot
I
took the time to write this Tutorial and I don't like to see my work Ripped by
others
I
Hope you have learned something from this :D
Good
luck on the creation of your Aimbot!