DaWu
2011-12-05 04:10:50
program new;
{loadlib sps}
{$i srl/srl/misc/Smart.scar}
{$i srl/srl.scar}
{$i sps/sps.simba}
{.include SRL\SRL\skill\Fighting.scar}
Var playtimeinminute, Rotate , PlayerTimer,MonsterTimer,wentToBank:Integer;
AnimationBox: TBox; clicked,fighting,wentBank:Boolean;
bankLoc, fightLoc,myLoc:TPoint;
thePath,thePath2:TPointArray;
const mSpeed=20; //Mousespeed
//monster settings
Const Monstername ='Guard'; // Monster name obviously
Const color1 = 988774; //Monster color
Const Tolerance = 6; // Tolerance
Const foodColor = 5987689; //food color ofc.
//you dont need to mind these tbh. Only makes u avoid the 6th hour kick, so you can go till 10 hours or so.
Const AvoidKick = True; // logout/log back in every X minutes if true.
Const LogoutEvery = 330; //minutes
//Animation settings, you might have to change these a bit ( Fight detection )
Const boxX1=237; //animation box settings
Const boxY1=151;
Const boxX2=274;
Const boxY2=187;
Const AnimTime=2000; //Time
Const shift = 480; //pixelshift, > this and you are fighting/animating
//look below and change wanted SPS locations and areas
Procedure SPSstuff;
begin
bankLoc:= point(3895, 3235);
fightLoc:= Point(3864,3365);
thePath:= [point(3895, 3235),Point(3863,3249),Point(3864,3278),Point(3867,3327),Point(3864,3365)];
SPS_Setup(RUNESCAPE_SURFACE, ['9_7','9_8']);
end;
Procedure DeclarePlayers;
begin
NumberOfPlayers(1);
CurrentPlayer := 0;
Players[0].Name :='';
Players[0].Pass :='';
Players[0].Active := True;
end;
Procedure PlayerSwitch;
begin
If (AvoidKick=true) then
begin
If (timefrommark(PlayerTimer) > LogoutEvery *60000 +random(300000) )
Then
begin
logout;
loginplayer;
setAngle(True);
setRun(True);
MarkTime(PlayerTimer);
End;
end;
end;
Function MustWeEat :boolean;
var HP: Integer;
Color: string;
begin
HP := GetMMLevels('hp', Color);
If(Color = 'Yellow') or (color = 'Orange') or (color = 'Red') then
result:=true
else
result:=false;
end;
Procedure Eat;
var x,y,i:Integer;
begin
if not InvEmpty then
if(findColoredAreaTolerance(x,y,foodColor,MIX1, MIY1, MIX2, MIY2,25,10)) then
begin
MMouse(x,y,5,5);
if WaitUptext('Eat', 500) then
begin
GetMousePos(x, y);
Mouse(x,y,0,0,true);
end;
end;
end;
function invContainsFood :boolean;
var x,y:integer;
begin
if(findColoredAreaTolerance(x,y,foodColor,MIX1, MIY1, MIX2, MIY2,25,10)) then
result:=true
else
result:=false;
end;
//All credit to BobboHobbo and Nava2
procedure PrintOnSmart(TP: TStringArray; Placement: TPoint; Colour, Shadow: integer);
var
mx, my, Pic, I, B, H, TPH, Numb: Integer;
TTP: TPointArray;
Canvas: TCanvas;
begin
SmartSetDebug(True);
GetClientDimensions(mx,my);
Pic := BitmapFromString(mx,my,'');
TPH := High(TP);
for I := 0 to TPH do
begin
TTP := LoadTextTPA(TP[i], SmallChars, H);
for B := 0 to High(TTP) do
begin
Numb := ((I + 1) * 13);
FastSetPixel(Pic, TTP[b].x + 1, TTP[b].y + Numb + 1, Shadow);
FastSetPixel(Pic, TTP[b].x, TTP[b].y + Numb, Colour);
end;
end;
Canvas := TCANVAS.Create;
Canvas.Handle := SmartGetDebugDC;
DrawBitmap(Pic, Canvas, Placement.x, Placement.y);
FreeBitmap(Pic);
end;
procedure PrintProggy;
begin
PrintOnSmart(['DAF Revived - By Dwu - 0.3 '],Point(205, 209), 1, 131072);
PrintOnSmart([
'Time Running: ' + TimeRunning,
'Animating: ' + booltostr(fighting),
'Banked: ' + inttostr(wentToBank) +' times',
''], Point(196, 255), 20, 131072);
end;
Procedure RandomCompassLeft;
begin
KeyDown(VK_Left);
Wait((526)+ Random(1000));
KeyUp(VK_Left);
end;
Procedure RandomCompassRight;
begin
KeyDown(VK_Right);
Wait((526)+ Random(1000));
KeyUp(VK_Right);
end;
Procedure RandomCompassDirection;
var c:integer;
begin
c := random(10);
case c of
0:RandomCompassLeft;
1:RandomCompassRight;
2:wait(1000+random(150));
end;
end;
procedure doAttack;
var x,y :Integer;
D: TPoint;
begin
D:= Point(MSCX, MSCY);
if not LoggedIn then terminatescript;
FindNormalRandoms;
fighting:=false;
printproggy;
MarkTime(MonsterTimer);
Repeat
if FindColorSpiralTolerance(D.x, D.y, Color1, MSX1, MSY1, MSX2, MSY2, tolerance) and not isFightAt(D.x,D.y) then
mmouse(D.x,D.y,1,1)
else
RandomCompassDirection;
if WaitUpTextMulti([monstername], 450) then
begin
GetMousePos(x,y);
mouse(x,y,0,0,true);
Flag;
clicked:=true;
end
else
randomCompassDirection;
Until (TimefromMark(MonsterTimer)> 60000) or (clicked = true)
if(timeFromMark(MonsterTimer) > 60000 ) then
begin
MyLoc:=sps_getMyPos;
if(distance(fightloc.x,fightloc.y,myLoc.x,myLoc.y) > 32) and InvContainsFood then
begin
sps_walkPath(thePath);
end;
end;
{ If (TimefromMark(Rotate)> 30000) then
begin
RandomCompassDirection;
End; }
end;
Procedure Loop;
begin
wentbank:=false;
wentToBank:=0;
MarkTime(PlayerTimer);
Repeat
if mustWeEat then
begin
if invContainsFood then
eat;
end;
if not invContainsFood then
begin
MyLoc:=sps_getMyPos;
if(distance(bankloc.x,bankloc.y,myLoc.x,myLoc.y) > 12) then
begin
wentBank:=true;
wentToBank:=wentToBank+1;
InvertTpa(thePath);
SPS_WalkPath(thePath);
InvertTpa(thePath);
end;
MyLoc:=sps_getMyPos;
if(distance(bankloc.x,bankloc.y,myLoc.x,myLoc.y) < 12) then
begin
if not(BankScreen) then begin
openBankNPC;
Withdraw(9, 0, 0);
end;
end;
end;
if wentBank=true and invContainsFood then
begin
MyLoc:=sps_getMyPos;
if(distance(fightloc.x,fightloc.y,myLoc.x,myLoc.y) > 16) and InvContainsFood then
begin
sps_walkPath(thePath);
end
else
wentbank:=false;
end;
if wentBank=false then begin
clicked:=false;
if pixelShift(AnimationBox,AnimTime) < shift then
DoAttack
else
fighting:=true;
end;
printproggy;
FindNormalRandoms;
PlayerSwitch;
until(false);
end;
Begin
AnimationBox:= IntToBox(boxX1, boxY1,boxX2, boxY2);
Smart_Server := 1;
Smart_Members := False;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
SPSstuff;
Declareplayers;
Mousespeed:=mSpeed;
loginplayer;
setAngle(true);
SetRun(true);
Loop;
End. Ok I had this idea about making a generic fighter with banking support, and wrote this up in less than an hour.
This is something that I don't see myself releasing to public due to the fact that its a bit tricky to setup, most likely you will have to play around with animation settings due to the fact that different weapons and shields got different animations and obviously, you have to set your own paths and areas. Oh, and have your food in top right corner of your bank.
It should theoreticly be able to fight anywhere thats accessible without going through an obstacle. It is currently set to fight falador guards at the south gate and use trout as food.
Give it a shot if you will, needless to say its still VERY early version, an can be a bit missclickish at times and has little to none failsafes.
Programming-wise its currently very ugly, I had this weird bug where it skipped a part of the loop for no reason, messing up with banking so I had to mutilate the loop and make it ugly. Not to mention the fact that my techniques are still mainly of the 2006 standard, but I'm looking forward to updating knowledge to meet the 2011 standards of making a color script, much has changed from the time I left color for bcel/reflection and most of all, Java. I will most likely end up rewriting pretty much the whole script, now that I've proven myself the idea in the basic form of it.

Pretty amazing results for a script of this sort written under an hour ? Something that wasn't really possible before SPS.
All hail SPS.