PDA

View Full Version : [USCRIPT] Faster Script MS


howler2345
24th July 2005, 09:14
Ok everyone, im almost sure all of you have a postrender function and a pawnrelated function in your aimbot... well i have a way to take out pawnrelated and make the script in your bot run a little faster.

Say if you just got the basicbot source and you wanted to make it run a little faster. This is what you would start out with.

function PostRender (Canvas Canvas)
{
MyController = ViewportOwner.Actor;
MyCanvas = Canvas;
MyCanvas.SetDrawColor(255,0,0);
MyCanvas.bCenter=True;
If (MyController.Pawn != None)
{
PawnRelated();
}
}

function PawnRelated ()
{
BestTargetLocation = NullVector;
MyLocation = MyController.Pawn.EyePosition();
MyPingCorrection = PingCorrection(MyController.Pawn);
If ( MyController.Pawn.Weapon.AmmoType.AmmoAmount == 0)
{
MyController.Pawn.ServerReload();
}
For (I=0; I < MyController.GameReplicationInfo.PRIArray.Length; I++)
{
PRI = MyController.GameReplicationInfo.PRIArray[I];
If ( PRI.Team.TeamIndex != MyController.Pawn.PlayerReplicationInfo.Team.TeamI ndex && !PRI.isDead() )
{
CurrentTargetLocation = PRI.GetPawnLocation();
if (bESP)
{
ESPvector = MyController.Player.Console.WorldToScreen(CurrentT argetLocation);
MyCanvas.SetPos(ESPvector.X, ESPvector.Y);
MyCanvas.DrawTextClipped(PRI.PlayerName);
}
TargetPawn = PRI.myPawn;
If (TargetPawn == None && CurrentTargetLocation != NullVector)
{
CurrentTargetLocation.Z += rand(40);
If (MyController.FastTrace(CurrentTargetLocation,MyLo cation + PingCorrection(MyController.Pawn)))
{
If ( BestTargetLocation == NullVector || Vsize(CurrentTargetLocation - MyLocation) < Vsize(BestTargetLocation - MyLocation) )
{
BestTargetLocation = CurrentTargetLocation;
}
}
}
Else
{
if (bWallHack)
{
MyCanvas.DrawActor(TargetPawn,False,True);
TargetPawn.bHidden=False;
}
CurrentTargetLocation = GetBone();
If (CurrentTargetLocation != NullVector)
{
If ( BestTargetLocation == NullVector || Vsize(CurrentTargetLocation - MyLocation) < Vsize(BestTargetLocation - MyLocation) )
{
BestTargetLocation = CurrentTargetLocation;
}
}
}
}
}

If (BestTargetLocation != NullVector)
{
If (bAutoAim)
{
AimRotation = rotator( BestTargetLocation - MyLocation );
MyController.SetRotation(AimRotation);
If (bAutoFire)
{
For (K=0;K < FireRate;K++)
{
MyController.Pawn.Weapon.ServerFire(True,False,Fal se);
}
}
}
}
}

To make it faster you just make it like this.

