SRL Archive - MSI Archives

Object finding


marpis

2010-06-16 05:30:40

Omg look at the time I gotta go, but quickly:
TAutoColorInfo support! Like in FindObjRecord!

That's a must when fiding Rocks, for example.

Coh3n

2010-06-17 06:15:49

What's wrong with the system you wrote? Don't TMSObject and TAutoColorInfo have similar records?

marpis

2010-06-17 09:54:01

From: Coh3n
What's wrong with the system you wrote? Don't TMSObject and TAutoColorInfo have similar records?


Currently it doesn't have RGB nor HSL checks. Started modifying it today, so that "if Object.AutoColorInfo <> null then" use FindObjectsRecord.

RGB/HSL checks are very important when finding objects with most accuracy possible, like rocks.

Coh3n

2010-06-17 10:00:11

Alright well why not add them to TMSObject? I would rather see that then using two separate types.

marpis

2010-06-17 10:16:47

From: Coh3n
Alright well why not add them to TMSObject? I would rather see that then using two separate types.


Hmm you're right. I'll do that.

Coh3n

2010-06-17 10:25:35

Awesome. PM Wizzup for committing rights if you don't aready have them. Since you just recently got mod powers, I wouldn't be surprised if you couldn't commit either. :)

Sir R. M8gic1an

2010-06-20 05:35:33

From: Coh3n
Awesome. PM Wizzup for committing rights if you don't aready have them. Since you just recently got mod powers, I wouldn't be surprised if you couldn't commit either. :)


Do remember that committing rights are very different from mod rights :p And all SLs having mod rights was a strike of sudden inspiration, and at the time marpis wasn't active ;)

~RM

Coh3n

2010-06-20 20:10:38

From: Rasta Magician
Do remember that committing rights are very different from mod rights :p And all SLs having mod rights was a strike of sudden inspiration, and at the time marpis wasn't active ;)

~RM

Yes I know, I didn't mean for it to sound like they were similar. :p

marpis

2010-06-21 06:18:18

Ok my SRL/MSI/Reflection is acting wierd again, can't compile. Someone try if this compiles:
  • It used to sort from (MMCX, MMCY) but now from (MSCX, MSCY)
  • A few other bugs
  • MSI_FindObjectsTPA now takes these parameters

  • MSI_FindObjectsTPA(Var Objs: TPointArray; ObjInfo: TMSObject; SearchBox: TBox): Boolean;
  • Also all other object finders now take TBox instead of cordinates.
  • Modified WC.scar to match the changes

Next step: apply FindObjectRecord to MSI functions.Pfft, this will be a rather tough one. How should we proceed?
I've got an idea: Have all the MinH, MinS, MinL, MaxH, MaxS etc. properties in TMSObject. In the beginning of FindObjectsTPA, check if all these values are greater than 0. If so, use FindObjsRecord.

Done, let's see if it works. Code below.

Objects.scar

{==============================================================================\
| MSI Group Scripting Include |
| Objects.scar |
|==============================================================================|
| Object and Item finding routines |
| |
| * function MSI_GetObject(): TMSObject; * by The MSI Team |
| * function MSI_GetObjects(): TMSObjectArray; * by marpis |
| * function MSI_ReturnPointsInBox(): TPointArray; * by marpis |
| * function MSI_FindObjectsTPA(): Boolean; * by marpis |
| * function MSI_FindObjectsIn(): Boolean; * by marpis |
| * function MSI_FindObjects(): Boolean; * by marpis |
| * function MSI_FindObjectIn(): Boolean; * by marpis |
| * function MSI_FindObject(): Boolean; * by marpis |
\_____________________________________________________________________________}

{******************************************************************************}
{ Function MSI_GetObject(Which: Integer): TMSObject; }
{ By: The MSI Team }
{ Date: 10 June 2010 }
{ Description: Load all the necessary object information }
{******************************************************************************}
Function MSI_GetObject(Which: Integer): TMSObject;
Begin
Case Which Of
OBJ_TREE_NORMAL: // marpis
With Result Do
Begin
Name := 'Normal tree';
UpText := 'Tree';
Option := 'Chop down';
Exp := 25;
Colors := [736046];
Tol := 5;
Hue := 1.54;
Sat := 5.00;
FindAllColors := False;
W := 25;
H := 25;
Accuracy := 5;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
End;

OBJ_TREE_OAK: // marpis
With Result Do
Begin
Name := 'Oak tree';
UpText := 'Oak';
Option := 'Chop down';
Colors := [736046];
Exp := 37.5;
Tol := 5;
Hue := 1.54;
Sat := 5.00;
FindAllColors := False;
W := 30;
H := 30;
Accuracy := 10;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
End;

OBJ_TREE_WILLOW: // Coh3n
With Result Do
Begin
Name := 'Willow tree';
UpText := 'llow';
Option := 'Chop down';
Colors := [4481105];
Exp := 67.5;
Tol := 14;
Hue := 0.18;
Sat := 0.28;
FindAllColors := False;
W := 30;
H := 30;
Accuracy := 10;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
End;

OBJ_TREE_MAPLE: // Coh3n
With Result Do
Begin
Name := 'Maple tree';
UpText := 'aple';
Option := 'Chop down';
Colors := [2440040];
Exp := 100;
Tol := 6;
Hue := 0.04;
Sat := 0.20;
FindAllColors := False;
W := 25;
H := 25;
Accuracy := 10;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
End;

OBJ_TREE_YEW: // Coh3n
With Result Do
Begin
Name := 'Yew tree';
UpText := 'ew';
Option := 'Chop down';
Colors := [4162165];
Exp := 175;
Tol := 14;
Hue := 0.01;
Sat := 0.76;
FindAllColors := False;
W := 35;
H := 35;
Accuracy := 10;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
End;

{
OBJ_TREE_MAGIC: // Coh3n
With Result Do
Begin
Name := 'Magic tree';
UpText := 'agic';
Option := 'Chop down';
Colors := [11003627];
Exp := 250;
Tol := 11;
Hue := 0.03;
Sat := 2.39;
FindAllColors := False;
W := 30;
H := 30;
Accuracy := 10;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
End;
}

OBJ_BANK_VE: // Coh3n
With Result Do
Begin
Name := 'Varrock east bank';
UpText := 'ooth';
Option := 'uick';
Colors := [2379871];
Tol := 5;
Hue := 0.06;
Sat := 1.61;
FindAllColors := False;
W := 40;
H := 40;
Accuracy := 50;
ExcludeSelf := True;
RightClickOnly := True;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
End;


OBJ_ROCK_IRON: // marpis
With Result Do
Begin
Name := 'Iron rock';
UpText := 'Mine';
Option := 'ine';
Colors := [2963025];
Tol := 3;
Hue := 0.17;
Sat := 1.16;
FindAllColors := False;
W := 5;
H := 5;
Accuracy := 10;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
End;


