Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. Const
  2. Loot_Items = [3031,3585]
  3. Loot = 1
  4. Var
  5. Looting: Boolean
  6. Function GetTileFromXYZ(X, Y, Z: integer): TTile;
  7. begin
  8. Result := nil;
  9. if abs((Self.X - 7) - X) > 14 then
  10. Exit;
  11. if abs((Self.Y - 5) - Y) > 11 then
  12. Exit;
  13. if Self.Z <> Z then
  14. Exit;
  15. Result := Screen.Tile[abs((Self.X - 7) - X), abs((Self.Y - 5) - Y)];
  16. end;
  17.  
  18. Procedure Event_ItemCreated(ID, X, Y, Z: integer);
  19. Var
  20. i: Integer
  21. Tile: TTile;
  22. begin
  23. if not Loot then
  24. Exit;
  25. Tile := GetTileFromXYZ(X, Y, Z);
  26. for i := 0 to Tile.Count-1 do
  27. begin
  28. if i >= Tile.Count then
  29. Break;
  30. if Tile.Item[i].ID = ID then
  31. begin
  32. if Tile.Item[i].Properties.Container then
  33. Tile.Item[i].OpenInNewWindow;
  34. Exit;
  35. end;
  36. end;
  37. end;
  38.  
  39. Procedure Event_ContainerOpened(Index, ID: integer; Name: String);
  40. begin
  41. if not Loot then
  42. Exit;
  43. Looting := True;
  44. end;
  45.  
  46. Function GetItemFromOpenBackpack(ID, Index: integer): TItem;
  47. var
  48. x: integer;
  49. y: integer;
  50. begin
  51. Result := nil;
  52. for x := 0 to Self.Containers.Count - 1 do
  53. begin
  54. if x >= Self.Containers.Count then
  55. Break;
  56. if x = Index then
  57. Continue;
  58. for y := 0 to Self.Containers.Container[x].Count - 1 do
  59. begin
  60. if y >= Self.Containers.Container[x].Count then
  61. Break;
  62. if Self.Containers.Container[x].Item[y].ID = ID then
  63. begin
  64. Result := Self.Containers.Container[x].Item[y];
  65. Exit;
  66. end;
  67. end;
  68. end;
  69. end;
  70.  
  71. Procedure EatFood;
  72. Const
  73. FoodList = [3595,3577,3578,3579,3582,3583,3584,3600,3584,3585, 3586,3587,3588,3589,3590,3591,3592,3593,3594,3598, 3599,3601,3602,3607,3725]
  74. Var
  75. i: Integer
  76. begin
  77. for i := Low(FoodList) to High(FoodList) do
  78. begin
  79. Food := GetItemFromOpenBackpack(FoodList[i], Self.Containers.Count);
  80. if Food <> nil then
  81. begin
  82. Food.Use;
  83. break;
  84. end;
  85. end;
  86. end;
  87.  
  88. function OpenBags: Boolean;
  89. var
  90. x: integer;
  91. y: integer;
  92. begin
  93. Result := False;
  94. for x := 0 to Self.Containers.Count - 1 do
  95. begin
  96. if x >= Self.Containers.Count then
  97. Break;
  98. for y := 0 to Self.Containers.Container[x].Count - 1 do
  99. begin
  100. if y >= Self.Containers.Container[x].Count then
  101. Break;
  102. if Self.Containers.Container[x].Item[y].ID = 2853 then
  103. begin
  104. Self.Containers.Container[x].Item[y].Open;
  105. Result := True;
  106. end;
  107. end;
  108. end;
  109. end;
  110.  
  111. Function SortLoot: Boolean;
  112. var
  113. Item: TItem
  114. begin
  115. Result := False
  116. for x := Low(Loot_Items) to High(Loot_Items) do
  117. begin
  118. if x > High(Loot_Items) then
  119. break;
  120. Item := GetItemFromOpenBackpack(Loot_Items[x], x);
  121. If Item <> nil then
  122. begin
  123. Item.MoveToContainer(Self.Containers.Container[X], 0, 0);
  124. Result := True;
  125. Exit;
  126. end;
  127. end;
  128. end;
  129.  
  130.  
  131. begin
  132. Looting := False
  133. while not Terminated do
  134. begin
  135. //Event_ItemCreated(Screen.Tile[abs((Self.X - 7) - X)], Screen.Tile[abs((Self.Y - 5) - Y)], Self.Z);
  136. //ProcessEvents;
  137. UpdateWorld;
  138. if Looting then
  139. begin
  140. Looting := SortLoot;
  141. if not Looting then
  142. begin
  143. EatFood;
  144. if OpenBags then
  145. Looting := SortLoot;
  146. end;
  147. end;
  148. Sleep(100);
  149. end;
  150. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement