Shuttleu
07-30-2010, 08:33 AM
i have this function (MyFindBirdNest) which i made for my vine vanquisher, but it seems to crash my simba after being called about 30 times, but i cannot reproduce it if i run the function by itself
i know it is the function because if i comment out the line that calls it then simba doesn't crash
here are the functions
function AddGroundItemArrays(Array1, Array2: TGroundItemArray): TGroundItemArray;
var
x, y, z: Integer;
begin
x:= Length(Array1);
y:= Length(Array2);
SetArrayLength(Result, x+y);
for z:= 0 to High(Array1) do
Result[z]:= Array1[z];
for z:= 0 to y-1 do
Result[(x+y)-(y-z)]:= Array2[z];
end;
function GetItemsInBox(Box: TBox): TGroundItemArray;
var
x, y: Integer;
Temp: TGroundItemArray;
begin
for x:= Box.X1 to Box.X2 do
for y:= Box.Y1 downto Box.Y2 do
begin
Temp:= GetItemsAt(Tile(x, y));
Result:= AddGroundItemArrays(Result, Temp);
end;
end;
function MyFindBirdNest: Boolean;
var
GroundItems: TGroundItemArray;
i: Integer;
BirdNestLoc: TTile;
begin
if Debug then
Writeln('Searching for birds nest');
GroundItems:= GetItemsInBox(Box);
for i:=0 to High(GroundItems) do
if (GroundItems[i].ID > 5069) and (GroundItems[i].ID < 5076) then
begin
writeln('found birds nest');
writeln('picking up birds nest');
BirdNestLoc:= TileToMS(GroundItems[i].Tile, 0);
Mouse(BirdNestLoc.x, BirdNestLoc.y, 0, 0, False);
Wait(250+Random(500));
if ChooseOptionMulti(['ake', 'ird', 'est']) then
begin
Result:= True;
writeln('picked up birds nest :)');
Break;
end;
end;
if Debug then
Writeln('Finished searching for birds nest');
end;
if you have any idea what is causing it then i would be very greatful
~shut
i know it is the function because if i comment out the line that calls it then simba doesn't crash
here are the functions
function AddGroundItemArrays(Array1, Array2: TGroundItemArray): TGroundItemArray;
var
x, y, z: Integer;
begin
x:= Length(Array1);
y:= Length(Array2);
SetArrayLength(Result, x+y);
for z:= 0 to High(Array1) do
Result[z]:= Array1[z];
for z:= 0 to y-1 do
Result[(x+y)-(y-z)]:= Array2[z];
end;
function GetItemsInBox(Box: TBox): TGroundItemArray;
var
x, y: Integer;
Temp: TGroundItemArray;
begin
for x:= Box.X1 to Box.X2 do
for y:= Box.Y1 downto Box.Y2 do
begin
Temp:= GetItemsAt(Tile(x, y));
Result:= AddGroundItemArrays(Result, Temp);
end;
end;
function MyFindBirdNest: Boolean;
var
GroundItems: TGroundItemArray;
i: Integer;
BirdNestLoc: TTile;
begin
if Debug then
Writeln('Searching for birds nest');
GroundItems:= GetItemsInBox(Box);
for i:=0 to High(GroundItems) do
if (GroundItems[i].ID > 5069) and (GroundItems[i].ID < 5076) then
begin
writeln('found birds nest');
writeln('picking up birds nest');
BirdNestLoc:= TileToMS(GroundItems[i].Tile, 0);
Mouse(BirdNestLoc.x, BirdNestLoc.y, 0, 0, False);
Wait(250+Random(500));
if ChooseOptionMulti(['ake', 'ird', 'est']) then
begin
Result:= True;
writeln('picked up birds nest :)');
Break;
end;
end;
if Debug then
Writeln('Finished searching for birds nest');
end;
if you have any idea what is causing it then i would be very greatful
~shut