SRL Archive - Outdated / Broken

World switching with RC


Markus

2007-05-23 12:36:50

When I watch a script running in my VM, I often want it to switch worlds. Sometimes because the world is too crowded, and sometimes because of stupid people saying things and stuff.
Now that we have the new worldswitcher, it is much easier to switch worlds with SCAR.
What about a command in RC like "switch world 14", and then it will logout and switch to world 14.

Smartzkid

2007-05-23 12:59:15

I like that idea…

~alex~

2007-05-23 13:22:51

That wouldn't be hard to impletment… I might give it a go.

Boreas

2007-05-23 14:20:11

I like too, not sure how to approach though. This would at the very least need a global boolean AutoColorDone or something, and scripts that support this would have to involve that.

Edit: I assuming colors change?

shaunthasheep

2007-05-23 14:48:49

yes. im pretty sure All colors change when a new applet is loaded… some stay the same afterwords.. others change dynamically after every loading screen.

Markus

2007-05-23 16:08:14

The builtin worldswitcher doesn't reload the applet, it only changes some variables that determine to which server it connects as far as I know.

shaunthasheep

2007-05-23 16:52:48

it only will reload the applet if

your switch from a Free World To Member World
your switch from a Member World To Free World

Free to Free And Member To Member worlds don't reload the applet.

Boreas

2007-05-23 22:23:38

Ah in that case, get to work Fawki! :p

Bobarkinator

2007-05-23 23:15:35

From: Boreas
Ah in that case, get to work Fawki! :p


You're dev also!!

Unless RC is Fawki's thing.

Boreas

2007-05-23 23:26:25

Well Fawki made RC and I think the WS.scar, and I'm busy with B4, soo…

me_ntal

2007-05-24 00:20:17

I was also thinking about a simple home teleport command would be helpful for a few scripts.

Markus

2007-05-24 13:25:39

I made it, replace RC.scar with this:


//----------------------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ยป Remote Control Routines Beta --//
//----------------------------------------------------------------------------//
// * function RCReadCommand: String; // * by WT-Fakawi
// * procedure RCMakeNick; // * by WT-Fakawi
// * function RCFindMaster(var Mx, My: Integer; X1, Y1, X2, Y2: Integer): Boolean; // * by WT-Fakawi
// * function RCHowManyOnline: Integer; // * by WT-Fakawi
// * function RCFindFriend: String; // * by WT-Fakawi
// * function RCPrivateMessageColorFound: Boolean; // * by WT-Fakawi
// * function ReturnStatus: String; // * by WT-Fakawi
// * procedure RCResetStatus; // * by WT-Fakawi
// * function RC: Boolean; // * by WT-Fakawi

{.include srl/srl/misc/worldswitcher.scar}


{ var RCMaster: String;
Description: Master Player (Controller) User Nick. }
var
RCMaster, RCLoc: string;

{ var MasterBitMapMask, RCTimeMark: Integer;
Description: Variables used in the Remote Control include. }
var
MasterBitMapMask, RCTimeMark: Integer;

const
RCStatus = 'status'; // commands the RCMaster types.
RCReset = 'reset'; // may be replaced by anything less suspicious
RCStop = 'stop';
RCLogOut = 'logout';
RCswitchworld = 'goto world';

{*******************************************************************************
function RCReadCommand: String;
by: WT-Fakawi
Description: Returns string of red typed message (color 128)
*******************************************************************************}

function RCReadCommand: string;
begin
Result := LowerCase(Trim(GetTextAtEx(20, 415, 45, SmallChars, False, False, 0,
2, 128, 45, False, tr_NormalChars)));
end;

{*******************************************************************************
procedure RCMakeNick;
by: WT-Fakawi
Description: Creates MasterBitMapMask for recognisition
*******************************************************************************}

procedure RCSetNick;
begin
MasterBitMapMask := CreateBitmapMaskFromText(RCMaster, smallChars);
end;

{*******************************************************************************
function RCFindMaster(var Mx, My: Integer; X1, Y1, X2, Y2: Integer): Boolean;
by: WT-Fakawi
Description: Finds MasterBitMapMask (Master Name) and returns its coordinates
in Mx and My.
Could be usefull also for friend-finding.
*******************************************************************************}

function RCFindMaster(var Mx, My: Integer; X1, Y1, X2, Y2: Integer): Boolean;
begin
Result := FindBitmapMaskTolerance(MasterBitMapMask, Mx, My, X1, Y1, X2, Y2,
50, 10)
end;

{*******************************************************************************
function RCHowManyOnline: Integer;
by: WT-Fakawi
Description: Returns the number of online Friends.
*******************************************************************************}

function RCHowManyOnline: Integer;
var
i, frX, frY, incY: Integer;
begin
for i := 1 to 12 do
begin
if FindColor(frX, frY, 65280, 667, 235 + incY, 672, 243 + incY) or
// green - same world
FindColor(frX, frY, 65535, 667, 235 + incY, 672, 243 + incY) then
// yellow - different world
Result := Result + 1;
incY := incY + 15;
end;
end;

{*******************************************************************************
function RCFindFriend: String;
by: WT-Fakawi
Description: Returns the name of the First Friend in the FriendList
*******************************************************************************}

function RCFindFriend: string;
begin
Result := LowerCase(Trim(GetTextAtEx(562, 233, 45, SmallChars, True, False, 0,
2, 16777215, 20, False, tr_NormalChars)));
end;

{*******************************************************************************
function RCPrivateMessageColorFound: Boolean;
by: WT-Fakawi
Description: Returns True if Color 128 (red) was found in ChatWindow.
*******************************************************************************}

