SRL Archive - OutDated Tutorials

Some Reflection Stuff


Widget

2008-07-22 00:38:02

Don't know what reflection is?
Reflection is SMART's equivalent to the client hacking that RSBot does and whatever iBot/Nexus does to read variables directly from the Runescape client. Reflection does not modify the client and is therefore undetectable. Reflection currently allows us to flawlessly find NPCs and Players, get the mainscreen position of any tile.

As you've probably figured out, Runescape is made up of squares, or "tiles". The tiles are layed out on a big grid, and as such, each one has a coordinate. Using this, flawless walking becomes possible, and we can now embark on scripts that we've never imagined possible :D.

All this is made possible using BenLand100's SMART reflection methods and a little help from the RSBot creators (Speljohan and Quaters).


SUBVERSION!!
Using the subversion that you have installed to download SRL:
svn checkout http://scarreflection.googlecode.com/svn/trunk/ scarreflection-read-only
or with TortoiseSVN, just
http://scarreflection.googlecode.com/svn/trunk/

People wishing to be able to update it should PM Timer, and here's the project page.

Reflection files should be placed in SRL/SRL/Reflection, and including it will look like this:
{.include srl/srl/misc/smart.scar}
{.include srl/srl.scar}
{.include srl/srl/reflection/reflection.scar}


Thanks to BenLand100, Quaters, Speljohan, Timer, ss23, TheGuyWhoGotOn, n3ss3s, MasterKill, Waddo, Yakman, and Method for helping with functions and hooks :) (There's probably more people now but whatever [just post if I forgot you]).


(* Core.scar *)
function StringFromBytes(jbytearray: integer): string;
function DumpSettingArray: array[0..1999] of integer;
function GetBoxAnswer: integer;
function GetMinimapAngleDeg: extended;
function GetMinimapAngleRad: extended;
Function R_MakeCompass(Dir: String): Boolean;
procedure R_SetAngle(Setting: Variant);
function GetSpeed: integer;
function CharacterMoving: boolean;
function GetMyPos:TPoint;
function TileToMS(Tile:TPoint; height: integer): TPoint;
Function TileOnMS(Tile: TPoint; Height : Integer) : Boolean;
function TileToMM(Tile: TPoint): TPoint;
function MMToTile(Screen: TPoint): TPoint;
Function TileOnMM(Tile: TPoint): Boolean;
function R_LoggedIn: Boolean;

(* Walking.scar *)
Function WalkToTile(Tile: TPoint; Randomness, FlagD: Integer): Boolean;
function GetFlag(var x, y: Integer): boolean;
procedure R_FFlag(Dist: Integer);
Procedure R_Flag;
Function DistanceFrom(Tile: TPoint) : Integer;

(* Characters.scar *)
function GetMyName: string;
function GetNPCs: array of TNPC;
function GetNPCsByName(name:string): array of TNPC;
function GetNPCsByID(TheType:integer): array of TNPC;
function SortNPCs(NPCs:array of TNPC): array of TNPC;
Function FindNPC(Name: string; var NPC: TNPC): boolean;
Function FindNPCByID(ID: integer; var NPC: TNPC):boolean;
function GetPlayers: array of TPlayer;
function GetPlayer(name: string): TPlayer;
function GetMe: TMe;

(* Objects.scar *)
Function OpenBankReflection(Bank : String): Boolean;
type
TNPC = record
Tile, MS, MM: TPoint;
NPCType, height, animation: integer;
Name : string;
InFight, IsMoving: boolean;
end;
TPlayer = record
Tile, MS, MM: TPoint;
animation, speed: integer;
HPRatio, height, level: integer;
Name: string;
end;
TMe = record
Tile, MS: TPoint;
animation, speed, LoginIndex: integer;
HPRatio, height, level: integer;
Combat: integer;
Name: string;
InFight: boolean;
Experience, Levels: array[0..23] of Integer;
end;



Ok, and then here's an NPC Debugger (sorry for my standards >.<):
program DebugNPCs;
{.include srl/srl/misc/smart.scar}
{.include srl/srl.scar}
{.include srl/srl/reflection/reflection.scar}
var
i:integer;
NPCs:array of TNPC;
Peoples: array of TPlayer;
s:string;
p:TPoint;
begin
SetupSRL;
SetupReflection;
SmartSetup('world60', True, False, False);
//sleep(25000);
while true do
repeat
try
ClearDebug;
NPCs := SortNPCs(GetNPCs);
//NPCs := SortNPCs(GetNPCsByID(3795));
p := GetMyPos;
writeln('Tile ('+inttostr(p.x)+', '+inttostr(p.y)+')');
writeln('MS ('+inttostr(TileToMS(p,20).x)+', '+inttostr(TileToMS(p,20).y)+')');
Writeln('NPCs on screen: '+inttostr(GetArrayLength(NPCs)));
for i := 0 to High(NPCs) do
begin
s := padr(NPCs[i].Name,20);
s := s + ' ID: '+padr(inttostr(NPCs[i].NPCType),7);
s := s + ' ('+inttostr(NPCs[i].Tile.X)+', '+inttostr(NPCs[i].Tile.Y)+')';
s := s + ' In Fight: '+BoolToStr(NPCs[i].InFight);
s := s + ' Is Moving: '+BoolToStr(NPCs[i].IsMoving);
Writeln(s);
end;
Peoples := GetPlayers;
for i := 0 to High(Peoples) do
begin
s := padr(Peoples[i].Name,15);
s := s + ' ('+inttostr(Peoples[i].Tile.X)+', '+inttostr(Peoples[i].Tile.Y)+')';
s := s + ' Level: '+Padr(IntToStr(Peoples[i].Level),2);
s := s + ' Is Moving: '+Padr(BoolToStr(Peoples[i].Speed > 0),5);;
s := s + ' HP%: '+Padr(IntToStr(Peoples[i].HPRatio),3);
Writeln(s);
end;
sleep(1500);
except
writeln('oh noes!')
sleep(1500);
end;
until False;
end.

And last but not least, I've made two crappyish video tutorials:
- http://www.youtube.com/watch?v=kTFqJgy9kZk
- http://www.youtube.com/watch?v=qc_X_o1REMM


Also, a reflection Tut by Timer!
- http://www.srl-forums.com/forum/showthread.php?t=36307

Bourdou!

2008-07-22 00:40:24

*Dies*

Things have changed…

*Dies again*

NiCbaZ

2008-07-22 02:18:10

Great, this is great o have had this for a few days now and im loving it i use walking for it ( backed with dtms and radialwalk of course) but never have been able to get the NPC finding working… il try later anyway great job…

also here is a more user friendly walktotile, im sure you can edit it to make it better but more user friendly.

Function WalkToTile(TileX, TileY,Flag,xrandom,yrandom : Integer): Boolean;
{*******************************************************************
Function - Function WalkToTile(TileX, TileY,Flag,xrandom,yrandom : Integer): Boolean;
By: ss23 and Widget and nicbaz
Description: Walks to the tile using minimap.
********************************************************************}
Var
x, y : Integer;
Begin
TileToMinimap(Tilex, Tiley, x, y);
if not TileOnMM(TileX, TileY) then
begin
Writeln('Tile off minimap');
Result := False;
Exit;
end;
Mouse(x, y, xrandom, yrandom, True);
FFlag(Flag);
Result := True;
end;

Waddo

2008-07-22 06:58:00

yer now we need to know more about them i wasnt in the cheating scene when kyab was around so i dont really undrstad then and there downsides all i know is it reads java variables

Claymore

2008-07-23 14:18:54

So, i put this is in the Misc folder and rename to Reflection.scar?

Sorry, im just new to the SRL Members thing =3

Wanted

2008-07-23 15:14:16

From: deathscytex
So, i put this is in the Misc folder and rename to Reflection.scar?

Sorry, im just new to the SRL Members thing =3


Yes

{.Include SRL\SRL.SCAR}
{.Include SRL\SRL\Misc\Reflection.SCAR}

after you did that stuff above… there are many other ways of doing this as well.

Widget

2008-07-24 04:40:23

{.include SRL\SRL\Misc\Smart.SCAR}
{.Include SRL\SRL.SCAR}
{.Include SRL\SRL\Misc\Reflection.SCAR}
Remember to include SMART ;)

But yeah, updated NPC finding since NPC heights were returning negative thus making it not return the right coords. Also some preview stuff for Player getting (doesn't work yet) :)

mastaraymond

2008-07-24 11:44:26

Gj! Widget! Now teach us howto do it ;).

MasterKill

2008-07-24 12:14:46

teatch meh! I love now and better things :) Good job on your read runscape smar thingy. And good job widget and ss23 for making a good start with it.

Waddo

2008-07-24 19:26:35

Function FindNPCByID(ID: integer; var NPC: TNPC):boolean;
{*******************************************************************
function FindNPC(Name: string; var x,y:integer):boolean;

you need to fix that =]

Wooo credits.
but where's my function:rolleyes:

Procedure GetNPCInfo;
{*******************************************************************
Procedure GetNPCInfo;
By: Waddo
Description: Displays the info of loaded NPC's.
********************************************************************}
var
i: integer;
NPCs: array of TNPC;
begin
NPCs := GetNPCs;
if (GetArrayLength(NPCs)=0) then Exit;
for i := 0 to High(NPCs) do
writeln('NPC: '+NPCs[i].Name+' ID: '+IntToStr(NPCs[i].NPCType)+
' Tile X: '+IntToStr(NPCs[i].TileX)+' Tile Y: '+IntToStr(NPCs[i].TileY));
end;

TheGuyWhoGotOn

2008-07-24 19:47:11

I've added LongWalk and LongWalkEx. I've also made OpenBankReflection more reliable. Should I post my changes?

Edit: Waddo, what use is your procedure? (Not meant as an insult but an actual question)
I mean it doesn't seem to benefit the script in any way :P. It would be neat though just not necessary.

Also yah…I've noticed a few of the FindNPC things don't correspond with anything else where they are mentioned. Maybe Widget will fix that :P.

Waddo

2008-07-24 19:50:11

this is coming together pretty fast how what other variables does it out put?
can we use it for obj finding

TheGuyWhoGotOn

2008-07-24 20:01:08

From: Waddo
this is coming together pretty fast how what other variables does it out put?
can we use it for obj finding


I doesn't work with object finding right now I heard n3ss3s (Did I spell that right?) is working it. I don't know how to setup object finding. To me it looks like the hook isn't there but I'm a bit of a reflection noob.

I did make LongWalk for KYAB though so it was easy to re-make but I think my new one might be better. For the variables it can output…From a quick glance it seems like it can output just about anything. What's setup right now (Also told from Widget's post) are many NPC things (Thanks to Widget), your move speed (Making it so you can see if you're walking), your animation, your name, your position, a mysterious box answer, the level of a skill, and your CompassAngle. There is of course probably many more things it can read but that's just at a glance.

Funny here I am working on the include and I wasn't planning on using reflection. After the post about the fail safes though…I decided that maybe we could use reflection to good use.

Edit: Done path walking…Can I post it please?

Waddo

2008-07-24 20:30:11

just post it already ;-] and yes you spelt N3ss3s right

I wasn't around when kyab was so I I'm complete beginner to reflection.

TheGuyWhoGotOn

2008-07-24 20:50:44

Ok ok, I'll post it…Any opinions on LongWalk or PathWalk?

Edit: OK now NPC stuff works ^_^ thanks to Widget!


//------------------------------------------------------------------\\
//-- Scar Non-Standard Resource Library --||
//-- » Reflection Routines --||
//------------------------------------------------------------------//
// * Function GetLevel(index: integer): integer; // * by BenLand100
// * Function StringFromBytes(jbytearray: integer): string; // * by BenLand100
// * Function GetMyName: string; // * by BenLand100
// * Function GetAnimation: integer; // * by BenLand100
// * Function GetSpeed: integer; // * by Widget
// * Function CharacterMoving: boolean; // * by BenLand100
// * Procedure GetMyPos(var x, y: Integer); // * by BenLand100
// * Function GetBoxAnswer: integer; // * by BenLand100
// * Function GetMinimapAngleDeg: extended; // * by BenLand100
// * Function GetMinimapAngleRad: extended; // * by BenLand100
// * Procedure TileToMinimap(tileX, tileY: integer; var screenX, // * by BenLand100
// screenY: integer); //
// * Procedure MinimapToTile(screenX, screenY: integer; var tileX, // * by BenLand100
// tileY: integer); //
// * Procedure TileToMS(tileX, tileY, height: integer; // * by BenLand100
// var screenX, screenY: integer); //
// * Function TileOnMM(TileX, TileY : Integer) : Boolean; // * by ss23
// * Function TileOnMS(TileX, TileY, Height : Integer) : Boolean; // * by ss23
// * Function DistanceFrom(TileX, TileY: Integer) : Integer; // * by Widget
// * Function GetNPCs: array of TNPC; // * by Widget
// * Function GetNPCsByName: array of TNPC; // * by Widget
// * Function GetNPCsByID: array of TNPC; // * by Widget
// * Function SortNPCs(NPCs: array of TNPC): array of TNPC; // * by Widget
// * Function FindNPC(Name: string): TNPC; //
// * Function FindNPCByID(ID: integer): TNPC; //
// * Function ClickTile(TileX, TileY, Height : Integer; // * by ss23 and Widget
// Left : Boolean) : Boolean; //
// * Function WalkToTile(Tilex, Tiley : Integer): Boolean; // * by ss23 and Widget
// * Function WalkToTileTol(TileX, TileY, Tol : Integer): Boolean; // * by ss23, Widget and TheGuyWhoGotOn
// * Function LongWalkEx(TileX, TileY, DisX, DisY, // * by TheGuyWhoGotOn
// Tol : integer): Boolean; //
// * Function LongWalk(TileX, TileY, Tol : integer): Boolean; // * by TheGuyWhoGotOn
// * Function PathWalk(Path : array of TPoint; Long : boolean; // * by TheGuyWhoGotOn
// Tol : integer): Boolean; //
// * Function MMtoMS(x, y: Integer; left: Boolean): Boolean; // * by LeeLokHin
// * Function OpenBankReflection(Bank : String): Boolean; // * by ss23 and TheGuyWhoGotOn
// * Function GetPlayers: array of TPlayer; // * by Widget
//------------------------------------------------------------------//
// NPC stuff completely re-written
//
// Added TNPC type, will use later; Improved TileOn functions - ss23
//
// Thanks to Speljohan and Quaters for making hooks that we can steal =)
//------------------------------------------------------------------//


type
TNPC = record
TileX, TileY, MSX, MSY, NPCType, height : integer;
Name : string;
InFight, IsMoving: boolean;
end;
TPlayer = record
x, y:integer;
animation, speed: integer;
HPRatio, height, level: integer;
Name: string;
Levels, Experiences: array[1..24]{or whatever} of integer;
end;



const
// Global Static Hooks
BaseLayer = 'bc.f';
BaseX = 'pa.e';
BaseY = 'rb.D';
CamX = 'ph.j';
CamY = 'bb.y';
CamZ = 'bi.w';
CamPitch = 'sh.N';
CamYaw = 'pi.E';
CompassAngle = 'oj.p';
CurrentLevels = 'fd.eb';
Experiences = 'e.n';
FlagX = 'sc.Y';
FlagY = 'le.f';
GroundHeights = 'lh.N';
GroundSettings = 'ad.P';
LoopCycle = 'lg.a';
MapOffsetAngle = 'fa.m';
MaxLevels = 'hk.e';
MyPlayer = 'th.u';
NPCArray = 'gj.o';
NPCCount = 'qi.h';
NPCIndexArray = 'cf.c';
PlayerArray = 'fg.h';
PlayerCount = 'li.h';
PlayerIndArray = 'sf.K';
SettingsArray = 'ki.c';

// Character Hooks
CharAnim = 'cb';
CharMotion = 'pb';
CurrentX = 'Q';
CurrentY = 'Bb';
CharHeight = 'y';
LoopCycleStatus= 'qb';

// Player Hooks
CharName = 'uc';

// NPC Hooks
NPCDef = 'Nb';

// NPCDef Hooks
GetNPCName = 'V';
GetNPCType = 'j';

// RSString Hooks
StringBytes = 'B';

//----------------------------------------------------------------------//

function GetLevel(index: integer): integer;
{*******************************************************************
Function - GetLevel(index: integer): integer;
By: BenLand100
Description: Returns the current level of your player (its a funny array)
********************************************************************}
begin
result:= SmartGetFieldArrayInt(0,CurrentLevels,index);
end;

function StringFromBytes(jbytearray: integer): string;
{*******************************************************************
Function - StringFromBytes(jbytearray: integer): string;
By: BenLand100
Description: Converts a byte[] from StringWrap to a DelphiString
(max length 256)
********************************************************************}
begin
SetLength(result, 256);
SetLength(result, SmartStringFromBytes(jbytearray,result));
end;

function GetMyName: string;
{*******************************************************************
Function - GetMyName: string;
By: BenLand100
Description: Returns last logged in player's name
********************************************************************}
var
bytes: Integer;
begin
bytes:= SmartGetFieldObject(0,MyPlayer+'.'+CharName+'.'+StringBytes);
result:= StringFromBytes(bytes);
SmartFreeObject(bytes);
end;

function GetAnimation: integer;
{*******************************************************************
Function - GetAnimation: integer;
By: BenLand100
Description: Returns your animation
********************************************************************}
begin
result:= SmartGetFieldInt(0,MyPlayer+'.'+CharAnim);
end;

function GetSpeed: integer; // :)
{*******************************************************************
Function - GetSpeed: integer;
By: Widget
Description: Gets character speed (squares per second)
********************************************************************}
begin
result:= SmartGetFieldInt(0,MyPlayer+'.'+CharMotion);
end;

function CharacterMoving: boolean; //:)
{*******************************************************************
Function - CharacterMoving: boolean;
By: BenLand100
Description: True if you are moving
********************************************************************}
begin
result:= (GetSpeed > 0);
end;

procedure GetMyPos(var x, y: Integer); // :)
{*******************************************************************
procedure - GetMyPos(var x, y: Integer);
By: BenLand100
Description: Calculates your x,y position or [somehugenumber] if not
logged in
********************************************************************}
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;

function DumpSettingArray: array[0..1999] of integer;
{*******************************************************************
function - DumpSettingArray: array[0..1999] of integer;
By: BenLand100
Description: Dumps the settings array to an integer array
********************************************************************}
var
i: integer;
begin
for i:= 0 to 1999 do
Result[i]:= SmartGetFieldArrayInt(0,SettingsArray,i);
end;

function GetBoxAnswer: integer;
{*******************************************************************
function - GetBoxAnswer: integer;
By: BenLand100
Description: Returns -1 if no box open or 0..2 for the correct
answer to the box
Comments: Yet another reason reflection is leet =) [-Widget]
********************************************************************}
var
boxIndex: Integer;
begin
boxIndex:= SmartGetFieldArrayInt(0,SettingsArray,312);
if boxIndex = 0 then
result:= -1
else
result:= (boxIndex shr 24) and $FF;
end;

function GetMinimapAngleDeg: extended;
{*******************************************************************
function - GetMinimapAngleDeg: extended;
By: BenLand100
Description: Returns the current Map angle in degrees
********************************************************************}
var
clientAngle: integer;
begin
clientAngle:= (SmartGetFieldInt(0,CompassAngle) + SmartGetFieldInt(0,MapOffsetAngle)) mod 2048;
result:= clientAngle * 180 / 1024;
end;

function GetMinimapAngleRad: extended;
{*******************************************************************
function - GetMinimapAngleRad: extended;
By: BenLand100
Description: Returns the current map angle in radians
********************************************************************}
var
clientAngle: integer;
begin
clientAngle:= (SmartGetFieldInt(0,CompassAngle) + SmartGetFieldInt(0,MapOffsetAngle)) mod 2048;
result:= clientAngle * Pi / 1024;
end;

procedure TileToMinimap(tileX, tileY: integer; var screenX, screenY: integer);
{*******************************************************************
procedure - TileToMinimap(tileX, tileY: integer; var screenX, screenY: integer);
By: BenLand100
Description: Converts the tile position tileX,tileY to a minimap location
********************************************************************}
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)) + 629;
screenY:= round(tempX*sin(angle) + tempY*cos(angle)) + 85;
end;