OBJ_ROCK_COPPER: // NCDS
with Result do
begin
Name := 'Copper';
UpText := 'ocks';
Option := 'ine';
Colors := [4088718];
Tol := 5;
Hue := 0.03;
Sat := 0.13;
FindAllColors := False;
W := 29;
H := 23;
Accuracy := 5;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
end;


OBJ_ROCK_TIN: // NCDS
with Result do
begin
Name := 'Tin';
UpText := 'ocks';
Option := 'ine';
Colors := [8882318];
Tol := 7;
Hue := 0.35;
Sat := 0.09;
FindAllColors := False;
W := 25;
H := 28;
Accuracy := 5;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
end;


OBJ_ROCK_IRON // NCDS
with Result do
begin
Name := 'Iron';
UpText := 'ocks';
Option := 'ine';
Colors := [2568006];
Tol := 5;
Hue := 0.07;
Sat := 0.18;
FindAllColors := False;
W := 30;
H := 23;
Accuracy := 5;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
end;
End;
End;

{******************************************************************************}
{ Function MSI_GetObjects(Which: TIntegerArray): TMSObjectArray; }
{ By: marpis }
{ Date: 10 June 2010 }
{ Description: Load all object info for object in the array }
{******************************************************************************}
Function MSI_GetObjects(Which: TIntegerArray): TMSObjectArray;
Var
I, H: Integer;
Begin
H := High(Which);
SetLength(Result, H + 1);

For I := 0 To H Do
Result[I] := MSI_GetObject(Which[I]);
End;

{******************************************************************************}
{ Function ReturnPointsInBox(TPA: TPointArray; B: TBox): TPointArray; }
{ By: marpis }
{ Date: 10 June 2010 }
{ Description: Self explanatory }
{******************************************************************************}
Function MSI_ReturnPointsInBox(TPA: TPointArray; B: TBox): TPointArray;
Var
I, H, N: Integer;
Begin
H := High(TPA);
SetLength(Result, 1 shl 20);

For I := 0 To H Do
If PointInBox(TPA[I], B) Then
Begin
Result[N] := TPA[I];
Inc(N);
End;

SetLength(Result, N);
End;

{******************************************************************************}
{ Function MSI_FindObjectsTPA( ... ): Boolean; }
{ By: marpis }
{ Date: 10 June 2010 }
{ Description: Finds objects in mainscreen, saves co-ords in TPA }
{******************************************************************************}
Function MSI_FindObjectsTPA(Var Objs: TPointArray; ObjInfo: TMSObject; SearchBox: TBox): Boolean;
Var
TPA, TempTPA: TPointArray;
ATPA: T2DPointArray;
I, II, CTS, TMP, H: Integer;
Box: TBox;
Boxes: TBoxArray;
Animating2: TBooleanArray;
BadPoint: Boolean;
tmp_ACI: TAutoColorInfo;
Begin
If (Not LoggedIn) Then Exit;
With ObjInfo Do
Begin
if MaxDist > 0 then
if (MinR + MaxR) > 0 then
if (MinG + MaxG) > 0 then
if (MinB + MaxB) > 0 then
if (MinX + MaxX) > 0 then
if (MinY + MaxY) > 0 then
if (MinZ + MaxZ) > 0 then
begin
tmp_ACI.MinR := MinR; tmp_ACI.MaxR := MaxR;
tmp_ACI.MinG := MinG; tmp_ACI.MaxG := MaxG;
tmp_ACI.MinB := MinB; tmp_ACI.MaxB := MaxB;
tmp_ACI.MinX := MinX; tmp_ACI.MaxX := MaxX;
tmp_ACI.MinY := MinY; tmp_ACI.MaxY := MaxY;
tmp_ACI.MinZ := MinZ; tmp_ACI.MaxZ := MaxZ;
tmp_ACI.MaxDist := MaxDist;
tmp_ACI.Color := Colors[0];
tmp_ACI.LumTol := Tol;
Result := FindAllObjsRecord(Objs, tmp_ACI, SearchBox.X1, SearchBox.Y1, SearchBox.X2, SearchBox.Y2, True, True);
Exit;
end;
End;

CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(ObjInfo.Hue, ObjInfo.Sat);
Box := IntToBox(228, 150, 275, 200);

H := High(ObjInfo.Colors);
SetLength(ATPA, H + 1);

For I := 0 To H Do
FindColorsSpiralTolerance(MSCX, MSCY, ATPA[I], ObjInfo.Colors[I], SearchBox.X1, SearchBox.Y1, SearchBox.X2, SearchBox.Y2, ObjInfo.Tolerance);

ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);

{ Check if some of the colors was not on MS. }
If FindAllColors Then
For I := 0 To H Do
If (Length(ATPA) < 1) Then
Begin
MSI_Debug('MSI_FindObjectsTPA', 'All colors weren''t found!', DEBUG_SMALL_DETAILS);
Objs := [];
Exit;
End;

{ Check if we have enough pixels on MS. }
TPA := MergeATPA(ATPA);
//DrawDots(TPA, 1000);

If (Length(TPA) < ObjInfo.Accuracy) Then
Begin
MSI_Debug('MSI_FindObjectsTPA', 'No colors found!', DEBUG_SMALL_DETAILS);
Objs := [];
Exit;
End;

ATPA := TPAtoATPAEx(TPA, ObjInfo.W, ObjInfo.H);
SortATPAFrom(ATPA, Point(MSCX, MSCY));
H := High(ATPA);
SetLength(TPA, H + 1);

For I := 0 To H Do
TPA[I] := MiddleTPA(ATPA[I]);

H := High(TPA);
SetLength(Boxes, H + 1);

For I := 0 To H Do
Begin
Boxes[I].X1 := TPA[I].X - (ObjInfo.W / 2);
Boxes[I].Y1 := TPA[I].Y - (ObjInfo.H / 2);
Boxes[I].X2 := TPA[I].X + (ObjInfo.W / 2);
Boxes[I].Y2 := TPA[I].Y + (ObjInfo.H / 2);
End;

If CheckAnimation Then
Animating2 := AnimatingMulti(Boxes, 100, 1);

For I := 0 To High(TPA) Do
Begin
BadPoint := False;
//DrawBox(Boxes[I], 200);

{ Animation }
If (Not BadPoint) Then
If ObjInfo.Anim Then
If (Not Animating2[I]) Then
Begin
MSI_Debug('MSI_FindObjectsTPA', 'Not animating!', DEBUG_SMALL_DETAILS);
BadPoint := True;
End;