function PostRender (Canvas Canvas)
{
MyController = ViewportOwner.Actor;
MyCanvas = Canvas;
MyCanvas.SetDrawColor(255,0,0);
MyCanvas.bCenter=True;
BestTargetLocation = NullVector;
MyLocation = MyController.Pawn.EyePosition();
MyPingCorrection = PingCorrection(MyController.Pawn);
If ( MyController.Pawn.Weapon.AmmoType.AmmoAmount == 0)
{
MyController.Pawn.ServerReload();
}
For (I=0; I < MyController.GameReplicationInfo.PRIArray.Length; I++)
{
PRI = MyController.GameReplicationInfo.PRIArray[I];
If ( PRI.Team.TeamIndex != MyController.Pawn.PlayerReplicationInfo.Team.TeamI ndex && !PRI.isDead() )
{
CurrentTargetLocation = PRI.GetPawnLocation();
if (bESP)
{
ESPvector = MyController.Player.Console.WorldToScreen(CurrentT argetLocation);
MyCanvas.SetPos(ESPvector.X, ESPvector.Y);
MyCanvas.DrawTextClipped(PRI.PlayerName);
}
TargetPawn = PRI.myPawn;
If (TargetPawn == None && CurrentTargetLocation != NullVector)
{
CurrentTargetLocation.Z += rand(40);
If (MyController.FastTrace(CurrentTargetLocation,MyLo cation + PingCorrection(MyController.Pawn)))
{
If ( BestTargetLocation == NullVector || Vsize(CurrentTargetLocation - MyLocation) < Vsize(BestTargetLocation - MyLocation) )
{
BestTargetLocation = CurrentTargetLocation;
}
}
}
Else
{
if (bWallHack)
{
MyCanvas.DrawActor(TargetPawn,False,True);
TargetPawn.bHidden=False;
}
CurrentTargetLocation = GetBone();
If (CurrentTargetLocation != NullVector)
{
If ( BestTargetLocation == NullVector || Vsize(CurrentTargetLocation - MyLocation) < Vsize(BestTargetLocation - MyLocation) )
{
BestTargetLocation = CurrentTargetLocation;
}
}
}
}
}

If (BestTargetLocation != NullVector)
{
If (bAutoAim)
{
AimRotation = rotator( BestTargetLocation - MyLocation );
MyController.SetRotation(AimRotation);
If (bAutoFire)
{
For (K=0;K < FireRate;K++)
{
MyController.Pawn.Weapon.ServerFire(True,False,Fal se);
}
}
}
}
}

This may cause a few minor bugs and whatnot, and esp and everythign will always be on even if your dead, but i beleive it is worth it for how much speed is gained in doing this.

Greets,
Howler

PS. - Im drunk, so if there is something wrong, just tell me and ill fix it :)

EDIT-this also goes along with alot of other things...you can put prefire in there, healthbars, shit even your aimbot if you do it right...have fun :)

kolbybrooks
24th July 2005, 09:19
Very Very nice add, In my next bot ill surely implement this

Thanks Howler, I give you an A+

irac
24th July 2005, 09:27
naice man, houwler yoar my brao fora life lol, we'rea bwasted and aona mmeysn, naice post, and thanksa manog

HyPeR-X
24th July 2005, 11:06
lol, calling a function doesn't take that much resource's or speed, it's the way u code the script wich speed's up everything ;)

- HyPz

[R]>>Killer
24th July 2005, 11:11
true hyper but it would save some space :)

howler2345
24th July 2005, 12:24
just giving out the idea, im not going through it with all the details ;)

DEMON2k5
24th July 2005, 13:09
i made it in that way too... it much more faster. and about the bugs... u can fix them buy putting "If (MyController.Pawn != None)" on some places.. =P

O,M,F,G
24th July 2005, 13:29
ok i done this got a couple of error's fixed them but i can not fix this one:

Error in MyInteraction.uc (62): Call to 'WorldToScreen': bad or missing parameter 1

why do i get this thanks

JaMMo
24th July 2005, 13:45
ESPvector = MyController.Player.Console.WorldToScreen(CurrentT argetLocation);

^^ Forum bug, remove the space between (CurrentT argetLocation);

O,M,F,G
24th July 2005, 13:54
Ty JaMMo i did see that so i made it:

ESPvector = MyController.Player.Console.WorldToScreen(Current TargetLocation);


silly me thanks it compiled ill go test

Wtf is going on i added:

if(bColName)
{
if ( Target.Health > 60)
{
Canvas.SetDrawColor(0,255,0);
}
else if ( Target.Health > 40 )
{
Canvas.SetDrawColor(255,255,0);
}
else if ( Target.Health > 0 )
{
Canvas.SetDrawColor(255,0,0);
}
}
}

Now i get this error:

Error in MyInteraction.uc (69): Bad or missing expression in 'If'

line 69:

if ( Target.Health > 60)

