Official Soldat Forums
Server Talk => Scripting Releases => Topic started by: DorkeyDear on July 20, 2007, 07:37:30 pm
-
Script Name: Polygon Edge XY
Script Description: It finds the X and Y coordinates of a point on the edge of a polygon (not completely accurate, you may change the number 10 to a larger number for more accurate numbers) by the intersection of a specified line (made by 2 points) where as point 1 is outside of the polygon and point 2 is within the polygon.
Original Author: Curt (DorkeyDear)
Core Version: 2.6.2 (untested)
Code: procedure GetPolygonEdgeXY(X1,Y1,X2,Y2: single; var X,Y: single; const MaxDist: integer);
var
i: integer;
D: single;
begin
for i := 1 to 10 do begin
if RayCast(X1,Y1,X2,Y2,D,MaxDist) then begin
X1 := (X1 + X2) / 2;
Y1 := (Y1 + Y2) / 2;
end else begin
X2 := (X1 + X2) / 2;
Y2 := (Y1 + Y2) / 2;
end;
end;
X := (X1 + X2) / 2;
Y := (Y1 + Y2) / 2;
end;
-
Wait - what is this?!
I don't understand what this does and how it's useful :/
-
Yeah uh, whats the point... And you should not be posting crap you haven't testing
-
well, finding how far a polygon is away can be useful... ;Q
-
A better method would be to convert to parameterized vectors, and calculate the point exactly... I'll find some some VB code I have in a bit, and let someone convert it.
Edit: Scratch that, not possible currently as you can't get map information. :'(
-
ummm, mines anyone?
-
Yeah uh, whats the point... And you should not be posting crap you haven't testing
but it's curt, he always posts random short-scripts...
-
:D I love posting random stuff, and its really hard to test a script that is untestable unless somebody with access to the unreleased server version tests it for me :)