SRL Archive - OSR Help

Make a box with sps?


Element17

2012-06-15 17:08:45

Is there a way to use spsgetmypos and make a box?

like this:

http://s1192.photobucket.com/albums/aa321/andrewvar/?action=view¤t=fq4t3tt3t.png


Which would make a box. Now if I do that could I say if the player is in that box then exit whatever function/loop etc.

YoHoJo

2012-06-15 17:10:27

Might want to draw a picture on paint or something to better explain exactly what you want?
Your text format didn't work properly :D.

Also look into ObjectDTMs, they have a feature like that for sure, and they are AWESOME!

Element17

2012-06-15 17:12:52

I love ObjectDTM! hahah, I did see something about making sure if you are in an area, but also saw there was some controversy over it too? Either way I will check it out and I uploaded a picture to try and explain it better :)

putonajonny

2012-06-15 17:16:59

This might be useful, it determines whether you are in an area using SPS co-ords, it also debugs it on the MM if you set ObjDTM_Debug to true (uses some ObjDTM functions):
Function PosToMM(Pos, MyPos : TPoint) : TPoint;
begin
Result := Point(MMCX + Pos.X - MyPos.X, MMCY + Pos.Y - MyPos.Y);
end;

Function SPS_InArea(x, y : integer; Area : array of TPoint; MyPos : TPoint) : Boolean;
Var
A : array of TPoint;
i, H : integer;
begin

SetArrayLength(A, GetArrayLength(Area));

H := high(Area);
for i := 0 to H do
A[i] := PosToMM(Area[i], MyPos);

Result := PointInPolygon(x, y, A);

end;

kitchenrange

2012-06-15 18:03:41

From: putonajonny
This might be useful, it determines whether you are in an area using SPS co-ords, it also debugs it on the MM if you set ObjDTM_Debug to true (uses some ObjDTM functions):
Function PosToMM(Pos, MyPos : TPoint) : TPoint;
begin
Result := Point(MMCX + Pos.X - MyPos.X, MMCY + Pos.Y - MyPos.Y);
end;

Function SPS_InArea(x, y : integer; Area : array of TPoint; MyPos : TPoint) : Boolean;
Var
A : array of TPoint;
i, H : integer;
begin

SetArrayLength(A, GetArrayLength(Area));

H := high(Area);
for i := 0 to H do
A[i] := PosToMM(Area[i], MyPos);

Result := PointInPolygon(x, y, A);

end;


I like that a lot. I'm using one that uses rectangles, but I like the idea of the polygon. You can define your areas better.

Nebula

2012-06-15 18:10:10

PointToBox?

Runaway

2012-06-15 18:10:26


var
SPSPos: TPointArray;
MyPos: TPoint;
Box: TBox;

MyPos := {whatever gets your position};
Box := IntToBox(SPSPos[1].x, SPSPos[1].y, SPSPos[2].x, SPSPos[2].y);
if PointInBox(MyPos, Box) then
begin
// ...
end;

I'm unfamiliar with SPS, but I think that is what the picture you made suggests you want done.

putonajonny

2012-06-15 18:36:12

If you made mine work with boxes it would look like this:
Function PosToMM(Pos, MyPos : TPoint) : TPoint;
begin
Result := Point(MMCX + Pos.X - MyPos.X, MMCY + Pos.Y - MyPos.Y);
end;

Function SPS_InArea(x, y : integer; Box : TBox; MyPos : TPoint) : Boolean;
Var
A : TBox;
i, H : integer;
begin

SetArrayLength(A, GetArrayLength(Area));

H := high(Area);
A := PointToBox(PosToMM(Box.x1, Box.y1), PosToMM(Box.x2, Box.y2));

SMART_ClearCanvasArea(MMBox);
SMART_DrawBoxEx(False, A, clPurple);
SMART_DrawCircle(False, Point(x, y), 5, True, clAqua);

Result := PointInBox(Point(x, y), A);

end;

Element17

2012-06-15 21:06:54

Wow thanks guys! Seriously a great community. Rep++