{ Exclude own character }
If (Not BadPoint) Then
If ObjInfo.ExcludeSelf Then
If PointInBox(TPA[I], Box) Then
Begin
MSI_Debug('MSI_FindObjectsTPA', 'Own character!', DEBUG_SMALL_DETAILS);
BadPoint := True;
End;

{ Invalid point }
If (Not BadPoint) Then
If ((TPA[I].X + TPA[I].Y) < 1) Then
Begin
MSI_Debug('MSI_FindObjectsTPA', 'Invalid point!', DEBUG_SMALL_DETAILS);
BadPoint := True;
End;

{ Accuracy }
If (Not BadPoint) Then
If (Length(ATPA[I]) < ObjInfo.Accuracy) Then
Begin
MSI_Debug('MSI_FindObjectsTPA', 'Not enough points!', DEBUG_SMALL_DETAILS);
BadPoint := True;
End;

{ Bad colors }
If (Not BadPoint) Then
For II := 0 To High(ObjInfo.BadColors) Do
Begin
MSI_Debug('MSI_FindObjectsTPA', 'Looking for bad color: '+IntToStr(BadColors[II]), DEBUG_SMALL_DETAILS);
If FindColorSpiralTolerance(TMP, TMP, ObjInfo.BadColors[II], TPA[I].X - (Width / 2), TPA[I].Y - (Height / 2), TPA[I].X + (Width / 2), TPA[I].Y + (Height / 2), ObjInfo.BadColorTolerance) Then
Begin
MSI_Debug('MSI_FindObjectsTPA', 'Bad color found!', DEBUG_SMALL_DETAILS);
BadPoint := True;
Break;
End;
End;

{ FindAllColors }
If (Not BadPoint) Then
If ObjInfo.FindAllColors Then
For II := 0 To H Do
Begin
TempTPA := MSI_ReturnPointsInBox(ATPA[II], IntToBox(TPA[I].X - (Width / 2), TPA[I].Y - (Height / 2), TPA[I].X + (Width / 2), TPA[I].Y + (Height / 2)));
If (Length(TempTPA) < 1) Then
Begin
MSI_Debug('MSI_FindObjectsTPA', 'All colors weren''t found!', DEBUG_SMALL_DETAILS);
BadPoint := True;
Break;
End;
End;

{ Valid point! }
If (Not BadPoint) Then
Begin
SetLength(Objs, Length(Objs) + 1);
Objs[High(Objs)] := TPA[I];
End;
End;

Result := (Length(Objs) > 0);
End;

{******************************************************************************}
{ Function MSI_FindObjectsIn( ... ): Boolean; }
{ By: marpis }
{ Date: 10 June 2010 }
{ Description: Finds objects in mainscreen }
{******************************************************************************}
Function MSI_FindObjectsIn(Objs: TMSObjectArray; Var IndexFound: Integer; SearchBox: TBox; Action: fnct_ActionOptions): Boolean;
Var
TPA: TPointArray;
TheOptions, UpTexts: TStringArray;
I, II, III, HH, HHH, Hi: Integer;
CheckUpText: Boolean;
Begin
Hi := High(Objs);

SetLength(TheOptions, Hi + 1);
SetLength(UpTexts, Hi + 1);
For I := 0 To Hi Do
Begin
UpTexts[I] := Objs[I].UpText;
TheOptions[I] := Objs[I].Option;
End;

For II := 0 To Hi Do
With Objs[II] Do
If MSI_FindObjectsTPA(TPA, Objs[II], SearchBox) Then
Begin
HH := Min((Objs[II].Tries - 1), High(TPA));

For I := 0 to HH Do
Begin
MSI_Debug('MSI_FindObjects', IntToStr(Length(TPA))+' objects found!', DEBUG_SMALL_DETAILS);
X := Objs[II].X;
Y := Objs[II].Y;
IndexFound := II;

If (Action = Nothing) Then
Begin
Result := True;
Exit;
End;

HHH := High(UpTexts);
CheckUpText := True;
For III := 0 To HHH Do
If (UpTexts[III] = '') Then
Begin
CheckUpText := False;
Break;
End;

MMouse(TPA[I].X, TPA[I].Y, 2, 2);
Wait(20 + Random(50));

If CheckUpText Then
Result := WaitUpTextMulti(UpTexts, 150 + Random(20))
Else
Result := True;

If (Action = Move) Then
Exit;

If Result Then
Begin
GetMousePos(X, Y);
If (Objs[II].RightClickOnly) Or InRange(Random(100), 0, 20) Or (Action = ClickRight) Then
Begin
Mouse(X, Y, 0, 0, False);
If (Action = ClickRight) or (Action = ClickLeft) Then
Result := WaitOptionMulti(TheOptions, 750 + Random(100))
Else
Result := True;
End Else
Begin
Mouse(X, Y, 0, 0, True);
Result := DidRedClick;
End;

If Objs[II].WaitToMove Then
If WaitFunc(@IsMoving, 15, 2000 + Random(200)) Then
While IsMoving Do
Wait(10 + Random(5));

Exit;
End Else
MSI_Debug('MSI_FindObjects', 'Uptext didn''t match!', DEBUG_SMALL_DETAILS);
End;
End;

MSI_Debug('MSI_FindObjects', 'Objects not found!', DEBUG_SMALL_DETAILS);
End;

{******************************************************************************}
{ Function MSI_FindObjects( ... ): Boolean; }
{ By: marpis }
{ Date: 10 June 2010 }
{ Description: Finds multiple objects on the mainscreen }
{******************************************************************************}
Function MSI_FindObjects(Objs: TMSObjectArray; Var IndexFound: Integer; Action: fnct_ActionOptions): Boolean;
Begin
Result := MSI_FindObjectsIn(Objs, IndexFound, MSBox, Action);
End;

{******************************************************************************}
{ Function MSI_FindObjectIn( ... ): Boolean; }
{ By: marpis }
{ Date: 10 June 2010 }
{ Description: Finds object in specified location }
{******************************************************************************}
Function MSI_FindObjectIn(Obj: TMSObject; SearchBox: TBox; Action: fnct_ActionOptions): Boolean;
Var
TMP: Integer;
Begin
Result := MSI_FindObjectsIn([Obj], TMP, SearchBox, Action);
End;

{******************************************************************************}
{ Function MSI_FindObject( ... ): Boolean; }
{ By: marpis }
{ Date: 10 June 2010 }
{ Description: Finds object on the mainscreen }
{******************************************************************************}
Function MSI_FindObject(Obj: TMSObject; Action: fnct_ActionOptions): Boolean;
Var
TMP: Integer;
Begin
Result := MSI_FindObjectsIn([Obj], TMP, MSBox, Action);
End;

Woodcutting.scar

