bud_wis_er_420
2013-05-30 15:16:35
I'm having a problem with setting a box array length and storing only valid cords.
if you take a look at the output below, under the red text, you will see…
I have a hard time explaining things so let me know if you need further detail of what I'm trying to accomplish.
The the output of the script below
The Script I am using. This is a striped down ver of the original function.
if you take a look at the output below, under the red text, you will see…
Converted MS Point 0 := (-1, -1)
Converted MS Point 1 := (-1, -1)
Converted MS Point 2 := (-1, -1)
Converted MS Point 3 := (-1, -1)Those are invalid points I need to remove before I try making boxes out of them. Then I will have to set the Abox length. For the Example output below I want the ending results to look like this…Find Colors 0 in box (156, 4, 236, 61)
Find Colors 1 in box (189, 6, 269, 86)
Find Colors 2 in box (117, 27, 197, 107)
Find Colors 3 in box (262, 96, 342, 176)
Find Colors 4 in box (168, 236, 248, 260)not like it is now…Find Colors 0 in box (156, 4, 236, 61)
Find Colors 1 in box (189, 6, 269, 86)
Find Colors 2 in box (117, 27, 197, 107)
Find Colors 3 in box (262, 96, 342, 176)
Find Colors 4 in box (168, 236, 248, 260)
Find Colors 5 in box (0, 0, 0, 0)
Find Colors 6 in box (0, 0, 0, 0)
Find Colors 7 in box (0, 0, 0, 0)
Find Colors 8 in box (0, 0, 0, 0)I have a hard time explaining things so let me know if you need further detail of what I'm trying to accomplish.
The the output of the script below
Number of Player dots found: 8
MM Point 0 := (604, 38)
MM Point 1 := (616, 50)
MM Point 2 := (612, 54)
MM Point 3 := (619, 58)
MM Point 4 := (619, 66)
MM Point 5 := (623, 70)
MM Point 6 := (615, 73)
MM Point 7 := (631, 82)
MM Point 8 := (622, 97)
Converted MS Point 0 := (-1, -1)
Converted MS Point 1 := (-1, -1)
Converted MS Point 2 := (-1, -1)
Converted MS Point 3 := (-1, -1)
Converted MS Point 4 := (196, 21)
Converted MS Point 5 := (229, 46)
Converted MS Point 6 := (157, 67)
Converted MS Point 7 := (302, 136)
Converted MS Point 8 := (208, 276)
MS Point out of bounds: (-1, -1)
MS Point out of bounds: (-1, -1)
MS Point out of bounds: (-1, -1)
MS Point out of bounds: (-1, -1)
Find Colors 0 in box (156, 4, 236, 61)
Find Colors 1 in box (189, 6, 269, 86)
Find Colors 2 in box (117, 27, 197, 107)
Find Colors 3 in box (262, 96, 342, 176)
Find Colors 4 in box (168, 236, 248, 260)
Find Colors 5 in box (0, 0, 0, 0)
Find Colors 6 in box (0, 0, 0, 0)
Find Colors 7 in box (0, 0, 0, 0)
Find Colors 8 in box (0, 0, 0, 0)The Script I am using. This is a striped down ver of the original function.
program new;
{$DEFINE SMART8}
{$I SRL/SRL.Simba}
{$IFDEF SIMBAMAJOR980}
{$I SRL/SRL/Misc/PaintSmart.Simba}
{$ELSE}
{$I SRL/SRL/Misc/SmartGraphics.Simba}
{$ENDIF}
function AttackPlayer: Boolean;
Var
x, y, i, L, c, tmpCTS: Integer;
TP: TPoint;
TPA, TempTPA, TTPA, MMTPA: TPointArray;
ATPA: T2DPointArray;
Box: TBox;
ABox: TBoxArray;
Begin
Result := False;
MMTPA := GetMiniMapDots('w');
L := High(MMTPA);
SetArrayLength(ABox, L + 1);
writeln('Number of Player dots found: ' + ToStr(L));
for i := 0 to L do
begin
Writeln('MM Point ' + ToStr(i) + ' := ' + ToStr(MMTPA[i]));
end;
for i := 0 to L do
begin
Writeln('Converted MS Point ' + ToStr(i) + ' := ' + ToStr(MMtoMS(MMTPA[i])));
end;
//keeps boxes in Main Screen range
c := 0;
for i := 0 to L do
begin
TP := MMtoMS(MMTPA[i]); // Gets Main Screen Point from MM Point
// if TPoint is off main screen I need to remove one array length from ABox
if (TP.x < 0) or (TP.x < 0) then
begin
writeln('MS Point out of bounds: ' + ToStr(TP));
//Dec(DCount); //Couldn't get this way to work
//SetArrayLength(ABox, DCount);
end else
begin
// if box cord out of bounds, changes it to edge of main screen
if ((TP.x - 40) < MSX1) then
ABox[c].x1 := MSX1
else ABox[c].x1 := TP.x - 40;
if ((TP.x + 40) > MSX2) then
ABox[c].x2 := MSX2
else ABox[c].x2 := TP.x + 40;
if ((TP.y - 40) < MSY1) then
ABox[c].y1 := MSY1
else ABox[c].y1 := TP.y - 40;
if ((TP.y + 40) > 260) then
ABox[c].y2 := 260
else ABox[c].y2 := TP.y + 40;
Inc(c);
end;
end;
SMART_DrawBoxes(False, False, ABox, clRed);
for i := 0 to L do
begin
writeln('Find Colors ' + ToStr(i) + ' in box ' + ToStr(ABox[i]));
end;
end;
begin
ClearDebug;
AttackPlayer;
end.