SRL Archive - MSI Suggestions

Objects.scar Library


Coh3n

2009-09-17 18:45:59

Here are the only functions I've come up with so far. To be honest, I can't think of anything else as basically everything we need can be put into on of these four functions (unless I'm forgetting something).
{==============================================================================\
| MSI Group Scripting Include |
| Objects.scar |
|==============================================================================|
| Object and Item finding routines |
| |
\_____________________________________________________________________________}



// Function header just to be in easy reach.
{******************************************************************************}
{ Function SetUpWalk(City, WhereTo: integer): TWalk; }
{ By: Rasta Magician }
{ Rev: 1 }
{ Date: 13 Sep 09 }
{ Description: Returns a TWalk, depending on City and desired destination }
{******************************************************************************}


//Used to find items in inventory and bank.
//Should use TItem record in Globals.scar.
//FindTool(Tool_Axe, Axe_Rune).
function FindTool(ToolType, ToolMaterial: Integer): TPoint;
begin

end;

//Used to find certain items in inventory and bank.
//Should use TItem record in Globals.scar.
//Should use TSkill record in Skills.scar -> Not made yet.
//FindItem(Skill_Smithing, Bar_Steel).
function FindItem(Skill, ItemMaterial: Integer); TPoint;
begin

end;


//Used to find items on the MainScreen.
//Should use TMSObj in Globals.scar.
//FindMSObj(Obj_Rock, Ore_Iron).
function FindMSObj(ObjType, ObjMaterial: Integer): TPoint;
begin

end;


//Used to find obstacles on the MainScreen.
//Should use TMSObj in Globals.scar
//FindObstacle(Obj_Door).
function FindObstacle(ObjType: Integer): TPoint;
begin

end;
If you can think of another function please tell me. :)

Coh3n

Blumblebee

2009-09-17 18:51:23

heres my "object.scar" for a different script. Most noted would be the followPixelBox and FindObjectSilent, I think those both would be benificial to object.scar (A modification of them of course).

Function FindObjectEx(var TP: TPoint): Boolean;
var TPA: TpointArray; ATPA: T2DPointArray; i, h, c: Integer; P: TPoint;
begin
c := CurrentPlayer;
I := GlobalIndex;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Arr[c][I].Hue, Arr[c][I].Sat);
FindColorsSpiralTolerance(MScx, MScy, TPA, Arr[c][I].Col, MSX1, MSY1, MSX2, MSY2, Arr[c][I].Lum);
ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);
ATPA := TPAtoATPAEx(TPA, Arr[c][I].Width, Arr[c][I].Height);
SortATPAFrom(ATPA, Point(MScx, MScy));
h := High(ATPA);
if h < 3 then Exit;
for i := 0 to 3 do
begin
P := MiddleTPA(ATPA[i]);
MMouse(P.x, P.y, 5, 5);
Wait(300+random(300));
if IsUpText('ishing') then
begin
Result := True;
Break;
end;
end;
GetMousePos(TP.x, TP.y);
end;

Function FindObjectSilent(var TP: TPoint): Boolean;
var TPA: TpointArray; ATPA: T2DPointArray; i, h, c: Integer; P: TPoint;
begin
c := CurrentPlayer;
I := GlobalIndex;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Arr[c][I].Hue, Arr[c][I].Sat);
FindColorsSpiralTolerance(MScx, MScy, TPA, Arr[c][I].Col, MSX1, MSY1, MSX2, MSY2, Arr[c][I].Lum);
ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);
ATPA := TPAtoATPAEx(TPA, Arr[c][I].Width, Arr[c][I].Height);
SortATPAFrom(ATPA, Point(MScx, MScy));
h := High(ATPA);
if h < 5 then Exit;
for i := 0 to 5 do
begin
P := MiddleTPA(ATPA[i]);
if P.x and P.y <> 0 then
begin
TP := P;
WriteLn('Found the Object at: '+IntToStr(TP.x)+','+IntToStr(TP.y));
Result := True;
Exit;
end;
end;
end;

Function FindColorInBox(Center: TPoint): Boolean;
var TPA: TPointArray;
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.12, 0.56);
FindColorsTolerance(TPA, 727846, Center.x-10, Center.y-30, Center.x+35, Center.y+10, 15); // 35, 30, 45, 30
ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);
Result := Length(TPA) > 15;
WriteLn('TPA Length = '+IntToStr(Length(TPA)));
end;

Function FollowSkillBox(Index: Integer; Point: TPoint): Boolean;
var Col, x, y: Integer;
begin
case Index of
PWR_Mining, PWR_Woodcutting:
begin
Col := GetColor(Point.x, Point.y);
Result := FindColorTolerance(x, y, Col, Point.x-25, Point.y-25, Point.x+35, Point.y+25, 17);
end;
PWR_Fishing:
begin
Result := FindColorInBox(Point);
end;
end;
end;

Function FollowPixelBox(Point: TPoint): Boolean;
var i: Integer;
begin
i := GetSystemTime;
while FollowSkillBox(ConstIndex, Point) do
begin
FindNormalRandoms;
Wait(150+random(100));
if (GetSystemTime-i > Arr[CurrentPlayer][GlobalIndex].Timer) then
Break;
if InvFull then Break;
end;
Result := True;
end;

Sir R. M8gic1an

2009-09-17 18:51:29

Looking good :)

~RM

Coh3n

2009-09-17 18:58:20

From: Blumblebee
heres my "object.scar" for a different script. Most noted would be the followPixelBox and FindObjectSilent, I think those both would be benificial to object.scar (A modification of them of course).

Indeed they would. ;)

EDIT: Does it only look for the object at the specified TPoint parameter, or am I missing something?