{==============================================================================\
| MSI Group Scripting Include |
| WoodCutting.scar |
|==============================================================================|
| For all woodcutting routines. |
| |
| * procedure MSI_WaitWhileChopping(); * by marpis |
| * function MSI_ChopTree(): Boolean; * by marpis |
| * function MSI_ChopInvFull(): Boolean; * by marpis |
| * function MSI_PowerChop(): Boolean; * by marpis and Coh3n |
\ _____________________________________________________________________________}

{******************************************************************************}
{ Procedure WaitWhileChopping(TreeX, TreeY: Integer; TreeInfo: TMSObject); }
{ By: marpis }
{ Description: Wait while tree's been cut }
{******************************************************************************}
Procedure MSI_WaitWhileChopping(TreeX, TreeY: Integer; TreeInfo: TMSObject);
Var
CTS, HalfWidth, HalfHeight, L, I, T, OldInvCount, NewInvCount: Integer;
TotalChopTime, R, CT: Integer;
ATPA: T2DPointArray;
TPA: TPointArray;
B: TBox;
TreeExists: Boolean;
Begin
CTS := GetColorToleranceSpeed;
SetColorSpeed2Modifiers(TreeInfo.Hue, TreeInfo.Sat);

HalfWidth := (TreeInfo.W / 2);
HalfHeight := (TreeInfo.H / 2);
B := IntToBox(TreeX - HalfWidth, TreeY - HalfHeight, TreeX + HalfWidth, TreeY + HalfHeight);

L := Length(TreeInfo.Colors);
SetLength(ATPA, L);
Dec(L);
OldInvCount := InvCount;
T := GetSystemTime + 20000 + Random(5000);
TotalChopTime := GetSystemTime;

Repeat
If InvFull Then Break;

MSI_AntiBan(RandomRange(0, 10000), ANTI_BAN_CHANCE);

{ Check if the tree Exists }
For I := 0 To L Do
FindColorsTolerance(ATPA[I], TreeInfo.Colors[I], B.X1, B.Y1, B.X2, B.Y2, TreeInfo.Tol);
TPA := MergeATPA(ATPA);
//WriteLn(Length(TPA));

TreeExists := Length(TPA) >= TreeInfo.Accuracy;
If (TreeExists) Then
If (Random(4) <> 0) Then
Wait(200 + Random(50))
Else
SleepAndMoveMouse(200 + Random(50));
MSI_FindRandoms;

{ InvCount check }
NewInvCount := InvCount;
If (NewInvCount > OldInvCount) Then
Begin
OldInvCount := NewInvCount;
T := GetSystemTime + 20000 + Random(5000);
End;

{ Prevent logout }
If ((GetSystemTime - TotalChopTime) > 60000) Then
Begin
CT := GetCurrentTab;
Repeat
R := RandomRange(Tab_Combat, Tab_Notes);
Until(R <> CT);
GameTab(R);
End;

Until(Not TreeExists) Or (GetSystemTime > T) Or (Not LoggedIn);
End;

{******************************************************************************}
{ Function MSI_ChopTree(Which: TIntegerArray): Boolean; }
{ By: marpis }
{ Description: Chops tree }
{******************************************************************************}
Function MSI_ChopTree(Which: TIntegerArray): Boolean;
Var
X, Y, TreeIndex: Integer;
Trees: TMSObjectArray;
Begin
Trees := MSI_GetObjects(Which);
If MSI_FindObjects(Trees, TreeIndex, ClickLeft) Then
Begin
X := Trees[TreeIndex].X;
Y := Trees[TreeIndex].Y;
If MSI_FindObjectIn(Trees[TreeIndex], IntToBox(X - 20, Y - 20, X + 20, Y + 20), Nothing) Then
Begin
Result := True;
MSI_WaitWhileChopping(X, Y, Trees[TreeIndex]);
End;
End;
End;

{******************************************************************************}
{ Function MSI_ChopInvFull(Which: TIntegerArray): Boolean; }
{ By: marpis }
{ Description: Chops trees until inventory is full }
{******************************************************************************}
Function MSI_ChopInvFull(Which: TIntegerArray): Boolean;
Var
T: Integer;
Begin
T := GetSystemTime + 5*60000;
While (Not InvFull) And (LoggedIn) And (GetSystemTime < T) Do
Begin
If MSI_ChopTree(Which) Then
T := GetSystemTime + 5*60000;
Wait(RandomRange(300, 800));
End;
Result := InvFull;
End;

{******************************************************************************}
{ function MSI_PowerChop(WhichTrees, WhichLogs: TIntegerArray): Boolean; }
{ By: marpis and Coh3n }
{ Description: Chops trees until inventory is full, then drops. }
{ Time is in milliseconds. }
{******************************************************************************}
procedure MSI_CountItems; forward;
function MSI_PowerChop(WhichTrees, WhichLogs: TIntegerArray): Boolean;
Var
TT: Integer;
Begin
TT := GetSystemTime + 30*60000;
Repeat
If MSI_ChopInvFull(WhichTrees) Then
TT := GetSystemTime + 30*60000;
Until(InvFull) Or (Not LoggedIn) Or (GetSystemTime > TT);

MSI_CountItems; //Adds the logs/exp to the progress report
MSI_ClickItems(WhichLogs, ['Drop', 'rop', 'Dro', 'Dr']);
MSI_AddToProggy(-1, -1, ADD_LOADS);
Result := True; //To satisfy MSI_DoSkill
End;

Globals.scar

{==============================================================================\
| MSI Group Scripting Include |
| Globals.scar |
|==============================================================================|
| Used to store all necessary global types, consts and vars |
| |
\_____________________________________________________________________________}

const
MSI_VERSION_NUMBER = '1.0';

{
Abbreviations:
- FS: Fishing Spot
- GS: General Store
- GE: Grand Exchange
- VE: Varrock East
- VW: Varrock West
- FW: Falador West
- FE: Falador East
- CG: Castle Guards
- DW: Dark Wizards
- V: Volcan
- SO: Stronghold Of *
- AK: Al Kharid
- SW: Spinning Wheel
- LB: Lumby
- EV: EdgeVille
- BV: Barbarian Village
}

{ const Debug
Description: The several debugging levels, so the user receives as much
detail as he wishes to receive. }
const
DEBUG_FORCE = 10; // For MSI SLs to force it to be debuged, not for Script Users!
DEBUG_PROGGIE = 7; // Only debug proggie and more important things
DEBUG_PLAYER_ACTIONS = 5; // Only debug proggie, Player Actions and more important things
DEBUG_FUNCTIONS = 3; // Debug the at the start of each function, Player Actions, Proggie and +
DEBUG_SMALL_DETAILS = 1; // Debug small details and more important
DEBUG_EVERYTHING = 0; // For Script Users to have everything in debug box.

{ const Other
Description: Represents miscellaneous constants }
const
STATS_LINK = 'http://scriptmanager.freehostia.com/submit.php'; //for stats
WALK_TOL = 8; //the tolerance for a color point compared to a reflection point
ANTI_BAN_CHANCE = 10; //the chance (in %) of antiban

{ const Stats
Description: Represents all the custom variables to add to the stats }
const
STATS_LOGINS = 1;
STATS_BANKS = 2;
STATS_LOADS = 3;
STATS_RANDOMS = 4;
STATS_LEVELS = 5;
STATS_EXP = 6;
STATS_LOGS = 7;
STATS_ORES = 8;

{ const Players
Constants representing the different Players array records. }
const
// Integers
P_LOC = 0;

// Booleans
P_BANK = 0;

{ const Location Constants
Description: Constants used to represent player locations }
const
LOC_POWER_SKILL = 0;
LOC_LOST = 1;
LOC_VE_TREES = 2;
LOC_VE_BANK = 3;
LOC_IN_RANDOM = 4;

{ const AutoColor
Description: Constants used for autocoloring the minimap }
const
COLOR_ROAD_GENERAL = 6579821;
COLOR_ROAD_VARROCK = 8686729;
COLOR_ROAD_FALLY = 7831173;
COLOR_ROAD_LUMBY = 8225677;
COLOR_ROAD_DIRT = 1853272;
COLOR_BANKER = 1179390;
COLOR_WATER = 10850700;
COLOR_ROCK = 5789528;
COLOR_SAND = 0;
COLOR_TREE = 1532978;

{ const Walking
Description: Constants representing the color walking points }
const
WALK_WC_VE_TREE_1 = 0; // rock
WALK_WC_VE_TREE_2 = 1; // road
WALK_WC_VE_TREE_3 = 2; // path
WALK_WC_VE_TREE_4 = 3; // final

WALK_WC_VE_BANK_1 = 4; // rock
WALK_WC_VE_BANK_2 = 5; // path
WALK_WC_VE_BANK_3 = 6; // road
WALK_WC_VE_BANK_4 = 7; // final

{ const Banking
Description: Constants used in bank procedures }
const
BANK_SYMBOL_ACCURACY = 0.45; // The symbol accuracy of the bank
INC_TOL = 5; // How much to increase the tolerance by
MAX_TOL = 40; // The max tolerance reached before the object cannot be found.

{ const DDTM
Description: Constants representing the DDTM points }
const
DTM_TOLERANCE = 12;
DTM_POINT_1 = 0; //corresponds to the TPA returned in MSI_GetDTMPoints
DTM_POINT_2 = 1;
DTM_POINT_3 = 2;
DTM_POINT_4 = 3;
DTM_POINT_5 = 4;

{ const Hatchet/Pickaze requirements.
Constants representing the requirements to use each tool }
const
//hatchets and pickaxes
REQ_BRONZE = 1;
REQ_IRON = 1;
REQ_STEEL = 6;
REQ_MITHRIL = 21;
REQ_ADAMANT = 31;
REQ_RUNE = 41;
REQ_MAX_LEVEL = 99;

{ const Item Info
Description: Constants representing all the items used in MSI. }
const
MSI_ITEM_COUNT = 17; //change this to the number of items in ItemInfo.scar
{
PICKAXE_BRONZE = 0;
PICKAXE_IRON = 1;
PICKAXE_STEEL = 2;
PICKAXE_MITHRIL = 3;
PICKAXE_ADAMANT = 4;
PICKAXE_RUNE = 5;
}
HATCHET_BRONZE = 6;
HATCHET_IRON = 7;
HATCHET_STEEL = 8;
HATCHET_MITHRIL = 9;
HATCHET_ADAMANT = 10;
HATCHET_RUNE = 11;

LOGS_NORMAL = 12;
LOGS_OAK = 13;
LOGS_WILLOW = 14;
LOGS_MAPLE = 15;
LOGS_YEW = 16;

{ const Objects
Description: Constants representing all the main screen objects used in MSI }
const
OBJ_TREE_NORMAL = 0;
OBJ_TREE_OAK = 1;
OBJ_TREE_WILLOW = 2;
OBJ_TREE_MAPLE = 3;
OBJ_TREE_YEW = 4;
OBJ_TREE_MAGIC = 5;

OBJ_ROCK_CLAY = 6;
OBJ_ROCK_TIN = 7;
OBJ_ROCK_COPPER = 8;
OBJ_ROCK_IRON = 9;
OBJ_ROCK_SILVER = 10;


OBJ_BANK_VE = 9;


{ Type TMSObject
Description: To be used for finding on the MS. Stores all necessary
information. }
Type
TMSObject = Record
X, Y : Integer;
Name : String;
UpText : String;
Option : String;
Exp : Extended;
Colors : TIntegerArray;
FindAllColors : Boolean; // Result False if not ALL colors are found
Tol : Integer;
Hue : Extended;
Sat : Extended;
W, H : Integer;
Accuracy : Integer; // Min pixels to be found
ExcludeSelf : Boolean; // Exclude pixels in a box, the box might need revamping / making it dynamic
RightClickOnly : Boolean;
Tries : Integer;
Anim : Boolean; // Result False if not animating
WaitToMove : Boolean; // When ClickLeft, wait till we have stopped moving?
BadColors : TIntegerArray;
BadColorTolerance: Integer;
// TAutoColorInfo
MaxCount, MaxDist: Integer;
MinR, MaxR, MinG, MaxG, MinB, MaxB: Integer;
MinX, MaxX, MinY, MaxY, MinZ, MaxZ: Extended;
End;
TMSObjectArray = Array of TMSObject;

{ Type TItem
Description: To be used for handling Items in all situations. }
TItem = Record
Name : String;
UpText : TStringArray;
ItemP : TPoint;
Stackable : Boolean;
Colors : TIntegerArray;
Tol : Integer;
DTM : Integer;
BMP : Integer;
End;

//Used in Banking.Scar
Type MSI_TItemArray = Array Of TItem;

{ Type TMMLocation
Description: Stores all needed colorwalking information. }
TMMLocation = Record
Symbol : String;
DTM : Integer;
W, H : Integer;
Colors : TIntegerArray;
Tolerances : TIntegerArray;
Counts : TIntegerArray;
End;

{ Type TPlayerSkillInfo
Description: Stores information for one player for one skill. }
TPlayerSkillInfo = record
TotalTime : integer;
TotalObj : integer;
TotalLoads : integer;
Level : integer;
TotalEXP : integer;
ObjQuants : array of integer;
end;

{ Type TProggy
Description: Stores information all progress related information for one
player. }
TProggy = record
PlayerName : string;
PlayerStatus: boolean;
FalseReason : string;
PlayerRandom: string;
PlayerCity : string;
PlayerLoc : integer;
PlayerTime : integer;
SkillInfo : array of TPlayerSkillInfo;
end;

var
//To be used to store information for Players individually
ProgressReportArray: Array of TProggy;

//Used like CurrentPlayer, but for the skills in the player array
CurrentSkill: Integer;

//For script user to choose how much to debug
Debug_LevelToDebug: integer;

//Used in the DeclarePlayers arrays for skills and objects
PlayerSkills: Array of TVariantArray;
PlayerObjects: Array of Array of TVariantArray;

//Used for script setup (assinged to constatns in RunMe.scar)
BreakAfter, BreakTime: Integer;

//Used when loading items for MSI
MSI_Item: Array[0..(MSI_ITEM_COUNT - 1)] Of TItem;
IsItemLoaded: Array[0..(MSI_ITEM_COUNT - 1)] of Boolean;

//Used for saving the debug box
ScriptStart: String;
SaveDebug: Boolean;

//Used to determine whether the reflection hooks are outdated
ReflectionBroken: Boolean;

//Used in the stats system
Stats_UserID, Stats_Password, Stats_ScriptID: string;
Stats_LastTime: Integer;
Stats_CustomVars: array [1..20] of Integer;
statsID, statsPass: String; //For compiling issues

Sir R. M8gic1an

2010-06-21 06:53:12

guys, if the only reason we are using TAutoColorInfo are the rocks, then there are a few points to consider:

There's a million different ways to find rocks. We don't need TAutoColorInfo.
If we want to use SRL's FindRock so badly, we can add a TAutoColorInfo inside of TMSObject:

[php]
TMSObject = record
blablabla : blabla;
TAC : TAutoColorInfo;
end;

FindRock(TMSObject.TAC);
[/php]

But the main point is, we don't need SRL's FindRock. I always found TAutoColorInfo to be way too bloated. CTS2 with modifiers and tol is usually more than enough.

~RM

marpis

2010-06-21 07:03:03

From: Rasta Magician
guys, if the only reason we are using TAutoColorInfo are the rocks, then there are a few points to consider:

There's a million different ways to find rocks. We don't need TAutoColorInfo.
If we want to use SRL's FindRock so badly, we can add a TAutoColorInfo inside of TMSObject:

[php]
TMSObject = record
blablabla : blabla;
TAC : TAutoColorInfo;
end;

FindRock(TMSObject.TAC);
[/php]

But the main point is, we don't need SRL's FindRock. I always found TAutoColorInfo to be way too bloated. CTS2 with modifiers and tol is usually more than enough.

~RM

Yes, usually. Not always though.

I tried searching for iron rocks with modifiers and tolerance without good results. TAutoColorInfo is rarely necessary, but if there are some cases where it is why not implement it?

What do you think of the way I did it in the previous post?
  • Using the RGB/XYZ is 100% optional, and they can be ignored when building a TMSObject.
  • When using RGB/XYZ you can still use the exact same functions, like MSI_FindObject.
  • This will make things easier, not more complicated. With ACA2 it takes a minute to gather the info.

EDIT: Feels good to be actually doing something for SRL in a long time.

Sir R. M8gic1an

2010-06-21 11:11:46

Hadn't properly read through the code. Looks good.

I think that a simple boolean check for the TAC info would be better tho.

Can we make the checking into a function? We might want to use it elsewhere (eg inv, bank), and that'll also make it look cleaner.

-RM

marpis

2010-06-21 13:37:16

From: Rasta Magician
Hadn't properly read through the code. Looks good.

I think that a simple boolean check for the TAC info would be better tho.

Can we make the checking into a function? We might want to use it elsewhere (eg inv, bank), and that'll also make it look cleaner.

-RM


Umm, I don't quite get what you're trying to say. I think a boolean check is just one more useless property, because if some object has all the TACI properties set, why would it ever be set to false?

And objects <> items, in inv and bank we use TItem, not TMSObject :rolleyes:

Coh3n

2010-06-21 17:47:34

Let's see if I get this right. So now if someone builds a TMSObject and decides to add RGB/XYZ values, the script will use SRL's FindAllObjRecord? Which would be more accurate?

Since the RGB/XYZ would be optional, I would also rather see a TAutoColorInfo inside the TMSObject type. Just looks cleaner, IMO. Oh, and marpis, I think RM just means separate them:

function MSI_FindObjRecord(ObjInfo: TMSObject; SearchBox: TBox): Boolean;
var
tmp_ACI: TAutoColorInfo;
begin
With ObjInfo Do
Begin
if MaxDist > 0 then
if (MinR + MaxR) > 0 then
if (MinG + MaxG) > 0 then
if (MinB + MaxB) > 0 then
if (MinX + MaxX) > 0 then
if (MinY + MaxY) > 0 then
if (MinZ + MaxZ) > 0 then
begin
tmp_ACI.MinR := MinR; tmp_ACI.MaxR := MaxR;
tmp_ACI.MinG := MinG; tmp_ACI.MaxG := MaxG;
tmp_ACI.MinB := MinB; tmp_ACI.MaxB := MaxB;
tmp_ACI.MinX := MinX; tmp_ACI.MaxX := MaxX;
tmp_ACI.MinY := MinY; tmp_ACI.MaxY := MaxY;
tmp_ACI.MinZ := MinZ; tmp_ACI.MaxZ := MaxZ;
tmp_ACI.MaxDist := MaxDist;
tmp_ACI.Color := Colors[0];
tmp_ACI.LumTol := Tol;
Result := FindAllObjsRecord(Objs, tmp_ACI, SearchBox.X1, SearchBox.Y1, SearchBox.X2, SearchBox.Y2, True, True);
end;
End;
end;

Function MSI_FindObjectsTPA(Var Objs: TPointArray; ObjInfo: TMSObject; SearchBox: TBox): Boolean;
Var
TPA, TempTPA: TPointArray;
ATPA: T2DPointArray;
I, II, CTS, TMP, H: Integer;
Box: TBox;
Boxes: TBoxArray;
Animating2: TBooleanArray;
BadPoint: Boolean;
Begin
If (Not LoggedIn) or (MSI_FindObjRecord) Then Exit;

CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(ObjInfo.Hue, ObjInfo.Sat);
Box := IntToBox(228, 150, 275, 200);

H := High(ObjInfo.Colors);
SetLength(ATPA, H + 1);

For I := 0 To H Do
FindColorsSpiralTolerance(MSCX, MSCY, ATPA[I], ObjInfo.Colors[I], SearchBox.X1, SearchBox.Y1, SearchBox.X2, SearchBox.Y2, ObjInfo.Tolerance);

ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);

