SRL Archive - SRL Archives

Few of my functions/procedures


TOB

2006-12-03 14:41:27

These are some functions I made while working on a script to use to apply which I don't have to do now :P

]{*******************************************************************************
function SymbolExists(Name: String): Boolean;
By: TOB
Description: Finds if minimap symbol exists by name.
*******************************************************************************}
function SymbolExists(Name: string): Boolean;
var
necessaryx, necessaryy: Integer;
begin
if (GetSymbolColor(necessaryx, necessaryy, Lowercase(Name)) > 0) then
Result := True;
end;

{*****************************************************************************
procedure UnequipItem(itemPos: Integer);
By: TOB
Description: Unequips item in slot itemPos
*****************************************************************************}
procedure UnequipItem(itemPos: Integer);
var
equipmentXY: TPoint;
begin
if (WearingItem(itemPos)) then
begin
equipmentXY := EquipmentCoords(itemPos);
Mouse(equipmentXY.x, equipmentXY.y, 5, 5, True);
end;
end;

{*****************************************************************************
function CheckBareHandFightMode: String;
By: TOB
Description: Unequips item in weapon and shield spot then sets fight mode to fightMode
*****************************************************************************}
function CheckBareHandFightMode: Integer;
begin
UnequipItem(5);
//UnequipItem(7); // Wasn't sure if the shield affected fight modes
GameTab(1);
if(GetColor(593, 273) = 2106253) then
Result:= 1
else if(GetColor(669, 265) = 2106253) then
Result:= 2
else if(GetColor(589, 326) = 2106253) then
Result:= 3;
end;

{*****************************************************************************
procedure SetBareHandFightMode(fightMode: Integer);
By: TOB
Description: If fightMode != CheckBareHandFightMode
*****************************************************************************}
procedure SetBareHandFightMode(fightMode: Integer);
var
curFightMode: Integer;
curFightModeStr: string;
begin
curFightMode:= CheckBareHandFightMode;
if(curFightMode = 1) then
curFightModeStr:= 'Attack'
else if(curFightMode = 2) then
curFightModeStr:= 'Strength'
else if(curFightMode = 3) then
curFightModeStr:= 'Defence';
if(fightMode = 1) and (not(curFightMode = fightMode)) then
begin
Mouse(593, 271, 20, 20, True);
WriteLn(TheTime + ' Fight mode changed from ' + curFightModeStr + ' to Attack.');
end else if(fightMode = 2) and (not(curFightMode = fightMode)) then
begin
Mouse(699, 275, 20, 20, True);
WriteLn(TheTime + ' Fight mode changed from ' + curFightModeStr + ' to Strength.');
end else if(fightMode = 3) and (not(curFightMode = fightMode)) then
begin
Mouse(589, 326, 20, 20, True);
WriteLn(TheTime + ' Fight mode changed from ' + curFightModeStr + ' to Defense.');
end;
end;

{*******************************************************************************
procedure FTWait2(Time: Integer);
By: TOB
Description: Performs Wait and FindTalk. Time is a minimum of 250 msec, so FTWait(190)
waits approx 250 ms and performs 1 FindTalks;
*******************************************************************************}
procedure FTWait2(Time: Integer);
var
t, r: Integer;
begin
repeat
r:= 200 + Random(50);
Wait(r);
t:= t + r;
FindTalk;
until(t >= time);
end;

And here is my procedure to check if all players are inactive or not http://villu-reborn.com/showthread.php?p=42936

—-

Edit: Oops, just read and there was a function for UnequipItem :P I didn't see TakeOff before.

Arr0w

2006-12-03 14:46:56

Nice i liek these.

WT-Fakawi

2006-12-03 15:11:41

You can even shorten this:

[php]function SymbolExists(Name: string): Boolean;
var
necessaryx, necessaryy: Integer;
begin Result :=(GetSymbolColor(necessaryx, necessaryy, Lowercase(Name)) > 0)
end;[/php]