SRL Archive - SRL Archives

construction.scar


Awkwardsaw

2009-07-03 08:37:59

hobbit told me to post these ;)

yes i know most of these are simple, and any one that knows how to script can do 'em, but no one has so far(that im aware of) :p


{*******************************************************************************
function inhouseoptions: boolean;
By: akwardsaw
Description: It simply checks if your in the house options.
*******************************************************************************}
function inhouseoptions: boolean;
begin
result:= (getcolor(653, 280) = 2070783)
end;

{*******************************************************************************
procedure Houseoptions(onoroff: boolean);
By: akwardsaw
Description: It either turns house options on, or off. true = on.
*******************************************************************************}
procedure Houseoptions(onoroff: string);
begin
gametab(11);
case onoroff of
true: begin
case random(3) of
0..1: mousebox(685, 417, 711, 442, 1);
2: begin
mousebox(685, 417, 711, 442, 2);
chooseoption('Open House Options');
end;
end;
while not getcolor(657, 283) = 2070783 do wait(10 + random(30));
end;
false: case random(3) of
0..1: mousebox(714, 226, 728, 240, 1);
2: begin
mousebox(714, 226, 728, 240, 2);
chooseoption('Close');
end;
end;
end;
end;

{*******************************************************************************
procedure buildingmode(onoroff: boolean);
By: akwardsaw
Description: It either turns building mode on, or off. must be in house options
*******************************************************************************}
procedure buildingmode(onoroff: string);
begin
if not inhouseoptions then Houseoptions('on');
case onoroff of
true: mousebox(657, 283, 602, 298, 1);
false: mousebox(655, 300, 682, 325, 1);
end;
end;

{*******************************************************************************
procedure leavehouse;
By: akwardsaw
Description: It leaves the house. must be in house options
*******************************************************************************}
procedure leavehouse;
begin
if not inhouseoptions then Houseoptions('on');
mousebox(563, 384, 718, 408, 1);
end;

{*******************************************************************************
procedure almostleavehouse;
By: akwardsaw
Description: It almost leaves the house, just like almostlogout, almost logs out. must be in house options
*******************************************************************************}
procedure almostleavehouse;
var a, b: integer;
begin
if not inhouseoptions then Houseoptions('on');
getmousepos(a, b);
mousebox(563, 384, 718, 408, 3);
wait(100 + random(4000));
mmouse(a, b, 20, 20);
end;

{*******************************************************************************
function Findpohportal(var x, y: integer): boolean;
By: akwardsaw
Description: It *hopefully* finds the poh portal. it returns the x and y coords.
a better way to do this would be nice :)
*******************************************************************************}
function Findpohportal(var x, y: integer): boolean;
var
CTS, I: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.94, 33.16);
FindColorsSpiralTolerance(mscx, mscy, TPA, 7478100, msx1, msy1, msx2, msy2, 15);
ColorToleranceSpeed(CTS);
ATPA := TPAToATPAEx(TPA, 15, 15);
For I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 2, 2);
wait(10 + random(30));
if IsUpTextMultiCustom(['Enter', 'Portal', 'nter', 'ortal', 'ter', 'ort']) then
begin
Result := True;
GetMousePos(x, y);
Break;
end;
end;
end;

