Atacar Tal Monstro Primeiro
Autor: Nando Down | Publicado: 2011-07-07T19:13:00-07:00

Const 
Name=['Dworc Voodoomaster', 'Dworc Venomsniper', 'Dworc Fleshhunter']; 
SwitchAt=30;// the % of the current attacked monster 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //that if the monster has lass % hp than this, we Will NOt change to the stronger monster. 
function GetPlace(st:string):integer; 
var 
x:integer; 
begin 
Result:=1000; 
for x:=Low(Name) To High(Name) do 
&nbsp; begin 
&nbsp;&nbsp; if Name[x]=st then 
&nbsp;&nbsp; Result:=x; 
&nbsp;&nbsp; end; 
end; 
function GetCreatureByID(ID: integer): TCreature; 
var 
&nbsp; x: integer; 
begin 
&nbsp; Result := nil; 
&nbsp; for x := 0 to Creatures.Count - 1 do 
&nbsp; begin 
&nbsp;&nbsp;&nbsp; if x &gt;= Creatures.Count then Break; 
&nbsp;&nbsp;&nbsp; if Creatures.Creature[x].ID = ID then 
&nbsp;&nbsp;&nbsp; begin 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Result := Creatures.Creature[x]; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit; 
&nbsp;&nbsp;&nbsp; end; 
&nbsp; end; 
end; 
function IsCreatureBesideYou(c: TCreature): boolean; 
begin 
&nbsp;&nbsp; UpdateWorld; 
&nbsp;&nbsp; Result := False; 
&nbsp;&nbsp; if (abs(c.X-self.X) &lt;= 4) and (abs(c.Y-self.Y) &lt;= 4) then begin 
&nbsp;&nbsp;&nbsp; if c.Z = self.Z then begin 
&nbsp;&nbsp;&nbsp;&nbsp; Result := True; 
&nbsp;&nbsp;&nbsp; end; 
&nbsp;&nbsp; end; 
end; 
var 
x:integer; 
b:boolean; 
begin 
while not terminated do 
&nbsp; begin 
&nbsp;&nbsp;&nbsp; b:=false; 
&nbsp;&nbsp; updateworld; 
&nbsp;&nbsp; If (Self.Attacking&lt;&gt;0) then 
&nbsp;&nbsp;&nbsp; begin 
&nbsp;&nbsp;&nbsp; Creature:=GetCreatureByID(Self.Attacking); 
&nbsp;&nbsp;&nbsp;&nbsp; if Creature&lt;&gt;nil then 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if SwitchAt&lt;Creature.Health then 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for x := 0 to Creatures.Count - 1 do 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; updateworld; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if b then break; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if x &gt;= Creatures.Count then Break; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if Creatures.Creature[x].NPC then 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if Creatures.Creature[x].z=self.z then 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if Creatures.Creature[x].Name&lt;&gt;self.name then 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if Creatures.Creature[x].Attacking = false then 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if IsCreatureBesideYou(Creatures.Creature[x]) then 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if GetPlace(Creature.Name)&gt;GetPlace(Creatures.Creature[x].Name) then 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sleep(100); 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; updateworld; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Creatures.Creature[x].attacking:=true; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; B:=true; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end; 
&nbsp;&nbsp;&nbsp;&nbsp; Sleep(100); 
&nbsp;&nbsp; end; 
end;&nbsp;