function RCPrivateMessageColorFound: Boolean;
var
dumX, dumY: Integer;
begin
Result := FindColor(dumX, dumY, 128, MCX1, MCY1, MCX1 + 30, MCY2);
end;

{*******************************************************************************
function ReturnStatus: String;
by: WT-Fakawi
Description: Returns a concatenated string with the False Player Names.
If you feel this is too suspicious, use Players.nick (recommended)
*******************************************************************************}

function RCReturnStatus: string;
var
i: Integer;
var
PlayersString: string;
var
oneFalse: Boolean;
begin
for i := 0 to HowManyPlayers - 1 do
begin
if Players[i].Active = False then
begin
Insert(Players[i].Name, PlayersString, 0);
// insert(Players[i].Nick,PlayersString,0);
Insert(' ', PlayersString, 0);
oneFalse := True;
end;
end;
Result := PlayersString;
if not oneFalse then Result := 'Everything is cool.';
WriteFileString(TheFile, TheTime + ' ' + '********** RC STATUS: ' +
PlayersString + Chr(13));
end;

{*******************************************************************************
procedure RCResetStatus;
by: WT-Fakawi
Description: Resets the Status of ALL Players to True
*******************************************************************************}

procedure RCResetStatus;
var
i: Integer;
begin
for i := 0 to HowManyPlayers - 1 do
begin
if Players[i].Active = False then
begin
Players[i].Active := True;
if RCLoc <> '' then
Players[i].Loc := RCLoc;
end;
end;
WriteFileString(TheFile, TheTime + ' ' + '********** RC RESET ' + Chr(13));
end;

{*******************************************************************************
function RC: Boolean;
by: WT-Fakawi
Description: High Level Remote Control Command. Handles Remote Control.
Works as follows:
Checks for existence of red color in chat window.
If red color is found, it checks for the existence of the MasterBitMapMask.
If found it waits 60 seconds for pm "status" or pm "reset".
Then RC sleeps five minutes to get rid of the red text.
*******************************************************************************}

function RC: Boolean;
var
Masx, Masy, RCMark, world : Integer;
RCcommand : string;
begin
if ( Trim(RCMaster) = '') then Exit;
if RCPrivateMessageColorFound then // check for Color 128
begin
Result := True;
if TimeFromMark(RCTimeMark) > 300000 then // check once every five minutes
// if TimeFromMark(RCTimeMark) > 300 then // check once every five minutes
begin
MasterBitMapMask := CreateBitmapMaskFromText(RCMaster, smallChars);
MarkTime(RCTimeMark);
SetChat('off', 1);
if RCFindMaster(Masx, Masy, MCX1, MCY1, MCX2, MCY2) then
// check for MasterBitMapMask
begin
MarkTime(RCMark);
GameTab(8);
if RCHowManyOnline <> 0 then
begin
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend('hi');
repeat // wait 60 secs for command
if RCReadCommand = RCStatus then
begin
Wait(1000 + Random(500));
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend(RCReturnStatus);
SetChat('on', 1);
SetChat('on', 1); // hmm lets fix that :)
FreeBitmap(MasterBitMapMask);
Exit;
end;
if RCReadCommand = RCReset then
begin
GameTab(8);
Wait(1000 + Random(500));
RCResetStatus;
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend('reset');
SetChat('on', 1);
SetChat('on', 1);
FreeBitmap(MasterBitMapMask);
Exit;
end;
if RCReadCommand = RCLogout then
begin
Logout;
FreeBitmap(MasterBitMapMask);
Exit;
end;
if RCReadCommand = RCStop then
begin
TerminateScript;
end;
if (pos(RCswitchworld, lowercase(rcreadcommand)) <> 0) then // Is the rccommand there?
begin
RCcommand := lowercase(rcreadcommand);
Delete(RCcommand, pos(RCswitchworld, lowercase(rcreadcommand)), length(rcswitchworld));
while (RCcommand[1] = ' ') do
delete(RCcommand, 1, 1); //Delete all spaces
while (RCcommand[length(RCcommand)] = ' ') do
delete(RCcommand, length(RCcommand), 1); //Same as above.
try
world := strtoint(RCcommand);
except
writeln('RC: the world we should switch to is not an integer!');
exit;
end;
Gametab(8);
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
case random(3) of
0 : typesend('Ok! Hopping to world ' + inttostr(world) + ' now.');
1 : typesend('When you say world ' + inttostr(world) + ' then I go to world ' + inttostr(world));
2 : typesend('Whatever you wish, you are the Runescape expert.');
end;
wait(100 + random(1000));
logout;
wait(1000 + random(500));
SelectWorld(world);
loginplayer;
end;
Wait(1000);
until (TimeFromMark(RCMark) > 20000);
end;
end
SetChat('on', 1);
SetChat('on', 1);
FreeBitmap(MasterBitMapMask);
end;
end;
end;
It is fully functional, tested it with Wizzups VEM, my army was in a busy world, but when I said goto world 14 it went to world 14.

Just say goto world *worldno* and it should work fine.

Abyssal

2007-05-24 17:00:23

Very nice, I like it!

RAM

2007-05-24 23:00:47

Markus, I like your ingenuity, But why did you amend to an existing function, rather then create a new 1 ? Not that I can foresee it causing any problems, just curious? RAM

Markus

2007-05-25 00:47:11

I extended the existing RC so it works with any script that supports RC.
If I created a new function I had to make many changes to the script I want to use it in.