SRL Archive - OSR Help

Anyway to do this?


Riley

2013-04-16 18:09:06

I'm trying to make a fail safe where if its not doing an action for less than a 30 seconds it teleports. I have the code for the teleport function thanks to Sjoe. I've been tweeking it but i can never get a fail safe to work like this. here is the code for.



Gametab(tab_magic);
Wait(500);
MouseBox(658, 325, 674, 342, mouse_left);
Wait(2000 + Random(500));
MouseBox(230, 423, 288, 435, mouse_left);

Le Jingle

2013-04-16 18:44:24

You could have a global variable of type Integer that marks the time after/before an action/event is executed and then check throughout the script if that variable is ever over 30000 ms (30 seconds). This way as long as the timer keeps being reset, it should continue executing x action(s) - in theory of course.

Riley

2013-04-16 20:09:40

I'm a very big noob when it comes to scripting, care to explain that?

rj

2013-04-16 20:12:30

Do you mean checking if the player is no longer teleporting or not in a area? why would the player stop teleporting? If they are in the wrong area you could count a fiew colors on the minimap using the countcolortolerance function

You can do a timeout failsafe like

Marktime(t)
if (Timefrommark(t)>30000) then
blah blah

Riley

2013-04-16 21:49:26

No, its stealing. I want to make a fail safe for when it hasnt found or stole for like 30 seconds then it teleports (In case it walked away)

Haxz

2013-04-16 21:56:01

Check inventory count. If inventory count still same as 30 seconds ago, teleport.

serajin

2013-04-16 22:22:28

I think you'd be better off with using Pixelshift, to check movement of your character. You'd test to make sure your character is "moving" or performing an action. And if the pixel shift stays under a certain number for too long, you know you've been stuck too long.

Or the inventory thing. That may work assuming you are stealing a tangeable item that will add a slot to your inventory.

Third, the MarkTime will work as well. You simply have to mark a global time variable at the beginning of your Steal procedure. And then you just check it at a later point. This way it will reset your timer each time you successfully attempt a steal action.

Wu-Tang Clan

2013-04-16 22:28:34


procedure lalala;
var
t:integer;
begin
t := (getSystemTime + 30000);
dowutever;
if (getSystemTime > t) then
tele;
end;

Did it in browser but thats what I use

Riley

2013-04-18 14:38:03

How would i implement that?

Enslaved

2013-04-18 17:28:27

code atm? if its private, paste snipplets of where relevant

samerdl

2013-04-18 17:51:57

From: Enslaved
code atm? if its private, paste snipplets of where relevant


By using Marktime these are your main commands:


marktime(t);
repeat
(Look at the example code)
until(TimeFromMark(t) > 30000);
~
~ * Look at example*
~
if (TimeFromMark(TT) >= Twait2) then
begin to unstuck…
…..
….


If its hard for you to read this, then open it from this pastebin link: http://pastebin.com/xa1ps42G simply go on that site click on Raw and copy paste the code to simba. Note it wont compile, you have to do that, but this is what i use for my script, basically add the unstuck procedure to main loop and it only starts if its actually lost.


program StallStealer;

{$DEFINE SMART8}
{$I SRL-OSR/SRL.Simba}

var
x,y:integer; //anything that keeps the script stable and its always there undisrupted then add it...
checkifstuckicon,Foundmynpc,foundthestall,FoundthisFailsafeicon: boolean; // you can add as many icon/colors/objects whatever you want to add to the list as boolean functions.


procedure playersetup;
begin
//playername,pw etc.. all info
end;

procedure StealFromStall;
begin
//if find this npc, or this icon on the mini map, then right click stall.. steal then drop if inv full etc.. do whatever here. this is the heart of your script.
end;

