I'm stuck at this part, RSBot (and KBot) get this Renderdata through a callback function.. This is not possible in SMART, now Method said you can get this data through using fields in 'currentToolkit'.. However, I cannot find these hooks in any of the updater logs..
program new;
{.LoadDLL libsmart}
const
Plane = 'cw.T';
GroundByteArray = 'tk.k';
TileData = 'ta.M';
TileHeights = 'r';
function tilePlaneGetHeight(obj,xx,zz : integer) : integer;
var
x,z : integer;
i,j,k,l : integer;
begin
x := xx shr 7;
z := zz shr 7;
if ((x < 0) or (x>104) or (z < 0) or (z>104)) then
result := 0
else
begin
i := x and (128 - 1);
j := z and (128 - 1);
k := SmartGetFieldArray2DInt(obj,tileheights,x,z) * (128 - i) + (SmartGetFieldArray2DInt(obj,tileheights,x+1,z) * i) shr 7;
l := SmartGetFieldArray2DInt(obj,tileheights,x,z+1) * (128 - i) + (SmartGetFieldArray2DInt(obj,tileheights,x+1,z+1) * i) shr 7;
result := k * (128 - j) + (l * j) shr 7;
end;
end;
function GetTileHeight(xx,zz : integer) : integer;
var
p : integer;
x,z : integer;
obj : integer;
begin;
p := SmartGetFieldInt(0,Plane);
x := XX shr 7;
z := ZZ shr 7;
if ((x < 0) or (x>104) or (z < 0) or (z>104)) then
begin
result := 0;
exit;
end;
if ((p < 3) and ((SmartGetFieldArray3DByte(0,GroundByteArray,1,x,z) and 2) <> 0)) then
inc(p);
if SmartGetFieldArraySize(0,TileData) > p then
begin
obj := SmartGetFieldArrayObject(0,TileData,p);
result := tilePlaneGetHeight(obj,xx,zz);
SmartFreeObject(obj);
end;
end;
type
TRenderData = record
xOff,xX,xY,xZ : integer;
yOff,yX,yY,yZ : integer;
zOff,zX,zY,zZ : integer;
end;
TRender = record
absoluteX1,absoluteX2 : extended;
absoluteY1,absoluteY2 : extended;
xMultiplier,yMultiplier : integer;
zNear,zFar : integer;
end;
function w2s(x,y,z : integer) : TPoint;
var
RenderData : TRenderData;
Render : TRender;
_z,_x,_y : integer;
begin;
result := point(-1,-1);
with RenderData do
begin
xOff := 0; xX := 32768; xY := 0; xZ := 0;
yOff := 0; yX := 0; yY := 32768; yZ := 0;
zOff := 0; zX := 0; zY := 0; zZ := 32768;
end;
with Render do
begin
absoluteX1 := 0; absoluteX2 := 0;
absoluteY1 := 0; absoluteY2 := 0;
xMultiplier := 512; yMultiplier := 512;
zNear := 50; zFar := 3500;
end;
_z := (RenderData.zOff + ((RenderData.zX * x + RenderData.zY * y + RenderData.zZ * z) shr 15));
if( (_z < Render.zNear) or (_z > Render.zFar) ) then
exit;
_x := Render.xMultiplier * (RenderData.xOff + ( (RenderData.xX * x + RenderData.xY * y + RenderData.xZ * z) shr 15)) / _z;
_y L= Render.yMultiplier * (RenderData.yOff + ( (RenderData.yX * x + RenderData.yY * y + RenderData.yZ * z) shr 15)) / _z;
if ((_x >= Render.absoluteX1) and (_x <= Render.absoluteX2) and (_y >= Render.absoluteY1) and (_y <= Render.absoluteY2)) then
result := Point((_x - Render.absoluteX1), (_y - Render.absoluteY1));
end;
public static Point w2s(int x, int y, int z)
{
if(Bot.getClient().getDetailInfo() == null)
return new Point(-1, -1);
int detail_lvl = Bot.getClient().getDetailInfo().getDetailLevel();
if(detail_lvl == 0 || detail_lvl == 2)
{
int _z = (int) (RenderData.zOff + ((int) (RenderData.zX * x + RenderData.zY * y + RenderData.zZ * z) >> 15));
if( (_z < Render.zNear) || (_z > Render.zFar) )
return new Point(-1, -1);
int _x = Render.xMultiplier * ((int) RenderData.xOff + ((int) (RenderData.xX * x + RenderData.xY * y + RenderData.xZ * z) >> 15)) / _z;
int _y = Render.yMultiplier * ((int) RenderData.yOff + ((int) (RenderData.yX * x + RenderData.yY * y + RenderData.yZ * z) >> 15)) / _z;
if ((_x >= Render.absoluteX1) && (_x <= Render.absoluteX2) && (_y >= Render.absoluteY1) && (_y <= Render.absoluteY2))
return new Point((int) (_x - Render.absoluteX1), (int) (_y - Render.absoluteY1));
}
else if(detail_lvl == 1)
{
float _z = RenderData.zX * x + RenderData.zY * y + RenderData.zZ * z + RenderData.zOff;
if ( (_z < Render.zNear) || (_z > Render.zFar) )
return new Point(-1, -1);
final int _x = (int) (Render.xMultiplier * (RenderData.xX * x + RenderData.xY * y + RenderData.xZ * z + RenderData.xOff) / _z);
final int _y = (int) (Render.yMultiplier * (RenderData.yX * x + RenderData.yY * y + RenderData.yZ * z + RenderData.yOff) / _z);
if ((_x >= Render.absoluteX1) && (_x <= Render.absoluteX2) && (_y >= Render.absoluteY1) && (_y <= Render.absoluteY2))
return new Point((int) (_x - Render.absoluteX1), (int) (_y - Render.absoluteY1));
}
return new Point(-1, -1);
}
public static int tileHeight(final int X, final int Z) {
int p = Bot.getClient().getPlane();
final int x = X >> 7;
final int z = Z >> 7;
if ((x < 0) || (x > 104) || (z < 0) || (z > 104))
return 0;
if ((p < 3) && ((Bot.getClient().getGroundByteArray()[1][x][z] & 2) != 0)) {
p++;
}
final TileData[] dataArray = Bot.getClient().getTileData();
if ((dataArray.length > p) && (dataArray[p] != null))
return dataArray[p].getHeight(X, Z);
return 0;
}
// Calculations
public static Point tileToScreen(final int x, final int y, final double dX, final double dY, final int height) {
return Calculations.worldToScreen((int) ((x - Bot.getClient().getBaseX() + dX) * 128), (int) ((y - Bot.getClient().getBaseY() + dY) * 128), height);
}
public static Point tileToScreen(final int x, final int y, final int height) {
return Calculations.tileToScreen(x, y, 0.5, 0.5, height);
}
public static Point tileToScreen(final RSTile t) {
return Calculations.tileToScreen(t.getX(), t.getY(), 0);
}
public static Point tileToScreen(final RSTile t, final double dX, final double dY, final int height) {
return Calculations.tileToScreen(t.getX(), t.getY(), dX, dY, height);
}
public static Point tileToScreen(final RSTile t, final int h) {
return Calculations.tileToScreen(t.getX(), t.getY(), h);
}
public static void updateRenderInfo(final org.rsbot.accessors.Render r, final org.rsbot.accessors.RenderData rd) {
if ((r == null) || (rd == null))
return;
Render.absoluteX1 = r.getAbsoluteX1();
Render.absoluteX2 = r.getAbsoluteX2();
Render.absoluteY1 = r.getAbsoluteY1();
Render.absoluteY2 = r.getAbsoluteY2();
Render.xMultiplier = r.getXMultiplier();
Render.yMultiplier = r.getYMultiplier();
Render.zNear = r.getZNear();
Render.zFar = r.getZFar();
RenderData.xOff = rd.getXOff();
RenderData.xX = rd.getXX();
RenderData.xY = rd.getXY();
RenderData.xZ = rd.getXZ();
RenderData.yOff = rd.getYOff();
RenderData.yX = rd.getYX();
RenderData.yY = rd.getYY();
RenderData.yZ = rd.getYZ();
RenderData.zOff = rd.getZOff();
RenderData.zX = rd.getZX();
RenderData.zY = rd.getZY();
RenderData.zZ = rd.getZZ();
}
public static Point worldToMinimap(double x, double y) {
x -= Bot.getClient().getBaseX();
y -= Bot.getClient().getBaseY();
final int calculatedX = (int) (x * 4 + 2) - Bot.getClient().getMyRSPlayer().getX() / 32;
final int calculatedY = (int) (y * 4 + 2) - Bot.getClient().getMyRSPlayer().getY() / 32;
try {
final org.rsbot.accessors.RSInterface mm = DynamicConstants.getMinimapInterface();
if (mm == null)
return new Point(-1, -1);
final RSInterfaceChild mm2 = RSInterface.getChildInterface(mm.getID());
final int actDistSq = calculatedX * calculatedX + calculatedY * calculatedY;
final int mmDist = 10 + Math.max(mm2.getWidth() / 2, mm2.getHeight() / 2);
if (mmDist * mmDist >= actDistSq) {
int angle = 0x3fff & (int) Bot.getClient().getMinimapOffset();
if (Bot.getClient().getMinimapSetting() != 4) {
angle = 0x3fff & Bot.getClient().getMinimapAngle() + (int) Bot.getClient().getMinimapOffset();
}
int cs = Calculations.CURVESIN[angle];
int cc = Calculations.CURVECOS[angle];
if (Bot.getClient().getMinimapSetting() != 4) {
final int fact = 256 + Bot.getClient().getMinimapScale();
cs = 256 * cs / fact;
cc = 256 * cc / fact;
}
final int calcCenterX = cc * calculatedX + cs * calculatedY >> 15;
final int calcCenterY = cc * calculatedY - cs * calculatedX >> 15;
final int screenx = calcCenterX + mm2.getAbsoluteX() + mm2.getWidth() / 2;
final int screeny = -calcCenterY + mm2.getAbsoluteY() + mm2.getHeight() / 2;
// Check if point is within the circel of the minimap instead of
// the
// rectangle!
if ((Math.max(calcCenterY, -calcCenterY) <= mm2.getWidth() / 2.0 * .8) && (Math.max(calcCenterX, -calcCenterX) <= mm2.getHeight() / 2 * .8))
return new Point(screenx, screeny);
else
return new Point(-1, -1);
}
} catch (final NullPointerException ignored) {
}
return new Point(-1, -1);// not on minimap
}
public static Point worldToScreen(final int x, final int z, final int height) {
if ((Bot.getClient().getGroundByteArray() == null) || (Bot.getClient().getTileData() == null) || (Bot.getClient().getDetailInfo() == null) || (x < 128) || (z < 128) || (x > 13056) || (z > 13056))
return new Point(-1, -1);
int y = Calculations.tileHeight(x, z) - height;
Point p = w2s(x, y, z);
if ((p != null) && Calculations.onScreen(p))
return p;
return new Point(-1, -1);
}
private Calculations() {
}
}
function TileToMS(Tile:TPoint; height: integer): TPoint;
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;
begin
end.
Note that there is just some copied+pasted code in there, just the top 2 functions are up2date.. And the rest is from RSBot (and the current TileToMS)