const
StrongWeaponID = 1111; //The weapon that will be used to kill the mother slime
WeakWeaponID = 1111; //The weapon that will be used to train
MinCreatures = 3; //The minimum amount of creatures attacking you to kill the mother slime to avoid shieldbreaking
MaxTime = [5,0,0]; //The maximum training time (hours, minutes, seconds)
MinHP = 200; // The HP you need to have to kill the mother slime
function GetItemFromOpenBackpack(ID: Integer): TItem;
begin
UpdateWorld;
Result := nil;
for x := 0 to Self.Containers.Count - 1 do
begin
for y := 0 to Self.Containers.Container[x].Count - 1 do
begin
if Self.Containers.Container[x].Item[y].ID = ID then
Result := Self.Containers.Container[x].Item[y];
end;
end;
end;
function GetNumberOfAttackingCreatures: Integer;
begin
UpdateWorld;
Result := 0;
for x := 0 to Creatures.Count - 1 do
begin
if (Abs(Creatures.Creature[x].X - Self.X) <= 1) and
(Abs(Creatures.Creature[x].Y - Self.Y) <= 1) and
(Creatures.Creature[x].Z = Self.Z) and
Creatures.Creature[x].NPC then
Result := Result + 1;
end;
end;
function AttackCreatureByID(ID: Integer);
begin
UpdateWorld;
for x := 0 to Creatures.Count - 1 do
begin
if Creatures.Creature[x].ID = ID then
Creatures.Creature[x].Attacking := True;
end;
end;
var
MotherSlime, X1, Y1: Integer;
Finished: Boolean;
StartTime: Float;
MaxSeconds: Integer;
Item: TItem;
begin
UpdateWorld;
MotherSlime := Self.Following;
Finished := False;
StartTime := Time;
MaxSeconds := (MaxTime[0] * 3600) + (MaxTime[1] * 60) + MaxTime[2];
if MotherSlime = 0 then
begin
Self.DisplayText('Mother slime not found! Please follow it and then execute the script.');
Finished := True;
end;
while (not Terminated) and (not Finished) do
begin
UpdateWorld;
if GetNumberOfAttackingCreatures >= MinCreatures then
begin
Item := GetItemFromOpenBackpack(StrongWeaponID);
if Item <> nil then
begin
if Self.RightHand = WeakWeaponID then
Item.MoveToBody(Self.RightHand, 0);
else
Item.MoveToBody(Self.LeftHand, 0);
end;
AttackCreatureByID(MotherSlime);
Self.DisplayText('There are too many creatures around you. Exiting script.');
Finished := True;
end;
if StartTime + (MaxSeconds / 100000) <= FloatToStr(Time) then
begin
Item := GetItemFromOpenBackpack(StrongWeaponID);
if Item <> nil then
begin
if Self.RightHand = WeakWeaponID then
Item.MoveToBody(Self.RightHand, 0);
else
Item.MoveToBody(Self.LeftHand, 0);
end;
AttackCreatureByID(MotherSlime);
Self.DisplayText('You have trained for too long. Exiting script.');
Finished := True;
end;
if Self.Health <= MinHP then
begin
Item := GetItemFromOpenBackpack(StrongWeaponID);
if Item <> nil then
begin
if Self.RightHand = WeakWeaponID then
Item.MoveToBody(Self.RightHand, 0);
else
Item.MoveToBody(Self.LeftHand, 0);
end;
AttackCreatureByID(MotherSlime);
Self.DisplayText('Your health is too low. Exiting script.');
Finished := True;
end;
if not Self.Attacking then
begin
UpdateWorld;
for x := 0 to Creatures.Count - 1 do
begin
UpdateWorld;
if Creatures.Creature[x].ID <> MotherSlime then
begin
if (Creatures.Creature[x].Name <> Self.Name) and Creatures.Creature[x].NPC then
begin
UpdateWorld;
X1 := Creatures.Creature[x].X;
Y1 := Creatures.Creature[x].Y;
Z1 := Creatures.Creature[x].Z;
if (Abs(X1 - Self.X) <= 1) and (Z1 = Self.Z) then
begin
UpdateWorld;
if (Abs(Y1 - Self.Y) <= 1) and (Z1 = Self.Z) then
begin
Creatures.Creature[x].Attacking := true;
Break;
end;
end;
end;
end;
end;
end;
Sleep(1000);
end;
end;
quinta-feira, 31 de julho de 2008
Slime Trainer
às 16:33
Marcadores: Scripts Tibia Ng
Subscribe to:
Postar comentários (Atom)
0 Comments:
Post a Comment