SRL Archive - OSR Help

Error finding NPCs


HarryJames

2011-02-27 11:26:21

I'm back again, too soon methinks.. It's a learning process!

Procedure attackEnemy;
var
NPCs : TNPCArray;
I, II : Integer;
Begin
if (infight) then exit;

NPCs := SortNPCs(GetNPCs(['Tz-Kih','Tz-Kek','Tok-Xil']));
For I:=0 to high(NPCs) do
begin
Writeln('[' + ToStr(I) + ']Name: ' + NPCs[I].Name + '(' + ToStr(NPCs[I].Tile.X) + ', ' + ToStr(NPCs[I].Tile.Y) + ') ID: ' + ToStr(NPCs[I].ID) + ' - Index:' + ToStr(NPCs[I].Index));
Writeln(' Orientation: ' + ToStr(NPCs[I].Orientation) + ' - Level: ' + ToStr(NPCs[I].Level) + ' - Animation:' + ToStr(NPCs[I].Animation) + + ' - HPRatio:' + ToStr(NPCs[I].HPRatio));
Writeln(' Moving:' + ToStr(NPCs[I].Moving) + ' - InFight:' + ToStr(NPCs[I].Fighting) + ' - Interacting:' + ToStr(NPCs[I].Interacting) + ' - Height:' + ToStr(NPCs[I].Height));
Writeln(' Actions:');
For II:=0 to High(NPCs[I].Actions) do
Writeln(' ' + NPCs[I].Actions[II]);
end;

end;

Why does this just give an error message of 'Error: Could not call proc at line 259'?

And why can't I call 'MyNPC := SortNPCs(GetNPCs);' to get all of the NPCs around me?

~Harry

*Remade this thread in the correct section*

From: Zyt3x
What line is line 259?


It is the decleration of the proc.

HarryJames

2011-02-27 11:34:50

I will be back in about 6 hours, I'm not just ignoring the thread :)

Feroc1ty

2011-02-27 11:38:12

Here, just use my code.

function InteractWithNPC(action:string;npc:TNPC):boolean;
var t:TNPC;
begin
if not TileOnMS(npc.tile,30) then
begin
WalkToTile(npc.tile,1,1);
R_Flag;
end;
MoveBox(PtToBox(TileToMS(npc.tile,30),10));
Wait(100+random(125));
if R_IsUpText(action+' '+npc.name) then
ClickMouse2(true)
else
begin
ClickMouse2(false);
R_ChooseOptionMulti([action,npc.name]);
end;
wait(400+random(150));
r_Flag;
result := InteractingWithMe(npc);
end;

procedure FinishAnimating();
var i:integer;
begin
for i := 0 to 16 do
begin
if CharacterAnimating then i := 0;
wait(40);
end;
end;

function FightNPC(name:string):boolean;
var mobs:TNPCArray;
index:integer;
begin
index := 0;
mobs := SortNPCs(GetNPCs(name));
for index := 0 to high(mobs) do
begin

if (mobs[index].fighting or mobs[index].moving) then
continue;

result := InteractWithNPC('attack',mobs[index]);

FinishAnimating;

break;
end;
end;

Here's the mouse functions I used:
function MouseInBox(box:TBox):boolean;
var pt:TPoint;
begin
GetMousePos(pt.x,pt.y);
result := PointInBox(pt, box);
end;

procedure ClickBox(box:TBox;left:boolean);
var x,y:integer;
begin
x := (box.x2 - box.x1)/2;
y := (box.y2 - box.y1)/2;
if not MouseInBox(box) then
MMouse(box.x1 + x + Random(RandomRange(-x,x)), box.y1 + y + Random(RandomRange(-y,y)), 0, 0);
ClickMouse2(left);
end;

procedure MoveBox(box:TBox);
var x,y:integer;
begin
x := (box.x2 - box.x1)/2;
y := (box.y2 - box.y1)/2;
if not MouseInBox(box) then
MMouse(box.x1 + x + Random(RandomRange(-x,x)), box.y1 + y + Random(RandomRange(-y,y)), 0, 0);
end;

HarryJames

2011-02-27 19:26:28

Cheers Feroc1ty.
How can this be edited to allow for an array of enemies?

It's for the fight caves, so the enemies aren't all called the same unless Simba allows for wildcarding? (I'm guessing it doesn't).

Edit: nevermind, I was being silly!