SRL Archive - Research & Development Lounge

Script can't decide between 2 of the same NPC's (Runescape).


brolly

2015-01-06 15:17:32

So when pick pocketing a "Paladin" on this Runescape server, the script is having issues choosing between which one to pick pocket. So I am wondering if there is a way to choose to only pickpocket one, so it doesn't go back and fourth. It works fine for the Guards, but for Paladin's there are two next to each other and it just goes back and fourth and can't decide which one to choose from.

[CODE]program Alotic_PickPocketer;
{$i srl-osr/srl.simba}

var
x, y, pickpocketbmp, loginscreenbmp, steals, xpgained, TimesStunned, relogs, Is_Relogger, Gems, bankbmp:Integer;
status, NpcString, username, password:string;

Function ReloggingInfo:Boolean;
Begin
Is_Relogger := MessageBox('Would you like to use the auto relogger?', 'Relogger', 4);
if (Is_Relogger = 6) then
Begin
Result := true;
InputQuery('Relogger', 'Username?', username);
InputQuery('Relogger', 'Password?', password);
End;

if (Is_Relogger = 7) then
Exit;
End;

Procedure NpcInput;
Begin
(InputQuery('Which Npc would you like to thief from?', 'Choices are (Man, Guard, GemStall, Hero, Paladin, Rogue, and Farmer)', NpcString));
ReloggingInfo;
End;

Procedure Loadthings;
Begin
PickPocketBMP := BitmapFromString(60, 7, 'meJyTUdeWUdeeuuMYEMlgsLEiggr' +
'IRiSZjEcxRApZFs7FKo5pFEFxUk3GoxGTjccNeHQRwybDZFxhjlUN' +
'nkAjj02eyeS5mVrhTIzJuBIYSTFIeXogw2RcCJc38XsKT1AQFCcys' +
'uAIADSz1FM=');

LoginScreenBMP := BitmapFromString(51, 6, 'meJyNUkEOwjAM64dAA7oV/r7H7L5' +
'PYGTiJilMmyLUBjtxnK7bXkq5za+pLuu2M3Ce5ieiZ3CtDcGzwZrH' +
'KPODGzO+SAfUdn0sHkNh1FPsIxG/vLKpiMoTJhbOwHCEwDVhHpkBn' +
'Lo2JSXs6xUjDkiYL+59+FzNPf31jxtYscLYEcIQ1El5NKfELxUMYm' +
'zR3e04u+eq+CjMWyphemnIjNw8qe3LZ7KGQe2BY6kjjdIqEZf7PK6' +
'D46eOfE4H7U6t0iqgmn/8b0QEW+E=');

BankBmp := BitmapFromString(77, 8, 'meJybuuOYjLo2EE3dcWwqjE0qIqi' +
'X4f9/ICLPcAqNhaiBuBDTnVjFkQUxxfH4F497kKUw2XCEqQVTCpd6' +
'iMMwY4Q8Np44hVuNy220ZmN1Nq6II+hNYlIXjbyJK5bxeJN2sUk7b' +
'5IRm2SzicmbA+VNgkUQ2d7H9CnW8gFPYiM+cRJjzrBHAE5Kh+4=');
End;

Function XpBarCheck:Boolean;
var
x, y:Integer;
Begin
if FindColorTolerance(x, y, 4293300, 423, 53, 505, 76, 5) then
Result := true;
End;

Procedure Freethings;
Begin
FreeBitmap(PickPocketbmp);
FreeBitmap(LoginScreenbmp);
FreeBitmap(BankBMP);
End;

Function FindXp:Boolean;
Begin
if FindColorTolerance(x, y, 26316, 447, 73, 515, 79, 5) then
Result := true;
End;

Procedure ClickPickPocket;
Begin

if (Not (FindBitmap(PickPocketBMP, x, y))) then
mmouse(345, 78, 30, 30);

if FindBitmap(PickPocketBMP, x, y) then
Begin
Mouse(x + 50, y, 1, 1, true);
End;
End;

Procedure Proggy;
var
Stealsperhour, xpperhour, XpRate:Integer;
Begin

if Lowercase(NpcString) = 'guard' then
XpRate:=558;

if Lowercase(NpcString) = 'guard' then
XpRate:=516;

if Lowercase(NpcString) = 'farmer' then
XpRate:=516;

if Lowercase(NpcString) = 'hero' then
XpRate:=3279;

if Lowercase(NpcString) = 'hero' then
XpRate:=438;

if Lowercase(NpcString) = 'paladin' then
Xprate:=1821;

if Lowercase(NpcString) = 'gemstall' then
Xprate:=1200;