{ Check if some of the colors was not on MS. }
If FindAllColors Then
For I := 0 To H Do
If (Length(ATPA) < 1) Then
Begin
MSI_Debug('MSI_FindObjectsTPA', 'All colors weren''t found!', DEBUG_SMALL_DETAILS);
Objs := [];
Exit;
End;

{ Check if we have enough pixels on MS. }
TPA := MergeATPA(ATPA);
//DrawDots(TPA, 1000);

If (Length(TPA) < ObjInfo.Accuracy) Then
Begin
MSI_Debug('MSI_FindObjectsTPA', 'No colors found!', DEBUG_SMALL_DETAILS);
Objs := [];
Exit;
End;

ATPA := TPAtoATPAEx(TPA, ObjInfo.W, ObjInfo.H);
SortATPAFrom(ATPA, Point(MSCX, MSCY));
H := High(ATPA);
SetLength(TPA, H + 1);

For I := 0 To H Do
TPA[I] := MiddleTPA(ATPA[I]);

H := High(TPA);
SetLength(Boxes, H + 1);

For I := 0 To H Do
Begin
Boxes[I].X1 := TPA[I].X - (ObjInfo.W / 2);
Boxes[I].Y1 := TPA[I].Y - (ObjInfo.H / 2);
Boxes[I].X2 := TPA[I].X + (ObjInfo.W / 2);
Boxes[I].Y2 := TPA[I].Y + (ObjInfo.H / 2);
End;

