SRL Archive - SRL Archives

some procedure


Yakman

2006-09-01 19:14:43

i might be adding some more if i make any

{*******************************************************************************
procedure SaveScreenshotArea(s:string;xs,ys,xe,ye:integer);
By: Yakman
Description: Saves a screenshot of an area specified by xs,yx,xe,ye.
*******************************************************************************}
procedure SaveScreenshotArea(s:string;xs,ys,xe,ye:integer);
var bmp:integer;path:string;
begin
if(copy(s,1,10)<>copy(apppath,1,10))and(copy(s,1,10)<>copy(scriptpath,1,10))then
path:=apppath+s//checks if the people have used apppath or scriptpath
else
path:=s
bmp:=bitmapfromstring(xe-xs,ye-ys,'')
safecopycanvas(getclientcanvas,getbitmapcanvas(bmp),xs,ys,xe,ye,0,0,xe-xs,ye-ys)
savebitmap(bmp,path)
freebitmap(bmp)
end;


if(findnormalrandoms)then
savescreenshotarea(scriptpath+'normal random '+timerunning+'.bmp',104,104,453,345

{*******************************************************************************
procedure DisplayColor(color:integer;title:string);
By: Yakman
Description: Displays a color in the debug image window with a title.
*******************************************************************************}
procedure DisplayColor(color:integer;title:string);
var buffer,header,square:integer;
begin
header:=createbitmapmaskfromtext(title,upchars)
buffer:=bitmapfromstring(length(title)*8,50,'')
square:=bitmapfromstring(30,30,'')
fastdrawclear(buffer,0)
fastdrawclear(square,color)
fastdrawtransparent(length(title)*4-15,18,square,buffer)
fastdrawtransparent(2,2,header,buffer)
displaydebugimgwindow(length(title)*8,50)
safedrawbitmap(buffer,getdebugcanvas,0,0)
freebitmap(header)
freebitmap(buffer)
freebitmap(square)
end;

where to use:

if(isuptext('Chop Down Yew')then
begin
treecol:=getcolor(x,y)
displaycolor(treecol,'Treecolor = '+inttostr(treecol))

{*******************************************************************************
procedure DisplayColorMulti(color1,color2,color3:integer,title:string);
By: Yakman
Description: Displays three colors in the debug image window with a title.
Note: if the title is too short the colors may overlap
*******************************************************************************}
procedure DisplayColorMulti(color1,color2,color3:integer;title:string);
var buffer,header,square:integer;
begin
header:=createbitmapmaskfromtext(title,upchars)
buffer:=bitmapfromstring(length(title)*10,50,'')
square:=bitmapfromstring(30,30,'')
fastdrawclear(buffer,0)
fastdrawclear(square,color1)
fastdrawtransparent(5,18,square,buffer)
fastdrawclear(square,color2)
fastdrawtransparent(length(title)*5-15,18,square,buffer)
fastdrawclear(square,color3)
fastdrawtransparent(length(title)*10-35,18,square,buffer)
fastdrawtransparent(2,2,header,buffer)
displaydebugimgwindow(length(title)*10,50)
safedrawbitmap(buffer,getdebugcanvas,0,0)
freebitmap(header)
freebitmap(buffer)
freebitmap(square)
end;
this procedure was made because most colors seem to come in groups of three
where to use

if(isuptextmulti('wn Y','Chop','Yew'))then
begin
treecol1:=getcolor(x,y)
treecol2:=getcolor(x+1,y+1)
treecol3:=getcolor(x-1,y-1)
displaycolormulti(treecol1,treecol2,treecol3,'Treecolors '+inttostr(treecol1)+' '+inttostr(treecol2)+' '+inttostr(treecol3))


i used this next procedure in Ice Magicks.scar, but i think some other people already discovered it, but ill post it anyway

{*******************************************************************************
procedure SetSelfWindowState(state:TWindowState);
By: Yakman
Description: Sets SCAR to a windows state.
States are wsNormal, wsMinimized, wsMaximized and possibly some others
*******************************************************************************}
procedure unsafesetwindow(state:twindowState);
var self:tform;
begin //dont use this procedure, use the safe one below
self:=getself
self.windowstate:=state
end;
procedure SetSelfWindowState(state:twindowstate);
var p:tvariantarray;
begin
setarraylength(p,1)
p[0]:=state
threadsafecall('unsafesetwindow', p)
end;

where to use:

setupsrl
setupscript
setselfwindowstate(wsminimized)

{*******************************************************************************
function ProgPath:string;
By: Yakman
Description: Returns the file SCAR 2.03 is in, most likely C:\\program files\
*******************************************************************************}
function ProgPath:string;
var f:integer;
begin
result:=apppath
delete(result,length(result),1)
for f:=length(result) downto 0 do
begin
if(copy(result,f,1)='\')then break
else
delete(result,f,1)
end
end;

where to use
if(findnormalrandoms)and(screenshots)then
savescreenshot(ProgPath+'Normal random '+timerunning+'.bmp')
Im open to a different name for the function ProgPath

{*******************************************************************************
procedure WindowsSound(Which:integer);
By: Yakman
Description: Plays the sound specified in Which.
Possible arguments are
0=Windows startup
1=Windows shutdown
2=Information bar beep
3=Chime
4=Chord
5=Win sound
6=Error sound
7=Logoff sound
8=Logon sound
*******************************************************************************}
procedure WindowsSound(Which:integer);
begin
case which of
0:playsound('C:\Windows\Media\windows xp startup.wav')
1:playsound('C:\Windows\Media\windows xp shutdown.wav')
2:playsound('C:\Windows\Media\windows xp information bar.wav')
3:playsound('C:\Windows\Media\chimes.wav')
4:playsound('C:\Windows\Media\chord.wav')
5:playsound('C:\Windows\Media\tada.wav')
6:playsound('C:\Windows\Media\windows xp error.wav')
7:playsound('C:\Windows\Media\windows xp logoff sound.wav')
8:playsound('C:\Windows\Media\windows xp logon sound.wav')
end
end;
where to use

if(findnormalrandoms)then
begin
writeln('phew, random detected and the appropriate action taken')
windowssound(5)
Try this procedure to here them all
var f:integer;
begin
for f:=0 to 8 do
begin
windowssound(f)
writeln('Windows sound number '+inttostr(f))
wait(3000)
end
end.

{*******************************************************************************
procedure EnterHouse(building:boolean);
By: Yakman
Description: Enters your house, building or normal mode
*******************************************************************************}
procedure EnterHouse(building:boolean);
var tempx,tempy,attempt:integer;found:boolean;
begin
repeat
found:=(findcolortolerance(tempx,tempy,4593205,msx1,msy1,msx2,msy2,10))
or(findcolortolerance(tempx,tempy,11749771,msx1,msy1,msx2,msy2,10))
attempt:=attempt+1
wait(50)
until(found)or(attempt>=20)
if(found)then
begin
mmouse(tempx,tempy,0,0)
wait(300+random(300))
if(isuptextmulti('Enter','er Po','Portal'))then
begin
wait(300+random(300))
getmousepos(tempx,tempy)
mouse(tempx,tempy,0,0,true)
flag
wait(300+random(300))
if(building)then
mouse(186,381,3,3,true)
else
mouse(200,364,3,3,true)
wait(3000+random(1000))
attempt:=0
while(not loggedin)do
begin
if(attempt>=200)then exit
wait(300+random(300))
attempt:=attempt+1
end
end
end
end;

if(players[currentplayer].loc:='falador')then
walktoportal
if(players[currentplayer].loc:='portal')then
enterhouse(false)
//stuff for training constuction

{*******************************************************************************
procedure EnterFriendsHouse(name:string);
By: Yakman
Description: Enters friend house of the name you specify
*******************************************************************************}
procedure EnterFriendsHouse(name:string);
var tempx,tempy,attempt:integer;found:boolean;
begin
repeat
found:=(findcolortolerance(tempx,tempy,4593205,msx1,msy1,msx2,msy2,10))
or(findcolortolerance(tempx,tempy,11749771,msx1,msy1,msx2,msy2,10))
attempt:=attempt+1
wait(50)
until(found)or(attempt>=20)
if(found)then
begin
mmouse(tempx,tempy,0,0)
wait(300+random(300))
if(isuptextmulti('Enter','er Po','Portal'))then
begin
wait(300+random(300))
getmousepos(tempx,tempy)
mouse(tempx,tempy,0,0,true)
flag
wait(300+random(300))
mouse(142,410,3,3,true)
wait(300+random(300))
typesend(name)
wait(3000+random(1000))
attempt:=0
while(not loggedin)do
begin
if(attempt>=200)then exit
wait(300+random(300))
attempt:=attempt+1
end
end
end
end;
where to use

//cant think of anything, i just made it to go with EnterHouse(building:boolean);
these next ones were removed for a while because of the update, but i fixed them


{*******************************************************************************
function GetCombatLevel:integer;
By: Yakman
Description: Returns the combat level of the player
*******************************************************************************}
function GetCombatLevel:integer;
var lvl:string;
begin
if(not loggedin)then exit
gametab(1)
lvl:=trim(gettextatex(615,230,100,statchars,true,true,0,1,-1,40,true,tr_AlphaNumericChars))
if(copy(lvl,1,5)='ombat')then
delete(lvl,1,11)
lvl:=trim(lvl)
try
result:=strtoint(lvl)
except
writeln('Could Not Get Combat Level')
end
end;

i got the idea for this when i was making a procedure in my script which burys bones
{*******************************************************************************
function ItemBoxCoords:TBox
By: Yakman
Description: Returns the coords of an inventory space, good for using with
inventory Bitmaps or DTMs
*******************************************************************************}
function ItemBoxCoords(InvSpot:integer):TBox;
var itemcrd:tpoint;
begin
itemcrd:=itemcoords(invspot)
result.x1:=itemcrd.x-11
result.y1:=itemcrd.y-8
result.x2:=itemcrd.x+14
result.y2:=itemcrd.y+18
end;
where to use:

for f:=1 to 28 do
begin
itemb:=itemboxcoords(f)
if(findDTM(bones,x,y,itemb.x1,itemb.y1,itemb.x2,itemb.y2))then
begin
mmouse(x,y,5,5)
wait(500+random(300))
if(isuptext('ury'))then
begin
getmousepos(x,y)
mouse(x,y,0,0,true)


anyway, tell me what you think of this stuff

Janilabo

2006-09-06 07:18:23

Very nice procedures, Yakman!

Have Dankness already asked you to join SRL Developer Team? :rolleyes: :D Weird if he haven't, as you are very smart and also, you know how to do lots of nice things with SCAR. :eek:

So, hopefully you get invited soon. ;)

Good work man.

Edit: Ps. I love SaveScreenshotArea procedure. Works great!

Yakman

2006-09-06 08:11:08

well if dankness wants me to join, thats his choise

anyway, iv realised that i cant make "findbitmaprotated" because "rotatebitmap" distorts the bitmap too much, now i know why its in "finddeformedbitmaprotatedin"

if you want to see something else i made, click the link in my signature

oh yeah and how do you remove that plastic dummy from you avatar, i bet i need more posts

inferno

2006-09-06 09:33:24

From: Yakman
oh yeah and how do you remove that plastic dummy from you avatar, i bet i need more posts


That's a testers award :rolleyes:

Yakman

2006-09-06 11:42:28

Originally Posted by Yakman
oh yeah and how do you remove that plastic dummy from you avatar, i bet i need more posts



That's a testers award :rolleyes:


you mean thats a good thing ?! :eek:

Sumilion

2006-09-06 12:15:35

Well… yeah i gues so :tongue: , congrats ! I have a teddy bear :biggrin:

Yakman

2006-09-06 12:44:15

i dont mean to get off-topic, but when do these teddy bears and orange cats means, are there any more things like that?

Sumilion

2006-09-06 13:04:08

Yeah there are, the teddy bear is for my assistance for the noobs among us :) Search for ranks on this forum and you should get some results, among them is a sticky…

inferno

2006-09-06 14:57:12

http://dakotastorm.sslpowered.com/dakotastorm.com/SRL-Forum/showthread.php?t=211&highlight=ranks

It hasn't been updated in ages though.

http://dakotastorm.sslpowered.com/dakotastorm.com/SRL-Forum/showgroups.php?

To see who has what awards. ;)

