Mobs kills counter script

Scipt that count how many mobs character killed. Like 1 specific mob not total ammount.

Idea is that everytime you killed desired mob its gonna write number in party chat for example.

uses SysUtils;
type
  TIntegerArray = array of Cardinal;

var
  MobKillCount: array of Integer;
  MobIDs: TIntegerArray;
  Mob: TL2Live;
  KilledMobs: array of Cardinal;
  i, idx: Integer;

function IsMobTracked(OID: Cardinal): Boolean;
var
  j: Integer;
begin
  Result := False;
  for j := 0 to High(KilledMobs) do
  begin
    if KilledMobs[j] = OID then
    begin
      Result := True;
      Break;
    end;
  end;
end;

procedure AddMobToTrackedList(OID: Cardinal);
begin
  SetLength(KilledMobs, Length(KilledMobs) + 1);
  KilledMobs[High(KilledMobs)] := OID;
end;

procedure TrackMonsters(mobIds: TIntegerArray);
begin
  SetLength(MobKillCount, Length(mobIds));
  MobIDs := mobIds;

  while (Engine.Status <> lsOnline) do
    Delay(100);

  while True do
  begin
    if User.Dead then begin
      Delay(300);
      continue;
    end;

    for i := 0 to NpcList.Count - 1 do
    begin
      Mob := NpcList.Items(i) as TL2Live;
      for idx := 0 to High(MobIDs) do
      begin
        if (Mob.ID = MobIDs[idx]) and (Mob.Dead) and not IsMobTracked(Mob.OID) then
        begin
          Inc(MobKillCount[idx]);
          Engine.Say('Total kills of '+ Mob.name +' (' + IntToStr(MobIDs[idx]) + '): ' + IntToStr(MobKillCount[idx]), 3, '');
          AddMobToTrackedList(Mob.OID);
        end;
      end;
    end;

    for i := High(KilledMobs) downto 0 do
    begin
      if not NpcList.ByOID(KilledMobs[i], Mob) then
      begin
        KilledMobs[i] := KilledMobs[High(KilledMobs)];
        SetLength(KilledMobs, Length(KilledMobs) - 1);
      end;
    end;

    Delay(500);
  end;
end;

begin
  Script.NewThread(@TrackMonsters([21035,20213]));  // Specify the Monster ids here
  delay(-1);
end.

How it works?

Author: Velmsun