If CheckAnimation Then
Animating2 := AnimatingMulti(Boxes, 100, 1);

For I := 0 To High(TPA) Do
Begin
BadPoint := False;
//DrawBox(Boxes[I], 200);

{ Animation }
If (Not BadPoint) Then
If ObjInfo.Anim Then
If (Not Animating2[I]) Then
Begin
MSI_Debug('MSI_FindObjectsTPA', 'Not animating!', DEBUG_SMALL_DETAILS);
BadPoint := True;
End;

{ Exclude own character }
If (Not BadPoint) Then
If ObjInfo.ExcludeSelf Then
If PointInBox(TPA[I], Box) Then
Begin
MSI_Debug('MSI_FindObjectsTPA', 'Own character!', DEBUG_SMALL_DETAILS);
BadPoint := True;
End;

{ Invalid point }
If (Not BadPoint) Then
If ((TPA[I].X + TPA[I].Y) < 1) Then
Begin
MSI_Debug('MSI_FindObjectsTPA', 'Invalid point!', DEBUG_SMALL_DETAILS);
BadPoint := True;
End;

{ Accuracy }
If (Not BadPoint) Then
If (Length(ATPA[I]) < ObjInfo.Accuracy) Then
Begin
MSI_Debug('MSI_FindObjectsTPA', 'Not enough points!', DEBUG_SMALL_DETAILS);
BadPoint := True;
End;

