Feroc1ty
2011-02-23 03:39:52
Here's the code:
Here's the debug it gives me:
There's obviously something very wrong with the code, because the script doesn't start a new function after it's supposedly "finished" fighting.
function InteractWithNPC(action:string;npc:TNPC):boolean;
begin
fDebug('InteractWithNPC','Attempting to '+action+' (to) a '+npc.name);
ClickBox(PtToBox(TileToMS(npc.tile,30),10),false);
Wait(250+random(100));
result := r_ChooseOptionMulti([action,npc.name]);
r_Flag;
wait(10+random(40));
end;
function FightNPC(name:string):boolean;
var mobs:TNPCArray;
index:integer;
begin
index := 0;
result := FindNPCs(name, mobs);
if result then
begin
fDebug('FightNPC','Starting the function, some NPCs have been found!');
result := false;
while not result do
begin
if mobs[index].fighting then
begin
fDebug('FightNPC','mobs['+inttostr(index)+'] is already fighting, changing index!');
index := index + 1;
end else
begin
InteractWithNPC('attack',mobs[index]);
if InteractingWithMe(mobs[index]) then
begin
result := true;
fDebug('FightNPC','Fight confirmed.');
end;
while InteractingWithMe(mobs[index]) do
begin
Wait(500);
fDebug('FightNPC','Fighting.');
end;
fDebug('FightNPC','Finished fighting.');
end;
end;
end;
end; Here's the debug it gives me:
00:00:18 [ FightNPC ] Starting the function, some NPCs have been found!
00:00:18 [ InteractWithNPC ] Attempting to attack (to) a Chicken
00:00:21 [ FightNPC ] Finished fighting.
00:00:21 [ InteractWithNPC ] Attempting to attack (to) a Chicken
00:00:23 [ FightNPC ] Finished fighting.
00:00:23 [ InteractWithNPC ] Attempting to attack (to) a Chicken
00:00:26 [ FightNPC ] Finished fighting.
00:00:26 [ InteractWithNPC ] Attempting to attack (to) a Chicken
00:00:29 [ FightNPC ] Finished fighting.
00:00:29 [ InteractWithNPC ] Attempting to attack (to) a Chicken
00:00:31 [ FightNPC ] Finished fighting.There's obviously something very wrong with the code, because the script doesn't start a new function after it's supposedly "finished" fighting.