JaMMo
24th July 2005, 13:55
Var Bool bColName;
Var Pawn Target;

mic1989
24th July 2005, 14:05
Ty JaMMo i did see that so i made it:

ESPvector = MyController.Player.Console.WorldToScreen(Current TargetLocation);


silly me thanks it compiled ill go test

Wtf is going on i added:

if(bColName)
{
if ( Target.Health > 60)
{
Canvas.SetDrawColor(0,255,0);
}
else if ( Target.Health > 40 )
{
Canvas.SetDrawColor(255,255,0);
}
else if ( Target.Health > 0 )
{
Canvas.SetDrawColor(255,0,0);
}
}
}

Now i get this error:

Error in MyInteraction.uc (69): Bad or missing expression in 'If'

line 69:

if ( Target.Health > 60)
and put bCollname to your default proporties

No1uKnow
24th July 2005, 17:45
lol what hyper x said is true, this tut is useless, more better to name it

[uscript] how to give yourself critical errors every couple rounds


no offense howler lol, it doesnt make anthing faster besides the time in between gpfs :p

gil
24th July 2005, 18:24
It's in the list anyways.


It seems like you're always drunk howler ;)

mic1989
24th July 2005, 18:54
lol what hyper x said is true, this tut is useless, more better to name it

[uscript] how to give yourself critical errors every couple rounds


no offense howler lol, it doesnt make anthing faster besides the time in between gpfs :p
That's not true
Since we've changed this we both don't have much criticals
Normally i got 1 every 6-7 rounds
now i play for 40minutes without any critical+it seems to be faster :rambo:

yoyoyoyo22
24th July 2005, 21:17
omg howler i though u would now a little more by this time. moving it from a function does shit to the speed.

i suggest everyone to learn to code CLEAN meaning put as much as possible in functions. and if u want to speed up your bot. remove the crap, i again see comming up in lots of bots. maybe nice features but do you need em? no i dont think so.

HUMM3R
24th July 2005, 21:27
omg howler i though u would now a little more by this time. moving it from a function does shit to the speed.

i suggest everyone to learn to code CLEAN meaning put as much as possible in functions. and if u want to speed up your bot. remove the crap, i again see comming up in lots of bots. maybe nice features but do you need em? no i dont think so.

WRONG!!!
You should know by now the extra overhead of function calls. Even if they are native, not to talk about interpreted function calls. And, yeah, some crap are needed to be in a bot, because not everyone is 'just-gimme-fast-aim-and-high-firerate-to-kill-every-noob-on-server'.
Of course its different in a professional programming environment, but hey, this is cheating, everyone wants to squeeze every little drop of juice of his bot. But, yeah, there are in bots other functions that take more than 1-5 % of runtime that should have higher priority when trying to optimize stuff.

yoyoyoyo22
24th July 2005, 21:44
WRONG!!!
You should know by now the extra overhead of function calls. Even if they are native, not to talk about interpreted function calls. And, yeah, some crap are needed to be in a bot, because not everyone is 'just-gimme-fast-aim-and-high-firerate-to-kill-every-noob-on-server'.
Of course its different in a professional programming environment, but hey, this is cheating, everyone wants to squeeze every little drop of juice of his bot. But, yeah, there are in bots other functions that take more than 1-5 % of runtime that should have higher priority when trying to optimize stuff.

im not saying it doesnt affect speed maybe 0.000001% of a whole bots loop.
it keeps the code nice and clean. and still in my opinion if u want a fast bot to pwn other hackers, remove the trash features.

Dont cry about that little speed loss of 1 function, with all that crap in a bot. Dont even dare.

Ok if ya want an mega fast bot, you should consider removing functions, but still there are better ways. Target acquisition is one of the biggest. big deprovement there since full map aim and esp, it has to check through all those opfor even those not used at all.

HUMM3R
24th July 2005, 21:57
im not saying it doesnt affect speed maybe 0.000001% of a whole bots loop.
it keeps the code nice and clean. and still in my opinion if u want a fast bot to pwn other hackers, remove the trash features.

