Log in

View Full Version : Can you look at my code/need a tester



Troll
07-22-2011, 04:49 PM
Ok so i started i write a zombie fighter for the strong hold (bottom left secound floor) and it was just starting out and its my first script. I was also botting with rsbuddy to get my stats up there and bamm i got banned. So i have come to a stop for 2 weeks. Please can you look at my code/test it to see if it works :p

~Thanks

E: Just posting the code here


program new;
{$i SRL/SRL.scar}

Type
MonsterInfo = Record // so that i can add more later
MonName : String;
SecoundName : String; // so if a monster in the same room has same colour
MonColour : Integer;
MonSat : Extended;
MonHue : Extended;
MonToll : Integer;
End;

Type
FoodInfo = Record
FoodName : String;
DTM : String;
HealPoint : Integer;
End;

Function SetFood(TheName:String):FoodInfo;
Begin

Case TheName Of

'swordfish' : With Result Do
Begin
FoodName := 'Swordfish';
DTM := '';
HealPoint := 54;
End;
End;
End;

Function SetMonster(TheName:String; Which:Integer):MonsterInfo;
Begin

Case TheName Of

'zombie':Begin
Case Which Of
1:
With Result Do
Begin
MonName := 'Zombie';
SecoundName := 'Gaint rat';
MonColour := 2045728;
MonSat := 3.32;
MonHue := 2.35;
MonToll := 8;
End;
2:
With Result Do
Begin
MonName := 'False';
SecoundName := 'GaintRat';
MonColour := 5198163;
MonSat := 0.02;
MonHue := 0.50;
MonToll := 17;
End;
3:
With Result Do
MonName := 'False';
End;
End;

End;

End;


Function FindMonster(TheName:String):Boolean;
Var
x,y,a,i:Integer;
TheTPA:TPointArray;
ATPA: TPointArrayArray;
Click:TPoint;
Monster:MonsterInfo;
Begin

If Not LoggedIn Then Exit;

a := 1;

Repeat
Monster := SetMonster(Thename,a);
If (Monster.MonName = 'False') Then
Begin
writeln('Ran out of usable colours, exiting');
Result := False
Exit;
End;
SetColorspeed2Modifiers(Monster.MonHue,Monster.Mon Sat); //as the colour can change
If FindColorsSpiralTolerance(x,y,TheTPA,Monster.MonCo lour,MSX1,MSY1,MSX2,MSY2,Monster.MonToll) Then
Begin
writeln('Found colour');
SetColorToleranceSpeed(1);
If Length(TheTPA)>0 Then
Begin
writeln('Found it atleast once');
ATPA := TPAtoATPAEx(TheTPA,5,5);
For I:= 0 to High(ATPA) Do
Begin
Click :=MiddleTPA(ATPA[I]);
MMouse(Click.x,click.y,RandomRange(-3,3),RandomRange(-3,3));
writeln('Moved mouse to colour');
If (WaitUptext(Monster.MonName,1000) or WaitUpText(Monster.SecoundName,1000)) Then
Begin
writeln('Found Uptext');
GetMousePos(x,y);
If Random(20) = 5 Then
Begin
Mouse(x,y,0,0,False);
If WaitOption('Attack',1000) Then
Begin
Result := True;
writeln('Found and click monster');
wait(2500);
Exit;
End Else Begin
Mouse(x,y,0,0,True);
writeln('Found and clicked monster');
Result := True;
Wait(2500);
Exit;
End;
End;
End;
End;
End;
Inc(A);
End;
Until(False);
End;

Function Fighting:Boolean;
var timer,totalxp:Integer;
Begin
ToggleXPBar(True);
TotalXP := GetXPBarTotal;
writeln('Entered Fighting loop');
MarkTime(timer);
Repeat
If Not (TotalXP = GetXPBarTotal) Then
Begin
writeln('XP has changed');
Result := True
Exit;
End;
wait(750); //1 mins?
Until(TimeFromMark(timer)>=1000*60)
End;
{
Function Eat:Boolean;
Begin

If FindDTM(DTM,x,y,MIX1,MIY1,MIX2,MIY2) Then
Begin
MMouse(x,y,4,4);




}
begin
SetupSRL;
writeln('Setup SRL');
ActivateClient;
writeln('ActivateClient');
FindMonster('zombie');
writeln('Called FindMonster');
While Fighting Do
Begin
Wait(750);
writeln('in fight');
End;
writeln('not in fight');


end.

Zyt3x
07-22-2011, 05:10 PM
The standards are a bit off, read about it here:http://villavu.com/forum/showthread.php?t=49089&highlight=standards :)

Troll
07-22-2011, 05:13 PM
The standards are a bit off, read about it here:http://villavu.com/forum/showthread.php?t=49089&highlight=standards :)

Ok thanks :) ill look into that, anything else?

masterBB
07-22-2011, 05:19 PM
If Length(TheTPA)>0 Then
Begin

is not needed.

If Random(20) = 5 Then
Begin
Mouse(x,y,0,0,False);
If WaitOption('Attack',1000) Then
Begin
Result := True;
writeln('Found and click monster');
wait(2500);
Exit;
End Else Begin
Mouse(x,y,0,0,True);
writeln('Found and clicked monster');
Result := True;
Wait(2500);
Exit;
End;
End;

Should be:

If Random(20) = 5 Then
Begin
Mouse(x,y,0,0,False);
If WaitOption('Attack',1000) Then
Begin
Result := True;
writeln('Found and click monster');
wait(2500);
Exit;
End;
End Else
Begin
Mouse(x,y,0,0,True);
writeln('Found and clicked monster');
Result := True;
Wait(2500);
Exit;
End;

Echo_
07-22-2011, 05:51 PM
Some spelling errors might effect your scripts efficiency:

SecoundName := 'Gaint rat';

Should be:

SecoundName := 'Giant rat';

So that this will work right:

WaitUpText(Monster.SecoundName,1000)

it's nice to see somebody using types in their first script, it's not common :p

Troll
07-22-2011, 06:46 PM
Some spelling errors might effect your scripts efficiency:

SecoundName := 'Gaint rat';

Should be:

SecoundName := 'Giant rat';

So that this will work right:

WaitUpText(Monster.SecoundName,1000)

it's nice to see somebody using types in their first script, it's not common :p

Thanks, im dyslexic which is where the spelling error came from, and this is about my 5th go at a first script how ever now my accounts banned there is not alot a can do for now. Ill proberaly end not finishing it now lol