ClearDebug;
xpgained := ((steals) * (XpRate));
StealsPerHour := round((steals)/(gettimerunning/3600000.0));
XpPerHour := round((xpgained)/(gettimerunning/3600000.0));
Writeln('****************Spotifys AIO Thiever*****************')
Writeln('-----------------------------------------------------')
writeln(' Time Running: '+ MsToTime(GetTimeRunning,3))
Writeln('-----------------------------------------------------')
writeln(' Total Steals: ' + inttostr(steals) + ' (' + inttostr(stealsperhour) + '/hour)')
Writeln('-----------------------------------------------------')
writeln(' Total Xp Gained: ' + inttostr(xpgained) + ' (' + inttostr(xpperhour) + '/hour)')
Writeln('-----------------------------------------------------')
writeln(' We have been stunned ' + inttostr(timesstunned) + ' time(s)')
Writeln('-----------------------------------------------------')
writeln(' Status: ' + (status))
Writeln('-----------------------------------------------------')
if (Is_Relogger = 6) then
Begin
writeln(' We have had to relog ' + inttostr(Relogs) + ' time(s)')
Writeln('-----------------------------------------------------')
End;
writeln(' Thieving From: ' + (NpcString))
Writeln('-----------------------------------------------------')
Writeln('*****************************************************')

End;

Procedure ProggyGemStall;
var
Stealsperhour, xpperhour, gemsperhour:Integer;
Begin
ClearDebug;
GemsPerHour := round((Gems)/(gettimerunning/3600000.0));
stealsperhour:= round((steals)/(gettimerunning/3600000.0));
xpperhour := round((xpgained)/(gettimerunning/3600000.0));
Writeln('****************Spotifys AIO Thiever*****************')
Writeln('-----------------------------------------------------')
writeln(' Time Running: '+ MsToTime(GetTimeRunning,3))
Writeln('-----------------------------------------------------')
writeln(' Gems Thieved: ' + inttostr(Gems) + ' (' + inttostr(GemsPerHour) + '/hour)')
Writeln('-----------------------------------------------------')
writeln(' Total Xp Gained: ' + inttostr(xpgained) + ' (' + inttostr(xpperhour) + '/hour)')
Writeln('-----------------------------------------------------')
writeln(' Status: ' + (status))
Writeln('-----------------------------------------------------')
if (Is_Relogger = 6) then
Begin
writeln(' We have had to relog ' + inttostr(Relogs) + ' time(s)')
Writeln('-----------------------------------------------------')
End;
writeln(' Thieving From: ' + (NpcString))
Writeln('-----------------------------------------------------')
Writeln('*****************************************************')
End;

Function Is_Moving: Boolean;
var
PBox: TBox;
begin
PBox := IntToBox(245, 130, 285, 195);
if (AveragePixelShift(PBox, 250, 500) > 1000) then
result := true;
end;

Function Not_Moving: Boolean;
var
PBox: TBox;
begin
PBox := IntToBox(245, 130, 285, 195);
if (AveragePixelShift(PBox, 250, 500) < 1000) then
result := true;
end;
Function IsInvFull:Boolean;
Begin
if FindColorTolerance(x, y, 131072, 690, 435, 721, 462, 5) then
Result := true;
End;

Function BankInSight:Boolean;
var
x, y:Integer;
Begin
if FindColorTolerance(x, y, 8040172, msx1, msy1, msx2, msy2, 5) then
Result := true;
End;

Procedure ClickMiniMapBanking;
var
x, y:Integer;
Begin
if FindColorTolerance(x, y, 61937, 542, 17, 705, 165, 5) then
Begin
Mouse(X, y, 1, 1, true);
Status := 'Running to bank';
ProggyGemStall;
Wait(1000);
WaitFunc(@Not_Moving, 100, 8000);
End;
End;

Function IsBankOpen:Boolean;
var
x, y:Integer;
Begin
if FindColorTolerance(X, y, 4106994, 253, 31, 293, 42, 3) then
Result :=true;
End;

Procedure DepositGems;
Begin
Status := 'Depositing gems';
ProggyGemstall;
Mouse(400, 308, 3, 3, true);
Mouse(490, 34, 0, 0, true);
End;

Procedure ToGemStall;
var
x, y, WalkTime:integer;
Begin
Mouse(544, 24, 0, 0, true);
KeyDown(38);
Begin
if FindColorTolerance(x, y, 7039987, 542, 17, 705, 165, 5) then
Begin
Mouse(x, y, 0, 0, true);
Wait(1500);
KeyUp(38);
Status := 'Back to gem stall';
ProggyGemStall;
MarkTime(WalkTime);
Repeat
Wait(100);
until((not (Is_Moving)) or (TimeFromMark(WalkTime) > 8000));
End;
End;
End;

