Wizzup?
2008-01-17 16:35:22
Thanks, Ruroken:
//RS Build = #489
const
//Hooking RSString
StringBytes = 'X'; //byte[]*
// Hooking NPC
NPCIndexarray = 'o.P';//*
NPCArray = 'client.hb';//*
NPCDef = 'Ec';//*
NPCCount = 'gf.t';//*
//Hooking NPCDef
NPCActions = 'ib';//*
NPCsName = 'vb';//*
//Hooking PlayerDef
CharName = 'wc'; //StringWrap*
//Hooking Position
BaseX = 'ki.cb'; //int* (getBaseX)
MyPlayer = 'rf.B'; //Player* (getMyPlayer)
BaseY = 'eb.t'; //int* (getBaseY)
//Hooking Character
CharAnim = 'hc'; //int*
CharMotion = 'Eb'; //int*
CurrentX = 'sc'; //int*
CurrentY = 'Zb'; //int*
//Hooking Entity
CharHeight = 'Q';//*
//Hooking GroundInt
GroundHeights = 'ee.wb'; //int[][][] (groundIntArray)*
//Hooking GroundByteArray
GroundSettings = 'c.s'; //byte[][][] (groundByteArray)*
//Hooking Camera
BaseLayer = 'rc.F'; //int* (plane/terrainInt)
CamX = 'ga.B'; //int*
CamY = 'jh.h'; //int*
CamZ = 'qi.W'; //int*
//Hooking CameraCurves
CamPitch = 'sg.x'; //int* (CamCurveX)
CamYaw = 'sd.k'; //int* (CamCurveY)
//Hooking SettingArray
SettingsArray = 'ed.R'; //int[]*
//Hooking Skills
MaxLevels = 'client.fb'; //int[]* (getSkillLevelMaxes)
CurrentLevels = 'u.i'; //int[]* (getSkillLevels)
Experiances = 'bg.i'; //int[]* (getSkillExperiences)
//Hooking Minimap
MapOffsetAngle = 'oa.s'; //int* (MinimapInt2)
CompassAngle = 'oa.'; //int* (MinimapInt1)
Reflection:
{.include SRL\SRL\misc\Hooks.scar}
//Returns the current level of your player (its a funny array)
function GetLevel(index: integer): integer;
begin
result:= SmartGetFieldArrayInt(0,CurrentLevels,index);
end;
//Converts a byte[] from StringWrap to a DelphiString (max length 256)
function StringFromBytes(jbytearray: integer): string;
begin
SetLength(result, 256);
SetLength(result, SmartStringFromBytes(jbytearray,result));
end;
//Returns last logged in player's name
function GetMyName: string;
var
bytes: Integer;
begin
bytes:= SmartGetFieldObject(0,MyPlayer+'.'+CharName+'.'+StringBytes);
result:= StringFromBytes(bytes);
SmartFreeObject(bytes);
end;
//Returns your animation
function GetMyAnim: integer;
begin
result:= SmartGetFieldInt(0,MyPlayer+'.'+CharAnim);
end;
//True if you are moving
function GetMyMoving: boolean;
begin
result:= SmartGetFieldInt(0,MyPlayer+'.'+CharMotion) > 0;
end;
//Calculates your x,y position or [somehugenumber] if not logged in
procedure GetMyPos(var x, y: Integer);
var
me: Integer;
begin
me:= SmartGetFieldObject(0,MyPlayer);
x:= SmartGetFieldInt(0,BaseX) + SmartGetFieldInt(me,CurrentX) shr 7;
y:= SmartGetFieldInt(0,BaseY) + SmartGetFieldInt(me,CurrentY) shr 7;
SmartFreeObject(me);
end;
//Dumps the settings array to an integer array
function DumpSettingArray: array[0..1999] of integer;
var
i: integer;
begin
for i:= 0 to 1999 do
Result[i]:= SmartGetFieldArrayInt(0,SettingsArray,i);
end;
//Returns -1 if no box open or 0..2 for the correct answer to the box
function BoxAnswer: integer;
var
boxIndex: Integer;
begin
boxIndex:= SmartGetFieldArrayInt(0,SettingsArray,312);
if boxIndex = 0 then
result:= -1
else
result:= (boxIndex shr 24) and $FF;
end;
//Returns the current Map angle in degrees
function GetMinimapAngleDeg: extended;
var
clientAngle: integer;
begin
clientAngle:= (SmartGetFieldInt(0,CompassAngle) + SmartGetFieldInt(0,MapOffsetAngle)) mod 2048;
result:= clientAngle * 180 / 1024;
end;
//Returns the current map angle in radians
function GetMinimapAngleRad: extended;
var
clientAngle: integer;
begin
clientAngle:= (SmartGetFieldInt(0,CompassAngle) + SmartGetFieldInt(0,MapOffsetAngle)) mod 2048;
result:= clientAngle * Pi / 1024;
end;
//converts the tile position tileX,tileY to a minimap location
procedure TileToMinimap(tileX, tileY: integer; var screenX, screenY: integer);
var
angle: extended;
tempX, tempY: integer;
begin
angle:= getMinimapAngleRad;
GetMyPos(tempX, tempY);
tempX:= (tileX - tempX) * 4 - 2;
tempY:= (tempY - tileY) * 4 - 2;
screenX:= round(tempX*cos(angle) - tempY*sin(angle)) + 627;
screenY:= round(tempX*sin(angle) + tempY*cos(angle)) + 85;
end;
//converts the screen position screenX,screenY from the minimap to a tile
procedure MinimapToTile(screenX, screenY: integer; var tileX, tileY: integer);
var
angle: extended;
tempX, tempY: integer;
begin
angle:= getMinimapAngleRad;
tempX:= (screenX - 627);
tempY:= (95 - screenY);
tileX:= round(tempX*cos(angle) - tempY*sin(angle)) / 4;
tileY:= round(tempX*sin(angle) + tempY*cos(angle)) / 4;
GetMyPos(tempX, tempY);
tileX:= tileX + tempX;
tileY:= tileY + tempY;
end;
//converts the tile position tileX,tileY to a mainscreen location
//height is the distance (in px) off the ground
procedure TileToWorld(tileX, tileY, height: integer; var screenX, screenY: integer);
var
cx, cy, cz, dx, dy, dz, locX, locY, layer: Integer;
pitch, yaw, sinYaw, cosYaw, sinPitch, cosPitch, rotation: extended;
begin
locX:= tileX - SmartGetFieldInt(0,BaseX);
locY:= tileY - SmartGetFieldInt(0,BaseY);
if (locX < 0) or (locY < 0) or (locX > 103) or (locY > 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);
screenX:= (dx * 512) / dy + 256;
screenY:= (dz * 512) / dy + 167;
end;