procedure MinimapToTile(screenX, screenY: integer; var tileX, tileY: integer);
{*******************************************************************
procedure - MinimapToTile(screenX, screenY: integer; var tileX, tileY: integer);
By: BenLand100
Description: converts the screen position screenX,screenY from the minimap
to a tile
********************************************************************}
var
angle: extended;
tempX, tempY: integer;
begin
angle:= getMinimapAngleRad;
tempX:= (screenX - 643);
tempY:= (84 - 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;

procedure TileToMS(tileX, tileY, height: integer; var screenX, screenY: integer);
{*******************************************************************
procedure - TileToMS(tileX, tileY, height: integer; var screenX, screenY: integer);
By: BenLand100
Description: Converts the tile position tileX,tileY to a mainscreen location
Height is the distance (in px) above the ground
********************************************************************}
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;

Function TileOnMM(TileX, TileY : Integer) : Boolean;
{*******************************************************************
Function TileOnMM(TileX, TileY : Integer) : Boolean;
By: ss23
Description: True = Tile on MM
********************************************************************}
Var
PointEx : TPoint;
BoxEx : TBox;
Begin
BoxEx := IntToBox(MMX1, MMY1, MMX2, MMY2);
TileToMinimap(TileX, TileY, PointEx.x, PointEx.y);
Result := PointInBox(PointEx, BoxEx);
end;

Function TileOnMS(TileX, TileY, Height : Integer) : Boolean;
{*******************************************************************
Function TileOnMS(TileX, TileY, Height : Integer) : Boolean;
By: ss23
Description: True = Tile on MS
********************************************************************}
Var
PointEx : TPoint;
BoxEx : TBox;
Begin
BoxEx := IntToBox(MSX1, MSY1, MSX2, MSY2);
TileToMS(Tilex, Tiley, Height, pointex.x, pointex.y);
Result := PointInBox(PointEx, BoxEx);
end;

Function DistanceFrom(TileX, TileY: Integer) : Integer;
{*******************************************************************
Function DistanceFrom(TileX, TileY: Integer) : Integer;
By: Widget
Description: Returns the distance between your player and the tile
********************************************************************}
Var
MyX,MyY : integer;
Begin
GetMyPos(MyX, MyY);
result := Distance(TileX, TileY, MyX, MyY);
end;

function GetNPCs:array of TNPC;
{*******************************************************************
function GetNPCs:array of TNPC;
By: Widget
Description: Returns all the currently loaded NPCs
********************************************************************}
var
i,NumNPCs,Index,TheNPC,TheNPCDef,TheBytes: integer;
begin
NumNPCs := SmartGetFieldInt(0,NPCCount);
if (NumNPCs=0) then Exit;
SetArrayLength(Result,NumNPCs);
for i := 0 to (NumNPCs-1) do
begin
Index := SmartGetFieldArrayInt(0,NPCIndexArray,i);
TheNPC := SmartGetFieldArrayObject(0,NPCArray,Index);
TheNPCDef := SmartGetFieldObject(TheNPC,NPCDef);
TheBytes := SmartGetFieldObject(TheNPCDef,GetNPCName+'.'+StringBytes);
Result[i].Name := StringFromBytes(TheBytes);
Result[i].TileX := (SmartGetFieldInt(0, BaseX) + (SmartGetFieldInt(TheNPC, CurrentX) shr 7));
Result[i].TileY := (SmartGetFieldInt(0, BaseY) + (SmartGetFieldInt(TheNPC, CurrentY) shr 7));
Result[i].NPCType := SmartGetFieldInt(TheNPCDef,GetNPCType);
Result[i].Height := iabs(SmartGetFieldInt(TheNPC,CharHeight));
Result[i].InFight := (SmartGetFieldInt(0,LoopCycle)<SmartGetFieldInt(TheNPC,LoopCycleStatus));
Result[i].IsMoving := (SmartGetFieldInt(TheNPC,CharMotion)>0);
if TileOnMS(Result[i].TileX, Result[i].TileY, Result[i].Height * 2 / 3) then
TileToMS(Result[i].TileX, Result[i].TileY, Result[i].Height * 2 / 3, Result[i].MSX, Result[i].MSY);
SmartFreeObject(TheNPC);
SmartFreeObject(TheNPCDef);
SmartFreeObject(TheBytes);
end;
end;

function GetNPCsByName(name:string):array of TNPC;
{*******************************************************************
Function GetNPCsByName(name:string):array of TNPC;
By: Widget
Description: Returns NPCs matching the name.
********************************************************************}
var
i: integer;
NPCs: array of TNPC;
begin
NPCs := GetNPCs;
if (GetArrayLength(NPCs)=0) then Exit;
for i := 0 to High(NPCs) do
if (pos(trim(name),trim(NPCs[i].Name))>0) then
begin
SetArrayLength(result,GetArrayLength(result)+1);
result[GetArrayLength(result)-1] := NPCs[i];
end;
end;

function GetNPCsByID(TheType:integer):array of TNPC;
{*******************************************************************
Function GetNPCsByID(TheType:integer):array of TNPC;
By: Widget
Description: Returns NPCs matching the ID.
********************************************************************}
var
i: integer;
NPCs: array of TNPC;
begin
NPCs := GetNPCs;
if (GetArrayLength(NPCs)=0) then Exit;
for i := 0 to High(NPCs) do
if (NPCs[i].NPCType=TheType) then
begin
SetArrayLength(result,GetArrayLength(result)+1);
result[GetArrayLength(result)-1] := NPCs[i];
end;
end;

function SortNPCs(NPCs:array of TNPC):array of TNPC;
{*******************************************************************
Function SortNPCs(NPCs:array of TNPC):array of TNPC;
By: Widget
Description: Sorts NPCs by distance from you.
********************************************************************}
var
i,i2,ix,iy: integer;
tpa: TPointArray;
begin
SetArrayLength(TPA,GetArrayLength(NPCs));
SetArrayLength(Result,GetArrayLength(NPCs));
for i := 0 to high(NPCs) do
TPA[i] := Point(NPCs[i].TileX, NPCs[i].TileY);
GetMyPos(ix, iy);
SortTPAFrom(TPA, Point(ix, iy));
for i := 0 to high(TPA) do
for i2 := 0 to high(NPCs) do // they really should be the same
if (TPA[i].x=NPCs[i2].TileX) and (TPA[i].y=NPCs[i2].TileY) then
Result[i] := NPCs[i2];
end;

Function FindNPC(Name: string; var NPC: TNPC):boolean;
{*******************************************************************
function FindNPC(Name: string; var x,y:integer):boolean;
By: Widget
Description: Finds the tile of the named NPC and puts it in the NPC var.
Returns true if found, false if not. (Try checking for tiles if
it's not on the mainscreen.)
********************************************************************}
var
NPCs: array of TNPC;
begin
NPCs := SortNPCs(GetNPCsByName(Name));
result := GetArrayLength(NPCs)<>0;
if not result then
Exit;
NPC := NPCs[0];
end;

Function FindNPCByID(ID: integer; var NPC: TNPC):boolean;
{*******************************************************************
function FindNPC(Name: string; var x,y:integer):boolean;
By: Widget
Description: Finds the tile of the named NPC and puts it in the NPC var.
Returns true if found, false if not. (Try checking for tiles if
it's not on the mainscreen.)
********************************************************************}
var
NPCs: array of TNPC;
begin
NPCs := SortNPCs(GetNPCsByID(ID));
result := GetArrayLength(NPCs)<>0;
if not result then
Exit;
NPC := NPCs[0];
end;

Function ClickTile(TileX, TileY, Height : Integer; Left : Boolean) : Boolean;
{*******************************************************************
Function ClickTile(TileX, TileY, Height : Integer; Left : Boolean) : Boolean;
By: ss23 and Widget
Description: Clicks a tile. Height is the approximate heigh in pixels
Height doesnt matter if HighestAngle;
********************************************************************}
Var
x, y : Integer;
Begin
TileToMS(TileX, TileY, Height, x, y);
result := TileOnMs(x,y,height);
if not result then
Exit;
Mouse(x, y, 5, 5, False);
end;

Function WalkToTile(TileX, TileY : Integer): Boolean;
{*******************************************************************
Function - WalkToTile(TileX, TileY : Integer): Boolean;
By: ss23 and Widget
Description: Walks to the tile using minimap.
********************************************************************}
Var
x, y : Integer;
Begin
TileToMinimap(Tilex, Tiley, x, y);
if not TileOnMM(TileX, TileY) then
begin
Writeln('Tile off minimap');
Result := False;
Exit;
end;
Mouse(x, y, 3, 3, True);
Result := True;
end;

Function WalkToTileTol(TileX, TileY, Tol : Integer): Boolean;
{*******************************************************************
Function - WalkToTileTol(TileX, TileY, Tol : Integer): Boolean;
By: ss23 and Widget and TheGuyWhoGotOn
Description: Walks to the tile using minimap and tolerance.
********************************************************************}
Var
x, y : Integer;
Begin
TileToMinimap(Tilex, Tiley, x, y);
if not TileOnMM(TileX, TileY) then
begin
Writeln('Tile off minimap');
Result := False;
Exit;
end;
Mouse(x, y, Tol, Tol, True);
Result := True;
end;

function LongWalkEx(TileX, TileY, DisX, DisY, Tol : integer): boolean;
{*******************************************************************
Function - LongWalkEx(TileX, TileY, DisX, DisY, Tol : Integer): Boolean;
By: TheGuyWhoGotOn
Description: Walks to a far tile using the minimap and tolerance.
DisX/DisY is how many tiles it will move at a time.
********************************************************************}
var TX, TY, DX, DY : integer;
begin
repeat
GetMyPos(TX, TY);
if ((DX) > (TileX - DisX)) and ((DX) < (TileX + DisX)) then else
if TileX > TX then DX := TX + DisX
else DX := TX - DisX;
if ((DY) > (-TileY - DisY)) and ((DY) < (TileY + DisY)) then else
if TileY > TY then DY := TY + DisY
else DY := TY - DisY;
WalkToTileTol(DX, DY, Tol);
repeat
Wait(1000 + Random(500));
until (Flag) or (not(CharacterMoving));
until (TileOnMM(TileX, TileY)) or (not(TileOnMM(DX, DY)));
Result := WalkToTileTol(TileX, TileY, Tol);
end;

function LongWalk(TileX, TileY, Tol : integer): boolean;
{*******************************************************************
Function - LongWalk(TileX, TileY, Tol : Integer): Boolean;
By: TheGuyWhoGotOn
Description: Walks to a far tile using the minimap and tolerance.
********************************************************************}
begin
Result := LongWalkEx(TileX, TileY, 11, 11, Tol);
end;

function PathWalk(Path : array of TPoint; Long : boolean; Tol : integer): Boolean;
{*******************************************************************
Function - PathWalk(Path : array of TPoint; Long : boolean; Tol : integer): Boolean;
By: TheGuyWhoGotOn
Description: Walks a path for you with LongWalk options.
********************************************************************}
var Count : integer;
begin
Count := 0;
repeat
if Long then Result := LongWalk(Path[Count].x, Path[Count].y, Tol)
else Result := WalkToTileTol(Path[Count].x, Path[Count].y, Tol);
repeat
Wait(1000 + Random(500));
until (Flag) or (not(CharacterMoving));
if not(Result) then
begin
WriteLn('Path walk failed');
Exit;
end;
Count := Count + 1;
until (not(Result)) or (Count = GetArrayLength(Path))
end;

procedure MMtoMS(MMX,MMY:integer; var MSX,MSY:integer);
{*******************************************************************
Function MMtoMS(x, y: Integer; left: Boolean): Boolean;
By: LeeLokHin
Description: Converts Coordinates x and y on the minimap
to equivilants on the MainScreen and clicks right or left according
to boolean left.
********************************************************************}
var
tx,ty:integer;
begin
MinimapToTile(MMX, MMY, tx, ty);
TileToMS(tx, ty, 5, MSX, MSY);
end;

Function OpenBankReflection(Bank : String): Boolean;
{*******************************************************************
Function OpenBankReflection(Bank : String): Boolean;
By: ss23 and TheGuyWhoGotOn
Description: Opens the bank. Opens nearest slot
********************************************************************}
Var
x, y : Integer;
Me : TPoint;
Tiles : TPointArray;
Begin
Case Bank of
'veb': Tiles := [Point(3251,3419), Point(3252,3419), Point(3253,3419),
Point(3254,3419), Point(3255,3419), Point(3256,3419)];
'vwb': Tiles := [Point(3190,3435), Point(3190,3437), Point(3190,3439),
Point(3190,3441), Point(3190,3443), Point(3181,3444), Point(3181,3442),
Point(3181,3440), Point(3181,3438), Point(3181,3436)];
'fwb': Tiles := [Point(2945,3367), Point(2946,3367), Point(2947,3367),
Point(2948,3367)];
'feb': Tiles := [Point(3010,3354), Point(3011,3354), Point(3012,3354),
Point(3013,3354), Point(3014,3354), Point(3015,3354)];
'lum': Tiles := [Point(3208,3221)];
'dra': Tiles := [Point(3091,3419), Point(3091,3245), Point(3091,3244),
Point(3091,3243), Point(3091,3242)];
'alk': Tiles := [Point(3268,3168), Point(3268,3167), Point(3268,3166),
Point(3268,3165), Point(3268,3164)];
end;
GetMyPos(Me.x, Me.y);
SortTPAFrom(Tiles, Me);
If (DistanceFrom(Tiles[0].x, Tiles[0].y) > 3) then
Begin
If not(TileOnMM(Tiles[0].x, Tiles[0].y)) then
Begin
Writeln('Couldn''t find bank');
Result := False;
Exit;
end;
WalkToTile(Tiles[0].x, Tiles[0].y);
repeat
Wait(1000 + Random(500));
until (Flag) or (not(CharacterMoving));
Wait(100 + Random(100));
end;
If not(TileOnMS(Tiles[0].x, Tiles[0].y, 15)) then
Begin
SetAngle(True);
MakeCompass('n');
If not(TileOnMS(Tiles[0].x, Tiles[0].y, 20)) then
Begin
Writeln('Couldnt'' find bank booth');
Result := False;
Exit;
end;
end;
TileToMS(Tiles[0].x, Tiles[0].y, 20, x, y);
Mouse(x, y, 5, 5, False);
Wait(100 + Random(100));
Result := ChooseOption('e-q');
end;

function GetPlayers: array of TPlayer;
{*******************************************************************
function - GetPlayers: array of TPlayer;
By: Widget
Description: Returns all the players on the minimap
--- DOESN'T WORK YET ---
********************************************************************}
//var
// i, IndexPos, Count, Player, Name: integer;

begin
result := result; // stops a Variable 'Result' never used thing
{ Count := SmartGetFieldInt(0, PlayerCount);
writeln('Number of players: '+inttostr(Count));
SetArrayLength(result, Count);
for i := 0 to (count-1) do
begin
IndexPos := SmartGetFieldArrayInt(0, PlayerIndArray, i);
writeln('Index position: '+inttostr(count));
Player := SmartGetFieldArrayObject(0, PlayerArray, IndexPos);
writeln('Player placement: '+inttostr(Player));
Name := SmartGetFieldObject(Player, CharName);
writeln(inttostr(name));
writeln(StringFromBytes(Name));
Result[indexpos].Name := StringFromBytes(Name);
SmartFreeObject(Name);
Writeln(Result[indexpos].Name);
end; }
end;

function GetPlayer(name: string): TPlayer;
{*******************************************************************
function - GetPlayer(name: string): TPlayer;
By: Widget
Description: Gets available stats for a player (Levels only work on you).
--- DOESN'T WORK YET ---
********************************************************************}
begin
result := result; // stops a Variable 'Result' never used thing
end;

Edit2: You may use this script to test the include:


program New;
{.include SRL/SRL/Misc/SMART.scar}
{.include SRL/SRL.scar}
{.include SRL/SRL/Misc/Reflection.scar}

var TX, TY, Count : integer;
NPCs : array of TNPC;

begin
ActivateClient;
SetUpPhoenix;
SmartSetup('world157', True, True, False);
SetTargetDC(SMARTGetDC);
repeat
WriteLn('Running with user: ' + GetMyName);
GetMyPos(TX, TY);
WriteLn('Who is at: ' + IntToSTr(TX) + ', ' + IntToStr(TY));
NPCs := SortNPCs(GetNPCs);
Count := 0;
if GetArrayLength(NPCs) = 0 then WriteLn('Failed To Find NPC')
else begin
WriteLn('Name Tile MS ID');
repeat
WriteLn(NPCs[Count].Name + ' ' + IntToStr(NPCs[Count].TileX) + ', ' +
IntToStr(NPCs[0].TileY) + ' ' + IntToStr(NPCs[Count].MSX) +
', ' + IntToStr(NPCs[Count].MSY) + ' '
+ IntToStr(NPCs[Count].NPCType));
Count := Count + 1
until(Count = GetArrayLength(NPCs));
end;
Wait(500);
ClearDebug;
until(false);
end.

Claymore

2008-07-25 01:55:33

I'm upset. My Computer is stupid and can;t run SMART (Its 526MB RAM) :( Well you guys enjoy this…I'll just sit back, study this a little till i get myself a new computer (Parents wont let me use SCAR on the new computers because they said its full of "Viruses" and "trojans" and what not. I scared them for life when i downloaded a Trojan.

Man this looks AWESOME!

Widget

2008-07-25 02:06:01

Agh people keep posting so much XD

I made some fast video tutorials although they might not make sense, the best way to learn is to read through the include itself ;)
- http://www.youtube.com/watch?v=kTFqJgy9kZk
- http://www.youtube.com/watch?v=qc_X_o1REMM
(You can also look at my profile in case you want to watch random Guitar Hero vids ;))

Anyway, now I need to update the first post again and merge a bamillion random things >.<

TheGuyWhoGotOn

2008-07-25 02:16:50

From: Deathscytex
I'm upset. My Computer is stupid and can;t run SMART (Its 526MB RAM) :( Well you guys enjoy this…I'll just sit back, study this a little till i get myself a new computer (Parents wont let me use SCAR on the new computers because they said its full of "Viruses" and "trojans" and what not. I scared them for life when i downloaded a Trojan.

Man this looks AWESOME!


I have 448MB of RAM.

mastaraymond

2008-07-25 04:57:48

From: Widget
Agh people keep posting so much XD

I made some fast video tutorials although they might not make sense, the best way to learn is to read through the include itself ;)
- http://www.youtube.com/watch?v=kTFqJgy9kZk
- http://www.youtube.com/watch?v=qc_X_o1REMM
(You can also look at my profile in case you want to watch random Guitar Hero vids ;))

Anyway, now I need to update the first post again and merge a bamillion random things >.<

You have a sexy voice! :D

ShowerThoughts

2008-07-25 06:59:34

My EYES Burn use Camtasia Studio 5!!!!!!

Did you fap before you recorded that?

MasterKill

2008-07-25 07:13:32

since reflection is not getting into the real base of srl, i had this crappy idee to have an update system, so a new srl doesn't have to be release when reflection is only outdated.

like I said it's crap, but maybe usefull?

//------------------------------------------------------------------\\
//-- Scar Non-Standard Resource Library --||
//-- » Reflection Routines --||
//------------------------------------------------------------------//
// * Procedure SetupReflection; // * by MasterKill
// * Function GetLevel(index: integer): integer; // * by BenLand100
// * Function StringFromBytes(jbytearray: integer): string; // * by BenLand100
// * Function GetMyName: string; // * by BenLand100
// * Function GetAnimation: integer; // * by BenLand100
// * Function GetSpeed: integer; // * by Widget
// * Function CharacterMoving: boolean; // * by BenLand100
// * Procedure GetMyPos(var x, y: Integer); // * by BenLand100
// * Function GetBoxAnswer: integer; // * by BenLand100
// * Function GetMinimapAngleDeg: extended; // * by BenLand100
// * Function GetMinimapAngleRad: extended; // * by BenLand100
// * Procedure TileToMinimap(tileX, tileY: integer; var screenX, // * by BenLand100
// screenY: integer); // º
// * Procedure MinimapToTile(screenX, screenY: integer; var tileX, // * by BenLand100
// tileY: integer); // º
// * Procedure TileToMS(tileX, tileY, height: integer; // * by BenLand100
// var screenX, screenY: integer); // º
// * Function TileOnMM(TileX, TileY : Integer) : Boolean; // * by ss23
// * Function TileOnMS(TileX, TileY, Height : Integer) : Boolean; // * by ss23
// * Function DistanceFrom(TileX, TileY: Integer) : Integer; // * by Widget
// * Function GetNPCs: array of TNPC; // * by Widget
// * Function GetNPCsByName: array of TNPC; // * by Widget
// * Function GetNPCsByID: array of TNPC; // * by Widget
// * Function SortNPCs(NPCs: array of TNPC): array of TNPC; // * by Widget
// * Function FindNPC(Name: string): TNPC; // * by Widget
// * Function FindNPCByID(ID: integer): TNPC; // * by Widget
// * Function ClickTile(TileX, TileY, Height : Integer; // * by ss23 and Widget
// Left : Boolean) : Boolean; // º
// * Function WalkToTile(Tilex, Tiley : Integer): Boolean; // * by ss23 and Widget
// * Function WalkToTileTol(TileX, TileY, Tol : Integer): Boolean; // * by ss23, Widget and TheGuyWhoGotOn
// * Function LongWalkEx(TileX, TileY, DisX, DisY, // * by TheGuyWhoGotOn
// Tol : integer): Boolean; // º
// * Function LongWalk(TileX, TileY, Tol : integer): Boolean; // * by TheGuyWhoGotOn
// * Function PathWalk(Path : array of TPoint; Long : boolean; // * by TheGuyWhoGotOn
// Tol : integer): Boolean; // º
// * Function MMtoMS(x, y: Integer; left: Boolean): Boolean; // * by LeeLokHin
// * Function OpenBankReflection(Bank : String): Boolean; // * by ss23 and TheGuyWhoGotOn
// * Function GetPlayers: array of TPlayer; // * by Widget
//------------------------------------------------------------------//
// NPC stuff completely re-written
//
// TPlayer not used yet but eventually I'll stop being lazy -Widget
//
// Thanks to Speljohan and Quaters for making hooks that we can steal =)
//------------------------------------------------------------------//


type
TNPC = record
TileX, TileY, MSX, MSY, NPCType, height : integer;
Name : string;
InFight, IsMoving: boolean;
end;
TPlayer = record
x, y:integer;
animation, speed: integer;
HPRatio, height, level: integer;
Name: string;
Levels, Experiences: array[1..24]{or whatever} of integer;
end;

Var
BaseLayer, BaseX, BaseY, CamX, CamY, CamZ, CamPitch, CamYaw,
CompassAngle, CurrentLevels, Experiences, FlagX, FlagY, GroundHeights,
GroundSettings, LoopCycle, MapOffSetAngle, MaxLevels, MyPlayer,
NPCArray, NPCCount, NPCIndexArray, PlayerArray, PlayerCount,
PlayerIndArray, SettingsArray, CharAnim, CharMotion, CurrentX, CurrentY, CharHeight, LoopCycleStatus,
CharName, NPCDef, GetNPCName, GetNPCType, StringBytes: String;



//----------------------------------------------------------------------//

// fucntion explode my by: A G E N T 83
function Explode(Delimiter : string; Str : string) : array of string;
var
DelimPos, i : integer;
Arr1 : array of string;
begin
SetArrayLength(Arr1, 100000);
i := 0;
repeat
if (pos(Delimiter, Str) = 0) then Break;
DelimPos := pos(Delimiter, Str);
Arr1[i] := Replace((copy(Str,0,DelimPos)),Delimiter,'');
Delete(Str,1,DelimPos);
i := i + 1;
until(pos(Delimiter, Str) = 0);
Arr1[i] := Str;
SetArrayLength(Arr1, i+1);
Result := Arr1;
end;

{*******************************************************************
Procedure SetupReflection;
By: MasterKill
Description: Loads RS hooks from an text file
********************************************************************}
Procedure SetupReflection;
Var
HooksPage: String;
Hook: TStringArray;
StartTime: Integer;
Begin
StartTime := GetSystemTime;
HooksPage := GetPage('http://www.freewebs.com/srlfiles/hooks.txt');
Hook := Explode(',', HooksPage);
BaseLayer := Hook[0];
BaseX := Hook[1];
BaseY := Hook[2];
CamX := Hook[3];
CamY := Hook[4];
CamZ := Hook[5];
CamPitch := Hook[6];
CamYaw := Hook[7];
CompassAngle := Hook[8];
CurrentLevels := Hook[9];
Experiences := Hook[10];
FlagX := Hook[11];
FlagY := Hook[12];
GroundHeights := Hook[13];
GroundSettings := Hook[14];
LoopCycle := Hook[15];
MapOffsetAngle := Hook[16];
MaxLevels := Hook[17];
MyPlayer := Hook[18];
NPCArray := Hook[19];
NPCCount := Hook[20];
NPCIndexArray := Hook[21];
PlayerArray := Hook[22];
PlayerCount := Hook[23];
PlayerIndArray := Hook[24];
SettingsArray := Hook[25];
CharAnim := Hook[26];
CharMotion := Hook[27];
CurrentX := Hook[28];
CurrentY := Hook[29];
CharHeight := Hook[30];
LoopCycleStatus:= Hook[31];
CharName := Hook[32];
NPCDef := Hook[33];
GetNPCName := Hook[34];
GetNPCType := Hook[35];
StringBytes := Hook[36];
WriteLn('Setting up reflection took ' + IntToStr(GetSystemTime - StartTime) + ' ms.');
End;

function GetLevel(index: integer): integer;
{*******************************************************************
Function - GetLevel(index: integer): integer;
By: BenLand100
Description: Returns the current level of your player (its a funny array)
********************************************************************}
begin
result:= SmartGetFieldArrayInt(0,CurrentLevels,index);
end;

function StringFromBytes(jbytearray: integer): string;
{*******************************************************************
Function - StringFromBytes(jbytearray: integer): string;
By: BenLand100
Description: Converts a byte[] from StringWrap to a DelphiString
(max length 256)
********************************************************************}
begin
SetLength(result, 256);
SetLength(result, SmartStringFromBytes(jbytearray,result));
end;

function GetMyName: string;
{*******************************************************************
Function - GetMyName: string;
By: BenLand100
Description: Returns last logged in player's name
********************************************************************}
var
bytes: Integer;
begin
bytes:= SmartGetFieldObject(0,MyPlayer+'.'+CharName+'.'+StringBytes);
result:= StringFromBytes(bytes);
SmartFreeObject(bytes);
end;

function GetAnimation: integer;
{*******************************************************************
Function - GetAnimation: integer;
By: BenLand100
Description: Returns your animation
********************************************************************}
begin
result:= SmartGetFieldInt(0,MyPlayer+'.'+CharAnim);
end;

function GetSpeed: integer; // :)
{*******************************************************************
Function - GetSpeed: integer;
By: Widget
Description: Gets character speed (squares per second)
********************************************************************}
begin
result:= SmartGetFieldInt(0,MyPlayer+'.'+CharMotion);
end;

function CharacterMoving: boolean; //:)
{*******************************************************************
Function - CharacterMoving: boolean;
By: BenLand100
Description: True if you are moving
********************************************************************}
begin
result:= (GetSpeed > 0);
end;

procedure GetMyPos(var x, y: Integer); // :)
{*******************************************************************
procedure - GetMyPos(var x, y: Integer);
By: BenLand100
Description: Calculates your x,y position or [somehugenumber] if not
logged in
********************************************************************}
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;

function DumpSettingArray: array[0..1999] of integer;
{*******************************************************************
function - DumpSettingArray: array[0..1999] of integer;
By: BenLand100
Description: Dumps the settings array to an integer array
********************************************************************}
var
i: integer;
begin
for i:= 0 to 1999 do
Result[i]:= SmartGetFieldArrayInt(0,SettingsArray,i);
end;

function GetBoxAnswer: integer;
{*******************************************************************
function - GetBoxAnswer: integer;
By: BenLand100
Description: Returns -1 if no box open or 0..2 for the correct
answer to the box
Comments: Yet another reason reflection is leet =) -Widget
********************************************************************}
var
boxIndex: Integer;
begin
boxIndex:= SmartGetFieldArrayInt(0,SettingsArray,312);
if boxIndex = 0 then
result:= -1
else
result:= (boxIndex shr 24) and $FF;
end;