Procedure GemBankingRepeat;
var
x, y, c, d:Integer;
Begin
if (IsInvFull) then
Begin
ClickMinimapBanking;
if FindColorTolerance(x, y, 6590146, msx1, msy1, msx2, msy2, 15) then
Begin
MoveMouse(x, y);
Wait(25);
if IsUpText('alk-') then
Begin
ClickMouse(x, y, 0);
Wait(100);
if FindBitMap(BankBMP, c, d) then
Begin
Mouse(x + 20, y, 0, 0, true);
WaitFunc(@IsBankOpen, 250, 5000);
DepositGems;
ToGemStall;
Exit;
End;
End;
End;
End;
End;

Procedure RightClickBank;
var
x, y:Integer;
Begin
if FindBitMap(BankBMP, x, y) then
Begin
Mouse(x + 20, y, 0, 0, true);
WaitFunc(@IsBankOpen, 250, 5000);
DepositGems;
ToGemStall;
Exit;
End;

if (Not (FindBitMap(BankBMP, x, y))) then
Begin
mmouse(77, 77, 30, 30);
GemBankingRepeat;
Exit;
End;

End;



Procedure GemBanking;
var
a, b, Looktime:Integer;
Begin
if (IsInvFull) then
Begin
ClickMinimapBanking;
Status := 'Looking for banker';
ProggyGemstall;
MarkTime(LookTime);
Repeat
KeyDown(37);
Until((FindColorTolerance(a, b, 8040172, msx1, msy1, msx2, msy2, 10)) or (TimeFromMark(LookTime) > 7500));
KeyUp(37);
if FindColorTolerance(a, b, 8040172, msx1, msy1, msx2, msy2, 10) then
Begin
MoveMouse(a, b);
Wait(50);
if IsUpText('alk-') then
Begin
Status := 'Opening bank';
ProggyGemstall;
ClickMouse(a, b, 0);
Wait(100);
RightclickBank;
End;

if (Not (IsUpText('alk-'))) then
GemBanking;
End;
End;
End;

Procedure ThiefGemStall;
Begin
if FindObjCustom(x, y, ['5Ieal', 'from', 'eal-'], [3476363], 5) then
Begin
Status := 'Thieving';
ProggyGemStall;
Mouse(x, y, 3, 3, true);
WaitFunc(@FindXp, 25, 6000);

if (IsInvfull) then
Begin
Status := 'Banking';
ProggyGemStall;
Repeat
Wait(10);
Until(FindColorTolerance(x, y, 61937, 542, 17, 705, 165, 5));
GemBanking;
End;

if (FindXp) then
Begin
IncEx(Gems, 1);
IncEx(XpGained, 1200);
ProggyGemStall;
End;

End;
End;

Procedure PickPocketMan;
var
x, y:Integer;
Begin
Mouse(615, 21, 3, 3, true);
KeyDown(38);
Wait(1500);
KeyUp(38);
if FindColorSpiralTolerance(X, y, 1258082, msx1, msy1, msx2, msy2, 5) or
FindColorSpiralTolerance(X, y, 5718851, msx1, msy1, msx2, msy2, 5) then
Begin
Mmouse(x, y, 0, 0);
Wait(100);
if FindColor(x, y, 65535, 1, 1, 103, 32) then
Begin
ClickMouse(x, y, 0);
Wait(200);
ClickPickPocket;
ProggyGemStall;
Wait(1100);
End;
End;
End;

Procedure Stunned;
Begin
if FindChatBoxText(')ou Dave', 8, clBlack) or
FindChatBoxText('You', 8, clBlack) or
FindChatBoxText('stunne', 8, clBlack) or
FindChatBoxText(')ou are', 8, clBlack) then
Begin
Status := 'Stunned!';
IncEx(TimesStunned, 1);
Proggy;
Wait(5000);
End;
End;

Function Is_Logged_Out:Boolean;
Begin
if (FindBitmap(Loginscreenbmp, x, y)) then
Result := true;
End;

Procedure LogBackIn;
Begin
if (Is_Logged_Out) then
Begin
Wait(1000);
Mouse(333, 187, 0, 0, true);
Wait(250);
TypeSend(Username);
Mouse(339, 235, 0, 0, true);
Wait(250);
TypeSend(Password);
Mouse(382, 276, 0, 0, true);
Wait(10000);
KeyDown(38);
Wait(1500);
KeyUp(38);
IncEx(Relogs, 1);
if (Not (XpBarCheck)) then
Mouse(533, 60, 0, 0, true);
End;
End;

Procedure PickPocketNPC;
var
x, y, colorcode, colorcode2:Integer;
Begin

if Lowercase(NpcString) = 'guard' then
ColorCode:=2447139;

if Lowercase(NpcString) = 'hero' then
ColorCode:=12293239;

if Lowercase(NpcString) = 'paladin' then
ColorCode:=16312824;

if Lowercase(NpcString) = 'rogue' then
ColorCode:=8039915;

