Guest User

Untitled

a guest
Dec 13th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.46 KB | None | 0 0
  1. unit c;
  2.  
  3. interface
  4. const
  5. FinalCharSet= ['a'..'z']+['A'..'Z']+['а'..'я']+['А'..'Я']+['0'..'9']+['-'..'-'];
  6.  
  7. MonLength = $36c0;
  8.  
  9. CharSelected= $00604530;
  10. MaxZoom = $0060B758;//$00604698;
  11. MinZoom = $005EB83C;//$005e483c;
  12.  
  13. Address_Exp = $011093D0; //Столько опыта на лвл
  14. Over_Exp_Tek = $34FEC; //Текущий опыт игрока
  15.  
  16. TStrOff = $90; //offset to structure of target
  17. //difference is always $74.
  18. MStrOff = $104;
  19.  
  20. CellOff1 = $000023d8-4;
  21. CellOff2 = $000003B8-4;
  22. CellOff3 = $000001A4;
  23.  
  24. BAutoAttackOff = $14E12C;
  25. AAutoAttackOff = $4FC50; // $4FBC8;
  26.  
  27. AutoRunOff = $4FC58; //Автобег
  28.  
  29. BNameOff = $34F4C; // offset to character name from basedata
  30. BHPOff = $34F74;
  31. BMHPOff = $34F70;
  32. BMPOff = $34F7C;
  33. BMMPOff = $34F78;
  34. CameraOff = $412F8;
  35. BDurOff = $350E2;
  36.  
  37. ActOff = $1A9;
  38. LActOff = $1AA;
  39. NameOff = $16B0; // offset to name in structure of monsters
  40. HPOff = $414; // hp }
  41. MHPOff = $418; // max hp }
  42.  
  43. XOff = $14C;
  44. YOff = $150;
  45. ZOff = $154;
  46. DistOff = $404;
  47. PvpSOff = $3F7;
  48. pvpfOff = $40D;
  49. LegOff = $1CCD;
  50. LvlOff = $1B4;
  51.  
  52. LvlOffChar = $34FF0;
  53.  
  54. KeyOff = $49C;
  55.  
  56. MailOff = $328E0E1;
  57.  
  58. // Button_R = $52;
  59. // Button_W = 38;
  60.  
  61. //Shift-state related.
  62. Const
  63. Shift = 16;
  64. Ctrl = 17;
  65. Alt = 18;
  66.  
  67. implementation
  68. uses windows, functions2, math, VarConstType;
  69. //Неиспользуемый код.
  70.  
  71.  
  72.  
  73. /// ///////////////////////////
  74. //
  75. // Adaptation from II
  76. //
  77. // Block of routines begins here
  78. //
  79. /// ///////////////////////////////
  80.  
  81. /// //////////////////////////////////////////////////////////////
  82. /// /// His infernal majesty, Procedure UpdateTarget
  83. /// ///
  84. /// /// Note: Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn
  85. /// //////////////////////////////////////////////////////////////
  86.  
  87. Procedure UpdateTarget(Address: dword;Var Target: pAnyCharacter); overload;
  88. var
  89. BytesRead: dword;
  90. Const
  91. OffsetName = NameOff;
  92. OffsetLevel = LvlOff;
  93. OffsetPvpSign = PvpSOff;
  94. OffsetPvpFlag = pvpFOff;
  95. OffsetTarHp = HPOff;
  96. OffsetAction = ActOff;
  97. OffsetCoord = XOff;
  98. OffsetDist = DistOff;
  99. begin
  100.  
  101. (*
  102.  
  103. //Some exception handling;
  104. if Address=0 then begin
  105. ClearEntry(Target);
  106. Exit;
  107. end;
  108.  
  109. *)
  110.  
  111. Target.name := GetString(Aika.ProcHandle, Address + OffsetName, 16);
  112. ReadProcessMemory(Aika.ProcHandle, ptr(Address + 4), @Target.uid, 4,
  113. BytesRead);
  114.  
  115. ReadProcessMemory(Aika.ProcHandle, ptr(Address + OffsetLevel), @Target.lvl, 2,
  116. BytesRead);
  117. // Read pvp flags
  118. ReadProcessMemory(Aika.ProcHandle, ptr(Address + OffsetPvpSign),
  119. @Target.pvpsign, 1, BytesRead);
  120. ReadProcessMemory(Aika.ProcHandle, ptr(Address + OffsetPvpFlag),
  121. @Target.pvpflag, 1, BytesRead);
  122.  
  123. // Read HP,MaxHp,Mp,MaxMp
  124. ReadProcessMemory(Aika.ProcHandle, ptr(Address + OffsetTarHp), @Target.hp,
  125. 4 * 4, BytesRead);
  126. // read both actions
  127. ReadProcessMemory(Aika.ProcHandle, ptr(Address + OffsetAction), @Target.act,
  128. 2, BytesRead);
  129. // read all coordinates;
  130. ReadProcessMemory(Aika.ProcHandle, ptr(Address + OffsetCoord), @Target.x,
  131. 4 * 3, BytesRead);
  132.  
  133. ReadProcessMemory(Aika.ProcHandle, ptr(Address + OffsetDist), @Target.Dist, 4,
  134. BytesRead);
  135.  
  136. (*
  137. if byte(Target.PvpSign)=1 then Target.PvpSign:=true else Target.PvpSign:=false;
  138. if byte(Target.PvpFlag)=1 then Target.Pvpflag:=true else Target.Pvpflag:=false;
  139. *)
  140. end;
  141.  
  142. Function Valid(Monster: pAnyCharacter;
  143. CheckAttackState: boolean = false): boolean;
  144. begin
  145.  
  146. Result := true;
  147. if (Monster.uid = $FFFFFFFF) Or (Monster.uid = 0) OR
  148. (Monster.hp > Monster.maxhp) OR (Monster.maxmp <> 0) OR (IsNan(Monster.x))
  149. OR (IsNan(Monster.y)) OR (IsNan(Monster.z)) OR (Monster.x = 0) OR
  150. (Monster.y = 0) Then
  151. Result := false;
  152.  
  153. // We are there? Hence result=true and CheckAttackState=True either
  154. // Note that CheckAttackState is optional parameter, in most cases - false;
  155. if Result And CheckAttackState then
  156.  
  157. // Do not try this at home
  158. Result := (Monster.act in [5 .. 7]) or (Monster.act in [21 .. 22]) Or
  159. (Monster.lastact in [5 .. 7]) or (Monster.lastact in [21 .. 22]);
  160.  
  161. end;
  162.  
  163. { ///////////////////////////////////////////////////////////
  164.  
  165. GetNearestDirect Proc:
  166.  
  167. Perform search of nearest to character mob;
  168.  
  169. Note: if custom parameter not specified, he sets to false
  170.  
  171. Algorithm:
  172.  
  173. 1)Create example of tMonster
  174. 2) In cycle //For OhNo:=1 to 256
  175. Read New monster
  176. Check whether monster valid
  177. If yes then inc MobArray(Vincitore) count, add Mob to array
  178.  
  179. 3)Find mob with least distance, In Cycle (for Ohno := 0 to Vincitore - 1)
  180. 4)Set this mob as char current target
  181. 5)Destroy example of tMonster;
  182.  
  183. ////////////////////////////////////////////////////////// }
  184.  
  185. Procedure GetNearestDirect(SearchAggr: boolean = false);
  186. var
  187. OhNo: word;
  188. vincitore: word;
  189. MobArr: array of tAnyCharacter;
  190.  
  191. BytesRead: dword;
  192. //
  193. StartAddress: dword;
  194. Nea: pAnyCharacter;
  195.  
  196. Const
  197. OffsetChar = $DC;
  198. OffsetTarget = $68;
  199. MonsterSize = MonLength;
  200.  
  201. begin
  202. Nea := New(pAnyCharacter);
  203. // Get start address;
  204. ReadProcessMemory(Aika.ProcHandle, ptr(Aika.ActionPtr + OffsetChar),
  205. @StartAddress, 4, BytesRead);
  206. vincitore := 0;
  207.  
  208. // Cycle that infiltrates valid mobs into MobArr;
  209. for OhNo := 1 to 256 do
  210. begin
  211. UpdateTarget(StartAddress + OhNo * MonsterSize, Nea);
  212. if Valid(Nea, SearchAggr) then
  213. begin
  214. Nea.id := OhNo;
  215. inc(vincitore);
  216. SetLength(MobArr, vincitore);
  217. MobArr[vincitore - 1] := Nea^;
  218. end;
  219. end; // for end;
  220.  
  221. // some exception handling;
  222. if vincitore = 0 then
  223. begin
  224. Dispose(Nea);
  225. exit;
  226. end;
  227.  
  228. // get last element
  229. Nea^ := MobArr[vincitore - 1];
  230.  
  231. // get nearest mob
  232. for OhNo := 0 to vincitore - 1 do
  233. if Nea.Dist > MobArr[OhNo].Dist then
  234. Nea^ := MobArr[OhNo];
  235.  
  236. SetLength(MobArr, 0);
  237.  
  238. // compute address of nearest mob.
  239. StartAddress := StartAddress + Nea.id * MonsterSize;
  240.  
  241. WriteProcessMemory(Aika.ProcHandle, ptr(Aika.ActionPtr + OffsetTarget),
  242. @StartAddress, 4, BytesRead);
  243. Dispose(@Nea^);
  244. end;
  245.  
  246. end.
  247.  
  248.  
  249.  
  250.  
  251.  
  252. Const
  253. BasePtr = $025B1D00; //Основной указатель
  254. ActionPtr = BasePtr-$4; //Указатель действий персонажа
  255. PanelPtr = BasePtr+$EC0; //Указатель на панели
Add Comment
Please, Sign In to add comment