const
RuneID=3155; // put the ID of the rune that you will like to shoot on the attacker.
Time=2.2;//how many seconds between each rune(exusted time).
Min=700;// minimum Hp.if our hp is lower than that we wont shoot so we can auto heal.
MonsterList=['Demon','Hydra','Dragon','Frost Dragon','Rotworm','Carrion Worm']; // List of monsters.
var
Creature:TCreature;
X,Target:integer;
Shoot:Boolean;
function GetCreatureByID(ID: integer): TCreature;
var
x: integer;
begin
Result := nil;
for x := 0 to Creatures.Count - 1 do
begin
if x >= Creatures.Count then Break;
if Creatures.Creature[x].ID = ID then
begin
Result := Creatures.Creature[x];
Exit;
end;
end;
end;
procedure Event_Attacked(ID: integer);
var
CreatureID:integer;
begin
updateworld;
Creature:=GetCreatureByID(ID);
if Creature <> nil then
if Creature.NPC=false then
begin
Target:=ID;
Shoot:=true;
end;
end;
while not Terminated do
begin
Shoot:=false;
ProcessEvents;
If Shoot then
begin
for i := 1 to 10000 do
begin
if Terminated then break;
updateworld;
if self.Health<=Min then
begin
sleep(200);
updateworld;
end;
Creature:=GetCreatureByID(Target);
if Creature<>nil then
Self.Containers.UseItemWithCreature(RuneID, Creature);
Sleep(Time*1000);
if Creature.Health = 0 then break;
end;
end;
UpdateWorld;
if Self.Attacking <> 0 then
begin
Monster := GetCreatureByID(Self.Attacking);
if Monster <> nil then
if Monster.NPC = true then
begin
A := 0;
for hi := Low(MonsterList) to High(MonsterList) do
begin
if Monster.Name = MonsterList[hi] then
A := 1;
end;
if A = 1 then
begin
if Self.Health > Min then
Self.Containers.UseItemWithCreature(RuneID,Monster);
Sleep(Time*1000);
end;
end;
end;
Sleep(100);
end;