function GetMinimapAngleDeg: extended;
{*******************************************************************
function - GetMinimapAngleDeg: extended;
By: BenLand100
Description: Returns the current Map angle in degrees
********************************************************************}
var
clientAngle: integer;
begin
clientAngle:= (SmartGetFieldInt(0,CompassAngle) + SmartGetFieldInt(0,MapOffsetAngle)) mod 2048;
result:= clientAngle * 180 / 1024;
end;

function GetMinimapAngleRad: extended;
{*******************************************************************
function - GetMinimapAngleRad: extended;
By: BenLand100
Description: Returns the current map angle in radians
********************************************************************}
var
clientAngle: integer;
begin
clientAngle:= (SmartGetFieldInt(0,CompassAngle) + SmartGetFieldInt(0,MapOffsetAngle)) mod 2048;
result:= clientAngle * Pi / 1024;
end;

procedure TileToMinimap(tileX, tileY: integer; var screenX, screenY: integer);
{*******************************************************************
procedure - TileToMinimap(tileX, tileY: integer; var screenX, screenY: integer);
By: BenLand100
Description: Converts the tile position tileX,tileY to a minimap location
********************************************************************}
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)) + 629;
screenY:= round(tempX*sin(angle) + tempY*cos(angle)) + 85;
end;

procedure MinimapToTile(screenX, screenY: integer; var tileX, tileY: integer);
{*******************************************************************
procedure - MinimapToTile(screenX, screenY: integer; var tileX, tileY: integer);
By: BenLand100
Description: converts the screen position screenX,screenY from the minimap
to a tile
********************************************************************}
var
angle: extended;
tempX, tempY: integer;
begin
angle:= getMinimapAngleRad;
tempX:= (screenX - 643);
tempY:= (84 - 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;

procedure TileToMS(tileX, tileY, height: integer; var screenX, screenY: integer);
{*******************************************************************
procedure - TileToMS(tileX, tileY, height: integer; var screenX, screenY: integer);
By: BenLand100
Description: Converts the tile position tileX,tileY to a mainscreen location
Height is the distance (in px) above the ground
********************************************************************}
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;

Function TileOnMM(TileX, TileY : Integer) : Boolean;
{*******************************************************************
Function TileOnMM(TileX, TileY : Integer) : Boolean;
By: ss23
Description: True = Tile on MM
********************************************************************}
Var
PointEx : TPoint;
BoxEx : TBox;
Begin
BoxEx := IntToBox(MMX1, MMY1, MMX2, MMY2);
TileToMinimap(TileX, TileY, PointEx.x, PointEx.y);
Result := PointInBox(PointEx, BoxEx);
end;

Function TileOnMS(TileX, TileY, Height : Integer) : Boolean;
{*******************************************************************
Function TileOnMS(TileX, TileY, Height : Integer) : Boolean;
By: ss23
Description: True = Tile on MS
********************************************************************}
Var
PointEx : TPoint;
BoxEx : TBox;
Begin
BoxEx := IntToBox(MSX1, MSY1, MSX2, MSY2);
TileToMS(Tilex, Tiley, Height, pointex.x, pointex.y);
Result := PointInBox(PointEx, BoxEx);
end;

Function DistanceFrom(TileX, TileY: Integer) : Integer;
{*******************************************************************
Function DistanceFrom(TileX, TileY: Integer) : Integer;
By: Widget
Description: Returns the distance between your player and the tile
********************************************************************}
Var
MyX,MyY : integer;
Begin
GetMyPos(MyX, MyY);
result := Distance(TileX, TileY, MyX, MyY);
end;

function GetNPCs:array of TNPC;
{*******************************************************************
function GetNPCs:array of TNPC;
By: Widget
Description: Returns all the currently loaded NPCs
********************************************************************}
var
i,NumNPCs,Index,TheNPC,TheNPCDef,TheBytes: integer;
begin
NumNPCs := SmartGetFieldInt(0,NPCCount);
if (NumNPCs=0) then Exit;
SetArrayLength(Result,NumNPCs);
for i := 0 to (NumNPCs-1) do
begin
Index := SmartGetFieldArrayInt(0,NPCIndexArray,i);
TheNPC := SmartGetFieldArrayObject(0,NPCArray,Index);
TheNPCDef := SmartGetFieldObject(TheNPC,NPCDef);
TheBytes := SmartGetFieldObject(TheNPCDef,GetNPCName+'.'+StringBytes);
Result[i].Name := StringFromBytes(TheBytes);
Result[i].TileX := (SmartGetFieldInt(0, BaseX) + (SmartGetFieldInt(TheNPC, CurrentX) shr 7));
Result[i].TileY := (SmartGetFieldInt(0, BaseY) + (SmartGetFieldInt(TheNPC, CurrentY) shr 7));
Result[i].NPCType := SmartGetFieldInt(TheNPCDef,GetNPCType);
Result[i].Height := iabs(SmartGetFieldInt(TheNPC,CharHeight));
Result[i].InFight := (SmartGetFieldInt(0,LoopCycle)<SmartGetFieldInt(TheNPC,LoopCycleStatus));
Result[i].IsMoving := (SmartGetFieldInt(TheNPC,CharMotion)>0);
if TileOnMS(Result[i].TileX, Result[i].TileY, Result[i].Height * 2 / 3) then
TileToMS(Result[i].TileX, Result[i].TileY, Result[i].Height * 2 / 3, Result[i].MSX, Result[i].MSY);
SmartFreeObject(TheNPC);
SmartFreeObject(TheNPCDef);
SmartFreeObject(TheBytes);
end;
end;

function GetNPCsByName(name:string):array of TNPC;
{*******************************************************************
Function GetNPCsByName(name:string):array of TNPC;
By: Widget
Description: Returns NPCs matching the name.
********************************************************************}
var
i: integer;
NPCs: array of TNPC;
begin
NPCs := GetNPCs;
if (GetArrayLength(NPCs)=0) then Exit;
for i := 0 to High(NPCs) do
if (pos(trim(name),trim(NPCs[i].Name))>0) then
begin
SetArrayLength(result,GetArrayLength(result)+1);
result[GetArrayLength(result)-1] := NPCs[i];
end;
end;

function GetNPCsByID(TheType:integer):array of TNPC;
{*******************************************************************
Function GetNPCsByID(TheType:integer):array of TNPC;
By: Widget
Description: Returns NPCs matching the ID.
********************************************************************}
var
i: integer;
NPCs: array of TNPC;
begin
NPCs := GetNPCs;
if (GetArrayLength(NPCs)=0) then Exit;
for i := 0 to High(NPCs) do
if (NPCs[i].NPCType=TheType) then
begin
SetArrayLength(result,GetArrayLength(result)+1);
result[GetArrayLength(result)-1] := NPCs[i];
end;
end;

function SortNPCs(NPCs:array of TNPC):array of TNPC;
{*******************************************************************
Function SortNPCs(NPCs:array of TNPC):array of TNPC;
By: Widget
Description: Sorts NPCs by distance from you.
********************************************************************}
var
i,i2,ix,iy: integer;
tpa: TPointArray;
begin
if (GetArrayLength(NPCs)=0) then Exit;
SetArrayLength(TPA,GetArrayLength(NPCs));
SetArrayLength(Result,GetArrayLength(NPCs));
for i := 0 to high(NPCs) do
TPA[i] := Point(NPCs[i].TileX, NPCs[i].TileY);
GetMyPos(ix, iy);
SortTPAFrom(TPA, Point(ix, iy));
for i := 0 to high(TPA) do
for i2 := 0 to high(NPCs) do // they really should be the same
if (TPA[i].x=NPCs[i2].TileX) and (TPA[i].y=NPCs[i2].TileY) then
Result[i] := NPCs[i2];
end;

Function FindNPC(Name: string; var NPC: TNPC):boolean;
{*******************************************************************
function FindNPC(Name: string; var NPC: TNPC):boolean;
By: Widget
Description: Finds the tile of the named NPC and puts it in the NPC var.
Returns true if found, false if not. (Try walking with the MM if
it's not on the main screen.
********************************************************************}
var
NPCs: array of TNPC;
begin
NPCs := SortNPCs(GetNPCsByName(Name));
result := GetArrayLength(NPCs)<>0;
if not result then
Exit;
NPC := NPCs[0];
end;

Function FindNPCByID(ID: integer; var NPC: TNPC):boolean;
{*******************************************************************
function FindNPCByID(ID: integer; var NPC: TNPC):boolean;
By: Widget
Description: Finds the tile of the named NPC and puts it in the NPC var.
Returns true if found, false if not. (Try checking for tiles if
it's not on the mainscreen.)
********************************************************************}
var
NPCs: array of TNPC;
begin
NPCs := SortNPCs(GetNPCsByID(ID));
result := GetArrayLength(NPCs)<>0;
if not result then
Exit;
NPC := NPCs[0];
end;

Function ClickTile(TileX, TileY, Height : Integer; Left : Boolean) : Boolean;
{*******************************************************************
Function ClickTile(TileX, TileY, Height : Integer; Left : Boolean) : Boolean;
By: ss23 and Widget
Description: Clicks a tile. Height is the approximate heigh in pixels
Height doesnt matter if HighestAngle;
********************************************************************}
Var
x, y : Integer;
Begin
TileToMS(TileX, TileY, Height, x, y);
result := TileOnMs(x,y,height);
if not result then
Exit;
Mouse(x, y, 5, 5, False);
end;

Function WalkToTile(TileX, TileY : Integer): Boolean;
{*******************************************************************
Function - WalkToTile(TileX, TileY : Integer): Boolean;
By: ss23 and Widget
Description: Walks to the tile using minimap.
********************************************************************}
Var
x, y : Integer;
Begin
TileToMinimap(Tilex, Tiley, x, y);
if not TileOnMM(TileX, TileY) then
begin
Writeln('Tile off minimap');
Result := False;
Exit;
end;
Mouse(x, y, 3, 3, True);
Result := True;
end;

Function WalkToTileTol(TileX, TileY, Tol : Integer): Boolean;
{*******************************************************************
Function - WalkToTileTol(TileX, TileY, Tol : Integer): Boolean;
By: ss23 and Widget and TheGuyWhoGotOn
Description: Walks to the tile using minimap and tolerance.
********************************************************************}
Var
x, y : Integer;
Begin
TileToMinimap(Tilex, Tiley, x, y);
if not TileOnMM(TileX, TileY) then
begin
Writeln('Tile off minimap');
Result := False;
Exit;
end;
Mouse(x, y, Tol, Tol, True);
Result := True;
end;

function LongWalkEx(TileX, TileY, DisX, DisY, Tol : integer): boolean;
{*******************************************************************
Function - LongWalkEx(TileX, TileY, DisX, DisY, Tol : Integer): Boolean;
By: TheGuyWhoGotOn
Description: Walks to a far tile using the minimap and tolerance.
DisX/DisY is how many tiles it will move at a time.
********************************************************************}
var TX, TY, DX, DY : integer;
begin
repeat
GetMyPos(TX, TY);
if ((DX) > (TileX - DisX)) and ((DX) < (TileX + DisX)) then else
if TileX > TX then DX := TX + DisX
else DX := TX - DisX;
if ((DY) > (-TileY - DisY)) and ((DY) < (TileY + DisY)) then else
if TileY > TY then DY := TY + DisY
else DY := TY - DisY;
WalkToTileTol(DX, DY, Tol);
repeat
Wait(1000 + Random(500));
until (Flag) or (not(CharacterMoving));
until (TileOnMM(TileX, TileY)) or (not(TileOnMM(DX, DY)));
Result := WalkToTileTol(TileX, TileY, Tol);
end;

function LongWalk(TileX, TileY, Tol : integer): boolean;
{*******************************************************************
Function - LongWalk(TileX, TileY, Tol : Integer): Boolean;
By: TheGuyWhoGotOn
Description: Walks to a far tile using the minimap and tolerance.
********************************************************************}
begin
Result := LongWalkEx(TileX, TileY, 11, 11, Tol);
end;

function PathWalk(Path : array of TPoint; Long : boolean; Tol : integer): Boolean;
{*******************************************************************
Function - PathWalk(Path : array of TPoint; Long : boolean; Tol : integer): Boolean;
By: TheGuyWhoGotOn
Description: Walks a path for you with LongWalk options.
********************************************************************}
var Count : integer;
begin
Count := 0;
repeat
if Long then Result := LongWalk(Path[Count].x, Path[Count].y, Tol)
else Result := WalkToTileTol(Path[Count].x, Path[Count].y, Tol);
repeat
Wait(1000 + Random(500));
until (Flag) or (not(CharacterMoving));
if not(Result) then
begin
WriteLn('Path walk failed');
Exit;
end;
Count := Count + 1;
until (not(Result)) or (Count = GetArrayLength(Path))
end;

procedure MMtoMS(MMX,MMY:integer; var MSX,MSY:integer);
{*******************************************************************
Function MMtoMS(x, y: Integer; left: Boolean): Boolean;
By: LeeLokHin
Description: Converts Coordinates x and y on the minimap
to equivilants on the MainScreen and clicks right or left according
to boolean left.
********************************************************************}
var
tx,ty:integer;
begin
MinimapToTile(MMX, MMY, tx, ty);
TileToMS(tx, ty, 5, MSX, MSY);
end;

Function OpenBankReflection(Bank : String): Boolean;
{*******************************************************************
Function OpenBankReflection(Bank : String): Boolean;
By: ss23
Description: Opens the bank. Opens nearest slot
********************************************************************}
Var
x, y : Integer;
Me : TPoint;
Tiles : TPointArray;
Begin
Case Bank of
'veb': Tiles := [Point(3251,3419), Point(3252,3419), Point(3253,3419),
Point(3254,3419), Point(3255,3419), Point(3256,3419)];
'vwb': Tiles := [Point(3190,3435), Point(3190,3437), Point(3190,3439),
Point(3190,3441), Point(3190,3443), Point(3181,3444), Point(3181,3442),
Point(3181,3440), Point(3181,3438), Point(3181,3436)];
'fwb': Tiles := [Point(2945,3367), Point(2946,3367), Point(2947,3367),
Point(2948,3367)];
'feb': Tiles := [Point(3010,3354), Point(3011,3354), Point(3012,3354),
Point(3013,3354), Point(3014,3354), Point(3015,3354)];
'lum': Tiles := [Point(3208,3221)];
'dra': Tiles := [Point(3091,3419), Point(3091,3245), Point(3091,3244),
Point(3091,3243), Point(3091,3242)];
'alk': Tiles := [Point(3268,3168), Point(3268,3167), Point(3268,3166),
Point(3268,3165), Point(3268,3164)];
end;
GetMyPos(Me.x, Me.y);
SortTPAFrom(Tiles, Me);
If (DistanceFrom(Tiles[0].x, Tiles[0].y) > 3) then
Begin
If not(TileOnMM(Tiles[0].x, Tiles[0].y)) then
Begin
Writeln('Couldn''t find bank');
Result := False;
Exit;
end;
WalkToTile(Tiles[0].x, Tiles[0].y);
Wait(10);
Flag;
Wait(100 + Random(100));
end;
If not(TileOnMS(Tiles[0].x, Tiles[0].y, 15)) then
Begin
SetAngle(True);
MakeCompass('n');
If not(TileOnMS(Tiles[0].x, Tiles[0].y, 20)) then
Begin
Writeln('Couldnt'' find bank booth');
Result := False;
Exit;
end;
end;
TileToMS(Tiles[0].x, Tiles[0].y, 20, x, y);
Mouse(x, y, 5, 5, False);
Wait(100 + Random(100));
Result := ChooseOption('e-q');
end;

function GetPlayers: array of TPlayer;
{*******************************************************************
function - GetPlayers: array of TPlayer;
By: Widget
Description: Returns all the players on the minimap
--- DOESN'T WORK YET ---
********************************************************************}
//var
// i, IndexPos, Count, Player, Name: integer;

begin
result := result; // stops the "Variable 'Result' never used" thing
{ Count := SmartGetFieldInt(0, PlayerCount);
writeln('Number of players: '+inttostr(Count));
SetArrayLength(result, Count);
for i := 0 to (count-1) do
begin
IndexPos := SmartGetFieldArrayInt(0, PlayerIndArray, i);
writeln('Index position: '+inttostr(count));
Player := SmartGetFieldArrayObject(0, PlayerArray, IndexPos);
writeln('Player placement: '+inttostr(Player));
Name := SmartGetFieldObject(Player, CharName);
writeln(inttostr(name));
writeln(StringFromBytes(Name));
Result[indexpos].Name := StringFromBytes(Name);
SmartFreeObject(Name);
Writeln(Result[indexpos].Name);
end; }
end;

function GetPlayer(name: string): TPlayer;
{*******************************************************************
function - GetPlayer(name: string): TPlayer;
By: Widget
Description: Gets available stats for a player (Levels only work on you).
--- DOESN'T WORK YET ---
********************************************************************}
begin
result := result; // stops the "Variable 'Result' never used" thing
end;

begin
SetupSRL;
SetupReflection;
end.

Setting up reflection took 313 ms.

ShowerThoughts

2008-07-25 07:47:35

Hmm good idea :)

Waddo

2008-07-25 08:16:02

Omg we must be able to use this to see what objects we can interact with

so we should be able to make Choose option functions.

And Masterkill = epic win.

what we need is a ay where kind find out all the available variables we can read.

n3ss3s

2008-07-25 08:51:28

Smartass :p

ZephyrsFury

2008-07-25 09:02:06

From: n3ss3s
Maybe more to the failure's side, Constants are called so because they are constant!


program New;

Const
A = 'Hello World!';
begin
A := 'lol';
end.

Variable Expected error pl0z.


Probably why he declared them as variables. :)

Waddo

2008-07-25 11:39:55

Added MakeCompassReflection and GetNPCInfo

//------------------------------------------------------------------\\
//-- Scar Non-Standard Resource Library --||
//-- » Reflection Routines --||
//------------------------------------------------------------------//
// * Procedure SetupReflection; // * by MasterKill
// * Function GetLevel(index: integer): integer; // * by BenLand100
// * Function StringFromBytes(jbytearray: integer): string; // * by BenLand100
// * Function GetMyName: string; // * by BenLand100
// * Function GetAnimation: integer; // * by BenLand100
// * Function GetSpeed: integer; // * by Widget
// * Function CharacterMoving: boolean; // * by BenLand100
// * Procedure GetMyPos(var x, y: Integer); // * by BenLand100
// * Function GetBoxAnswer: integer; // * by BenLand100
// * Function GetMinimapAngleDeg: extended; // * by BenLand100
// * Function GetMinimapAngleRad: extended; // * by BenLand100
// * Procedure TileToMinimap(tileX, tileY: integer; var screenX, // * by BenLand100
// screenY: integer); // º
// * Procedure MinimapToTile(screenX, screenY: integer; var tileX, // * by BenLand100
// tileY: integer); // º
// * Procedure TileToMS(tileX, tileY, height: integer; // * by BenLand100
// var screenX, screenY: integer); // º
// * Function TileOnMM(TileX, TileY : Integer) : Boolean; // * by ss23
// * Function TileOnMS(TileX, TileY, Height : Integer) : Boolean; // * by ss23
// * Function DistanceFrom(TileX, TileY: Integer) : Integer; // * by Widget
// * Function GetNPCs: array of TNPC; // * by Widget
// * Function GetNPCsByName: array of TNPC; // * by Widget
// * Function GetNPCsByID: array of TNPC; // * by Widget
// * Function SortNPCs(NPCs: array of TNPC): array of TNPC; // * by Widget
// * Function FindNPC(Name: string): TNPC; // * by Widget
// * Function FindNPCByID(ID: integer): TNPC; // * by Widget
// * Function ClickTile(TileX, TileY, Height : Integer; // * by ss23 and Widget
// Left : Boolean) : Boolean; // º
// * Function WalkToTile(Tilex, Tiley : Integer): Boolean; // * by ss23 and Widget
// * Function WalkToTileTol(TileX, TileY, Tol : Integer): Boolean; // * by ss23, Widget and TheGuyWhoGotOn
// * Function LongWalkEx(TileX, TileY, DisX, DisY, // * by TheGuyWhoGotOn
// Tol : integer): Boolean; // º
// * Function LongWalk(TileX, TileY, Tol : integer): Boolean; // * by TheGuyWhoGotOn
// * Function PathWalk(Path : array of TPoint; Long : boolean; // * by TheGuyWhoGotOn
// Tol : integer): Boolean; // º
// * Function MMtoMS(x, y: Integer; left: Boolean): Boolean; // * by LeeLokHin
// * Function OpenBankReflection(Bank : String): Boolean; // * by ss23 and TheGuyWhoGotOn
// * Function GetPlayers: array of TPlayer; // * by Widget
// * Function MakeCompassReflection(Direction: string; // * by Waddo
// Accuracy: integer): Boolean; // º
// * Procedure GetNPCInfo; // * by Waddo
//
//------------------------------------------------------------------//
// NPC stuff completely re-written
//
// TPlayer not used yet but eventually I'll stop being lazy -Widget
//
// Thanks to Speljohan and Quaters for making hooks that we can steal =)
//------------------------------------------------------------------//


type
TNPC = record
TileX, TileY, MSX, MSY, NPCType, height : integer;
Name : string;
InFight, IsMoving: boolean;
end;
TPlayer = record
x, y:integer;
animation, speed: integer;
HPRatio, height, level: integer;
Name: string;
Levels, Experiences: array[1..24]{or whatever} of integer;
end;

Var
BaseLayer, BaseX, BaseY, CamX, CamY, CamZ, CamPitch, CamYaw,
CompassAngle, CurrentLevels, Experiences, FlagX, FlagY, GroundHeights,
GroundSettings, LoopCycle, MapOffSetAngle, MaxLevels, MyPlayer,
NPCArray, NPCCount, NPCIndexArray, PlayerArray, PlayerCount,
PlayerIndArray, SettingsArray, CharAnim, CharMotion, CurrentX, CurrentY, CharHeight, LoopCycleStatus,
CharName, NPCDef, GetNPCName, GetNPCType, StringBytes: String;



//----------------------------------------------------------------------//

// fucntion explode my by: A G E N T 83
function Explode(Delimiter : string; Str : string) : array of string;
var
DelimPos, i : integer;
Arr1 : array of string;
begin
SetArrayLength(Arr1, 100000);
i := 0;
repeat
if (pos(Delimiter, Str) = 0) then Break;
DelimPos := pos(Delimiter, Str);
Arr1[i] := Replace((copy(Str,0,DelimPos)),Delimiter,'');
Delete(Str,1,DelimPos);
i := i + 1;
until(pos(Delimiter, Str) = 0);
Arr1[i] := Str;
SetArrayLength(Arr1, i+1);
Result := Arr1;
end;

{*******************************************************************
Procedure SetupReflection;
By: MasterKill
Description: Loads RS hooks from an text file
********************************************************************}
Procedure SetupReflection;
Var
HooksPage: String;
Hook: TStringArray;
StartTime: Integer;
Begin
StartTime := GetSystemTime;
HooksPage := GetPage('http://www.freewebs.com/srlfiles/hooks.txt');
Hook := Explode(',', HooksPage);
BaseLayer := Hook[0];
BaseX := Hook[1];
BaseY := Hook[2];
CamX := Hook[3];
CamY := Hook[4];
CamZ := Hook[5];
CamPitch := Hook[6];
CamYaw := Hook[7];
CompassAngle := Hook[8];
CurrentLevels := Hook[9];
Experiences := Hook[10];
FlagX := Hook[11];
FlagY := Hook[12];
GroundHeights := Hook[13];
GroundSettings := Hook[14];
LoopCycle := Hook[15];
MapOffsetAngle := Hook[16];
MaxLevels := Hook[17];
MyPlayer := Hook[18];
NPCArray := Hook[19];
NPCCount := Hook[20];
NPCIndexArray := Hook[21];
PlayerArray := Hook[22];
PlayerCount := Hook[23];
PlayerIndArray := Hook[24];
SettingsArray := Hook[25];
CharAnim := Hook[26];
CharMotion := Hook[27];
CurrentX := Hook[28];
CurrentY := Hook[29];
CharHeight := Hook[30];
LoopCycleStatus:= Hook[31];
CharName := Hook[32];
NPCDef := Hook[33];
GetNPCName := Hook[34];
GetNPCType := Hook[35];
StringBytes := Hook[36];
WriteLn('Setting up reflection took ' + IntToStr(GetSystemTime - StartTime) + ' ms.');
End;

function GetLevel(index: integer): integer;
{*******************************************************************
Function - GetLevel(index: integer): integer;
By: BenLand100
Description: Returns the current level of your player (its a funny array)
********************************************************************}
begin
result:= SmartGetFieldArrayInt(0,CurrentLevels,index);
end;

function StringFromBytes(jbytearray: integer): string;
{*******************************************************************
Function - StringFromBytes(jbytearray: integer): string;
By: BenLand100
Description: Converts a byte[] from StringWrap to a DelphiString
(max length 256)
********************************************************************}
begin
SetLength(result, 256);
SetLength(result, SmartStringFromBytes(jbytearray,result));
end;

function GetMyName: string;
{*******************************************************************
Function - GetMyName: string;
By: BenLand100
Description: Returns last logged in player's name
********************************************************************}
var
bytes: Integer;
begin
bytes:= SmartGetFieldObject(0,MyPlayer+'.'+CharName+'.'+StringBytes);
result:= StringFromBytes(bytes);
SmartFreeObject(bytes);
end;

function GetAnimation: integer;
{*******************************************************************
Function - GetAnimation: integer;
By: BenLand100
Description: Returns your animation
********************************************************************}
begin
result:= SmartGetFieldInt(0,MyPlayer+'.'+CharAnim);
end;

function GetSpeed: integer; // :)
{*******************************************************************
Function - GetSpeed: integer;
By: Widget
Description: Gets character speed (squares per second)
********************************************************************}
begin
result:= SmartGetFieldInt(0,MyPlayer+'.'+CharMotion);
end;

function CharacterMoving: boolean; //:)
{*******************************************************************
Function - CharacterMoving: boolean;
By: BenLand100
Description: True if you are moving
********************************************************************}
begin
result:= (GetSpeed > 0);
end;

procedure GetMyPos(var x, y: Integer); // :)
{*******************************************************************
procedure - GetMyPos(var x, y: Integer);
By: BenLand100
Description: Calculates your x,y position or [somehugenumber] if not
logged in
********************************************************************}
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;

function DumpSettingArray: array[0..1999] of integer;
{*******************************************************************
function - DumpSettingArray: array[0..1999] of integer;
By: BenLand100
Description: Dumps the settings array to an integer array
********************************************************************}
var
i: integer;
begin
for i:= 0 to 1999 do
Result[i]:= SmartGetFieldArrayInt(0,SettingsArray,i);
end;

function GetBoxAnswer: integer;
{*******************************************************************
function - GetBoxAnswer: integer;
By: BenLand100
Description: Returns -1 if no box open or 0..2 for the correct
answer to the box
Comments: Yet another reason reflection is leet =) -Widget
********************************************************************}
var
boxIndex: Integer;
begin
boxIndex:= SmartGetFieldArrayInt(0,SettingsArray,312);
if boxIndex = 0 then
result:= -1
else
result:= (boxIndex shr 24) and $FF;
end;