{ Bad colors }
If (Not BadPoint) Then
For II := 0 To High(ObjInfo.BadColors) Do
Begin
MSI_Debug('MSI_FindObjectsTPA', 'Looking for bad color: '+IntToStr(BadColors[II]), DEBUG_SMALL_DETAILS);
If FindColorSpiralTolerance(TMP, TMP, ObjInfo.BadColors[II], TPA[I].X - (Width / 2), TPA[I].Y - (Height / 2), TPA[I].X + (Width / 2), TPA[I].Y + (Height / 2), ObjInfo.BadColorTolerance) Then
Begin
MSI_Debug('MSI_FindObjectsTPA', 'Bad color found!', DEBUG_SMALL_DETAILS);
BadPoint := True;
Break;
End;
End;

{ FindAllColors }
If (Not BadPoint) Then
If ObjInfo.FindAllColors Then
For II := 0 To H Do
Begin
TempTPA := MSI_ReturnPointsInBox(ATPA[II], IntToBox(TPA[I].X - (Width / 2), TPA[I].Y - (Height / 2), TPA[I].X + (Width / 2), TPA[I].Y + (Height / 2)));
If (Length(TempTPA) < 1) Then
Begin
MSI_Debug('MSI_FindObjectsTPA', 'All colors weren''t found!', DEBUG_SMALL_DETAILS);
BadPoint := True;
Break;
End;
End;

{ Valid point! }
If (Not BadPoint) Then
Begin
SetLength(Objs, Length(Objs) + 1);
Objs[High(Objs)] := TPA[I];
End;
End;

Result := (Length(Objs) > 0);
End;
No idea if that will work, I probably forgot some variables or something.

Frement

2010-06-21 18:03:02

function MSI_FindObjRecord(ObjInfo: TMSObject; SearchBox: TBox): Boolean;
var
tmp_ACI: TAutoColorInfo;
begin
With ObjInfo Do
Begin
if MaxDist > 0 and (MinR + MaxR) > 0 and (MinG + MaxG) > 0 and (MinB + MaxB) > 0
and (MinX + MaxX) > 0 and (MinY + MaxY) > 0 and (MinZ + MaxZ) > 0 then
begin
tmp_ACI.MinR := MinR; tmp_ACI.MaxR := MaxR;
tmp_ACI.MinG := MinG; tmp_ACI.MaxG := MaxG;
tmp_ACI.MinB := MinB; tmp_ACI.MaxB := MaxB;
tmp_ACI.MinX := MinX; tmp_ACI.MaxX := MaxX;
tmp_ACI.MinY := MinY; tmp_ACI.MaxY := MaxY;
tmp_ACI.MinZ := MinZ; tmp_ACI.MaxZ := MaxZ;
tmp_ACI.MaxDist := MaxDist;
tmp_ACI.Color := Colors[0];
tmp_ACI.LumTol := Tol;
Result := FindAllObjsRecord(Objs, tmp_ACI, SearchBox.X1, SearchBox.Y1, SearchBox.X2, SearchBox.Y2, True, True);
end;
End;
end;

Can you shorten it like that?

Coh3n

2010-06-21 18:04:24

Yeah, but that seems less readable to me. They both would work.

Sir R. M8gic1an

2010-06-21 18:13:25

Don't separate them in that way. It would kill the whole point of it.

As Coh3n said, you might want to use RGB/XYZ/HSL WITHOUT using SRL's FindObjRecord (as it does not take into account a million things our FindObj does). A simple boolean for 'UseSRLFindObjRecord' would allow more versatility. Better if it has a shorter name tho.

That way we CAN use SRL's or MSI's, with whichever modifications we choose to make.
Also, have a TAC type inside of the TMSObj type, otherwise you'll be wasting memory every time you can FindObjRecord because you are loading a new type into 'Temp_ACI'.

~RM

Coh3n

2010-06-21 18:26:46

