Trocar arma para matar x monstro

Const 
  //Enter the settings for when to change to DEFENSIVE// 
  MonsterName = ['Snake']
  weapon1_ID = 3066
  //Enter the settings for when to change to OFFENSIVE back// 
  Weapon2_ID = 3327  
   
function GetItemFromOpenBackpack(ID: integer): TItem; 
var 
  y: integer; 
begin 
  Result := nil; 
  for x := 0 to Self.Containers.Count - 1 do 
  begin 
    if x >= Self.Containers.Count then Break; 
    for y := 0 to Self.Containers.Container[x].Count - 1 do 
    begin 
      if y >= Self.Containers.Container[x].Count then Break; 
      if Self.Containers.Container[x].Item[y].ID = ID then 
      begin 
        Result := Self.Containers.Container[x].Item[y]; 
        Exit; 
      end; 
    end; 
  end; 
end; 

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; 

function GetCreatureByName(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
    begin
      Result := Creatures.Creature[x];
      Exit;
    end;
  end;
end;


while not terminated do
begin 
  Continu := 0;
  UpdateWorld;
  Creature := GetCreatureByID(Self.Attacking); 
  if Creature <> nil then 
  begin
    for i := low(monstername) to high(monstername) do
    begin
      if MonsterName[i] = Creature.Name then
      Continu := 1;
    end;
    if Continu then
    begin
      Self.Defensive;
      Weapon := GetItemFromOpenBackpack(Weapon1_ID); 
      if Self.RightHand.ID <> Weapon1_ID then
      begin
        if Weapon = nil then 
          self.DisplayText('Weapon1 wasnt found in open backpack!'); 
        else
          Weapon.MoveToBody(Self.RightHand,0); 
      end;
    end;
    else   
    begin 
      Self.Offensive;   
      if Self.RightHand.ID <> Weapon2_ID then 
      begin
        Weapon := GetItemFromOpenBackpack(Weapon2_ID); 
        if Weapon <> nil then 
        Weapon.MoveToBody(Self.RightHand,0); 
        else Self.DisplayText('Weapon2 wasnt found in opened backpack!'); 
      end; 
    end;
  end;
  sleep(100);
end;

0 comments

Postar um comentário