Smarter Child
2009-08-28 01:09:38
NPCs!
Today i am going to be writing a tutorial on using NPCs in functions etc..
So lets get started:
- What is an NPC?
An NPC is a non player character in runescape. NPCs are like shopkeepers/fishing spots/Bankers.
( + Fishing Spots are weird they're like the only "non - living" npcs in runescape. + )
- What is not an NPC?
Rocks/Trees etc. These things are objects, which won't be discussed in the tutorial today :p.
—-
First lets make a basic reflection script template:
I use this to test any of my functions that i create with reflection.
So just make a function named: FindTheNPC or something, then we have to declare a var.
This variable stores TNPC in the npc variable.
Now type: FindNPC(
You'll get these parameters:
So lets start with TheVar:
For this parameter you can have either the npc id or the npc name[doesn't have to be whole thing].
For example:
Or:
Understand?
The next variable is NPC: TNPC; which you guys should have covered by now :p
So this is what i have currently:
Now we have to use NPC variable to find the tile of npc so we can click it!
So do this:
The NPC variable store the Tile of the npc so therefore u can do NPC.Tile.
Height is the distance in pixels above the ground, but we obviously know fishing spots are on the floor.(well not irl :p).
Now we have the mainscreen locations stored to TP, so all we have to do now is:
And thats your basic npc finding in reflection, good luck making your own functions.
:).
~~ END ~~
Today i am going to be writing a tutorial on using NPCs in functions etc..
So lets get started:
- What is an NPC?
An NPC is a non player character in runescape. NPCs are like shopkeepers/fishing spots/Bankers.
( + Fishing Spots are weird they're like the only "non - living" npcs in runescape. + )
- What is not an NPC?
Rocks/Trees etc. These things are objects, which won't be discussed in the tutorial today :p.
—-
First lets make a basic reflection script template:
program New;
{.Include SRL\SRL\Misc\Smart.Scar}
{.Include SRL\SRL.Scar}
{.Include SRL\SRL\Reflection\Reflection.Scar}
Const
World = 72;
Members = false;
Signed = true;
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active := True;
end;
begin
Smart_Members := Members;
Smart_Signed := Signed;
Smart_Server := World;
Smart_SuperDetail := false;
SetupSRL;
SetupReflection;
DeclarePlayers;
LoginPlayer;
{Next functions}
end.I use this to test any of my functions that i create with reflection.
So just make a function named: FindTheNPC or something, then we have to declare a var.
var npc: TNPC;This variable stores TNPC in the npc variable.
Now type: FindNPC(
You'll get these parameters:
FindNPC(TheVar: Variant;var NPC: TNPC): boolean;So lets start with TheVar:
For this parameter you can have either the npc id or the npc name[doesn't have to be whole thing].
For example:
Function FindFishingSpot: boolean;
var
NPC: TNPC:
begin
FindNPC('ishing Spot',
end;Or:
Function FindFishingSpot: boolean;
var
NPC: TNPC:
begin
FindNPC(434
//not real fishing spot id, but is an example
end;Understand?
The next variable is NPC: TNPC; which you guys should have covered by now :p
So this is what i have currently:
Function FindFishingSpot: boolean;
var
NPC: TNPC:
begin
if FindNPC('ishing Spot', NPC)then
end;Now we have to use NPC variable to find the tile of npc so we can click it!
So do this:
Function FindFishingSpot: boolean;
var
NPC: TNPC:
TP: TPoint;
begin
if FindNPC('ishing Spot', NPC)then
TP := TileToMs(NPC.Tile, 0);
end;Don't get :confused: just yet, its very simple.The NPC variable store the Tile of the npc so therefore u can do NPC.Tile.
Height is the distance in pixels above the ground, but we obviously know fishing spots are on the floor.(well not irl :p).
Now we have the mainscreen locations stored to TP, so all we have to do now is:
Function FindFishingSpot: boolean;
var
NPC: TNPC:
TP: TPoint;
begin
if FindNPC('ishing Spot', NPC)then
TP := TileToMs(NPC.Tile, 0);
MMouse(TP.x, TP.y, 2, 2);
end;Try that out yourself, on some other NPC, and it will move the mouse to it. But we won't a little more failsafes don't we?Function FindFishingSpot: boolean;
var
NPC: TNPC:
TP: TPoint;
begin
if FindNPC('ishing Spot', NPC)then //if it finds the npc it does..
TP := TileToMs(NPC.Tile, 0); //TP stores the mainscreen location of the npc
MMouse(TP.x, TP.y, 2, 2); //moves mouse to mainscreen location
if R_IsUpText('ishing')then ///checks the uptext using reflection
begin
Wait(500 + Random(500)): //small wait
Mouse(TP.x, TP.y, 3, 3, true);//left clicks the npc
Result := //function results true;
end;
if(not(FindNPC('ishing Spot', NPC)))then
begin
Result := false; //function results false
Exit; //exits function if it couldn't find the spot
end;
end;And thats your basic npc finding in reflection, good luck making your own functions.
:).
~~ END ~~