function GetMinimapAngleDeg: extended;
{*******************************************************************
function - GetMinimapAngleDeg: extended;
By: BenLand100
Description: Returns the current Map angle in degrees
********************************************************************}
var
clientAngle: integer;
begin
clientAngle:= (SmartGetFieldInt(0,CompassAngle) + SmartGetFieldInt(0,MapOffsetAngle)) mod 2048;
result:= clientAngle * 180 / 1024;
end;

function GetMinimapAngleRad: extended;
{*******************************************************************
function - GetMinimapAngleRad: extended;
By: BenLand100
Description: Returns the current map angle in radians
********************************************************************}
var
clientAngle: integer;
begin
clientAngle:= (SmartGetFieldInt(0,CompassAngle) + SmartGetFieldInt(0,MapOffsetAngle)) mod 2048;
result:= clientAngle * Pi / 1024;
end;

procedure TileToMinimap(tileX, tileY: integer; var screenX, screenY: integer);
{*******************************************************************
procedure - TileToMinimap(tileX, tileY: integer; var screenX, screenY: integer);
By: BenLand100
Description: Converts the tile position tileX,tileY to a minimap location
********************************************************************}
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)) + 629;
screenY:= round(tempX*sin(angle) + tempY*cos(angle)) + 85;
end;

procedure MinimapToTile(screenX, screenY: integer; var tileX, tileY: integer);
{*******************************************************************
procedure - MinimapToTile(screenX, screenY: integer; var tileX, tileY: integer);
By: BenLand100
Description: converts the screen position screenX,screenY from the minimap
to a tile
********************************************************************}
var
angle: extended;
tempX, tempY: integer;
begin
angle:= getMinimapAngleRad;
tempX:= (screenX - 643);
tempY:= (84 - 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;

procedure TileToMS(tileX, tileY, height: integer; var screenX, screenY: integer);
{*******************************************************************
procedure - TileToMS(tileX, tileY, height: integer; var screenX, screenY: integer);
By: BenLand100
Description: Converts the tile position tileX,tileY to a mainscreen location
Height is the distance (in px) above the ground
********************************************************************}
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;

Function TileOnMM(TileX, TileY : Integer) : Boolean;
{*******************************************************************
Function TileOnMM(TileX, TileY : Integer) : Boolean;
By: ss23
Description: True = Tile on MM
********************************************************************}
Var
PointEx : TPoint;
BoxEx : TBox;
Begin
BoxEx := IntToBox(MMX1, MMY1, MMX2, MMY2);
TileToMinimap(TileX, TileY, PointEx.x, PointEx.y);
Result := PointInBox(PointEx, BoxEx);
end;

Function TileOnMS(TileX, TileY, Height : Integer) : Boolean;
{*******************************************************************
Function TileOnMS(TileX, TileY, Height : Integer) : Boolean;
By: ss23
Description: True = Tile on MS
********************************************************************}
Var
PointEx : TPoint;
BoxEx : TBox;
Begin
BoxEx := IntToBox(MSX1, MSY1, MSX2, MSY2);
TileToMS(Tilex, Tiley, Height, pointex.x, pointex.y);
Result := PointInBox(PointEx, BoxEx);
end;

Function DistanceFrom(TileX, TileY: Integer) : Integer;
{*******************************************************************
Function DistanceFrom(TileX, TileY: Integer) : Integer;
By: Widget
Description: Returns the distance between your player and the tile
********************************************************************}
Var
MyX,MyY : integer;
Begin
GetMyPos(MyX, MyY);
result := Distance(TileX, TileY, MyX, MyY);
end;

function GetNPCs:array of TNPC;
{*******************************************************************
function GetNPCs:array of TNPC;
By: Widget
Description: Returns all the currently loaded NPCs
********************************************************************}
var
i,NumNPCs,Index,TheNPC,TheNPCDef,TheBytes: integer;
begin
NumNPCs := SmartGetFieldInt(0,NPCCount);
if (NumNPCs=0) then Exit;
SetArrayLength(Result,NumNPCs);
for i := 0 to (NumNPCs-1) do
begin
Index := SmartGetFieldArrayInt(0,NPCIndexArray,i);
TheNPC := SmartGetFieldArrayObject(0,NPCArray,Index);
TheNPCDef := SmartGetFieldObject(TheNPC,NPCDef);
TheBytes := SmartGetFieldObject(TheNPCDef,GetNPCName+'.'+StringBytes);
Result[i].Name := StringFromBytes(TheBytes);
Result[i].TileX := (SmartGetFieldInt(0, BaseX) + (SmartGetFieldInt(TheNPC, CurrentX) shr 7));
Result[i].TileY := (SmartGetFieldInt(0, BaseY) + (SmartGetFieldInt(TheNPC, CurrentY) shr 7));
Result[i].NPCType := SmartGetFieldInt(TheNPCDef,GetNPCType);
Result[i].Height := iabs(SmartGetFieldInt(TheNPC,CharHeight));
Result[i].InFight := (SmartGetFieldInt(0,LoopCycle)<SmartGetFieldInt(TheNPC,LoopCycleStatus));
Result[i].IsMoving := (SmartGetFieldInt(TheNPC,CharMotion)>0);
if TileOnMS(Result[i].TileX, Result[i].TileY, Result[i].Height * 2 / 3) then
TileToMS(Result[i].TileX, Result[i].TileY, Result[i].Height * 2 / 3, Result[i].MSX, Result[i].MSY);
SmartFreeObject(TheNPC);
SmartFreeObject(TheNPCDef);
SmartFreeObject(TheBytes);
end;
end;

function GetNPCsByName(name:string):array of TNPC;
{*******************************************************************
Function GetNPCsByName(name:string):array of TNPC;
By: Widget
Description: Returns NPCs matching the name.
********************************************************************}
var
i: integer;
NPCs: array of TNPC;
begin
NPCs := GetNPCs;
if (GetArrayLength(NPCs)=0) then Exit;
for i := 0 to High(NPCs) do
if (pos(trim(name),trim(NPCs[i].Name))>0) then
begin
SetArrayLength(result,GetArrayLength(result)+1);
result[GetArrayLength(result)-1] := NPCs[i];
end;
end;

function GetNPCsByID(TheType:integer):array of TNPC;
{*******************************************************************
Function GetNPCsByID(TheType:integer):array of TNPC;
By: Widget
Description: Returns NPCs matching the ID.
********************************************************************}
var
i: integer;
NPCs: array of TNPC;
begin
NPCs := GetNPCs;
if (GetArrayLength(NPCs)=0) then Exit;
for i := 0 to High(NPCs) do
if (NPCs[i].NPCType=TheType) then
begin
SetArrayLength(result,GetArrayLength(result)+1);
result[GetArrayLength(result)-1] := NPCs[i];
end;
end;

function SortNPCs(NPCs:array of TNPC):array of TNPC;
{*******************************************************************
Function SortNPCs(NPCs:array of TNPC):array of TNPC;
By: Widget
Description: Sorts NPCs by distance from you.
********************************************************************}
var
i,i2,ix,iy: integer;
tpa: TPointArray;
begin
if (GetArrayLength(NPCs)=0) then Exit;
SetArrayLength(TPA,GetArrayLength(NPCs));
SetArrayLength(Result,GetArrayLength(NPCs));
for i := 0 to high(NPCs) do
TPA[i] := Point(NPCs[i].TileX, NPCs[i].TileY);
GetMyPos(ix, iy);
SortTPAFrom(TPA, Point(ix, iy));
for i := 0 to high(TPA) do
for i2 := 0 to high(NPCs) do // they really should be the same
if (TPA[i].x=NPCs[i2].TileX) and (TPA[i].y=NPCs[i2].TileY) then
Result[i] := NPCs[i2];
end;

Function FindNPC(Name: string; var NPC: TNPC):boolean;
{*******************************************************************
function FindNPC(Name: string; var NPC: TNPC):boolean;
By: Widget
Description: Finds the tile of the named NPC and puts it in the NPC var.
Returns true if found, false if not. (Try walking with the MM if
it's not on the main screen.
********************************************************************}
var
NPCs: array of TNPC;
begin
NPCs := SortNPCs(GetNPCsByName(Name));
result := GetArrayLength(NPCs)<>0;
if not result then
Exit;
NPC := NPCs[0];
end;

Function FindNPCByID(ID: integer; var NPC: TNPC):boolean;
{*******************************************************************
function FindNPCByID(ID: integer; var NPC: TNPC):boolean;
By: Widget
Description: Finds the tile of the named NPC and puts it in the NPC var.
Returns true if found, false if not. (Try checking for tiles if
it's not on the mainscreen.)
********************************************************************}
var
NPCs: array of TNPC;
begin
NPCs := SortNPCs(GetNPCsByID(ID));
result := GetArrayLength(NPCs)<>0;
if not result then
Exit;
NPC := NPCs[0];
end;

Function ClickTile(TileX, TileY, Height : Integer; Left : Boolean) : Boolean;
{*******************************************************************
Function ClickTile(TileX, TileY, Height : Integer; Left : Boolean) : Boolean;
By: ss23 and Widget
Description: Clicks a tile. Height is the approximate heigh in pixels
Height doesnt matter if HighestAngle;
********************************************************************}
Var
x, y : Integer;
Begin
TileToMS(TileX, TileY, Height, x, y);
result := TileOnMs(x,y,height);
if not result then
Exit;
Mouse(x, y, 5, 5, False);
end;

Function WalkToTile(TileX, TileY : Integer): Boolean;
{*******************************************************************
Function - WalkToTile(TileX, TileY : Integer): Boolean;
By: ss23 and Widget
Description: Walks to the tile using minimap.
********************************************************************}
Var
x, y : Integer;
Begin
TileToMinimap(Tilex, Tiley, x, y);
if not TileOnMM(TileX, TileY) then
begin
Writeln('Tile off minimap');
Result := False;
Exit;
end;
Mouse(x, y, 3, 3, True);
Result := True;
end;

Function WalkToTileTol(TileX, TileY, Tol : Integer): Boolean;
{*******************************************************************
Function - WalkToTileTol(TileX, TileY, Tol : Integer): Boolean;
By: ss23 and Widget and TheGuyWhoGotOn
Description: Walks to the tile using minimap and tolerance.
********************************************************************}
Var
x, y : Integer;
Begin
TileToMinimap(Tilex, Tiley, x, y);
if not TileOnMM(TileX, TileY) then
begin
Writeln('Tile off minimap');
Result := False;
Exit;
end;
Mouse(x, y, Tol, Tol, True);
Result := True;
end;

function LongWalkEx(TileX, TileY, DisX, DisY, Tol : integer): boolean;
{*******************************************************************
Function - LongWalkEx(TileX, TileY, DisX, DisY, Tol : Integer): Boolean;
By: TheGuyWhoGotOn
Description: Walks to a far tile using the minimap and tolerance.
DisX/DisY is how many tiles it will move at a time.
********************************************************************}
var TX, TY, DX, DY : integer;
begin
repeat
GetMyPos(TX, TY);
if ((DX) > (TileX - DisX)) and ((DX) < (TileX + DisX)) then else
if TileX > TX then DX := TX + DisX
else DX := TX - DisX;
if ((DY) > (-TileY - DisY)) and ((DY) < (TileY + DisY)) then else
if TileY > TY then DY := TY + DisY
else DY := TY - DisY;
WalkToTileTol(DX, DY, Tol);
repeat
Wait(1000 + Random(500));
until (Flag) or (not(CharacterMoving));
until (TileOnMM(TileX, TileY)) or (not(TileOnMM(DX, DY)));
Result := WalkToTileTol(TileX, TileY, Tol);
end;

function LongWalk(TileX, TileY, Tol : integer): boolean;
{*******************************************************************
Function - LongWalk(TileX, TileY, Tol : Integer): Boolean;
By: TheGuyWhoGotOn
Description: Walks to a far tile using the minimap and tolerance.
********************************************************************}
begin
Result := LongWalkEx(TileX, TileY, 11, 11, Tol);
end;

function PathWalk(Path : array of TPoint; Long : boolean; Tol : integer): Boolean;
{*******************************************************************
Function - PathWalk(Path : array of TPoint; Long : boolean; Tol : integer): Boolean;
By: TheGuyWhoGotOn
Description: Walks a path for you with LongWalk options.
********************************************************************}
var Count : integer;
begin
Count := 0;
repeat
if Long then Result := LongWalk(Path[Count].x, Path[Count].y, Tol)
else Result := WalkToTileTol(Path[Count].x, Path[Count].y, Tol);
repeat
Wait(1000 + Random(500));
until (Flag) or (not(CharacterMoving));
if not(Result) then
begin
WriteLn('Path walk failed');
Exit;
end;
Count := Count + 1;
until (not(Result)) or (Count = GetArrayLength(Path))
end;

procedure MMtoMS(MMX,MMY:integer; var MSX,MSY:integer);
{*******************************************************************
Function MMtoMS(x, y: Integer; left: Boolean): Boolean;
By: LeeLokHin
Description: Converts Coordinates x and y on the minimap
to equivilants on the MainScreen and clicks right or left according
to boolean left.
********************************************************************}
var
tx,ty:integer;
begin
MinimapToTile(MMX, MMY, tx, ty);
TileToMS(tx, ty, 5, MSX, MSY);
end;

Function OpenBankReflection(Bank : String): Boolean;
{*******************************************************************
Function OpenBankReflection(Bank : String): Boolean;
By: ss23
Description: Opens the bank. Opens nearest slot
********************************************************************}
Var
x, y : Integer;
Me : TPoint;
Tiles : TPointArray;
Begin
Case Bank of
'veb': Tiles := [Point(3251,3419), Point(3252,3419), Point(3253,3419),
Point(3254,3419), Point(3255,3419), Point(3256,3419)];
'vwb': Tiles := [Point(3190,3435), Point(3190,3437), Point(3190,3439),
Point(3190,3441), Point(3190,3443), Point(3181,3444), Point(3181,3442),
Point(3181,3440), Point(3181,3438), Point(3181,3436)];
'fwb': Tiles := [Point(2945,3367), Point(2946,3367), Point(2947,3367),
Point(2948,3367)];
'feb': Tiles := [Point(3010,3354), Point(3011,3354), Point(3012,3354),
Point(3013,3354), Point(3014,3354), Point(3015,3354)];
'lum': Tiles := [Point(3208,3221)];
'dra': Tiles := [Point(3091,3419), Point(3091,3245), Point(3091,3244),
Point(3091,3243), Point(3091,3242)];
'alk': Tiles := [Point(3268,3168), Point(3268,3167), Point(3268,3166),
Point(3268,3165), Point(3268,3164)];
end;
GetMyPos(Me.x, Me.y);
SortTPAFrom(Tiles, Me);
If (DistanceFrom(Tiles[0].x, Tiles[0].y) > 3) then
Begin
If not(TileOnMM(Tiles[0].x, Tiles[0].y)) then
Begin
Writeln('Couldn''t find bank');
Result := False;
Exit;
end;
WalkToTile(Tiles[0].x, Tiles[0].y);
Wait(10);
Flag;
Wait(100 + Random(100));
end;
If not(TileOnMS(Tiles[0].x, Tiles[0].y, 15)) then
Begin
SetAngle(True);
MakeCompass('n');
If not(TileOnMS(Tiles[0].x, Tiles[0].y, 20)) then
Begin
Writeln('Couldnt'' find bank booth');
Result := False;
Exit;
end;
end;
TileToMS(Tiles[0].x, Tiles[0].y, 20, x, y);
Mouse(x, y, 5, 5, False);
Wait(100 + Random(100));
Result := ChooseOption('e-q');
end;

function GetPlayers: array of TPlayer;
{*******************************************************************
function - GetPlayers: array of TPlayer;
By: Widget
Description: Returns all the players on the minimap
--- DOESN'T WORK YET ---
********************************************************************}
//var
// i, IndexPos, Count, Player, Name: integer;

begin
result := result; // stops the "Variable 'Result' never used" thing
{ Count := SmartGetFieldInt(0, PlayerCount);
writeln('Number of players: '+inttostr(Count));
SetArrayLength(result, Count);
for i := 0 to (count-1) do
begin
IndexPos := SmartGetFieldArrayInt(0, PlayerIndArray, i);
writeln('Index position: '+inttostr(count));
Player := SmartGetFieldArrayObject(0, PlayerArray, IndexPos);
writeln('Player placement: '+inttostr(Player));
Name := SmartGetFieldObject(Player, CharName);
writeln(inttostr(name));
writeln(StringFromBytes(Name));
Result[indexpos].Name := StringFromBytes(Name);
SmartFreeObject(Name);
Writeln(Result[indexpos].Name);
end; }
end;

function GetPlayer(name: string): TPlayer;
{*******************************************************************
function - GetPlayer(name: string): TPlayer;
By: Widget
Description: Gets available stats for a player (Levels only work on you).
--- DOESN'T WORK YET ---
********************************************************************}
begin
result := result; // stops the "Variable 'Result' never used" thing
end;

Function Makecompassreflection(Direction:string;Accuracy:integer): Boolean;
{*******************************************************************
Function Makecompassreflection(Direction:string;Accuracy:integer): Boolean;
By: Waddo
Description: Rotates the camera using reflection
********************************************************************}
var
clientAngle,DirDeg,mark: integer;
left:boolean;
begin
case LowerCase(Direction) of
'n': DirDeg := 0;
'w': DirDeg := 90;
's': DirDeg := 180;
'e': DirDeg := 270;
end else
DirDeg := StrToInt(Direction);
ClientAngle:= (SmartGetFieldInt(0,CompassAngle) + SmartGetFieldInt(0,MapOffsetAngle)) mod 2048;
ClientAngle:=ClientAngle * 180 / 1024;
if ClientAngle=dirdeg then exit;
if (ClientAngle-DirDeg)>180 then
begin
left:=false;
keydown(vk_right);
end else
begin
left:=true;
keydown(vk_left);
end;
wait(1);
MarkTime(Mark);
repeat
clientAngle:= (SmartGetFieldInt(0,CompassAngle) + SmartGetFieldInt(0,MapOffsetAngle)) mod 2048;
clientangle:=clientAngle * 180 / 1024;
If left then
if clientangle>DirDeg then break;
if not left then
if clientangle<DirDeg then break;
If clientangle=dirDeg then break;
Wait(1);
until (TimeFromMark(Mark) > 14000) or ( ((clientangle>dirDeg-Accuracy) or (clientangle>dirDeg-Accuracy+360)) and (clientangle<dirDeg+Accuracy));
if left then
Keyup(vk_left)
else
keyup(vk_right);
if clientangle<>dirdeg then
Makecompassreflection(direction,0);
result:=clientangle=dirDeg;
end;

Procedure GetNPCInfo;
{*******************************************************************
Procedure GetNPCInfo;
By: Waddo
Description: Displays the info of loaded NPC's.
********************************************************************}
var
i: integer;
NPCs: array of TNPC;
begin
NPCs := GetNPCs;
if (GetArrayLength(NPCs)=0) then Exit;
for i := 0 to High(NPCs) do
writeln('NPC: '+NPCs[i].Name+' ID: '+IntToStr(NPCs[i].NPCType)+
' Tile X: '+IntToStr(NPCs[i].TileX)+' Tile Y: '+IntToStr(NPCs[i].TileY));
end;




(accuracy should be put at about 6-10 it will adjust itself to perfection)

TheGuyWhoGotOn

2008-07-25 14:32:35

Umm this is getting messy…I have no idea what GetNPCInfo could be used for. MoveCompassReflection seems a little long. And I'm not 100% sure if we should use SetupReflection right now however it is a very good idea…I don't know if I'm allowed to post a link to Widget's pastebin but he posted a link somewhere. I'll post the latest version from there and later today (But probably tomorrow) I will discuss with Widget how we're going to use those 3 new things :P.


//------------------------------------------------------------------\\
//-- Scar Non-Standard Resource Library --||
//-- » Reflection Routines --||
//------------------------------------------------------------------//
// * Function GetLevel(index: integer): integer; // * by BenLand100
// * Function GetCombat: integer; // * by TheGuyWhoGotOn
// * Function StringFromBytes(jbytearray: integer): string; // * by BenLand100
// * Function GetMyName: string; // * by BenLand100
// * Function GetAnimation: integer; // * by BenLand100
// * Function GetSpeed: integer; // * by Widget
// * Function CharacterMoving: boolean; // * by BenLand100
// * Procedure GetMyPos(var x, y: Integer); // * by BenLand100
// * function GetFlag(var x, y: Integer): boolean; // * by TheGuyWhoGotOn
// * Function GetBoxAnswer: integer; // * by BenLand100
// * Function GetMinimapAngleDeg: extended; // * by BenLand100
// * Function GetMinimapAngleRad: extended; // * by BenLand100
// * Procedure TileToMinimap(tileX, tileY: integer; var screenX, // * by BenLand100
// screenY: integer); //
// * Procedure MinimapToTile(screenX, screenY: integer; var tileX, // * by BenLand100
// tileY: integer); //
// * Procedure TileToMS(tileX, tileY, height: integer; // * by BenLand100
// var screenX, screenY: integer); //
// * Function TileOnMM(TileX, TileY : Integer) : Boolean; // * by ss23
// * Function TileOnMS(TileX, TileY, Height : Integer) : Boolean; // * by ss23
// * Function DistanceFrom(TileX, TileY: Integer) : Integer; // * by Widget
// * Function GetNPCs: array of TNPC; // * by Widget
// * Function GetNPCsByName: array of TNPC; // * by Widget
// * Function GetNPCsByID: array of TNPC; // * by Widget
// * Function SortNPCs(NPCs: array of TNPC): array of TNPC; // * by Widget
// * Function FindNPC(Name: string): TNPC; //
// * Function FindNPCByID(ID: integer): TNPC; //
// * Function ClickTile(TileX, TileY, Height : Integer; // * by ss23 and Widget
// Left : Boolean) : Boolean; //
// * Function WalkToTile(Tilex, Tiley : Integer): Boolean; // * by ss23 and Widget
// * Function WalkToTileTol(TileX, TileY, Tol : Integer): Boolean; // * by ss23, Widget and TheGuyWhoGotOn
// * Function AlmostThere: Boolean; // * by TheGuyWhoGotOn
// * Function LongWalkEx(TileX, TileY, DisX, DisY, // * by TheGuyWhoGotOn
// Tol : integer): Boolean; //
// * Function LongWalk(TileX, TileY, Tol : integer): Boolean; // * by TheGuyWhoGotOn
// * Function PathWalk(Path : array of TPoint; Long : boolean; // * by TheGuyWhoGotOn
// Tol : integer): Boolean; //
// * Function MMtoMS(x, y: Integer; left: Boolean): Boolean; // * by LeeLokHin
// * Function OpenBankReflection(Bank : String): Boolean; // * by ss23 and TheGuyWhoGotOn
// * Function GetPlayers: array of TPlayer; // * by Widget
//------------------------------------------------------------------//
// NPC stuff completely re-written
//
// Added TNPC type, will use later; Improved TileOn functions - ss23
//
// Thanks to Speljohan and Quaters for making hooks that we can steal =)
//------------------------------------------------------------------//
// Changes since last version //
// //
// Added combat level hooks //
// Added GetCombat //
// Added AlmostThere //
//------------------------------------------------------------------//


type
TNPC = record
TileX, TileY, MSX, MSY, NPCType, height : integer;
Name : string;
InFight, IsMoving: boolean;
end;
TPlayer = record
x, y:integer;
animation, speed: integer;
HPRatio, height, level: integer;
Name: string;
Levels, Experiences: array[1..24]{or whatever} of integer;
end;



const
// Global Static Hooks
BaseLayer = 'bc.f';
BaseX = 'pa.e';
BaseY = 'rb.D';
CamX = 'ph.j';
CamY = 'bb.y';
CamZ = 'bi.w';
CamPitch = 'sh.N';
CamYaw = 'pi.E';
CompassAngle = 'oj.p';
CurrentLevels = 'fd.eb';
Experiences = 'e.n';
FlagX = 'sc.Y';
FlagY = 'le.f';
GroundHeights = 'lh.N';
GroundSettings = 'ad.P';
LoopCycle = 'lg.a';
MapOffsetAngle = 'fa.m';
MaxLevels = 'hk.e';
MyPlayer = 'th.u';
NPCArray = 'gj.o';
NPCCount = 'qi.h';
NPCIndexArray = 'cf.c';
PlayerArray = 'fg.h';
PlayerCount = 'li.h';
PlayerIndArray = 'sf.K';
SettingsArray = 'ki.c';

// Character Hooks
CharAnim = 'cb';
CharMotion = 'pb';
CurrentX = 'Q';
CurrentY = 'Bb';
CharHeight = 'y';
LoopCycleStatus= 'qb';

// Player Hooks
CharName = 'uc';
CharLevel = 'mc';

// NPC Hooks
NPCDef = 'Nb';

// NPCDef Hooks
GetNPCName = 'V';
GetNPCType = 'j';

// RSString Hooks
StringBytes = 'B';

//----------------------------------------------------------------------//

function GetLevel(index: integer): integer;
{*******************************************************************
Function - GetLevel(index: integer): integer;
By: BenLand100
Description: Returns the current level of your player (its a funny array)
********************************************************************}
begin
result:= SmartGetFieldArrayInt(0,CurrentLevels,index);
end;

function GetCombat: integer;
{*******************************************************************
Function - GetCombat: integer;
By: TheGuyWhoGotOn
Description: Returns the combat level of your player
********************************************************************}
begin
result:= SmartGetFieldInt(0,MyPlayer+'.'+CharLevel);
end;

function StringFromBytes(jbytearray: integer): string;
{*******************************************************************
Function - StringFromBytes(jbytearray: integer): string;
By: BenLand100
Description: Converts a byte[] from StringWrap to a DelphiString
(max length 256)
********************************************************************}
begin
SetLength(result, 256);
SetLength(result, SmartStringFromBytes(jbytearray,result));
end;

function GetMyName: string;
{*******************************************************************
Function - GetMyName: string;
By: BenLand100
Description: Returns last logged in player's name
********************************************************************}
var
bytes: Integer;
begin
bytes:= SmartGetFieldObject(0,MyPlayer+'.'+CharName+'.'+StringBytes);
result:= StringFromBytes(bytes);
SmartFreeObject(bytes);
end;

function GetAnimation: integer;
{*******************************************************************
Function - GetAnimation: integer;
By: BenLand100
Description: Returns your animation
********************************************************************}
begin
result:= SmartGetFieldInt(0,MyPlayer+'.'+CharAnim);
end;

function GetSpeed: integer; // :)
{*******************************************************************
Function - GetSpeed: integer;
By: Widget
Description: Gets character speed (squares per second)
********************************************************************}
begin
result:= SmartGetFieldInt(0,MyPlayer+'.'+CharMotion);
end;

function CharacterMoving: boolean; //:)
{*******************************************************************
Function - CharacterMoving: boolean;
By: BenLand100
Description: True if you are moving
********************************************************************}
begin
result:= (GetSpeed > 0);
end;

procedure GetMyPos(var x, y: Integer); // :)
{*******************************************************************
procedure - GetMyPos(var x, y: Integer);
By: BenLand100
Description: Calculates your x,y position or [somehugenumber] if not
logged in
********************************************************************}
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;

function GetFlag(var x, y: Integer): boolean;
{*******************************************************************
procedure - GetFlag(var x, y: Integer): boolean;
By: TheGuyWhoGotOn
Description: Gets your destination (Tiles)
********************************************************************}
begin
x:= SmartGetFieldInt(0,BaseX) + SmartGetFieldInt(0,FlagX);
y:= SmartGetFieldInt(0,BaseY) + SmartGetFieldInt(0,FlagY);
Result := ((SmartGetFieldInt(0,FlagX) > 0) and (SmartGetFieldInt(0,FlagY) > 0));
end;

function DumpSettingArray: array[0..1999] of integer;
{*******************************************************************
function - DumpSettingArray: array[0..1999] of integer;
By: BenLand100
Description: Dumps the settings array to an integer array
********************************************************************}
var
i: integer;
begin
for i:= 0 to 1999 do
Result[i]:= SmartGetFieldArrayInt(0,SettingsArray,i);
end;

function GetBoxAnswer: integer;
{*******************************************************************
function - GetBoxAnswer: integer;
By: BenLand100
Description: Returns -1 if no box open or 0..2 for the correct
answer to the box
Comments: Yet another reason reflection is leet =) [-Widget]
********************************************************************}
var
boxIndex: Integer;
begin
boxIndex:= SmartGetFieldArrayInt(0,SettingsArray,312);
if boxIndex = 0 then
result:= -1
else
result:= (boxIndex shr 24) and $FF;
end;

function GetMinimapAngleDeg: extended;
{*******************************************************************
function - GetMinimapAngleDeg: extended;
By: BenLand100
Description: Returns the current Map angle in degrees
********************************************************************}
var
clientAngle: integer;
begin
clientAngle:= (SmartGetFieldInt(0,CompassAngle) + SmartGetFieldInt(0,MapOffsetAngle)) mod 2048;
result:= clientAngle * 180 / 1024;
end;

function GetMinimapAngleRad: extended;
{*******************************************************************
function - GetMinimapAngleRad: extended;
By: BenLand100
Description: Returns the current map angle in radians
********************************************************************}
var
clientAngle: integer;
begin
clientAngle:= (SmartGetFieldInt(0,CompassAngle) + SmartGetFieldInt(0,MapOffsetAngle)) mod 2048;
result:= clientAngle * Pi / 1024;
end;

procedure TileToMinimap(tileX, tileY: integer; var screenX, screenY: integer);
{*******************************************************************
procedure - TileToMinimap(tileX, tileY: integer; var screenX, screenY: integer);
By: BenLand100
Description: Converts the tile position tileX,tileY to a minimap location
********************************************************************}
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)) + 629;
screenY:= round(tempX*sin(angle) + tempY*cos(angle)) + 85;
end;