Yakman

2006-09-07 14:28:32

just added progpath :D

Sumilion

2006-09-07 14:54:57

You must be really looking forward on that dev award :wink:

Yakman

2006-09-08 10:39:29

im not too worried about a developer award, but i would like to see these procedures in SRL, anyway heres the next 1, WindowsSound

Yakman

2006-09-14 12:14:40

changed something with SaveScreenshotArea to make it so if you've not used "AppPath" or "ScriptPath" it will save in AppPath, before it saved in apppath and didnt give you a choice

for my next procedure, its more to do with runescape and less with just script control things

Yakman

2006-09-20 16:36:04

just added CombatLvl and the 2 EnterHouses, enjoy

Yakman

2006-09-26 02:45:21

heres another one, GetWeapon, could be good for some autofighters that can do many things

Cheesehunk

2006-09-26 18:25:16

From: Yakman
heres another one, GetWeapon, could be good for some autofighters that can do many things

Hmm, that could be used in order to check if your weapon had 4 options for combat or three, in conjuction with SetLowest; Good job. :)

Yakman

2006-09-27 19:04:18

i rewrote DisplayColor, you dont need to put width now, i also added DisplayColorMulti, i removed GetCombalLvl and GetWeapon because of the update, ill put them back as soon as i fix them

Yakman

2006-10-06 19:15:25

i fixed CombatLevel but i couldnt fix GetWeapon because the start of the text changes with every weapon you weild, its center aligned

Yakman

2006-10-07 18:42:49

i made ItemBoxCoords, and iv noticed that no-one else is posting :(