Kod :
const
// Time in seconds to kill a creature. If it takes more than it, script will assume that creature as an anti-botter.
AverageTimeKill = 25;
// Play alarm in case of an anti-botter detected? 1 = yes / 0 = no
SoundAlarm = 1;
// Alarm Path
AlertSound = 'c:\windows\media\notify.wav';
// Don't change this
IgnoreLimit = 250;
var
CreaturesIgnore: array of integer;
CreatureAttacking : integer;
CreatureAttackingBefore : integer;
TimeAttack, TimeStamp, TimeElapsed : integer;
y : integer;
// #credits hxxp://forums.tibiabot.com/showthread.php?t=77814
function TimeNow:integer;
var
hours, minutes, seconds, miliseconds:integer;
begin
DecodeTime(Now, hours, minutes, seconds, miliseconds);
Result := hours * 60 * 60 * 1000 + minutes * 60 * 1000 + seconds * 1000 + miliseconds;
end;
procedure PlayAlarm;
begin
if SoundAlarm then
begin
if (Pos('.wav', AlertSound) <> 0) then
begin
try
PlaySound(AlertSound);
except
ShowMessage('Please enter a valid path for the sound file!');
end;
end;
end;
end;
// Check if player is attacking something, if yes return attacked creature id
function CheckAttacking: integer;
begin
UpdateWorld;
for x := 0 to Creatures.Count - 1 do
begin
UpdateWorld;
if Creatures.Creature[x].Attacking then
begin
if CreatureAttackingBefore > 0 and CreatureAttackingBefore <> Creatures.Creature[x].ID then
CreatureAttackingBefore := CreatureAttacking;
Result := Creatures.Creature[x].ID;
Exit;
end;
end;
Result := 0;
Exit;
end;
//Check if an ID is in ignore list
function CheckIgnored(ID : integer) : boolean;
var x : integer;
begin
if y >= 1 then
begin
for x := 0 to y-1 do
begin
if ID = CreaturesIgnore[x] then // ignored creature
begin
Result := true;
Exit;
end;
end;
end;
Result := false;
end;
// Add an ID to the ignore list
procedure IgnoreCreature(ID : integer);
begin
Self.DisplayText('IgnoreCreature #' + IntToStr(ID));
CreaturesIgnore[y] := ID;
y := y + 1;
if y > IgnoreLimit then y := 1;
end;
procedure StopAttack;
begin
for x := 0 to Creatures.Count - 1 do
begin
UpdateWorld;
if Creatures.Creature[x].Attacking then
begin
Creatures.Creature[x].Attacking := false;
Exit;
end;
end;
end;
// Check if the player has been attacked, then attack the attacker if it isn't a player
procedure Event_Attacked(ID: integer);
begin
if not CheckIgnored(ID) then
begin
for x := 0 to Creatures.Count - 1 do
begin
UpdateWorld;
if Creatures.Creature[x].ID = ID and
(not Creatures.Creature[x].WhiteSkull and not Creatures.Creature[x].RedSkull and not Creatures.Creature[x].YellowSkull) // ignore player attack (is there a better way?)
then
begin
TimeAttack := TimeNow;
Creatures.Creature[x].Attacking := True;
Exit;
end;
end;
end;
end;
begin
CreatureAttackingBefore := 0;
CreatureAttacking := 0;
y := 0;
CreaturesIgnore := VarArrayCreate([y, IgnoreLimit], $C);
UpdateWorld;
while not Terminated do
begin
UpdateWorld;
if not CheckAttacking then
begin
ProcessEvents;
CreatureAttacking := CheckAttacking;
end;
if CheckAttacking then
begin
TimeStamp := TimeNow;
TimeElapsed := TimeStamp - TimeAttack;
if CreatureAttacking = CreatureAttackingBefore and (TimeElapsed > (AverageTimeKill*1000)) then
begin
IgnoreCreature(CreatureAttacking);
StopAttack;
PlayAlarm;
end;
CreatureAttackingBefore := CreatureAttacking;
end;
sleep(500);
end;
end;
Pisac Pomoge Z Botem NG !!
Zakładki