procedure MinimapToTile(screenX, screenY: integer; var tileX, tileY: integer);
{*******************************************************************
procedure - MinimapToTile(screenX, screenY: integer; var tileX, tileY: integer);
By: BenLand100
Description: converts the screen position screenX,screenY from the minimap
to a tile
********************************************************************}
var
angle: extended;
tempX, tempY: integer;
begin
angle:= getMinimapAngleRad;
tempX:= (screenX - 643);
tempY:= (84 - 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;

procedure TileToMS(tileX, tileY, height: integer; var screenX, screenY: integer);
{*******************************************************************
procedure - TileToMS(tileX, tileY, height: integer; var screenX, screenY: integer);
By: BenLand100
Description: Converts the tile position tileX,tileY to a mainscreen location
Height is the distance (in px) above the ground
********************************************************************}
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;

Function TileOnMM(TileX, TileY : Integer) : Boolean;
{*******************************************************************
Function TileOnMM(TileX, TileY : Integer) : Boolean;
By: ss23
Description: True = Tile on MM
********************************************************************}
Var
PointEx : TPoint;
BoxEx : TBox;
Begin
BoxEx := IntToBox(MMX1, MMY1, MMX2, MMY2);
TileToMinimap(TileX, TileY, PointEx.x, PointEx.y);
Result := PointInBox(PointEx, BoxEx);
end;

Function TileOnMS(TileX, TileY, Height : Integer) : Boolean;
{*******************************************************************
Function TileOnMS(TileX, TileY, Height : Integer) : Boolean;
By: ss23
Description: True = Tile on MS
********************************************************************}
Var
PointEx : TPoint;
BoxEx : TBox;
Begin
BoxEx := IntToBox(MSX1, MSY1, MSX2, MSY2);
TileToMS(Tilex, Tiley, Height, pointex.x, pointex.y);
Result := PointInBox(PointEx, BoxEx);
end;

Function DistanceFrom(TileX, TileY: Integer) : Integer;
{*******************************************************************
Function DistanceFrom(TileX, TileY: Integer) : Integer;
By: Widget
Description: Returns the distance between your player and the tile
********************************************************************}
Var
MyX,MyY : integer;
Begin
GetMyPos(MyX, MyY);
result := Distance(TileX, TileY, MyX, MyY);
end;

function GetNPCs:array of TNPC;
{*******************************************************************
function GetNPCs:array of TNPC;
By: Widget
Description: Returns all the currently loaded NPCs
********************************************************************}
var
i,NumNPCs,Index,TheNPC,TheNPCDef,TheBytes: integer;
begin
NumNPCs := SmartGetFieldInt(0,NPCCount);
if (NumNPCs=0) then Exit;
SetArrayLength(Result,NumNPCs);
for i := 0 to (NumNPCs-1) do
begin
Index := SmartGetFieldArrayInt(0,NPCIndexArray,i);
TheNPC := SmartGetFieldArrayObject(0,NPCArray,Index);
TheNPCDef := SmartGetFieldObject(TheNPC,NPCDef);
TheBytes := SmartGetFieldObject(TheNPCDef,GetNPCName+'.'+StringBytes);
Result[i].Name := StringFromBytes(TheBytes);
Result[i].TileX := (SmartGetFieldInt(0, BaseX) + (SmartGetFieldInt(TheNPC, CurrentX) shr 7));
Result[i].TileY := (SmartGetFieldInt(0, BaseY) + (SmartGetFieldInt(TheNPC, CurrentY) shr 7));
Result[i].NPCType := SmartGetFieldInt(TheNPCDef,GetNPCType);
Result[i].Height := iabs(SmartGetFieldInt(TheNPC,CharHeight));
Result[i].InFight := (SmartGetFieldInt(0,LoopCycle)<SmartGetFieldInt(TheNPC,LoopCycleStatus));
Result[i].IsMoving := (SmartGetFieldInt(TheNPC,CharMotion)>0);
if TileOnMS(Result[i].TileX, Result[i].TileY, Result[i].Height * 2 / 3) then
TileToMS(Result[i].TileX, Result[i].TileY, Result[i].Height * 2 / 3, Result[i].MSX, Result[i].MSY);
SmartFreeObject(TheNPC);
SmartFreeObject(TheNPCDef);
SmartFreeObject(TheBytes);
end;
end;

function GetNPCsByName(name:string):array of TNPC;
{*******************************************************************
Function GetNPCsByName(name:string):array of TNPC;
By: Widget
Description: Returns NPCs matching the name.
********************************************************************}
var
i: integer;
NPCs: array of TNPC;
begin
NPCs := GetNPCs;
if (GetArrayLength(NPCs)=0) then Exit;
for i := 0 to High(NPCs) do
if (pos(trim(name),trim(NPCs[i].Name))>0) then
begin
SetArrayLength(result,GetArrayLength(result)+1);
result[GetArrayLength(result)-1] := NPCs[i];
end;
end;

function GetNPCsByID(TheType:integer):array of TNPC;
{*******************************************************************
Function GetNPCsByID(TheType:integer):array of TNPC;
By: Widget
Description: Returns NPCs matching the ID.
********************************************************************}
var
i: integer;
NPCs: array of TNPC;
begin
NPCs := GetNPCs;
if (GetArrayLength(NPCs)=0) then Exit;
for i := 0 to High(NPCs) do
if (NPCs[i].NPCType=TheType) then
begin
SetArrayLength(result,GetArrayLength(result)+1);
result[GetArrayLength(result)-1] := NPCs[i];
end;
end;

function SortNPCs(NPCs:array of TNPC):array of TNPC;
{*******************************************************************
Function SortNPCs(NPCs:array of TNPC):array of TNPC;
By: Widget
Description: Sorts NPCs by distance from you.
********************************************************************}
var
i,i2,ix,iy: integer;
tpa: TPointArray;
begin
SetArrayLength(TPA,GetArrayLength(NPCs));
SetArrayLength(Result,GetArrayLength(NPCs));
for i := 0 to high(NPCs) do
TPA[i] := Point(NPCs[i].TileX, NPCs[i].TileY);
GetMyPos(ix, iy);
SortTPAFrom(TPA, Point(ix, iy));
for i := 0 to high(TPA) do
for i2 := 0 to high(NPCs) do // they really should be the same
if (TPA[i].x=NPCs[i2].TileX) and (TPA[i].y=NPCs[i2].TileY) then
Result[i] := NPCs[i2];
end;

Function FindNPC(Name: string; var NPC: TNPC):boolean;
{*******************************************************************
function FindNPC(Name: string; var x,y:integer):boolean;
By: Widget
Description: Finds the tile of the named NPC and puts it in the NPC var.
Returns true if found, false if not. (Try checking for tiles if
it's not on the mainscreen.)
********************************************************************}
var
NPCs: array of TNPC;
begin
NPCs := SortNPCs(GetNPCsByName(Name));
result := GetArrayLength(NPCs)<>0;
if not result then
Exit;
NPC := NPCs[0];
end;

Function FindNPCByID(ID: integer; var NPC: TNPC):boolean;
{*******************************************************************
function FindNPC(Name: string; var x,y:integer):boolean;
By: Widget
Description: Finds the tile of the named NPC and puts it in the NPC var.
Returns true if found, false if not. (Try checking for tiles if
it's not on the mainscreen.)
********************************************************************}
var
NPCs: array of TNPC;
begin
NPCs := SortNPCs(GetNPCsByID(ID));
result := GetArrayLength(NPCs)<>0;
if not result then
Exit;
NPC := NPCs[0];
end;

Function ClickTile(TileX, TileY, Height : Integer; Left : Boolean) : Boolean;
{*******************************************************************
Function ClickTile(TileX, TileY, Height : Integer; Left : Boolean) : Boolean;
By: ss23 and Widget
Description: Clicks a tile. Height is the approximate heigh in pixels
Height doesnt matter if HighestAngle;
********************************************************************}
Var
x, y : Integer;
Begin
TileToMS(TileX, TileY, Height, x, y);
result := TileOnMs(x,y,height);
if not result then
Exit;
Mouse(x, y, 5, 5, False);
end;

Function WalkToTile(TileX, TileY : Integer): Boolean;
{*******************************************************************
Function - WalkToTile(TileX, TileY : Integer): Boolean;
By: ss23 and Widget
Description: Walks to the tile using minimap.
********************************************************************}
Var
x, y : Integer;
Begin
TileToMinimap(Tilex, Tiley, x, y);
if not TileOnMM(TileX, TileY) then
begin
Writeln('Tile off minimap');
Result := False;
Exit;
end;
Mouse(x, y, 3, 3, True);
Result := True;
end;

Function WalkToTileTol(TileX, TileY, Tol : Integer): Boolean;
{*******************************************************************
Function - WalkToTileTol(TileX, TileY, Tol : Integer): Boolean;
By: ss23 and Widget and TheGuyWhoGotOn
Description: Walks to the tile using minimap and tolerance.
********************************************************************}
Var
x, y : Integer;
Begin
TileToMinimap(Tilex, Tiley, x, y);
if not TileOnMM(TileX, TileY) then
begin
Writeln('Tile off minimap');
Result := False;
Exit;
end;
Mouse(x, y, Tol, Tol, True);
Result := True;
end;

function AlmostThere: boolean;
{*******************************************************************
Function - AlmostThere: boolean;
By: TheGuyWhoGotOn
Description: True if you are almost at your destination
********************************************************************}
var TX, TY, MX, MY: integer;
begin
GetMyPos(TX, TY);
if not(GetFlag(MX, MY)) then
begin
MX := TX;
MY := TY;
end;
Result := (TX > MX - 6)and(TX < MX + 6)and(TY > MY - 6)and(TY < MY + 6);
end;

function LongWalkEx(TileX, TileY, DisX, DisY, Tol : integer): boolean;
{*******************************************************************
Function - LongWalkEx(TileX, TileY, DisX, DisY, Tol : Integer): Boolean;
By: TheGuyWhoGotOn
Description: Walks to a far tile using the minimap and tolerance.
DisX/DisY is how many tiles it will move at a time.
********************************************************************}
var TX, TY, DX, DY : integer;
begin
repeat
GetMyPos(TX, TY);
if ((DX) > (TileX - DisX)) and ((DX) < (TileX + DisX)) then else
if TileX > TX then DX := TX + DisX
else DX := TX - DisX;
if ((DY) > (-TileY - DisY)) and ((DY) < (TileY + DisY)) then else
if TileY > TY then DY := TY + DisY
else DY := TY - DisY;
WalkToTileTol(DX, DY, Tol);
repeat
Wait(1000 + Random(500));
until (Flag) or (not(CharacterMoving));
until (TileOnMM(TileX, TileY)) or (not(TileOnMM(DX, DY)));
Result := WalkToTileTol(TileX, TileY, Tol);
end;

function LongWalk(TileX, TileY, Tol : integer): boolean;
{*******************************************************************
Function - LongWalk(TileX, TileY, Tol : Integer): Boolean;
By: TheGuyWhoGotOn
Description: Walks to a far tile using the minimap and tolerance.
********************************************************************}
begin
Result := LongWalkEx(TileX, TileY, 11, 11, Tol);
end;

function PathWalk(Path : array of TPoint; Long : boolean; Tol : integer): Boolean;
{*******************************************************************
Function - PathWalk(Path : array of TPoint; Long : boolean; Tol : integer): Boolean;
By: TheGuyWhoGotOn
Description: Walks a path for you with LongWalk options.
********************************************************************}
var Count : integer;
begin
Count := 0;
repeat
if Long then Result := LongWalk(Path[Count].x, Path[Count].y, Tol)
else Result := WalkToTileTol(Path[Count].x, Path[Count].y, Tol);
repeat
Wait(1000 + Random(500));
until (Flag) or (not(CharacterMoving));
if not(Result) then
begin
WriteLn('Path walk failed');
Exit;
end;
Count := Count + 1;
until (not(Result)) or (Count = GetArrayLength(Path))
end;

procedure MMtoMS(MMX,MMY:integer; var MSX,MSY:integer);
{*******************************************************************
Function MMtoMS(x, y: Integer; left: Boolean): Boolean;
By: LeeLokHin
Description: Converts Coordinates x and y on the minimap
to equivilants on the MainScreen and clicks right or left according
to boolean left.
********************************************************************}
var
tx,ty:integer;
begin
MinimapToTile(MMX, MMY, tx, ty);
TileToMS(tx, ty, 5, MSX, MSY);
end;

Function OpenBankReflection(Bank : String): Boolean;
{*******************************************************************
Function OpenBankReflection(Bank : String): Boolean;
By: ss23 and TheGuyWhoGotOn
Description: Opens the bank. Opens nearest slot
********************************************************************}
Var
x, y : Integer;
Me : TPoint;
Tiles : TPointArray;
Begin
Case Bank of
'veb': Tiles := [Point(3251,3419), Point(3252,3419), Point(3253,3419),
Point(3254,3419), Point(3255,3419), Point(3256,3419)];
'vwb': Tiles := [Point(3190,3435), Point(3190,3437), Point(3190,3439),
Point(3190,3441), Point(3190,3443), Point(3181,3444), Point(3181,3442),
Point(3181,3440), Point(3181,3438), Point(3181,3436)];
'fwb': Tiles := [Point(2945,3367), Point(2946,3367), Point(2947,3367),
Point(2948,3367)];
'feb': Tiles := [Point(3010,3354), Point(3011,3354), Point(3012,3354),
Point(3013,3354), Point(3014,3354), Point(3015,3354)];
'lum': Tiles := [Point(3208,3221)];
'dra': Tiles := [Point(3091,3419), Point(3091,3245), Point(3091,3244),
Point(3091,3243), Point(3091,3242)];
'alk': Tiles := [Point(3268,3168), Point(3268,3167), Point(3268,3166),
Point(3268,3165), Point(3268,3164)];
end;
GetMyPos(Me.x, Me.y);
SortTPAFrom(Tiles, Me);
If (DistanceFrom(Tiles[0].x, Tiles[0].y) > 3) then
Begin
If not(TileOnMM(Tiles[0].x, Tiles[0].y)) then
Begin
Writeln('Couldn''t find bank');
Result := False;
Exit;
end;
WalkToTile(Tiles[0].x, Tiles[0].y);
repeat
Wait(1000 + Random(500));
until (Flag) or (not(CharacterMoving));
Wait(100 + Random(100));
end;
If not(TileOnMS(Tiles[0].x, Tiles[0].y, 15)) then
Begin
SetAngle(True);
MakeCompass('n');
If not(TileOnMS(Tiles[0].x, Tiles[0].y, 20)) then
Begin
Writeln('Couldnt'' find bank booth');
Result := False;
Exit;
end;
end;
TileToMS(Tiles[0].x, Tiles[0].y, 20, x, y);
Mouse(x, y, 5, 5, False);
Wait(100 + Random(100));
Result := ChooseOption('e-q');
end;

function GetPlayers: array of TPlayer;
{*******************************************************************
function - GetPlayers: array of TPlayer;
By: Widget
Description: Returns all the players on the minimap
--- DOESN'T WORK YET ---
********************************************************************}
//var
// i, IndexPos, Count, Player, Name: integer;

begin
result := result; // stops a Variable 'Result' never used thing
{ Count := SmartGetFieldInt(0, PlayerCount);
writeln('Number of players: '+inttostr(Count));
SetArrayLength(result, Count);
for i := 0 to (count-1) do
begin
IndexPos := SmartGetFieldArrayInt(0, PlayerIndArray, i);
writeln('Index position: '+inttostr(count));
Player := SmartGetFieldArrayObject(0, PlayerArray, IndexPos);
writeln('Player placement: '+inttostr(Player));
Name := SmartGetFieldObject(Player, CharName);
writeln(inttostr(name));
writeln(StringFromBytes(Name));
Result[indexpos].Name := StringFromBytes(Name);
SmartFreeObject(Name);
Writeln(Result[indexpos].Name);
end; }
end;

function GetPlayer(name: string): TPlayer;
{*******************************************************************
function - GetPlayer(name: string): TPlayer;
By: Widget
Description: Gets available stats for a player (Levels only work on you).
--- DOESN'T WORK YET ---
********************************************************************}
begin
result := result; // stops a Variable 'Result' never used thing
end;

Nice work though…M4st3rK1ll your idea is awesome actually we just need a server that key people can upload the new hooks. I added a new hook with to version I just posted.

Waddo, your reflection compass mover looks like a lot of unneeded work for the reason that compass finding and moving works fine without reflection. It can't be much better and failsafes for regular compass finding/moving would be used anyways.

As for your GetNPCInfo Widget already posted a script similar to that it just looks prettier. But it's not up to me we'll see what Widget says, that's just my opinion.

Waddo

2008-07-25 14:42:04

The GetNPCInfo is useful for finding the ID's of NPC's and therefore could be useful in creating hook updaters and for testing and the makecompassreflection was long but was good just because it is long doesnt mean it is bad. And the makecompass is less reliable and can sometimes be far enough out to actually make a script fail.

TheGuyWhoGotOn

2008-07-25 14:47:00

From: Waddo
The GetNPCInfo is useful for finding the ID's of NPC's and therefore could be useful in creating hook updaters and for testing and the makecompassreflection was long but was good just because it is long doesnt mean it is bad. And the makecompass is less reliable and can sometimes be far enough out to actually make a script fail.


Ok, points taken then. I'm just saying Widget also has pretty much the same thing and why restrict it to NPCs then? Why not everything?

Here is my latest version of the reflection tester (Prettier now too)


program New;
{.include SRL/SRL/Misc/SMART.scar}
{.include SRL/SRL.scar}
{.include SRL/SRL/Misc/Reflection.scar}

var TX, TY, Count : integer;
NPCs : array of TNPC;

begin
ActivateClient;
SmartSetup('world157', True, True, False);
SetTargetDC(SMARTGetDC);
repeat
WriteLn('Running with user: ' + GetMyName);
GetMyPos(TX, TY);
WriteLn('Who is at: ' + IntToStr(TX) + ', ' + IntToStr(TY));
if GetFlag(TX, TY) then
WriteLn('Who is going to: ' + IntToStr(TX) + ', ' + IntToStr(TY));
WriteLn('Who is level: ' + IntToStr(GetCombat));
NPCs := SortNPCs(GetNPCs);
Count := 0;
if GetArrayLength(NPCs) = 0 then WriteLn('Failed To Find NPC')
else begin
WriteLn('Name Tile MS ID');
repeat
WriteLn(Padr(NPCs[Count].Name, 14) + ' ' + IntToStr(NPCs[Count].TileX) + ', ' +
IntToStr(NPCs[0].TileY) + ' ' + Padr(IntToStr(NPCs[Count].MSX), 3) +
', ' + Padr(IntToStr(NPCs[Count].MSY), 3) + ' '
+ IntToStr(NPCs[Count].NPCType));
Count := Count + 1
until(Count = GetArrayLength(NPCs));
end;
Wait(500);
ClearDebug;
until(false);
end.

Waddo

2008-07-25 14:50:04

We don't have the ability to find objects and that yet do we I thought n3ss3s is still working on it.

TheGuyWhoGotOn

2008-07-25 14:57:44

From: Waddo
We don't have the ability to find objects and that yet do we I thought n3ss3s is still working on it.


Give them time lol, I'm not exactly sure how to do it so we have to wait :P.

http://www.villavu.com/forum/showthread.php?t=33033?p=435949#post435949

Widget

2008-07-25 15:01:41

Ok, this is getting ridiculously messy.

I now propose splitting this file up into several files:
- Reflection.scar
- ReflectionMap.scar
- ReflectionWalking.scar
- ReflectionNPCs.scar
- ReflectionObjects.scar

Does that sound good to anyone else?

*starts working on merging everything that's been written since i fell asleep >.<*

Shuttleu

2008-07-25 15:11:56

ermmm… could someone please explain what this reflection stuff is about please?

~shut

TheGuyWhoGotOn

2008-07-25 15:27:35

Try reading the first post. If you look a few posts above yours I posted a good reflection tester. Widget has one too on the topic post but I like mine better ^_^.

Widget

2008-07-25 15:30:53

Yours didn't use PadR at first :p

Oh, and if we're updating from the web we could use this:
function ReflectionWorks: boolean;
begin
Result := Players[CurrentPlayer].Name = GetMyName;
end;

TheGuyWhoGotOn

2008-07-25 16:03:23

From: Widget
Yours didn't use PadR at first :p

Oh, and if we're updating from the web we could use this:
function ReflectionWorks: boolean;
begin
Result := Players[CurrentPlayer].Name = GetMyName;
end;


Isn't there a way to check the name of the current logged in user with SRL?

Waddo

2008-07-25 16:22:37

Hmm I don't know there is getlastchatter so we would only have to change the co-ord's a bit for that

Widget

2008-07-25 19:10:56

From: TheGuyWhoGotOn
Isn't there a way to check the name of the current logged in user with SRL?

That's the point ;)

If getting our name via reflection matches what SRL says the current loggin in player is, then we know reflection isn't broken

Smartzkid

2008-07-25 19:53:18

Suggestion.

Make a new directory (ohmy!) called reflection and stuff it with everything you need. Thats a bit easier than appending like 20 includes with 'Reflection-'.

Also, if you must - make an include with all the debug stuff like GetNPCInfo. Actually, IMO that doesn't belong at all, because if people need to debug, they can write their own debugs. Sorry to burst your bubble, Waddo, but GetNPCInfo really wouldn't help with updating hooks.

Waddo

2008-07-25 21:07:39

=[ well i found it usefull for finding the ID of the dwarf with the mining skillcape

MasterKill

2008-07-26 02:38:19

From: TheGuyWhoGotOn
Nice work though…M4st3rK1ll your idea is awesome actually we just need a server that key people can upload the new hooks. I added a new hook with to version I just posted.


Ok man, thanks, cool I helped a bit. Also if you want to I can make you a script witch creates the txt file for you, so that would be easer and faster if you want to. I'll send you my msn :)

n3ss3s

2008-07-26 05:22:31

Here Widget -


Function TileOnMM(TileX, TileY: Integer): Boolean;

Var
X, Y: Integer;
Begin
TileToMM(TileX, TileY, X, Y);
Result := InCircle(X, Y, MMCX, MMCY, 73);
End;

Widget

2008-07-26 05:35:10

Oh wow, I didn't even realize there was an InCircle >.<

But anyway, I'm splitting this into 5 files
- Reflection.scar: core stuff, conversion functions
- Walking.scar: tiles, paths, etc
- Characters.scar: NPCs, Players
- Objects.scar: if n3ss3s ever finishes them ;)
- Hooks.scar: web updating and "does it work?" stuff

Waddo

2008-07-26 07:15:06

Ok im gunna make a reflection aid like yaks radial walk id but its going to show you npc info when you mouse over =]

the scar noob

2008-07-26 07:31:45

@Widget: What are your results with the song "Free Bird"from Lynyrd Skynyrd?

-Tsn.

TheGuyWhoGotOn

2008-07-26 10:03:36

From: n3ss3s
Here Widget -


Function TileOnMM(TileX, TileY: Integer): Boolean;

Var
X, Y: Integer;
Begin
TileToMM(TileX, TileY, X, Y);
Result := InCircle(X, Y, MMCX, MMCY, 73);
End;


Thank you so much…Damn square kept getting the answer wrong.

Also Widget I'll start converting the things to multiple files and we'll see who gets done first (Damn I have to go to work soon).

ZephyrsFury

2008-07-26 10:19:28

The minimap is has a radius of 76 pixels not 73 :)

TheGuyWhoGotOn

2008-07-26 10:34:30

Done putting it into separate files…It works but I have to Modify N3ss3s' thing because TileToMM doesn't exist *tsk, tsk, tsk*.

(Attached)

Test it with this:


program New;
{.include SRL/SRL/Misc/SMART.scar}
{.include SRL/SRL.scar}
{.include SRL/SRL/Misc/Reflection/Reflection.scar}
{.include SRL/SRL/Misc/Reflection/Walking.scar}
{.include SRL/SRL/Misc/Reflection/Characters.scar}

var TX, TY, Count : integer;
NPCs : array of TNPC;

begin
ActivateClient;
SmartSetup('world157', True, True, False);
SetTargetDC(SMARTGetDC);
repeat
WriteLn('Running with user: ' + GetMyName);
GetMyPos(TX, TY);
WriteLn('Who is at: ' + IntToStr(TX) + ', ' + IntToStr(TY));
if GetFlag(TX, TY) then
WriteLn('Who is going to: ' + IntToStr(TX) + ', ' + IntToStr(TY));
WriteLn('Who is level: ' + IntToStr(GetCombat));
NPCs := SortNPCs(GetNPCs);
Count := 0;
if GetArrayLength(NPCs) = 0 then WriteLn('Failed To Find NPC')
else begin
WriteLn('Name Tile MS ID');
repeat
WriteLn(Padr(NPCs[Count].Name, 14) + ' ' + IntToStr(NPCs[Count].TileX) + ', ' +
IntToStr(NPCs[0].TileY) + ' ' + Padr(IntToStr(NPCs[Count].MSX), 3) +
', ' + Padr(IntToStr(NPCs[Count].MSY), 3) + ' '
+ IntToStr(NPCs[Count].NPCType));
Count := Count + 1
until(Count = GetArrayLength(NPCs));
end;
Wait(500);
ClearDebug;
until(false);
end.

Timer

2008-07-26 10:38:40

From: TheGuyWhoGotOn
Done putting it into separate files…It works but I have to Modify N3ss3s' thing because TileToMM doesn't exist *tsk, tsk, tsk*.

(Attached)

Test it with this:


program New;
{.include SRL/SRL/Misc/SMART.scar}
{.include SRL/SRL.scar}
{.include SRL/SRL/Misc/Reflection/Reflection.scar}
{.include SRL/SRL/Misc/Reflection/Walking.scar}
{.include SRL/SRL/Misc/Reflection/Characters.scar}

var TX, TY, Count : integer;
NPCs : array of TNPC;

begin
ActivateClient;
SmartSetup('world157', True, True, False);
SetTargetDC(SMARTGetDC);
repeat
WriteLn('Running with user: ' + GetMyName);
GetMyPos(TX, TY);
WriteLn('Who is at: ' + IntToStr(TX) + ', ' + IntToStr(TY));
if GetFlag(TX, TY) then
WriteLn('Who is going to: ' + IntToStr(TX) + ', ' + IntToStr(TY));
WriteLn('Who is level: ' + IntToStr(GetCombat));
NPCs := SortNPCs(GetNPCs);
Count := 0;
if GetArrayLength(NPCs) = 0 then WriteLn('Failed To Find NPC')
else begin
WriteLn('Name Tile MS ID');
repeat
WriteLn(Padr(NPCs[Count].Name, 14) + ' ' + IntToStr(NPCs[Count].TileX) + ', ' +
IntToStr(NPCs[0].TileY) + ' ' + Padr(IntToStr(NPCs[Count].MSX), 3) +
', ' + Padr(IntToStr(NPCs[Count].MSY), 3) + ' '
+ IntToStr(NPCs[Count].NPCType));
Count := Count + 1
until(Count = GetArrayLength(NPCs));
end;
Wait(500);
ClearDebug;
until(false);
end.


Hehe, I already separated all the files, me a widget did it last night, its all already covered… ;)

