SRL Archive - OSR Help

Can't get worldhopper to make the 'jump'


i_liek2feesh

2013-03-16 05:34:43

So I have a world hopping procedure that works just fine, until I hit a break in the world numbers (306 to 309, 314 to 317, etc.)
Procedure WorldHop;
var
CWorld:integer;
Begin
CWorld:= CurrentWorldLS;
If (FullWorld(CWorld+1)) then
begin
SelectWorld(CWorld+2)
end else
SelectWorld(CWorld+1);
End;

Basically what will happen is it will hit 306 and the script will stop and ** Warning in SelectWorld: Invalid World ** shows up in the debug box. Anyone know how to get around this little problem. Thanks.

Edit: Forgot to mention I'm using the OSR worldswitcher https://raw.github.com/SRL/SRL-OSR/master/SRL/core/worldswitcher.simba

i_liek2feesh

2013-03-16 07:07:05

Well I'm using the OSR worldswitcher https://raw.github.com/SRL/SRL-OSR/master/SRL/core/worldswitcher.simba
function SelectWorld(W: integer): boolean;
var
i,t: integer;
validworld : boolean;
worldbox: tbox;
begin
result := currentworldls = w;
if result then
exit;

if Length(WorldArray) < 1 then
worldarray :=
[301,320,341,360,+
302,321,342,361,+
303,322,343,362,+
304,325,344,365,+
305,326,345,366,+
306,327,346,367,+
309,328,349,368,+
310,329,350,369,+
311,330,351,370,+
312,333,352,373,+
313,334,353,374,+
314,335,354,375,+
317,336,357,376,+
318,337,358,377,+
319,338,359,378];
for i:=0 to high(worldarray) do
begin
if worldarray[i]=W then
begin
arraynumber := i;
validworld := true;
break;
end
end;

if not validworld then
begin
srl_Warn('SelectWorld', 'Invalid World', warn_AllVersions);
ExitWorldScreen;
Exit;
end;

if OpenWorldScreen then
begin
worldbox:= FindWorld(I);
if worldbox.x1 = 0 then
begin
ExitWorldScreen;
exit;
end;
mousebox(worldbox.x1,worldbox.y1,worldbox.x2,worldbox.y2,mouse_left);
result:=true;
end;

marktime(t);
repeat
wait(randomrange(400,500));
if timefrommark(t)>6000 then
begin
ExitWorldScreen;
exit;
end;
until not worldscreen;

wait(randomrange(400,500));
if (not(Result)) then TypeByte(vk_Escape);
end;

But anyways I was thinking that I could use it as a function, write another one that would compensate for the the jump (+3/+4 instead of +1/+2). But then I have no idea how I would write a new world hopper that would differentiate between which one it would call. Like I've tried setting it up as a case, but it wouldn't work.

Or is there a way that I can get it to go to the next unfull/valid world. I doubt that something as simple as SelectWorld(Next) would work. lol

Ashaman88

2013-03-16 08:47:16

worldarray is an array - just have it select the next world in the array. Don't have time to write out the code but it would be something like worldarray[currentworldarraynumber+1]. It gives you the invalid thing b/c there are some worlds that don't exist in 07 (there are a few skips in the world number)

i_liek2feesh

2013-03-17 02:35:52

From: Ashaman88
worldarray is an array - just have it select the next world in the array. Don't have time to write out the code but it would be something like worldarray[currentworldarraynumber+1]. It gives you the invalid thing b/c there are some worlds that don't exist in 07 (there are a few skips in the world number)

Procedure WorldHop;
var
currentworldarraynumber:integer;
worldarray: array [0..59] of integer;
begin
If (FullWorld(worldarray[currentworldarraynumber+1])) then
Begin
SelectWorld(worldarray[currentworldarraynumber+2])
end else
SelectWorld(worldarray[currentworldarraynumber+1]);
end;
So something like that? Because I keep running into the same error. should I be declaring currentworldarraynumber as something different?

mmmvvvbbb

2013-03-17 10:56:49

I made my own that is not as sophisticated but it works all the same. It doesn't use actual world numbers because that is unimportant, it just goes to the next world. No failsafe, so i just set it to go world 10-63 because they are never full.
procedure World;
begin
mmouse(62,482, 5, 5);
ClickMouse2(mouse_left);
writeln('winning');
worldnum := worldnum+1
if (worldnum < 19)then
mmouse(245, (260+(worldnum-11)*25),0,0);
wait(200);

if ((worldnum <34) and (worldnum > 18)) then
mmouse(330, (88+(worldnum-19)*24),0,0);
wait(200);
if ((worldnum <49) and (worldnum > 33)) then
mmouse(420, (88+(worldnum-34)*24),0,0);
wait(200);
if ((worldnum <64) and (worldnum > 48)) then
mmouse(515, (88+(worldnum-49)*24),0,0);
wait(200);
if (worldnum > 63) then
begin
worldnum := 10
World;
end;
wait(200);
ClickMouse2(mouse_left);
writeln(inttostr(worldnum));
end;
If you wanted random world just change worldnum := 1+worldnum to worldnum := randomrange(10,63)
I know this is probably not the best way to do things, but it works.

hsxu

2013-03-19 11:08:56

Deleting the normal high population worlds (1, 2, 5, 6, 9, 10 and whatever else) out of the worldarray would be a effective but temporary fix

Edit: Nvm, I thought you were talking about skipping full worlds. Selecting the next element in the array should fix your problem:
You can declare worldarray as a global variable and then do this:

Procedure WorldHop;
var
WorldArrayIndex:integer;
begin
WorldArrayIndex:= 0;

repeat
If (FullWorld(worldarray[WorldArrayIndex+1])) then
SelectWorld(worldarray[WorldArrayIndex+2])
else
SelectWorld(worldarray[WorldArrayIndex+1]);

WorldArrayIndex := WorldArrayIndex + 1;
until (WorldArrayIndex = high(worldarray))
end;

This would enumerate through all the array once, if you wanted to do it again just set another loop around it.