From: Rasta Magician
Don't separate them in that way. It would kill the whole point of it.

As Coh3n said, you might want to use RGB/XYZ/HSL WITHOUT using SRL's FindObjRecord (as it does not take into account a million things our FindObj does). A simple boolean for 'UseSRLFindObjRecord' would allow more versatility. Better if it has a shorter name tho.

That way we CAN use SRL's or MSI's, with whichever modifications we choose to make.
Also, have a TAC type inside of the TMSObj type, otherwise you'll be wasting memory every time you can FindObjRecord because you are loading a new type into 'Temp_ACI'.

~RM

Honestly, I would rather not even use any of SRL's object finding functions. I would rather use SmartColors (I don't even remember why we decided not to).

EDIT: Here's what I think we should do:
  • First off, commit any of the bugs you found and fixed.
  • Determine whether we really need to use RGB/XYZ values (as I've never seen them used for MS object finding, other than in SRL's object functions). What exactly happened when you tried finding Iron rocks? Maybe it was something that can be fixed? I don't know…
  • If using RGB/XYZ is the best option, write it into MSI's functions. If we're going to have our own object finding methods, I'd like to keep it that way. This would also require adding acInfo: TAutoColorInfo to the TMSObject type and I guess would only be set on those objects that need it (such as rocks as it sounds).
  • Get it done! Oh, and test it. :p

Blumblebee

2010-06-21 20:09:58

I don't see the point in using RGB and XYZ support to be entirely honest, but then again that's just me. From my recollection they slow down the object finding do they not?

NCDS

2010-06-21 21:44:07

Tomorrow I plan on putting some stuff together for the mining portion so I can let you guys know what problems I run into if any.

marpis

2010-06-22 02:25:52

From: Coh3n
I would rather use SmartColors (I don't even remember why we decided not to).


SmartColors is in SRL just as much as FindObjRecord. :rolleyes:
And I had totally forgotten about SC, yea we should use that. That's simple to use and would be as accurate as using TAC.

How would this look?

function MSI_FindObjectsTPA(ObjectInfo: TMSObject): boolean;
var
SC: TMSObj;
index: integer;
begin
SC := GetObject(ObjectInfo.Name, index); // See /misc/SmartColors.scar
if ( index > 0) then
begin
UseSmartColorsThings;
Exit;
end;
...
end;

A couple of points
  • We could leave SmartColors use it's own TMSObj, we don't need to touch it except for only once in MSI_FindObjectsTPA
  • We don't need to add any types or properties to current types
  • How should we create the SmartColors objects?

Sir R. M8gic1an

2010-06-22 04:41:00

[php]
{*******************************************************************************
procedure MakeObjEx(Index, MyColor, MyTol: integer; MyHue, MySat: extended; MyUpTexts, MyOptions: TStringArray);
By: Rasta Magician
Description: Will save the information about an object to a global array.
Uses CTS 2
*******************************************************************************}
[/php]

Do notice that using SmartColors will reduce MSI's flexibility.

~RM

Coh3n

2010-06-22 05:54:59

From: marpis
SmartColors is in SRL just as much as FindObjRecord. :rolleyes:

I should have said if we were to use something in SRL, I would rather use SmartColors. :p

From: marpis

And I had totally forgotten about SC, yea we should use that. That's simple to use and would be as accurate as using TAC.

How would this look?

function MSI_FindObjectsTPA(ObjectInfo: TMSObject): boolean;
var
SC: TMSObj;
index: integer;
begin
SC := GetObject(ObjectInfo.Name, index); // See /misc/SmartColors.scar
if ( index > 0) then
begin
UseSmartColorsThings;
Exit;
end;
...
end;

A couple of points
  • We could leave SmartColors use it's own TMSObj, we don't need to touch it except for only once in MSI_FindObjectsTPA
  • We don't need to add any types or properties to current types
  • How should we create the SmartColors objects?

Are you talking about replacing what we currently have? Or just adding SmartColors?

From: Rasta Magician
[php]
{*******************************************************************************
procedure MakeObjEx(Index, MyColor, MyTol: integer; MyHue, MySat: extended; MyUpTexts, MyOptions: TStringArray);
By: Rasta Magician
Description: Will save the information about an object to a global array.
Uses CTS 2
*******************************************************************************}
[/php]

Do notice that using SmartColors will reduce MSI's flexibility.

~RM

Yeah, but right now, I can't think of where that would be a problem. =\ Maybe it was the mouse actions? I don't remember.

Sir R. M8gic1an

2010-06-22 05:59:24

From: Coh3n
I should have said if we were to use something in SRL, I would rather use SmartColors. :p


Are you talking about replacing what we currently have? Or just adding SmartColors?


Yeah, but right now, I can't think of where that would be a problem. =\ Maybe it was the mouse actions? I don't remember.


Mouse actions are easy enough to change. SmartColors ALWAYS has to move the mouse, but we can just simply not make it click.

Where it loses flexibility is that we can mix any other algorithms into and so on.

eg: In my GM I could've used MatchTPAs to avoid it hovering the torches, but as it used SmartColors I couldn't mix the two algorithms without re-writing SC or pasting it into my script and editing it there.

~RM

Coh3n

2010-06-22 06:05:01

True, I don't know what we should do to be honest. I think that no matter what we end up doing, we'll run into some sort of difficulty later down the road. It always seems to work out that way.

Sir R. M8gic1an

2010-06-22 06:08:34

From: Coh3n
True, I don't know what we should do to be honest. I think that no matter what we end up doing, we'll run into some sort of difficulty later down the road. It always seems to work out that way.


I'd say the best way to fight difficulties is flexibility.

The truth is, some algorithms are better for some things than others.
So why not?

If our algorithm doesn't work as well as FindObjRecords when it comes to rocks.. then use FindObjRecords!

But do notice that this will clutter up our code, quite badly. And it is usually 'much' slower. I'd say we should test reliability and speed?

For now use our finder, and develop (other) things further. Later on we can come back to cracking object finding. Our finder is already pretty damn good.

Not Broken? Don't fix it!

edit: using other algorithms reduces our flexibility. If anything, we can incorporate them.

~RM

marpis

2010-06-22 08:23:52

From: Rasta Magician

For now use our finder, and develop (other) things further. Later on we can come back to cracking object finding. Our finder is already pretty damn good.


Why thankyou :)
Yea it's good for objects like NPCs and trees that have lots of colors that stand out from the background, but some objects really do require more than H/S modifiers and tolerance. At least progressive tolerance, like in SC.

Let's see how NCDS will do with the rocks. If they work OK, then I'll stop worrying about this for now.

Coh3n

2010-06-22 09:48:27

Don't forget to commit those bug fixes if you haven't already. :)