MasterKill

2008-07-26 10:40:38

So it now seems that SetupReflection will be used;

I've written this script to make the taking care of the hooks.txt file hell of a lot easy'r.

It's fast written so idk how good it is, but it works! :D

program HooksTxt_care_taker_by_MasterKill;
var
frmDesign : TForm;
Button : Array [0..4] Of TButton;
Sticker: Array [0..8] Of TLabel;
Edit : TEdit;
Hook, WhatHooks: Array Of String;
CurrentlyAt: Integer;

Const // where to read the txt file from?
FileStored = 'http://www.freewebs.com/srlfiles/hooks.txt';

Procedure SetupWhatHooksArray;
Begin

// these are all hooks you currently have, if you want to add one make it the last one.

WhatHooks := [
'BaseLayer',
'BaseX',
'BaseY',
'CamX',
'CamY',
'CamZ',
'CamPitch',
'CamYaw',
'CompassAngle',
'CurrentLevels',
'Experiences',
'FlagX',
'FlagY',
'GroundHeights',
'GroundSettings',
'LoopCycle',
'MapOffsetAngle',
'MaxLevels',
'MyPlayer',
'NPCArray',
'NPCCount',
'NPCIndexArray',
'PlayerArray',
'PlayerCount',
'PlayerIndArray',
'SettingsArray',
'CharAnim',
'CharMotion',
'CurrentX',
'CurrentY',
'CharHeight',
'LoopCycleStatus',
'CharName',
'NPCDef',
'GetNPCName',
'GetNPCType',
'StringBytes'
// add new hook variables here!
];
End;










function Explode(Delimiter : string; Str : string) : array of string;
var
DelimPos, i : integer;
Arr1 : array of string;
begin
SetArrayLength(Arr1, 100000);
i := 0;
repeat
if (pos(Delimiter, Str) = 0) then Break;
DelimPos := pos(Delimiter, Str);
Arr1[i] := Replace((copy(Str,0,DelimPos)),Delimiter,'');
Delete(Str,1,DelimPos);
i := i + 1;
until(pos(Delimiter, Str) = 0);
Arr1[i] := Str;
SetArrayLength(Arr1, i+1);
Result := Arr1;
end;

