Runescapian321
2009-07-11 17:43:57
Well there's a TileToMS, I was wondering if it's possible to have an MSToTile? Something like:
function MSToTile(x,y : integer) : TPoint;
Here's TileToMS:
I'd do it myself, but I don't really understand all of the SmartGetFieldInt stuff :\ Could someone tell me if this is possible and/or point me in the right direction and/or make an MSToTile function? :)
function MSToTile(x,y : integer) : TPoint;
Here's TileToMS:
function TileToMS(Tile:TPoint; height: integer): TPoint;
var
cx, cy, cz, dx, dy, dz, locX, locY, layer: Integer;
pitch, yaw, sinYaw, cosYaw, sinPitch, cosPitch, rotation: extended;
begin
locX:= Tile.x - SmartGetFieldInt(0, BaseX);
locY:= Tile.y - SmartGetFieldInt(0, BaseY);
if not (InRange(LocX, 0, 103) or InRange(LocY, 0, 103)) then
Exit;
layer:= SmartGetFieldInt(0,BaseLayer);
if (layer < 3) and ((2 and SmartGetFieldArray3DByte(0,GroundSettings,1,locX,locY)) = 2) then
Inc(layer);
cz:= SmartGetFieldArray3DInt(0,GroundHeights,layer,locX,locY) +
SmartGetFieldArray3DInt(0,GroundHeights,layer,locX+1,locY) +
SmartGetFieldArray3DInt(0,GroundHeights,layer,locX,locY+1) +
SmartGetFieldArray3DInt(0,GroundHeights,layer,locX+1,locY+1);
cx:= locX * 128 + 64 - SmartGetFieldInt(0,CamX);
cy:= locY * 128 + 64 - SmartGetFieldInt(0,CamY);
cz:= (cz / 4) - height - SmartGetFieldInt(0,CamZ);
pitch:= SmartGetFieldInt(0,CamPitch) * Pi / 1024;
yaw:= SmartGetFieldInt(0,CamYaw) * Pi / 1024;
sinYaw:= sin(yaw);
cosYaw:= cos(yaw);
sinPitch:= sin(pitch);
cosPitch:= cos(pitch);
rotation:= cosYaw*cy-sinYaw*cx;
dx:= Round(sinYaw*cy+cosYaw*cx);
dy:= Round(sinPitch*cz+cosPitch*rotation);
dz:= Round(cosPitch*cz-sinPitch*rotation);
try
Result.x:= (dx * 512) / dy + 256;
Result.y:= (dz * 512) / dy + 167;
except end;
end;I'd do it myself, but I don't really understand all of the SmartGetFieldInt stuff :\ Could someone tell me if this is possible and/or point me in the right direction and/or make an MSToTile function? :)