function Checkifstuckicon: Boolean;
var
Minimapicon:TpointArray;
begin
if (FindBitmapToleranceIn(Minimapicon,X,y,MIX1, MIY1, MIX2, MIY2, 10)) then // I gave an example as a Bitmap, but you can use Colors and Tpoint Arrays or objects.. It all leads to the same desired result
begin
Safe := true;
result := true;
end
else
begin
Safe := False;
result := false;
end;
end;

procedure TelePort;
begin
Gametab(tab_magic);
Wait(500);
MouseBox(658, 325, 674, 342, mouse_left);
Wait(2000 + Random(500));
MouseBox(230, 423, 288, 435, mouse_left);
end;

//if find this icon that is ALWAYS on the minimap (be it a bank icon or some unique color dot/area/wall etc.. anything thats always there that can be used as a fail to KNOW your still at the right spot
//we'll start a mark time, and the script will exit it when ever it KNOWS its not lost/doesnt need to tele, so everytime it finds our Fail Safe objects/colors it will exit the count and continue with the main loop. Now if 30 seconds have passed and it still didn't find the Stable icons on our screen, it will start to unstuck. (its better to do marktime(tt), a second marktime for the unstuck phase, if that doesn't solve it and it still cant find the icons, then it will terminate.

procedure checkifstuck;
begin
marktime(t);
repeat
if (Checkifstuckicon) then
exit;
if (Checkifstuckicon2) then
exit;
if (not(loggedin)) then
exit;
FindnormalRandoms; // This wilL Find random events if you get any!
until(TimeFromMark(t) > 30000);
if (Checkifstuckicon) then
exit;
if (Checkifstuckicon2) then
exit;
if (not(loggedin)) then
exit;
Findnormalrandoms;
if (TimeFromMark(T) >= Twait1) then
begin
TelePort;
wait(randomrange(5000,10000);
if (Checkifstuckicon) then
exit;
if (Checkifstuckicon2) then
exit;
if (not(loggedin)) then
exit;
//So this is second failsafe now, if it teleports or tries to teleport and it still cant find the area, then we'll make it terminate
if (not(CheckifstuckIcon)) or (not(CheckifStuckicon2)) then
begin
Writeln('we are lost, we have teleported and still cant find the area, maybe we got stuck in a random event, time to terminate');
terminatescript;
end;
end;
end;

procedure mainloop;
begin
repeat
StealfromStall;
checkifstuck;
until (not(loggedin));
end;


begin
setupsrl;
playersetup;
repeat
mainloop;
until (not(loggedin))
if not (loggedin) then
loginplayer;
end.

Riley

2013-04-18 17:56:39

program PickSilk;
{$i SRL-OSR/SRL.simba}
Function GreenRandom: Boolean; //detects random
begin
Result := (CountcolorTolerance(1007173, 552, 4, 697, 152, 13) > 10000);
end;
// if we count more than 10k green pixels, we are in random.

function LeftGreenRandom:Boolean;
begin
if (not CountcolorTolerance(1007173, 552, 4, 697, 152, 13) > 10000) then
Result := True;
end;




function RandomSolver: Boolean;
begin
Gametab(tab_magic);
Wait(500);
MouseBox(658, 325, 674, 342, mouse_left);
Wait(2000 + Random(500));
MouseBox(230, 423, 288, 435, mouse_left);
if WaitFunc(@LeftGreenRandom, 100, 8000) then
Writeln('Left the random');
end;

function StealFromStall: Boolean;
var
x, y: Integer;
begin
if FindObjCustom(x, y, ['Gem', 'stall'], [2557811], 7) then
begin
Writeln('Found Gems') // debug
Mouse(x, y, 3, 3, true); // leftclicking :)
Result := True;
Wait(2500);
Exit;
end;
end;


begin
SetupSRL;
ActivateClient;
repeat
if (GreenRandom = True) then RandomSolver;
StealFromStall
until(false);

end.




Thats the code, im thinking about getting rid of the random solver, with a wait time then if it hasnt done the action in like 30-40 seconds it teleports.