Hi,
i am trying to work on a way to track a specific NPC until its dead for my Ratinator script.
I have made some progress but i need help to polish this off a bit.
the way i am doing it, or shall we say trying to do it is using the Index of the NPC to track it.
for most part is works fine but occasionally it will kill the rat but keep thinking its alive, i am not sure why, its possible at that point a new rat has spawned with the same Index but i would love some help with this.
This is my check to see if the rat index is found against the current rats on screen.
Simba Code:
Function FastFighting:Boolean; //using this now to check that we are attacking rat, no false positives (hopefully)
var
i:integer;
Char : TNPCArray;
mx, my, Colour, Shadow:integer;
ratBMP, TotalBMP:TMufasaBitmap;
Canvas: TCanvas;
ratBox:TBox;
ratpoint:TPoint;
Foundit:Boolean;
begin
Write('Checking for Fight');
ratBox.X1 := 0;
ratBox.Y1 := 0;
ratBox.X2 := 8;
ratBox.Y2 := 8;
Foundit:= false;
if Players[CurrentPlayer].Booleans[0] then
begin
repeat
Char := (SortNPCS(GetNPCS('Giant rat'))); //gets all rats
if(Length(Char) = 0)then
Exit;
{if TileOnMS(rattile, 0) then //used to draw on smart.
begin
SmartSetDebug(True);
GetClientDimensions(mx,my);
Colour := 225; //change color of text
Shadow := 65536;
ratBMP := TMufasaBitmap.create;
ratBMP.SetSize(mx,my);
ratBMP.FastDrawClear(clBlack);
ratBMP.Rectangle( ratBox, Colour);
Canvas := TCANVAS.Create;
Canvas.Handle := SmartGetDebugDC;
TotalBMP := TMufasaBitmap.create;
TotalBMP.SetSize(mx,my);
ratpoint:= tiletoms(rattile, 0);
//writeln('rat location is x: '+inttostr(ratpoint.x)+ ' y :'+inttostr(ratpoint.y));
ratBMP.FastDrawTransparent( ratpoint.x ,ratpoint.y , TotalBMP);
ratBMP.SetTransparentColor(clBlack);
TotalBMP.DrawToCanvas(0 ,0, Canvas);
ratBMP.Free;
TotalBMP.Free;
end; }
//Writeln('looking for '+inttostr(Rat)+' in array');
for i := 0 to High(Char) do //loops through all rats found
begin
//writeln('currently in array is ' +inttostr(char[i].Index));
if (Rat = Char[i].Index) then //checks rat index from attack function to ones in current array
begin
Writeln('Rat Index found rat coould still be alive');
Result:= True;
Break;
end;
if (I = High(Char)) then
begin
Write('looped through all rats, exiting');
Result:= False
Wait(800+Random(1000));
end;
end;
//writeln('');
Wait(500+Random(500));
until( not Result)
end;
end;
I get my initial Rat Index from my attack function when i click it.
what do you think? am i being stupid and this would not work?