Procedure ClearOne;
Var
MK: Integer;
Begin
For MK := 0 To 4 Do
Sticker[MK].Caption := '';
End;

Procedure ClearTwo;
Var
MK: Integer;
Begin
For MK := 5 To 8 Do
Sticker[MK].Caption := '';
End;

Procedure DoNextPrev(Command: String);
Var
MK, I: Integer;
begin
Try
Hook[CurrentlyAt] := Edit.Text;
Except
Status('load hooks plz');
End;
ClearOne;
ClearTwo;
Case Command Of
'+': CurrentlyAt := CurrentlyAt + 1;
'-': CurrentlyAt := CurrentlyAt - 1;
End;
If (CurrentlyAt = High(WhatHooks)) Then
Button[0].Enabled := False
Else
Button[0].Enabled := True;
If (CurrentlyAt = 0) Then
Button[1].Enabled := False
Else
Button[1].Enabled := True;
If ((CurrentlyAt - 1) > 0) Then
Begin
Sticker[0].Caption := WhatHooks[CurrentlyAt - 2];
Sticker[5].Caption := Hook[CurrentlyAt - 2];
End Else
Begin
Sticker[0].Caption := '';
Sticker[5].Caption := '';
End;
If ((CurrentlyAt) > 0) Then
Begin
Sticker[1].Caption := WhatHooks[CurrentlyAt - 1];
Sticker[6].Caption := Hook[CurrentlyAt - 1];
End Else
Begin
Sticker[1].Caption := '';
Sticker[6].Caption := '';
End;
Sticker[2].Caption := WhatHooks[CurrentlyAt];
Edit.Text := Hook[CurrentlyAt];
If ((CurrentlyAt + 1) < High(WhatHooks) + 1) Then
Begin
Sticker[3].Caption := WhatHooks[CurrentlyAt + 1];
Sticker[7].Caption := Hook[CurrentlyAt + 1];
End Else
Begin
Sticker[3].Caption := '';
Sticker[7].Caption := '';
End;
If ((CurrentlyAt + 2) < High(WhatHooks) + 1) Then
Begin
Sticker[4].Caption := WhatHooks[CurrentlyAt + 2];
Sticker[8].Caption := Hook[CurrentlyAt + 2];
End Else
Begin
Sticker[4].Caption := '';
Sticker[8].Caption := '';
End;
End;

Procedure GetNext(sender: TObject);
begin
DoNextPrev('+');
End;

Procedure GetPrev(sender: TObject);
begin
DoNextPrev('-');
End;

Procedure LoadHooks(sender: TObject);
Var
HooksPage: String;
begin
Edit.Top := 57;
HooksPage := GetPage(FileStored);
Hook := Explode(',', HooksPage);
SetArrayLength(Hook, 100000);
CurrentlyAt := 0;
ClearOne;
Sticker[2].Caption := WhatHooks[0];
Sticker[3].Caption := WhatHooks[1];
Sticker[4].Caption := WhatHooks[2];
Edit.Text := Hook[0];
Sticker[7].Caption := Hook[1];
Sticker[8].Caption := Hook[2];
Button[0].Enabled := True;
Button[1].Enabled := False;
End;

Procedure AddHook(sender: TObject);
begin
Edit.Top := 57;
End;

Procedure WriteAndSave(sender: TObject);
Var
SaveFileCreate: TStringList;
MK: Integer;
StringLine: String;
Begin
Hook[CurrentlyAt] := Edit.Text;
For MK := 0 To High(WhatHooks) Do
If (hook[MK] = '') Then
Begin
ShowMessage('[Warning] ' + WhatHooks[MK] + ' is empty!');
Exit;
End;
SaveFileCreate := TStringList.Create;
For MK := 0 To High(WhatHooks) Do
StringLine := StringLine + Hook[MK] + ',';
StringLine := StringLine + 'EndOfHooks'];
SaveFileCreate.Add(StringLine);
SaveToFile(SaveFileCreate, AppPath + 'HookFile\hooks.txt');
WriteLn('new hooks.txt is saved to: ' + AppPath + 'HookFile\hooks.txt');
frmDesign.ModalResult:= mrOk;
End;

procedure InitForm;
Var
MK: Integer;
begin
frmDesign := CreateForm;
frmDesign.Left := 100;
frmDesign.Top := 100;
frmDesign.Width := 230;
frmDesign.Height := 230;
frmDesign.Caption := 'Reflection hook.txt setup''r by MasterKill';
frmDesign.Color := clBtnFace;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := False;
frmDesign.PixelsPerInch := 96;
For MK := 0 To 4 Do
Begin
Button[MK] := Tbutton.Create(FrmDesign);
Button[MK].Parent := FrmDesign;
Button[MK].Width := 100;
Button[MK].Height := 20;
Case MK of
0: Begin
Button[MK].Left := 10;
Button[MK].Top := 130;
End;
1: Begin
Button[MK].Top := 130;
Button[MK].Left := 110;
End;
2: Begin
Button[MK].Left := 10;
Button[MK].Top := 150;
End;
3: Begin
Button[MK].Top := 150;
Button[MK].Left := 110;
End;
4: Begin
Button[MK].Left := 10;
Button[MK].Top := 170;
Button[MK].Width := 200;
End;
End;
End;
Button[0].Caption := 'Next';
Button[1].Caption := 'Previous';
Button[2].Caption := 'Load from web';
Button[3].Caption := 'Add new hook';
Button[4].Caption := 'WriteLn New Files + save hook.txt';
Button[0].Onclick := @GetNext;
Button[1].Onclick := @GetPrev;
Button[2].Onclick := @LoadHooks;
Button[3].Onclick := @AddHook;
Button[4].Onclick := @WriteAndSave;
Button[0].Enabled := False;
Button[1].Enabled := False;
Button[3].Enabled := False;
For MK := 0 To 8 Do
Begin
Sticker[MK] := TLabel.Create(FrmDesign);
Sticker[MK].Parent := FrmDesign;
Case MK Of
0, 1, 2, 3, 4:
Begin
Sticker[MK].Left := 10;
Sticker[MK].Top := 20 + 20 * MK;
End;
5, 6, 7, 8:
Begin
Sticker[MK].Left := 100;
Case MK Of
5, 6: Sticker[MK].Top := 20 + (MK - 5) * 20;
7, 8: Sticker[MK].Top := 40 + (MK - 5) * 20;
End;
End;
End;
End;
Edit := TEdit.Create(FrmDesign);
Edit.Parent := FrmDesign;
Edit.Left := 100;
Edit.Height := 20;
Edit.Width := 100;
Edit.Top := 57;
CurrentlyAt := 1;
DoNextPrev('-');
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmDesign.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
ClearDeBug;
SetupWhatHooksArray;
SetArrayLength(Hook, 100000);
SafeInitForm;
SafeShowFormModal;
end.

TheGuyWhoGotOn

2008-07-26 10:55:06

From: Timer
Hehe, I already separated all the files, me a widget did it last night, its all already covered… ;)


:( Mind sending it to me? All my work for nothing :'(…

Smartzkid

2008-07-26 14:56:57

From: Waddo
Ok im gunna make a reflection aid like yaks radial walk id but its going to show you npc info when you mouse over =]


Sorry to burst your bubble again :eek:


Check out RSBot. It gives you all the debug info you could ever want.


HyperSecret

2008-07-26 15:05:46

From: Waddo
Ok im gunna make a reflection aid like yaks radial walk id but its going to show you npc info when you mouse over =]


You should be able to graphicly (sp?) draw on the SMART client like RSBot does.

BenLand100

2008-07-26 15:11:12

From: Widget
Agh people keep posting so much XD

I made some fast video tutorials although they might not make sense, the best way to learn is to read through the include itself ;)
- http://www.youtube.com/watch?v=kTFqJgy9kZk
- http://www.youtube.com/watch?v=qc_X_o1REMM
(You can also look at my profile in case you want to watch random Guitar Hero vids ;))

Anyway, now I need to update the first post again and merge a bamillion random things >.<


I am going to make a transcript of your video when I get a chance and correct your mistakes :P I love watching people make up explanations for things, and say obfuscate :P Biggest info slip I noticed: RSBot does NOT use reflection, it edits the client. It is a bytecode based bot, SMART would be considered a reflection based bot. Note that the term "reflection" was first used by me due to the java package java.lang.reflect which contains the classes I employ to mess with the client without messing with it. :) If a bot does not use the package java.lang.reflect, it cannot be considered a reflection bot. imo.

Three types of bot:
Regex: (not the name of the creator, but of regular expressions) Aryan was an example. Decompiles the client, edits the SOURCE code and recompiles the client.
Bytecode: Uses a bytecode library (BCEL mostly) to modify the original classes directly, no actual decompiling done. (RSBot, ARGA, ARES, etc.)
Reflection: Uses an unmodified client and accesses data via the java.lang.reflect classes. (KYAB,SMART)

n3ss3s

2008-07-26 16:14:35

You should be able to graphicly (sp?) draw on the SMART client like RSBot does.


Yea you should, but you can't wipe the SMART debug canvas clear because Ben didn't make a function for that in SMART when I suggested it :(

Widget

2008-07-26 17:26:18

From: BenLand100
I am going to make a transcript of your video when I get a chance and correct your mistakes :P I love watching people make up explanations for things, and say obfuscate :P Biggest info slip I noticed: RSBot does NOT use reflection, it edits the client. It is a bytecode based bot, SMART would be considered a reflection based bot. Note that the term "reflection" was first used by me due to the java package java.lang.reflect which contains the classes I employ to mess with the client without messing with it. :) If a bot does not use the package java.lang.reflect, it cannot be considered a reflection bot. imo.

Three types of bot:
Regex: (not the name of the creator, but of regular expressions) Aryan was an example. Decompiles the client, edits the SOURCE code and recompiles the client.
Bytecode: Uses a bytecode library (BCEL mostly) to modify the original classes directly, no actual decompiling done. (RSBot, ARGA, ARES, etc.)
Reflection: Uses an unmodified client and accesses data via the java.lang.reflect classes. (KYAB,SMART)


Sorry Ben, I did make that in a big hurry and I'll put a note on the side of the video.

Also, drawing on SMART's debug canvas only works when SMART is enabled, any chance you could make it work when disabled, or is it being the barrier between the client and our mice now?

*Sigh again* Will update the main post soon. I'm surprised we actually have this much stuff to put in it.

P1nky

2008-07-26 18:25:25

Good Vid TUT!

Waddo

2008-07-26 21:41:59

yes im going to try that making an invisible canvas with drawings on

Smartzkid

2008-07-26 23:12:40

Sidenote: Take a look at your CPU usage with debugs enabled for smart.

HyperSecret

2008-07-26 23:59:12

From: Smartzkid
Sidenote: Take a look at your CPU usage with debugs enabled for smart.


yep, takes up alot ;)

Ruroken

2008-07-27 02:03:11

Make SMART have RSBot interface abilities and I will love you forever.

the scar noob

2008-07-27 05:06:14

From: Ruroken
Make SMART have RSBot interface abilities and I will love you forever.


Why should he? RSBot is RSBot and SMART is SMART..!

-Tsn.

n3ss3s

2008-07-27 05:23:34

He means interface capabilities as good as RSBot's.

the scar noob

2008-07-27 11:55:07

From: Smartzkid
Sorry to burst your bubble again :eek:


Check out RSBot. It gives you all the debug info you could ever want.



Same ID's from 4+ years ago?
I rememer ID 995 for coins from the time of duping at RS1:p

-Tsn.

Method

2008-07-27 12:25:42

From: the scar noob
Same ID's from 4+ years ago?
I rememer ID 995 for coins from the time of duping at RS1:p

-Tsn.


Changing the IDs of items, NPCs, etc. would be far too much work and I'm sure the Jagex developers would be quite confused trying to remember what's what. Leaving them the same on the assumption that most player's don't have Java knowledge (and also that it doesn't really matter if they know the ID) is much easier.

the scar noob

2008-07-27 15:52:54

It just doesn't work, a simple as that :s

-Tsn.

Widget

2008-07-27 20:36:52

From: the scar noob
@Widget: What are your results with the song "Free Bird"from Lynyrd Skynyrd?

-Tsn.


http://www.youtube.com/watch?v=tvpAXbpy-2E

About half done with player functions :)

rkroxpunk

2008-07-28 03:35:28

lul remind anyone else of KYAB? Only difference I can see is this one doesn't have a bunch of retard admins calling it the devils work.

Widget

2008-07-28 04:13:46

And there's no Solarwind, and this one's being developed by us and it'll be SCAR-side as opposed to being maintained by the Devs, so they can be as lazy as they damn well please :)

From: Ruroken
Make SMART have RSBot interface abilities and I will love you forever.
I might try tackling that once I finish up Player stuff and putting functions where they're supposed to be (because SOMEONE didn't check to even see if it compiles…)

Waddo

2008-07-28 07:35:28

SMART screen debug stuff thing
program ReflectionAid;
{.include SRL/SRL/Misc/Smart.scar}
{.include srl/srl.scar}
{.include srl/srl/misc/reflection.scar}

var
Blank : integer;
OurForm : TForm;
i :integer;
NPCs: array of TNPC;
Label1 : TLabel;
Label2 : TLabel;
Label3 : TLabel;
Label4 : TLabel;
Label5 : TLabel;
DefInfo : array [0..3] of string;
InfoUp : array [0..3] of string;

Procedure NPCInfoToArray;
{*******************************************************************
Procedure GetNPCInfo;
By: Waddo
Description: Displays the info of loaded NPC's.
********************************************************************}
begin
NPCs := GetNPCs;
end;

Procedure DrawMap(Sender: TObject);
begin
FastDrawClear(Blank,0);
CopyCanvas(GetClientCanvas,ourform.canvas,MMX1,MMY1,MMX2,MMY2,5,5,(MMX2-MMX1)+5,(MMY2-MMY1)+5);
end;

Procedure DoDefInfo;
begin
DefInfo := (['Name: ','ID: ','Tile X: ','Tile Y: ']);
label2.caption := DefInfo[0];
label3.caption := DefInfo[1];
label4.caption := DefInfo[2];
label5.caption := DefInfo[3];
end;

Procedure DoInfoUp;
begin
InfoUp := (['Name: '+NPCs[i].Name,'ID: '+inttostr(NPCs[i].NPCType),'Tile X: '+inttostr(NPCs[i].TileX),'Tile Y: '+inttostr(NPCs[i].TileY)]);
label2.caption := InfoUp[0];
label3.caption := InfoUp[1];
label4.caption := InfoUp[2];
label5.caption := InfoUp[3];
OurForm.Visible := False;
Sleep(50);
OurForm.Visible := True;

end;

Procedure ShowInfo(Sender: TObject);
var
MPX,MPY,MSX,MSY:integer;
begin
Getmousepos(MPX,MPY);
for i:=0 to high(NPCs) do
begin
wait(1);
If InRange(MPX,NPCs[i].MSX-100,NPCs[i].MSX+100) and InRange(MPY,NPCs[i].MSY-100,NPCs[i].MSY+100) then
DoInfoUp;
writeln(inttostr(i));
end;
while InRange(MPX,NPCs[i].MSX-100,NPCs[i].MSX+100) and InRange(MPY,NPCs[i].MSY-100,NPCs[i].MSY+100) do
begin
wait(1);
Getmousepos(MPX,MPY);
writeln('hi');
if iskeydown('s') then exit;
end;
DoDefInfo;
end;

procedure InitAndLoadForm;
begin
OurForm := CreateForm;
Ourform.OnClick := @showinfo;
OurForm.SetBounds(0, 0, 798,572);
OurForm.Top := 100;
OurForm.Left := 500;
OurForm.Brush.Style:= BsClear;
Label1 := TLabel.Create(OurForm);
Label1.Parent := OurForm;
Label1.Left := 168;
Label1.Top := 8;
Label1.Width := 83;
Label1.Height := 20;
Label1.Caption := 'NPC INFO';
Label1.Font.Color := clWindowText;
Label1.Font.Height := -17;
Label1.Font.Name := 'MS Sans Serif';
Label1.Font.Style := [fsBold, fsUnderline];
Label1.ParentFont := False;
Label2 := TLabel.Create(OurForm);
Label2.Parent := OurForm;
Label2.Left := 168;
Label2.Top := 40;
Label2.Width := 46;
Label2.Height := 20;
Label2.Caption := 'Name:';
Label2.Font.Color := clWindowText;
Label2.Font.Height := -16;
Label2.Font.Name := 'MS Sans Serif';
Label2.Font.Style := [];
Label2.ParentFont := False;
Label3 := TLabel.Create(OurForm);
Label3.Parent := OurForm;
Label3.Left := 168;
Label3.Top := 104;
Label3.Width := 46;
Label3.Height := 20;
Label3.Caption := 'ID:';
Label3.Font.Color := clWindowText;
Label3.Font.Height := -16;
Label3.Font.Name := 'MS Sans Serif';
Label3.Font.Style := [];
Label3.ParentFont := False;
Label4 := TLabel.Create(OurForm);
Label4.Parent := OurForm;
Label4.Left := 168;
Label4.Top := 72;
Label4.Width := 46;
Label4.Height := 20;
Label4.Caption := 'Tile X:';
Label4.Font.Color := clWindowText;
Label4.Font.Height := -16;
Label4.Font.Name := 'MS Sans Serif';
Label4.Font.Style := [];
Label4.ParentFont := False;
Label5 := TLabel.Create(OurForm);
Label5.Parent := OurForm;
Label5.Left := 168;
Label5.Top := 128;
Label5.Width := 46;
Label5.Height := 20;
Label5.Caption := 'Tile Y:';
Label5.Font.Color := clWindowText;
Label5.Font.Height := -16;
Label5.Font.Name := 'MS Sans Serif';
Label5.Font.Style := [];
Label5.ParentFont := False;
Ourform.ShowModal;
end;

procedure SafeLoadForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitAndLoadForm', v);
end;

Procedure Setup;
begin
SmartSetupEx(136, false, false, False);
SetTargetDC(SmartGetDC);
If Not (LoggedIn) Then
While Not (SmartGetColor(360, 172) = 13158) Do
Wait(100);
setupsrl;
setupreflection;
end;

begin
setup;
NPCInfoToArray;
SafeLoadForm;
writeln('hi');
FreeForm(OurForm);
end.

it doesn't work at the moment im still working on it if any one wants to help.

ZephyrsFury

2008-07-29 07:12:23

The hooks appear to have been updated. Would someone mind telling me how I would go about finding the new ones?

BobboHobbo

2008-07-29 08:38:07

I was wathcing that vid. Like wow, you sound smart. GOD im dumb compared to like everyone here :(

MylesMadness

2008-07-29 08:42:45

From: ZephyrsFury
The hooks appear to have been updated. Would someone mind telling me how I would go about finding the new ones?
Steal them from rsbot :p

edit:where did they stash them, I've looked almost everywhere in the source

the scar noob

2008-07-29 10:22:35

[Runtime Error] : Exception: Access violation at address 0050DE49 in module 'scar.exe'. Write of address 00000000 in line 388 in script C:\Program Files\SCAR 3.15\includes\SRL/SRL/Misc/Reflection.scar


The line:
SetArrayLength(Result,NumNPCs);


Reflection.scar = outdated

Btw, nice job with that song "Free Bird" Widget;)

-Tsn.

MylesMadness

2008-07-29 12:50:30

the hooks broke, rsbot hasn't updated yet to steal them

n3ss3s

2008-07-29 12:57:13

Qauters has posted them at Mopar's Client Hacking Tips section.

MasterKill

2008-07-29 13:46:49

I updated the golbal static hooks allready, I just don't know how to get the others, but TheGuyWhoGotOn is working on those :)

Global static hooks:
const
// Global Static Hooks for #506
BaseLayer = 'ui.A';
BaseX = 'id.l';
BaseY = 'jg.X';
CamX = 'pa.G';
CamY = 'na.e';
CamZ = 'ci.d';
CamPitch = 've.W';
CamYaw = 'ph.L';
CompassAngle = 'vj.h';
CurrentLevels = 'ng.L';
Experiences = 'nd.W';
FlagX = 'pe.w';
FlagY = 'fk.h';
GroundHeights = 'ld.R';
GroundSettings = 'pa.j';
LoopCycle = 'kc.a';
MapOffsetAngle = 'k.c';
MaxLevels = 've.fb';
MyPlayer = 'wf.q';
NPCArray = 'hb.k';
NPCCount = 'jk.g';
NPCIndexArray = 'bj.c';
PlayerArray = 'wh.D';
PlayerCount = 'ba.d';
PlayerIndArray = 'ef.i';
SettingsArray = 'ca.A';

n3ss3s

2008-07-29 14:16:22

Great :)

Bad thing is that most of the hooks that we need aren't in Global Static Hooks.

Something is wrong with Qauters' loc X and Y, they don't work… BaseX and Y are fine though.

MasterKill

2008-07-29 14:24:31

here you go thanks to TGWGO, at least those are the lasted hooks, but TGWGO said they don't work :s test it :o

//------------------------------------------------------------------\\
//-- Scar Non-Standard Resource Library --||
//-- » Reflection Routines - Hooks --||
//------------------------------------------------------------------//

type
TNPC = record
TileX, TileY, MSX, MSY: integer;
NPCType, height, animation: integer;
Name : string;
InFight, IsMoving: boolean;
end;
TPlayer = record
TileX, TileY, MSX, MSY:integer;
animation, speed: integer;
HPRatio, height, level: integer;
Name: string;
end;

const
// Global Static Hooks
// #506 - TGWGO (Master Kill made me)
BaseLayer = 'ui.A';
BaseX = 'id.l';
BaseY = 'jg.X';
CamX = 'pa.G';
CamY = 'na.e';
CamZ = 'ci.d';
CamPitch = 've.W';
CamYaw = 'ph.L';
CompassAngle = 'vj.h';
CurrentLevels = 'ng.L';
Experiences = 'nd.W';
FlagX = 'pe.w';
FlagY = 'fk.h';
GroundHeights = 'ld.R';
GroundSettings = 'pa.j';
LoopCycle = 'kc.a';
MapOffsetAngle = 'k.c';
MaxLevels = 've.fb';
MyPlayer = 'wf.q';
NPCArray = 'hb.k';
NPCCount = 'jk.g';
NPCIndexArray = 'bj.c';
PlayerArray = 'wh.D';
PlayerCount = 'ba.d';
PlayerIndArray = 'ef.i';
SettingsArray = 'ca.A';