{*******************************************************************************
Function FindPlank(var x, y: integer; plank: string; cx, cy, cx2, cy2: integer):Boolean;
By: akwardsaw
Description: it finds a dtm of the planks, and returns the x and y coords.
*******************************************************************************}
Function FindPlank(var x, y: integer; plank: string; cx, cy, cx2, cy2: integer):Boolean;
var plank: integer;
begin
case plank of
'plank': plankdtm := DTMFromString('78DA63CC63606010634001595136609A11CA6' +
'72CC654039385ABA90012BC04D41402092E026AB28084280135C9' +
'404281809A1C20A1825F0D00F2AD04B4');
'oak': plankdtm := DTMFromString('78DA639CCEC0C020CE80021A333DC1342394C' +
'F380B487031A0014654357381841801357D404289809A29404295' +
'809A49986E46570300EC66055C');
'teak': plankdtm := DTMFromString('78DA6394606060B0664001996106609A11CA6' +
'79401127A0C688011558D32903026A0461648D81150230A243C09' +
'A8E107122E04D40803095BFC6A0023B50353');
'mahogany': plankdtm := DTMFromString('78DA6374616060B0664001C10EFA609A11CA6' +
'77403127A0C688011558D1F903024A0C60348D81250E308243C09' +
'A8B10212CE04D4D861FA0B5D0D00A14D044E');
end;
Result := finddtm(plankdtm, x, y, cx, cy, cx2, cy2);
If not(Result) then
writeln('Plank not found');
freedtm(plankDTM);
end;

also if your wondering, the only "hard" part about making a construction script is making sure the room is where you need it to be. this can easily be done by making sure that the specified room is next to the entrance, or use reflection, go into building mode(where there aren't any doors) and have the use put in they're own path.

Infantry001

2009-07-03 08:44:27

I don't do construction, but I must say, good job!

A good way to failsafe the procedures that require to be in house options is, well, to check whether you are already in house options!

Awkwardsaw

2009-07-03 08:47:39

im adding that right now ;P should get it in a few moments

edit: i finished. simplicity ftw :D (as long as it works good)

Simtoon

2009-07-03 09:03:38

It's good to see people add scripts or make scripts for the SRL SVN :)

Awkwardsaw

2009-07-03 09:06:41

yeah, :) but what about the procedures? what all can i do to make them better/ make more usefull ones

Gu3st...

2009-07-03 13:14:26

I am thinking that it might be faster to use bitmaps instead of DTMs, but good job! Very nice! :D

Da 0wner

2009-07-03 14:50:45

Indeed it is, in 3.20d bitmaps are MUCH faster than DTMs now.

Tickyy

2009-07-03 15:15:00

Did you even try the last function…. it doesn't work

here i made this very quick don't know if it works tho.


{*******************************************************************************
Function FindPlank(var x, y: integer; plank: string; cx, cy, cx2, cy2: integer):Boolean;
By: akwardsaw
Description: it finds a dtm of the planks, and returns the x and y coords.
*******************************************************************************}
Function FindPlank(var x, y: integer; plank: string; cx, cy, cx2, cy2: integer):Boolean;
var
i : integer;
Plankdtm : array of integer;
begin
Result := False;
case plank of
'plank': plankdtm[1] := DTMFromString('78DA63CC63606010634001595136609A11CA6' +
'72CC654039385ABA90012BC04D41402092E026AB28084280135C9' +
'404281809A1C20A1825F0D00F2AD04B4');
'oak': plankdtm[2] := DTMFromString('78DA639CCEC0C020CE80021A333DC1342394C' +
'F380B487031A0014654357381841801357D404289809A29404295' +
'809A49986E46570300EC66055C');
'teak': plankdtm[3] := DTMFromString('78DA6394606060B0664001996106609A11CA6' +
'79401127A0C688011558D32903026A0461648D81150230A243C09' +
'A8E107122E04D40803095BFC6A0023B50353');
'mahogany': plankdtm[4] := DTMFromString('78DA6374616060B0664001C10EFA609A11CA6' +
'77403127A0C688011558D1F903024A0C60348D81250E308243C09' +
'A8B10212CE04D4D861FA0B5D0D00A14D044E');
end;
for i := 1 to 4 do
if finddtm(plankdtm[i], x, y, cx, cy, cx2, cy2) then
begin
GetMousePos(x, y);
Mouse(x, y, 5, 5, True);
Result := True;
end else
Writeln('Plank Not Found');
end;

Awkwardsaw

2009-07-03 17:02:16

hmm, no i havn't tried bitmaps yet, i'll fool around with them today.

and what do you mean that findplank doesn't work? like, does it not find a plank, or does it find the wrong ones