Dont cry about that little speed loss of 1 function, with all that crap in a bot. Dont even dare.

Ok if ya want an mega fast bot, you should consider removing functions, but still there are better ways. Target acquisition is one of the biggest. big deprovement there since full map aim and esp, it has to check through all those opfor even those not used at all.

Well, its not just 0.000001%, just imagine, its called every tick. If you have 30 fps its called 30 times a second. if you have 10 function calls in main postrender, that could even take 0.5 fps even on a highspec computer, not to talk about 1.7 ghz stuff most people have. But the main suggestion is to ALWAYS restrict the use of AllActors and other non-hashed iterators, traces, and math calculations.

squirrel5153
24th July 2005, 22:39
http://wiki.beyondunreal.com/wiki/Code_Optimization

has alot on jow to make your bot go faster including as humm3r said not using allactors as often its better to use collidingacors up to 2000 uu then the next step is radiusactors, also some things on how to use clocks to time the time it takes to execute a function in ms, you can draw that time on your canvas or log it in your army ops log :smoke:

No1uKnow
24th July 2005, 23:07
lol what hyper x said is true, this tut is useless, more better to name it

[uscript] how to give yourself critical errors every couple rounds


no offense howler lol, it doesnt make anthing faster besides the time in between gpfs :p
That's not true
Since we've changed this we both don't have much criticals
Normally i got 1 every 6-7 rounds
now i play for 40minutes without any critical+it seems to be faster :rambo:

not true? maybe you need to play with the code he posted then try to correct me, if you still think its faster try playing me and ill show you whats fast and whats not :|

mic1989
24th July 2005, 23:40
not true? maybe you need to play with the code he posted then try to correct me, if you still think its faster try playing me and ill show you whats fast and whats not :|
I do play with the methode Howler mentoined i didnt said it was faster or whatever
I only say it dont give more criticals or what ever.

howler2345
25th July 2005, 04:16
once again im getting flamed for something i posted, why dont you give hard proof that im wrong next time you try to flame me. I was just releasing the idea not every single thing that you can do to make the bot script run faster...so shut the **** up and die.

gil
25th July 2005, 11:06
Can you stop?
If it's not useful, don't use it.

If you want to discuss about it, do it like matures.

yoyoyoyo22
25th July 2005, 20:43
lol for the first time(i think) i agree with no1uknow, howlers and hummers point is just based on crap.

1 little functioncall isnt even noticed on a 1.7ghz machine. u know how much calculations a 17ghz is?

howler2345
25th July 2005, 20:56
once again, its just the idea...an example...you can take your prefire and put it into post render, or you could take it and put it into your isvisible or whatever you have. the point is that you can cut down on functions + pointers(that point to that function) if you look on wiki im sure it has something about how using a lot of unneeded functions and pointers will slow down your script ms. its not like only doing this will make your script ms 100x faster but it does help if you cut down on all those unneeded functions.

and humm3r knows alot more about uscript than you think.

No1uKnow
25th July 2005, 21:00
Can you stop?
If it's not useful, don't use it.

If you want to discuss about it, do it like matures.

indeed gil, sorry, figured you'd know we're joking, but from now on ill be sure to leave the joking to irc or msn

wont happen again bro :p

- no1


also: howler is just trying to give people a fresh idea, so thanks for atleast trying h0wl, <3 <3 <3

HUMM3R
25th July 2005, 22:09
lol for the first time(i think) i agree with no1uknow, howlers and hummers point is just based on crap.

1 little functioncall isnt even noticed on a 1.7ghz machine. u know how much calculations a 17ghz is?

You must have the last word, don't ya...If I would respect your crap, I would time an elegantly written bot, and a howler-style bot, just to prove how much the time difference is and what other things you can do by sparing by extra function calls...

And, btw, my glass is full of you and your useless, uncreative comments, which makes me now to post things that makes me to be like you...crap.