// Character Hooks
CharAnim = 'ub';
CharMotion = 'ab';
CurrentX = 'G';
CurrentY = 'o';
CharHeight = 'nb';
CharHPRatio = 'qb';
LoopCycleStatus= 'a';

// Player Hooks
CharName = 'Fb';
CharLevel = 'Sb';

// NPC Hooks
NPCDef = 'Ob';

// NPCDef Hooks
GetNPCName = 'U';
GetNPCType = 'cb';

// RSString Hooks
StringBytes = 'eb';

Timer

2008-07-29 16:10:54

masterkill, you don't have to post every thing… :)

just have them download the svn… :rolleyes:

MasterKill

2008-07-29 17:27:17

From: Timer
masterkill, you don't have to post every thing… :)

just have them download the svn… :rolleyes:


I only post the hooks for people who don't have acces to it…. :)

Timer

2008-07-29 20:19:36

every one does you silly goose.

TheGuyWhoGotOn

2008-07-29 22:07:24

Also the hooks I posted work…

n3ss3s

2008-07-30 03:23:06

Hooks you posted as in the ones in MK's post?

MasterKill

2008-07-30 04:18:17

From: n3ss3s
Hooks you posted as in the ones in MK's post?


um yes lol :) I was a lil late with reading what TGWGO said on msn and they work :p

~

n3ss3s you should use the SNV then :p

n3ss3s

2008-07-30 05:41:20

They actually work! Thanks :)

Back to flax picking…

ZephyrsFury

2008-07-30 06:47:31

The hooks on the svn and the autoupdater don't work and are different to the ones posted by MasterKill.

EDIT: I think someone made an error while copying. The ones in the svn/autoupdater are correct but for the wrong variable :p

EDIT: Heres the corrected hooks.ini file:

[Global Static Hooks]
BaseLayer=ui.A
BaseX=id.l
BaseY=jg.X
CamX=pa.G
CamY=na.e
CamZ=ci.d
CamPitch=ve.W
CamYaw=ph.L
CurrentLevels=ng.L
Experiences=nd.W
FlagX=pe.w
FlagY=fk.h
GroundHeights=ld.R
GroundSettings=pa.j
LoopCycle=kc.a
MapOffsetAngle=k.c
MaxLevels=ve.fb
MyPlayer=wf.q
NPCArray=hb.k
NPCCount=jk.g
NPCIndexArray=bj.c
PlayerArray=wh.D
PlayerCount=ba.d
PlayerIndArray=ef.i
SettingsArray=ca.A

[Character Hooks]
CharAnim=ub
CharHPRatio=qb
CharHeight=nb
CharMotion=ab
CurrentX=G
CurrentY=o
LoopCycleStatus=u

[NPC Hooks]
NPCDef=Ob

[NPCDef Hooks]
GetNPCName=U
GetNPCType=cb

[Player Hooks]
CharName=Fb
CharLevel=Sb

[RSString Hooks]
StringBytes=eb

MasterKill

2008-07-30 07:52:07

you don't have to worry about the hooks anymore IF you use the reflection from our SNV, just make sure you call SetupReflection; in your mean loop :)

ZephyrsFury

2008-07-30 08:28:42

From: ZephyrsFury
The hooks on the svn and the autoupdater don't work and are different to the ones posted by MasterKill.

EDIT: I think someone made an error while copying. The ones in the svn/autoupdater are correct but for the wrong variable :p


:p

Waddo

2008-07-30 09:30:02

So does reflection work atm or not?

MylesMadness

2008-07-30 15:09:41

Svn?

TheGuyWhoGotOn

2008-07-30 22:32:56

From: Waddo
So does reflection work atm or not?


Yes…That's what the hooks are for…

@Mylesmadness: Umm…I think I link was posted in this topic.

MylesMadness

2008-08-01 09:30:22

No, the walking is broken as qauters updater basex and y hooks broke.

TheGuyWhoGotOn

2008-08-01 10:36:01

From: Mylesmadness
No, the walking is broken as qauters updater basex and y hooks broke.


Aww really? It all seemed fine when I tested it.

Narcle

2008-08-01 10:51:44

Is it just me or is TileToMS not working? Walking and majority of the others are working tho. GetExperience and such work…

TheGuyWhoGotOn

2008-08-01 10:53:34

From: Narcle
Is it just me or is TileToMS not working? Walking and majority of the others are working tho. GetExperience and such work…


I'm not sure if TileToMS works but if I get the MS location of an NPC that works…

Widget

2008-08-02 22:45:01

Sorry for all the broken hooks, delete your hooks.inis and update to the newest SvN. I'm just a retard and don't know how to name stuff properly :(

But on the bright side, everything works again and we're still making progress for stuff. A new group Pest Control script is being worked on and you will be able to track it here (PM me or MasterKill to be added). N3ss3s is working on Objects, Player finding is finished (I think), and I'm not sure what to go for next :p

n3ss3s

2008-08-03 05:29:39

N3ss3s is working on Objects, Player finding is finished (I think), and I'm not sure what to go for next


Items.

Widget, you remember when the Reflection.scar was posted at here, I made the TileOnMM for you which used InCircle, and put it in there? Well isn't it great that now it was moved to rev, in the Core.scar the exact same function is in Timer's credits :mad:

I don't care about the credits so thats like… Facepalm. :(

Damn Zeph :p

NiCbaZ

2008-08-03 05:40:27

From: n3ss3s
Items.

Widget, you remember when the Reflection.scar was posted at here, I made the TileOnMM for you which used InCircle, and put it in there? Well isn't it great that now it was moved to rev, in the Core.scar the exact same function is in Timer's credits :mad:

Not that I care about the credits but like… Facepalm.


Timer is re-writing or making the same types of functions with no standards what so ever and spamming them through the SNV, i mean there are like 4 of his functions in there that could be made into 2 and there are like 3 different WalkToTile, i know timer is the project owner on the SNV but i think it should be cleaner.

Shuttleu

2008-08-03 05:52:16

i ran the npc script thingy on the first post and all it says is "oh noes!"
why?:confused:

~shut

TheGuyWhoGotOn

2008-08-04 00:56:57

From: Shuttleu
i ran the npc script thingy on the first post and all it says is "oh noes!"
why?:confused:

~shut


Do you have the latest SVN?

BobboHobbo

2008-08-04 06:26:10

From: Shuttleu
i ran the npc script thingy on the first post and all it says is "oh noes!"
why?:confused:

~shut


Happens to me also. And yes i got the latest think its 36 now.

EDIT* Ok now its 40 ill give it a run :)

EDIT* Nope just says Oh nose.. It starts smart, i disable then i login. Am i doing anything wrong :)?

Shuttleu

2008-08-04 09:42:04

ok well i have just updated to rev 40 and i will test now

~shut

EDIT: nope still doesnt work
here is what i do
i press play
wait for smart to load
pause the script
disable smart
login my player
i enable smart
run the script

and all it says is oh noes!

EDIT: never mind i figured out what was wrong
there isnt a loadhooks; or setupreflection; in there

TheGuyWhoGotOn

2008-08-04 10:01:02

Ah I forgot about those, sorry. Thanks Shuttleu!

Timer

2008-08-04 10:33:36

Use SetupReflection;

Because it'll be updated later… It just calls LoadHooks; for now, but use it so when we do update it, scripts will still be compatible… ;)

Wizzup?

2008-08-04 12:18:54

From: Timer
Use SetupReflection;

Because it'll be updated later… It just calls LoadHooks; for now, but use it so when we do update it, scripts will still be compatible… ;)


Wow… why do you need all that…?
Just declare them all as const's and such…

Timer

2008-08-04 12:25:05

The only reason we took a huge step from const's is because we wanted web updating for the hooks, that means no more updates just for hooks, or people with older outdated reflection versions can still use those versions… (For procs and such that may have been changed, or removed in later versions). Plus they get updated faster… MK and Widget hosts the web files… One or the other is ALWAYS on… :) Reflection revolves around the hooks, its as simple as that… :p With out hooks, none of this would be possible, well, we need smart, but smarts readings are useless without hooks.

Waddo

2008-08-04 18:51:31

Ok if any one doesnt know how to use reflection, pm me or add my msn and ill teach you enough to work the rest out yourself easily in 5-10 mins =p

Timer

2008-08-04 19:26:56

Or you can read my tutorial, is is juicy and covers every thing… :p

Widget, will you add…

"For more information visit Timer's tutorial on reflection."

Bobarkinator

2008-08-04 19:37:30

N3ss3s and I are working on objects, getting closer, just a few bugs to work out.

BTW, are the RSBot hooks public? They would be very useful for anybody developing anything. I realize you can go and get an output, but it helps a lot to see how they used them in RSBot

Waddo

2008-08-04 20:31:33

Yes timer but im better at explaining things i have a way of putting things extremely simply not every one understands the tuts

Method

2008-08-04 22:43:18

From: Bobarkinator
N3ss3s and I are working on objects, getting closer, just a few bugs to work out.

BTW, are the RSBot hooks public? They would be very useful for anybody developing anything. I realize you can go and get an output, but it helps a lot to see how they used them in RSBot


If you extract the rs.jar file and decompile the class files it produces you'll be able to see where RSBot inserts its methods. For example, there's quite a few of them in the very bottom of the client class file. There's also more in other files, but you need to need to know where RSBot implements its interfaces to figure out where.

You can see how they're used in RSBot's source files also just by browsing through them. Files in the accessors folder show what's gathered from the client and other folders, like script and wrappers show how they're used.

Bobarkinator

2008-08-04 23:39:51

From: Method
If you extract the rs.jar file and decompile the class files it produces you'll be able to see where RSBot inserts its methods. For example, there's quite a few of them in the very bottom of the client class file. There's also more in other files, but you need to need to know where RSBot implements its interfaces to figure out where.

You can see how they're used in RSBot's source files also just by browsing through them. Files in the accessors folder show what's gathered from the client and other folders, like script and wrappers show how they're used.


Ok sounds good

Negaal

2008-08-05 05:08:56

I have a good recommendation, make a complete list of working reflection functions… it's pretty hard to browse them atm..

NiCbaZ

2008-08-05 05:39:27

most of them work ( i think you implying about the walking), but there like 3 different function, form each guy and they do the same think :p widget will sort it out ;)

n3ss3s

2008-08-05 14:18:43

I nominate Wizzup's to be used, try and prove to him why should your one be there instead of his ;)

MasterKill

2008-08-05 15:16:34

A friend of mine is making a onlyne HOOKSupdater.html page, wich will update the hooks.ini files and hosts them online.

I'll give all reflection devs they password do change ini file, so no more shit with the hoosting and updating.

this will be a very good and super fast way to stay up to date.

I'll commit it in the new reflection when its done, it it works :)

n3ss3s

2008-08-05 15:59:21

We are fast as Qauters' update…

Shuttleu

2008-08-05 16:11:06

From: n3ss3s
We are fast as Qauters' update…

what have the hooks been updated because i cant see the updated hooks on here http://trac2.assembla.com/rsbotsvn/timeline

~shut

Waddo

2008-08-05 17:15:31

Wait there so does this mean that hooks will be updated almost instantly which means that now reflection is perfect for us?

the scar noob

2008-08-05 19:03:31

hooks outdated again?

-Tsn.

Method

2008-08-05 19:24:25

If reflection isn't working right now, then yes they are.

Negaal

2008-08-05 22:55:23

So, could someone teach where to get new ones? Rly annoying..And could it be possible to make them self-updating..?

Method

2008-08-05 23:03:23

You need some pretty extensive Java knowledge to be able to write an updater that will grab the hooks as needed from the RuneScape client. It's definitely possible to do, considering there have been quite a few bots like RSBot that do the same, but I think we lack the knowledge here at SRL.

I'm certainly willing to try and learn how, but most of the Java proficient users over at communties like MITB have a "teach yourself" mentality about new users wanting to write updaters and get hooks.

Widget

2008-08-06 00:28:36

Yeah sorry about this. Quaters went on vacation apparently and both our reflection and all of RSBot will be dead. But this is why we have SRL :D

Waddo

2008-08-06 06:02:10

Hmm I think its stupid how only one person can update atm. SB is good at java he might be able to teach us how.

Hugolord

2008-08-06 06:41:15

From: Waddo
Hmm I think its stupid how only one person can update atm. SB is good at java he might be able to teach us how.


lol SB doesn't really like reflection (I think) and alot of people at RSCheata or RSBot know how to update the hooks.

Waddo

2008-08-06 10:42:31

hmm i wonder
possibly a scar hook updater. . .
logs in to an account positioned specially
and tries out different things

eg
npcs
the hooks that return npc values are saved
then it moves onto tiles etc

n3ss3s

2008-08-06 10:47:53

hmm i wonder
possibly a scar hook updater. . .
logs in to an account positioned specially
and tries out different things

eg
npcs
the hooks that return npc values are saved
then it moves onto tiles etc


Hey, that's actually a great idea if you don't think about how do you have to try out all 26 letters for hooks we use that have a parent, which are the minors, and for the rest, at maximum, 26^4^Amount of hooks. Qauters' comes back from holiday before you have a working path bruteforcer.

Waddo

2008-08-06 11:21:54

it couldnt possibly be 26^4$how many hooks as they cant all be zz.z
its more of on average about 16^4^howmany hooks
where does the 4 come from

and do you actually think it was a good idea or just being sarcastic =p

Bobarkinator

2008-08-06 11:23:23

I'm working on an updater right now, kinda slow going :p

Waddo

2008-08-06 11:26:16

OH thats good news what language is it in?

im going to look into drawing on smart canvas to make a debug info screen like in rs bot i tried it earlier on a form but taking it from client to canvas and form got it to get a bit fucked up but i can use the same basic principles.

Method

2008-08-06 12:40:17

From: Waddo
OH thats good news what language is it in?

im going to look into drawing on smart canvas to make a debug info screen like in rs bot i tried it earlier on a form but taking it from client to canvas and form got it to get a bit fucked up but i can use the same basic principles.


It's in Java, of course. It's really the only language you can use to make a decent updater.

Waddo

2008-08-06 13:32:05

I thought as much

Widget

2008-08-06 14:08:05

From: Waddo
hmm i wonder
possibly a scar hook updater. . .
logs in to an account positioned specially
and tries out different things

eg
npcs
the hooks that return npc values are saved
then it moves onto tiles etc

Yeha, I've thought of it too, but it won't work with SCAR. Calling the reflection does lag it a bit, and brute-forcing *maths*7,311,616 hooks (26*2[uppercase/lowercase]^4[up to 4 chars]) really won't work that well. However, if it's written in Java then it might work since with BCEL you can just get a list of the fields that actually exist and go through them :).

These updaters really are hard to make, and the people creating them are very smart. It's not exactly XML :rolleyes:

Waddo

2008-08-06 14:23:22

Do we know when hooks are going to be updated?

Bobarkinator

2008-08-06 14:32:27

Mine won't be ready for a while, you'll have to wait for quaters

Widget

2008-08-06 18:39:27

Around Friday I've been told

MylesMadness

2008-08-06 19:56:53

Where do we through our hat in the ring to be a reflection dev.

Bobarkinator

2008-08-06 21:28:17

From: Mylesmadness
Where do we through our hat in the ring to be a reflection dev.


Most likely invite only

Widget

2008-08-06 21:49:44

If you make something useful, just PM/MSN me or get in the IRC and we'll let you in :)

Just don't write crap functions to get your name in there, we have enough to get rid of >.<

Bobarkinator

2008-08-07 01:39:29

From: Widget
If you make something useful, just PM/MSN me or get in the IRC and we'll let you in :)

Just don't write crap functions to get your name in there, we have enough to get rid of >.<


I was meaning to suggest something to you about that. I'll PM you

Widget

2008-08-07 04:05:02

Reflection works again!!

xD

MasterKill

2008-08-07 04:15:29

From: Widget
Reflection works again!!

xD


you commited? :)

Widget

2008-08-07 04:17:35

You could just try updating and see :rolleyes: (Yes, I commited :p)

Edit: Someone should make me a better sig, 'cause I fail at Photoshop ;))

EvilChicken!

2008-08-07 07:39:08

From: Widget
You could just try updating and see :rolleyes: (Yes, I commited :p)

Edit: Someone should make me a better sig, 'cause I fail at Photoshop ;))


Yay, one more rev 'till #50!

I'll try, but it won't be anything that much better than yours..

Waddo

2008-08-07 07:51:50

Am I a reflection dev im not sure my name is on the first post.

MasterKill

2008-08-07 08:03:08

From: Waddo
Am I a reflection dev im not sure my name is on the first post.


no
and it will stay that way for now, we have enough :p

reflection devs:

BenLand100
Widget
TheGuyWhoGotOn
Timer
Wizzup
MasterKill
ss23
ZephyrsFury
n3ss3s
LeeLokHin
Method
NiCbaZ

n3ss3s

2008-08-07 08:08:55


I think I'll have to have a chat with speljohan about how bannable are their flaxers :rolleyes:

Because if not… Andrew - Welcome Zimbabwe style inflation ;)

NiCbaZ

2008-08-07 08:40:12

LOL anyway use n33 sig for now gl come and own it soon with a better one

Bobarkinator

2008-08-07 12:03:40

I heard it was a joke…

Edit: Nope it works

Naike

2008-08-07 18:07:07

Hooks broken again :/

Shuttleu

2008-08-07 18:17:43

From: N1ke!
Hooks broken again :/

nope hooks still work

what made you say they were broken?

~shut

Waddo

2008-08-07 18:23:05

You sure some have changed i think npc.msx and npc.msy have broke

Shuttleu

2008-08-07 18:24:43

i will check

1 min

~shut

EDIT: nope still work for me

Waddo

2008-08-07 18:33:49

http://www.villavu.com/forum/showthread.php?t=33699

Ok what you all think of this

Widget

2008-08-10 19:33:49

Big update, finally got around to converting all X/Y coords into TPoints like Wizzup?'s been bothering me to. This means most scripts will probably break, but oh well.

Negaal

2008-08-11 14:45:05

Could you at least add GetAnimation back? It's pretty useful..(Doh)

Method

2008-08-11 15:09:12

Animation is under the TMe type. Call GetMe and use a variable of type TMe to find your player's animation.

Shuttleu

2008-08-11 17:23:08

ummm… idk wether anyone else is getting this error but when i run this script i get this error
program New;
{.include srl/srl/misc/smart.scar}
{.include srl/srl.scar}
{.include srl/srl/reflection/reflection.scar}
var
x,y:integer;
Path: TPointArray;

procedure LoadPath;//Not used yet// but should work/
begin
SetLength(Path, 7);
Path[0] := Point(3186, 3444);
Path[1] := Point(3177, 2448);
Path[2] := Point(3169, 3456);
Path[3] := Point(3163, 3464);
Path[4] := Point(3164, 3471);
Path[5] := Point(3164, 3480);
Path[6] := Point(3164, 3487);
end;

function WalkTo(trees:boolean): Boolean;
var
I: Integer;
begin
if trees then
begin
for I := 1 to High(Path) do
begin
if TileOnMM(Path[i]) then
begin
If WalkToTile(Path[i], 0, 0) then
FFlag(8);
end else
exit;
end;
end else
for I := High(Path)-1 downto 0 do
begin
if TileOnMM(Path[i]) then
begin
If WalkToTile(Path[i], 0, 0) then
FFlag(8);
end else
exit;
end;
Result := True;
end;

begin
SetupSRL;
LoadPath;
SmartSetupEx(123, true, true, false);
SetTargetDC(SmartGetDC);
WalkTo(false);
end.
[Runtime Error] : Invalid Opcode Parameter in line 32 in script C:\Program Files\SCAR 3.15\includes\SRL\SRL\Reflection\Walking.Scar
it clicks the first point then gives that error
i can't see anything wrong so i dont understand why im getting that error

please tell me what im doing wrong :s

oh and sorry for the standards

~shut

Method

2008-08-11 17:30:04

You're not doing anything wrong, it's something in GetFlag that's causing it. I'm not really sure what it is, though, but we really should get it fixed.

Shuttleu

2008-08-11 17:39:40

so should i revert back to a older rev for now?

~shut

Method

2008-08-11 17:53:57

From: Shuttleu
so should i revert back to a older rev for now?

~shut


You could just change R_FFlag in WalkToTile to FFlag and that might work as a temporary fix.

Widget

2008-08-11 22:11:23

Reverted to FFlag; and committed :)

Naike

2008-08-13 08:16:10

GetMe.Experience is not working : /

Method

2008-08-13 14:37:19

From: N1ke!
GetMe.Experience is not working : /


It's an array, are you sure you're calling it correctly?

n3ss3s

2008-08-13 15:07:02

Omfg FAILTUB \_______|


Can't just use my functions in the public SMART section?

Yea, the Experience is an array btw… And it's one funky array…

Waddo

2008-08-16 07:05:31

Ive been away for a while do we have object recognition yet?

or will it be finished. . ."tomorrow…" :p

Method

2008-08-16 12:20:03

From: Waddo
Ive been away for a while do we have object recognition yet?

or will it be finished. . ."tomorrow…" :p


No, it's not finished yet.

Naike

2008-08-16 15:04:49

I made BenLand do the thingy n3ss3s needed to complete it :)
So its not far away…

Pure Jenno

2008-08-18 13:23:27

Oooh, I love this reflection stuff XD can't wait for object recognition.

djbeng

2008-08-27 01:02:48

Well done on stealing 99% of RSBot, Reflection.
:duh:

Bourdou!

2008-08-27 01:10:48

You don't know what your talking about ben.

n3ss3s

2008-08-27 07:24:27

Well done on stealing 99% of RSBot, Reflection.


One, you are wrong if you think that Speljohan invented reflection, Two, RSBot doesn't use reflection, it uses a modified client with the in-coded accessor methods if I'm correct…


Getting values from the client itself is years old, iBot has had tilewalking for ages, ARGA and Ares were alive and kicking a long time ago.


Also, we didn't steal anything.

Claymore

2008-08-29 17:13:48

how about a tutorial on making a FindItems.

randy marsh

2008-08-30 20:00:26

When i try add it to the srl folders it comes up with



TViYH

2008-08-30 20:05:50

hmmm…you don't have permissions?

lordsaturn

2008-12-18 21:14:46

Jagex owned your first video tutorial :(

moparisthebest

2010-09-17 19:37:07

From: Widget
Reflection does not modify the client and is therefore undetectable.


That is an entirely 100% false statement, it really should be removed from the first post or at least revised. Just because it doesn't modify the client doesn't mean it's not detectable. SCAR or Simba for example just using color can still be detectable, it all depends what you do with it.

Not to mention the way the client is currently loaded is very detectable.