Runescapian321
2010-06-13 22:50:21
I think the problem is caused by something I'm doing wrong, but Simba doesn't seem to be pointing the flaw out too well (it crashes).
So I have this:
(Debug pretty much just displays the text) It displays 'Found some monsters…' and never gets to neither 'Got some fightable monsters' nor 'Done fighting'. Therefore we know the problem is in IsMonsterOnMSMM:
Thus the problem occurs as it leaves that function. Immediately after those Debugs, it writes "Exception in Script: Access Violation". It also displays this dialog box:

Whereupon it immediately closes Simba without waiting for a response.
Any ideas?
EDIT: I ran it a couple times more and once it told me the access violation was at line 93, which is
:confused:
So I have this:
begin
Debug('Found some monsters...');
MonsterFS := 0;
if IsMonsterOnMSMM(Monster, MS) then
begin
Debug('Got some fightable monsters');
[etc...]
end;
Debug('Done fighting');
end; (Debug pretty much just displays the text) It displays 'Found some monsters…' and never gets to neither 'Got some fightable monsters' nor 'Done fighting'. Therefore we know the problem is in IsMonsterOnMSMM:
function IsMonsterOnMSMM(var Monsters: TNPCArray;var MS: boolean): boolean;
var
AllMonsters: TNPCArray;
i, THigh, k: integer;
begin
if not LoggedIn then LoginPlayer;
Debug('Initated IsMonsterOnMSMM');
k := 0;
MS := True;
AllMonsters := T_GetNPCByEx(MonsterName);
THigh := High(AllMonsters);
AllMonsters := SortNPCs(AllMonsters);
SetLength(Monsters, Length(AllMonsters));
Debug('MS Loop Starting');
for i:=0 to THigh do
begin
if TileOnMS(AllMonsters[i].Tile, 10) then
begin
if not AllMonsters[i].Fighting then
begin
Monsters[k] := AllMonsters[i];
Inc(k);
end;
end else
break;
end;
Debug('MS Loop Ends');
if k <> 0 then
begin
Debug('Monsters on MS found!');
MS := true;
result := true;
Debug('Setting Length');
SetLength(Monsters, k);
Debug('Exiting function');
exit;
end;
Debug('MM Loop Starting');
for i:=i to THigh do
begin
if TileOnMM(AllMonsters[i].Tile) then
begin
if not AllMonsters[i].Fighting then
begin
Monsters[k] := AllMonsters[i];
Inc(k);
end;
end else
break;
end;
Debug('MM Loop Ends'); //Displays this
if k <> 0 then
begin
Debug('k <> 0 so monster(s) found!'); //Displays this
MS := false;
result := true;
Debug('Monsters Length about to be set'); //Displays this
SetLength(Monsters, k);
end;
Debug('End IsMonsteronMSMM'); //Displays this
end; Thus the problem occurs as it leaves that function. Immediately after those Debugs, it writes "Exception in Script: Access Violation". It also displays this dialog box:

Whereupon it immediately closes Simba without waiting for a response.
Any ideas?
EDIT: I ran it a couple times more and once it told me the access violation was at line 93, which is
procedure Debug(text: string);
begin
if DoDebug then
writeln(TimeRunning+' - '+text); //Line 93
end;:confused: