Hiho Monk Trainer

This is a script for stop attacking monk at "SwitchAT" hitpoint presantage and to start hit monk when it has "AttackAt" hitpoint presantage.
Also if there are more than 1 monk in screen the script will switch between the monk when the one you are attacking got to the "SwithAt" value.

Const    
SwitchAt=40;//switch to next monk when the current monk has less than 40% hp.    
AttackAt=50;// attack a monk if the monk has more than 50% hp.    

var    
creature:tcreature;    

function GetCreatureByNameHPHIGH(Name: string): 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].Name = Name then    
    if Creatures.Creature[x].Health>AttackAt then    
    begin    
      Result := Creatures.Creature[x];    
      Exit;    
    end;    
  end;    
end;    
function Attacking: boolean;    
var    
  x: integer;    
begin    
  Result := False;    
  for x := 0 to Creatures.Count - 1 do    
  begin    
    if x >= Creatures.Count then Break;    
    if Creatures.Creature[x].Attacking then    
    begin    
      Result := True;    
      Exit;    
    end;    
  end;    
end;    
function GetAttackedCreature: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].Attacking=true then    
    begin    
      Result := Creatures.Creature[x];    
      Exit;    
    end;    
  end;    
end;    

begin    

while not Terminated do    
   begin    
    UpdateWorld;    
     if not attacking then    
      begin    
       Creature:=GetCreatureByNameHPHIGH('Monk');    
        if  Creature <> nil then    
         creature.attacking:=true;    
      end;    
  if attacking then    
   begin    
    Creature:=GetAttackedCreature;    
     if  Creature <> nil then    
      if creature.Health < SwitchAt then creature.attacking:=false;    
    end;    
  sleep(1000);    
  end;    
end;
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License