Drakan
2008-09-12 23:38:23
Hey, welcome to my second tutorial on NPC Finding and Clicking. In this tutorial I will cover pretty much anything you need to know about fighting, talking, and interacting with NPC's.
With Smart's reflection, we can see different actions of NPC's and other players. We can find their animations, levels, if they're under attack, and more. In case you didn't know what animation is, here is my way of explaining it: Every action you do (mining, fishing, dancing, etc.) has its own ID we call Animation. Each animation is unique. Lets say you are mining with a rune pick and your animation is 645 (made up number). If you switch to a different pick the number will also change.
So, how do you find NPC's and Players on the screen? Simple. Lets start with my basic template I use for reflection scripts:
Now, we are going to go with the scenario that you want to find and talk to an NPC. Let's create a function called TalkToNPC(Name: String);
There's lots of info you can get from the npc. Here is a list!
Well thats all for this tutorial! Good luck, and post if you have questions/comments!
With Smart's reflection, we can see different actions of NPC's and other players. We can find their animations, levels, if they're under attack, and more. In case you didn't know what animation is, here is my way of explaining it: Every action you do (mining, fishing, dancing, etc.) has its own ID we call Animation. Each animation is unique. Lets say you are mining with a rune pick and your animation is 645 (made up number). If you switch to a different pick the number will also change.
So, how do you find NPC's and Players on the screen? Simple. Lets start with my basic template I use for reflection scripts:
program NPCsAndPlayers;
{.Include SRL\SRL\Misc\Smart.Scar}
{.Include SRL\SRL.Scar}
{.Include SRL\SRL\Reflection\Reflection.Scar}
procedure SetupSmart;
begin
SmartSetup('world51', True, True, false);
Wait(1000);
SetTargetDC(SmartGetDC);
end;
begin
SetupSRL;
SetupSmart;
wait(2000);
end;Now, we are going to go with the scenario that you want to find and talk to an NPC. Let's create a function called TalkToNPC(Name: String);
function TalkToNPC(Name: String);
begin
end;Now you need to declare a variable to store the NPC's info in. We will call this var TheNPC: TNPC; Lets also add in a variable called P: TPoint; We will store the mainscreen location of the NPC into this.function TalkToNPC(Name: String);
var
TheNPC: TNPC;
P: TPoint;
begin
end;Now that we have that declared, lets use the FindNPC function in the Characters.scar inside of the reflection folder.function TalkToNPC(Name: String);
var
TheNPC: TNPC;
P: TPoint;
begin
if not FindNPC(Name, TheNPC) then Exit;
end;Now we want to set our variable P to the mainscreen coords. To do this, add the following line to our function: P := TheNPC.MS;This will store the point inside of P. Now we can use Mouse to click that NPC!function TalkToNPC(Name: String);
var
TheNPC: TNPC;
begin
if not FindNPC(Name, TheNPC) then Exit;
P := TheNPC.MS;
Mouse(P.x, P.y, 5, 5, false);
wait(100+Random(200));
Result := ChooseOption('Talk-to');
end;
I went ahead and added a wait and ChooseOption. Now you have a simple, NPC talker to-er. To use it all you would have to do is: TalkToNPC('Bob');Tada!There's lots of info you can get from the npc. Here is a list!
TNPC = record
Tile, MS, MM: TPoint;
NPCType, height, animation, HPRatio: integer;
Name : string;
InFight, IsMoving: boolean;
end;I find InFight to be one of the most helpful when making a Fighting script. It returns true or false depending on if the current npc is under attack. This makes sure that you don't click someone else's monster and look botty :).Well thats all for this tutorial! Good luck, and post if you have questions/comments!