Da 0wner

2009-07-03 17:05:16

It seems like it would work to me.

Naike

2009-07-03 17:07:18

Ain't all the planks the exact same shape?

Infantry001

2009-07-03 17:48:05

Wait, bitmaps are faster than DTMs?

Since when?!?

Da 0wner

2009-07-03 18:47:50

Since SCAR 3.20.

noidea

2009-07-03 21:19:24

You should try learning custom TPA's, so you can edit the Machine made ones. Like your FindpohPortal() ;)

Shuttleu

2009-07-03 23:42:36

change HouseOptions and BuildingMode to a boolean instead of a string

~shut

Awkwardsaw

2009-07-04 00:06:33

From: N1ke!
Ain't all the planks the exact same shape?


yes, but the colors arent ;) also they never change

From: noidea
You should try learning custom TPA's, so you can edit the Machine made ones. Like your FindpohPortal()

i'm just now learning the basics of cts :) i'll lurk more in teh advanced tuts

also, bitmaps dont work either. here are the ones that i have:

  plankbmp := BitmapFromString(20, 16, 'beNpjYMALGCvTXYuTnHJj' + 
'7bKibJNDLWP9TSN9jIPc9IFS+DXWZLqXpbgUxDsA9aaHW0P0hnkaW' +
'uqKEtQLtBSiF2gpUG9CkDnQUqBeYizF6mBjTWFSHQy0FOJgQhoZ6n' +
'I8kR0MtBTiYF0VAfIc7GklTVAj0FKsDiboWoheiKXIDrYzEidoaWO' +
'eF7KD4dFKjEbkUII7mJjEAPcpcigB9ZLkWuS0BE4M+DS2FPiguZZC' +
'S4F6CQUvShDBfQpxMD6NAL6ciOM=');
oakbmp := BitmapFromString(15, 10, 'beNpjYEAGU8qD+4oDO/P9Wr' +
'K969M8KpNcimMdC6Lts8JsStP9GRgYkRVPLA3qKfRvz/VpzPSEK86' +
'NsEsPtkJTCTEWrrgmxa0swRmHsYxY3YDNWMZplaHIboAbC1RcnOpL' +
'0Fi4G9Bci2YsshvQjJ1RHQY3FtNrmMbi8lp9QRh+N0CMhShGU8kAA' +
'I/Rcj8=');
teakbmp := BitmapFromString(13, 15, 'beNpjYEADxXGmuZFGmWEGa' +
'cH6SQG60d5a4e4aIS5qaGoKok0gyoBq4v108CiDGwVRBlQT4KgKU8' +
'JYlmgGNwrNxgg/G7gyuI3IRgGVgY1ihBuF5nigMiSjGNGMgihDdTy' +
'KUZg2AtWEeltClFUmW+BxPMwoBmSj0IIrKcwJUxlmcMHVQJRhdXxW' +
'nAeyMlzBhawGM64hwVWc6oumDKuNaGoYABPBeag=');
mahbmp := BitmapFromString(16, 19, 'beNpjYMADEr3MYz1Mo1yNw5' +
'0Ngx30fay0Pcw1cCtnRFbsb6uLVz0jmuEQ9S4magTVIxuOQz12w3G' +
'pT/G1wOpToGIgA9NwoHpKDIerx2U4RD0RhjOSbTgR0cSY7m+Fy6cY' +
'6qGKSTUcq3ogg0TDGYlXD+Siqc8KssGjHsNwBjyKgYIkqcdUzAAAK' +
'yiJ0g==');

Tickyy

2009-07-04 01:20:05

From: akwardsaw
hmm, no i havn't tried bitmaps yet, i'll fool around with them today.

and what do you mean that findplank doesn't work? like, does it not find a plank, or does it find the wrong ones


duplicate error….

Awkwardsaw

2009-07-04 01:49:12

From: Tickyy
duplicate error….


oh. yeah, change the plank parameter to name