if Lowercase(NpcString) = 'man' then
ColorCode :=1125462;
ColorCode2 :=5390143;

Mouse(541, 24, 3, 3, true);
KeyDown(38);
Wait(1500);
KeyUp(38);
repeat
repeat
KeyDown(37);
if (Is_Relogger = 6) then
LogBackIn;
until(FindColorTolerance(X, y, Colorcode , msx1, msy1, msx2, msy2, 5));

Begin
KeyUp(37);
if FindObjEx(X, y, ['AIIack', 'AII', 'ack'], [ColorCode], 5, 50, 84, 71, 447, 291) then
Begin
MoveMouse(X, y);
Wait(10);
ClickMouse(X, y, 0);
Wait(100);
ClickPickPocket;
WaitFunc(@FindXp, 50, 3500);
Stunned;

if FindXp then
Begin
IncEx(Steals, 1);
Wait(100);
End;


Status := 'Thieving';
Proggy;
End;
End;
until(Iskeydown(113));
End;

Procedure PickPocketFarmer;
var
x, y:Integer;
Begin
Mouse(541, 24, 3, 3, true);
KeyDown(38);
Wait(1500);
KeyUp(38);
repeat
repeat
KeyDown(37);
if (Is_Relogger = 6) then
LogBackIn;
until(FindColorTolerance(X, y, 4280125 , msx1, msy1, msx2, msy2, 5));

Begin
KeyUp(37);
if FindObjEx(X, y, ['pickpocke', 'ickpoc', 'pocke'], [4280125, 2897193], 5, 50, 96, 67, 488, 273) then
Begin
MoveMouse(X, y);
Wait(10);
ClickMouse(X, y, 1);
WaitFunc(@FindXp, 50, 3000);
Stunned;
Status := 'Thieving';
if FindXp then
IncEx(Steals, 1);
Proggy;
End;
End;
until(Iskeydown(113));
End;

Procedure NpcToPickpocket;

Begin

if Lowercase(NpcString) = 'man' then
PickPocketMan;

if Lowercase(NpcString) = 'guard' then
PickPocketNPC;

if Lowercase(NpcString) = 'hero' then
PickPocketNPC;

if Lowercase(NpcString) = 'paladin' then
PickPocketNPC;

if Lowercase(NpcString) = 'rogue' then
PickPocketNPC;

if Lowercase(NpcString) = 'gemstall' then
ThiefGemStall;

if Lowercase(NpcString) = 'farmer' then
PickPocketFarmer;

End;

begin
MouseSpeed := 15;
LoadThings;
Addonterminate('Freethings');
Cleardebug;
MessageBox('Hello! Welcome to Spotifys AIO Alotic Thiever, please fill out the required information in the boxes that pop up. Post any bugs or suggestions on the thread, thank you and enjoy!', 'Spotifys AIO Alotic Thiever', 1);
NpcInput
if (Not (XpBarCheck)) then
Mouse(533, 60, 0, 0, true);
Proggy;
Repeat
NpcToPickpocket
until(iskeydown(113));
end.[/CODE]

Verfy

2015-03-03 09:13:38

If you were using lape reflection you could get his location by ID. I'm not sure this would work 100% but I think every object even tho it's the same has different ID number. But in your case you should try checking the distance from paladin and choose the closest one or limit the bot to only click the one that's on certain location around certain tile or something like that. I don't know how ors performs doing things like that because I'm not using it anymore. I really reccommend looking at lape reflection if you didn't already :) Hope I helped you, I'm not really the master of this but I did my best.

the bank

2015-03-03 09:59:46

From: magicalll
If you were using lape reflection you could get his location by ID. I'm not sure this would work 100% but I think every object even tho it's the same has different ID number. But in your case you should try checking the distance from paladin and choose the closest one or limit the bot to only click the one that's on certain location around certain tile or something like that. I don't know how ors performs doing things like that because I'm not using it anymore. I really reccommend looking at lape reflection if you didn't already :) Hope I helped you, I'm not really the master of this but I did my best.


Nope. Everything doesn't have a different ID, if its the same thing it has the same ID, therefore none of that helps the OP at all.

@OP

Build a TPA from the return of the color searching, and then sort that tpa using yourTPA.sortFromPoint(mainScreen.playerPoint) or something along those lines. That will make the first indicie of your TPA equal to the point of the closest paladin.

King

2015-03-03 11:27:46

You cannot really differentiate from two of the exact same character with color. However, you can sort from the player using TPA functions. Another way to do it if they do not move around too much, would be to create a TPA box around the paladin and then use that box to each within using setbounds for the TPA/ATPA. However that would not work if it moves around. Do you just want the closest? Do you want a specific paladin?

Turpinator

2015-03-03 12:02:47

1) this guy hasnt been active in 2 weeks.
2) this is for a RSPS, so reflection wont work.