Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. Const
  2. Name=['Dwarf Guard', 'Dwarf Soldier', 'Dwarf']; // nome dos monstros
  3. SwitchAt=30; // the % of the current attacked monster
  4.  
  5. function GetPlace(st:string):integer;
  6. var
  7. x:integer;
  8. begin
  9. Result:=1000;
  10. for x:=Low(Name) To High(Name) do
  11. begin
  12. if Name[x]=st then
  13. Result:=x;
  14. end;
  15. end;
  16.  
  17. function GetCreatureByID(ID: integer): TCreature;
  18. var
  19. x: integer;
  20. begin
  21. Result := nil;
  22. for x := 0 to Creatures.Count - 1 do
  23. begin
  24. if x >= Creatures.Count then Break;
  25. if Creatures.Creature[x].ID = ID then
  26. begin
  27. Result := Creatures.Creature[x];
  28. Exit;
  29. end;
  30. end;
  31. end;
  32.  
  33. function IsCreatureBesideYou(c: TCreature): boolean;
  34. begin
  35. UpdateWorld;
  36. Result := False;
  37. if (abs(c.X-self.X) <= 1) and (abs(c.Y-self.Y) <= 1) then begin if c.Z = self.Z then begin Result := True; end; end; end; var x:integer; b:boolean; begin while not terminated do begin b:=false; updateworld; If (Self.Attacking<>0) then
  38. begin
  39. Creature:=GetCreatureByID(Self.Attacking);
  40. if Creature<>nil then
  41. if SwitchAt= Creatures.Count then Break;
  42. if Creatures.Creature[x].NPC then
  43. if Creatures.Creature[x].z=self.z then
  44. if Creatures.Creature[x].Name<>self.name then
  45. if Creatures.Creature[x].Attacking = false then
  46. if IsCreatureBesideYou(Creatures.Creature[x]) then
  47. if GetPlace(Creature.Name)>GetPlace(Creatures.Creature[x].Name) then
  48. begin
  49. sleep(100);
  50. updateworld;
  51. Creatures.Creature[x].attacking:=true;
  52. B:=true;
  53. end;
  54. end;
  55. end;
  56. end;
  57. Sleep(100);
  58. end;
  59. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement