SRL Archive - OSR Help

Remove a TBox


P1ng

2012-08-29 03:07:36

Well I'd like to remove a TPA from a TBox or remove a TBox from a TBox and have this result as a new TBox.

I'm checking rocks immediately next to me for their ore vein colour but occassionally it will include my player in this box, I want to be able to remove the TBox of my player from this area to search.

I thought splitting the TPA into 25x25 sections would stop it selecting the player, not sure why this isn't working

Related function:
function IsOre: Boolean;
var
x, y, CTS: Integer;
RockTPA, Player: TPointArray;
Rock: T2DPointArray;
OreBox: TBox;
begin
Player := TPAFromBox(IntToBox(MSCx - 15, MSCy - 20, MSCx + 15, MSCy + 20));
// box around the player ^
CTS := GetColorToleranceSpeed; //< sets up for finding lighter rock colour
ColorToleranceSpeed(2); //<
SetColorSpeed2Modifiers(0.03, 0.72);//<

if FindColorsSpiralTolerance(x, y, RockTPA, 3759724, MSX1, MSY1, MSX2, MSY2, 14) then
begin //finds lighter rock colour ^
ClearTPAFromTPA(RockTPA, Player); //removes player from tpa
SortTPAFrom(RockTPA, IntToPoint(MSCx, MSCy)); //sorts points from closes to you
Rock := TPAToATPAEx(RockTPA, 25, 25); //splits into aTPA 25 by 25

OreBox := GetTPABounds(Rock[0]); //area to search for ore vein
SMART_DrawBoxEx(True, False, OreBox, ClGreen); //pretty box

SetColorSpeed2Modifiers(2.50, 0.28);//sets for ore searh
Result := FindColorTolerance(x, y, 2369061, OreBox.x1, OreBox.y1, OreBox.x2, OreBox.y2, 10);
end; //results true if ^ colour is found
SetColorSpeed2Modifiers(0.2, 0.2); //resets colour modifiers
end;

Runaway

2012-08-29 03:24:42

You forgot to set the CTS back to normal at the end ;) It looks like you've done everything else correctly though… maybe your Player TBox is too small?

riwu

2012-08-29 03:43:48

ClearTPAFromTPA is a function which returns the cleared TPA. You should assign a new variable to it to use the cleared TPA. Otherwise you will be using the same old unaltered TPA.

masterBB

2012-08-29 03:48:44

What Riwu said. But also to stop memory leaks:

ClearTPAFromTPAWrap(RockTPA, Player, RockTPA);

VastlySuperior

2012-08-29 07:19:46

From: P1ng
Well I'd like to remove a TPA from a TBox or remove a TBox from a TBox and have this result as a new TBox.

I'm checking rocks immediately next to me for their ore vein colour but occassionally it will include my player in this box, I want to be able to remove the TBox of my player from this area to search.

I thought splitting the TPA into 25x25 sections would stop it selecting the player, not sure why this isn't working

Related function:
function IsOre: Boolean;
var
x, y, CTS: Integer;
RockTPA, Player: TPointArray;
Rock: T2DPointArray;
OreBox: TBox;
begin
Player := TPAFromBox(IntToBox(MSCx - 15, MSCy - 20, MSCx + 15, MSCy + 20));
// box around the player ^
CTS := GetColorToleranceSpeed; //< sets up for finding lighter rock colour
ColorToleranceSpeed(2); //<
SetColorSpeed2Modifiers(0.03, 0.72);//<

if FindColorsSpiralTolerance(x, y, RockTPA, 3759724, MSX1, MSY1, MSX2, MSY2, 14) then
begin //finds lighter rock colour ^
ClearTPAFromTPA(RockTPA, Player); //removes player from tpa
SortTPAFrom(RockTPA, IntToPoint(MSCx, MSCy)); //sorts points from closes to you
Rock := TPAToATPAEx(RockTPA, 25, 25); //splits into aTPA 25 by 25

OreBox := GetTPABounds(Rock[0]); //area to search for ore vein
SMART_DrawBoxEx(True, False, OreBox, ClGreen); //pretty box

SetColorSpeed2Modifiers(2.50, 0.28);//sets for ore searh
Result := FindColorTolerance(x, y, 2369061, OreBox.x1, OreBox.y1, OreBox.x2, OreBox.y2, 10);
end; //results true if ^ colour is found
SetColorSpeed2Modifiers(0.2, 0.2); //resets colour modifiers
end;


Grrr, now you have gone and spoiled all my fun:p

P1ng

2012-08-29 07:27:13

Haha, sorry mate. Been working on this guild miner for a little while now, gave up until I could get the walking fixed and now that's done :D

E: Okay, so what Riwu suggested works just fine for ClearTPAFromTPA but ClearTPAFromTPAWrap is a procedure not a function and thus doesn't return a new TPA for me to use it with?