Advertisement
toko214

kami + loot

Mar 19th, 2016
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. define(KEY_NORMAL,0)
  2. define(KEY_EXTENDED,1)
  3.  
  4. // you can add more virtual key codes by getting them here
  5. // http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
  6. // for letters, the uppercase character is enough
  7. define(VK_CONTROL,11)
  8.  
  9. // Kami Setting (optional)
  10.  
  11. // 1 if you want the autoattack to trigger combos
  12. // 0 for normal attacks
  13. define(Kami_HoldAttack,0)
  14.  
  15. // attack key
  16. define(Kami_AttackKey,VK_CONTROL)
  17.  
  18. // KEY_EXTENDED if the attack key is an extended key (such as CTRL, ALT, etc...)
  19. // for every other key, use KEY_NORMAL
  20. // NOTE: I dont think this actually matters for maplestory keypresses, but w/e
  21. define(Kami_AttackKeyType,KEY_EXTENDED)
  22.  
  23. // loot key
  24. define(Kami_LootKey,'Z')
  25. define(Kami_LootKeyType,KEY_NORMAL)
  26.  
  27. // X, Y offset (you usually wont need to change this)
  28. define(Kami_RangeX,#0)
  29. define(Kami_RangeY,#0)
  30.  
  31. // loot when items > ...
  32. // Options
  33. // set to -1 to only loot when monsters run out
  34. // set to 30 for looting periodically but not when monsters run out
  35. define(Kami_LootWhen,#30)
  36.  
  37. // Adresses and offsets
  38.  
  39. define(TSingleton_CUserLocal___ms_pInstance,020B7C9C) // A1 ? ? ? ? 85 C0 75 ? 5F C3 8D 48 [POINTER]
  40. define(TSingleton_CMobPool___ms_pInstance,020BC4BC) // 8B 0D ? ? ? ? ? E8 ? ? ? ? 8B ? 85 ? 74 ? 8B ? ? 8B ? ? 8D [POINTER]
  41. define(TSingleton_CWndMan___ms_pInstance,020BC5D4) // 8B ? ? ? ? ? C6 ? ? ? E8 ? ? ? ? 8B ? BA ? ? ? ? C6 [POINTER]
  42. define(CWndMan__OnKey,017ED630) // A1 ? ? ? ? 85 ? 74 ? 8D ? ? 8B ? 8B ? FF ? C2 08 00
  43. define(GetVectorController,0171B170) // E8 ? ? ? ? 85 C0 74 ? B8 ? ? ? ? 5E  [Before Last Green Result & Function Below]
  44. define(TeleportFunc,015901F0) // 8B ? 24 ? 8B ? ? 8B ? ? ? 8D ? ? 8B ? ? ? ? ? ? FF ? 85 C0 ? ? ? ? ? ? ? ? ? E8 [Second Result]
  45. define(TSingleton_CDropPool___ms_pInstance,020BCD70) // 89 3D ? ? ? ? 8D 4E ? C7 [POINTER]
  46. define(pUpdateFunc,01E553C8) // 4-Byte Scan Exact Value UpdateFunc
  47. define(UpdateFunc,0163E120) // 6A ? 68 ? ? ? ? 64 ? ? ? ? ? 50 83 ? ? 56 A1 ? ? ? ? 33 ? 50 8D ? ? ? 64 ? ? ? ? ? 8B ? ? ? ? ? 85 ? 74 ? 8D ? ? ? 50
  48. define(UpdateHook_ret,0161DA0A) // 8B ? ? FF ? 8B ? B8 ? ? ? ? F7 ? C1 ? ? 8B ? C1 ? ? 03 ? 83 ? ? 74 ? 81 ? ? ? ? ? 75 ? 80 ? ? ? ? ? ? 74 [mov ecx,eax]
  49. define(TSingleton_CWvsPhysicalSpace2D___ms_pInstance,020BC4C8) // A1 ? ? ? ? 8B 50 ? 83 C0 [POINTER]
  50. define(pPtInRect,020D090C) // Above PtInRectHook_ret
  51. define(PtInRectHook_ret,00733234) // 85 C0 75 ? 8D ? 24 ? C7 ? 24 ? ? ? ? ? E8 ? ? ? ? 8B
  52. define(Mob3Offset,1F4) // 83 ? ? ? ? ? ? 0F 84 ? ? ? ? 83 ? ? 39 ? ? ? ? ? 0F 8E ? ? ? ? 68 ? ? ? ? 8D ? ? ? E8 ? ? ? ? 68 ? ? ? ? 8D ? ? ? C7 ? ? ? ? ? ? ? E8 [OFFSET]
  53.  
  54. //--------------------------------------------------//
  55.  
  56. [Enable]
  57. alloc(Kami,512)
  58. label(TeleTopLeft)
  59. alloc(ItemHook,128)
  60. alloc(GetMobXY,512)
  61. alloc(NewTeleportXY,128)
  62. alloc(PressKey,128)
  63. alloc(ItemX,4)
  64. alloc(ItemY,4)
  65. alloc(HoldAttack,1)
  66. alloc(IsLooting,1)
  67. alloc(LootWhen,4)
  68. label(GetMobXYFalse)
  69. label(GetMobXYTrue)
  70. label(TeleportEnd)
  71. label(NextMob)
  72. label(Loot)
  73. label(KamiExit)
  74. label(NoLoot)
  75.  
  76. HoldAttack:
  77. db Kami_HoldAttack
  78.  
  79. LootWhen:
  80. dw Kami_LootWhen
  81.  
  82. IsLooting:
  83. db 0
  84.  
  85. GetMobXY:
  86. push esi
  87. push edx
  88. push ebx
  89. mov esi,[TSingleton_CMobPool___ms_pInstance]
  90. test esi,esi
  91. je GetMobXYFalse
  92. mov edx,[esi+10] // mob count
  93. test edx,edx
  94. je GetMobXYFalse
  95. mov esi,[esi+28] // mob 1
  96. test esi,esi
  97. je GetMobXYFalse
  98. sub esi,10 // mob 1 points to first mob struct + 0x10 for some reason
  99.  
  100. NextMob:
  101. mov edx,[esi+18] //  not mob2
  102. test edx,edx
  103. je GetMobXYFalse
  104. mov edx,[edx+Mob3Offset] // mob 3
  105. test edx,edx
  106. je GetMobXYFalse
  107. mov edx,[edx+24] // mob 4
  108. test edx,edx
  109. je GetMobXYFalse
  110. mov ebx,[edx+68] // mob invx
  111. or ebx,[edx+6C] // mob invy
  112. test ebx,ebx
  113. jne GetMobXYTrue
  114. mov esi,[esi+04] // next mob
  115. test esi,esi
  116. je GetMobXYFalse
  117. jmp NextMob
  118.  
  119. GetMobXYFalse:
  120. pop ebx
  121. pop edx
  122. pop esi
  123. xor eax,eax
  124. ret
  125.  
  126. GetMobXYTrue:
  127. lea eax,[edx+60] // mob x
  128. pop ebx
  129. pop edx
  130. pop esi
  131. ret
  132.  
  133. NewTeleportXY:
  134. mov esi,[TSingleton_CUserLocal___ms_pInstance]
  135. lea ecx,[esi+04]
  136. call GetVectorController
  137. test eax,eax
  138. je TeleportEnd
  139. push ebx
  140. push edx
  141. push 00
  142. mov ecx,eax
  143. call TeleportFunc
  144.  
  145. TeleportEnd:
  146. ret
  147.  
  148. // PressKey flags and internal stuff
  149. define(KEY_PRESS,0)
  150. define(KEY_UP,1)
  151. define(MAPVK_VK_TO_VSC,0)
  152.  
  153. // void __stdcall PressKey(uint32_t virtual_key, uint32_t extended_flag, uint32_t transition_state)
  154. PressKey:
  155. push ebx // backup
  156. push edx // backup
  157. push esi // backup
  158. push ecx // backup
  159.  
  160. mov edx, [esp+10+4] // edx = virtual keycode
  161. mov esi, [esp+10+8] // esi = is extended keycode
  162. mov ebx, [esp+10+C] // ebx = transition state flag
  163. mov ecx, edx        // ecx = virtual keycode (will later contain the scancode)
  164.  
  165. // generate scancode with MapVirtualKeyA(virtual_key, MAPVK_VK_TO_VSC) << 16
  166. // credits to Shadow and Waty
  167. push MAPVK_VK_TO_VSC
  168. push ecx
  169. call MapVirtualKeyA
  170. shl eax,#16
  171. shl esi,#24 // extended flag
  172. shl ebx,#31 // transition state
  173. or eax, esi
  174. or eax, ebx
  175. mov ecx,eax
  176.  
  177. push ecx // lparam (keycode)
  178. push edx // wparam (virtual keycode)
  179. mov ecx,[TSingleton_CWndMan___ms_pInstance]
  180. call CWndMan__OnKey
  181.  
  182. pop ecx // backup
  183. pop esi // backup
  184. pop edx // backup
  185. pop ebx // backup
  186. ret 000C
  187.  
  188. Kami:
  189. cmp dword ptr [esp], UpdateHook_ret
  190. pushad
  191. jne KamiExit
  192.  
  193. mov eax,[TSingleton_CUserLocal___ms_pInstance]
  194. test eax,eax
  195. je KamiExit
  196. call GetMobXY
  197. test eax,eax
  198. je Loot
  199.  
  200. cmp byte ptr [IsLooting], 1
  201. je Loot
  202.  
  203. cmp dword ptr [LootWhen], #-1
  204. je NoLoot
  205. mov esi,[TSingleton_CDropPool___ms_pInstance]
  206. mov esi,[esi+14] // item count offset (shouldnt change)
  207. cmp esi,dword ptr [LootWhen]
  208. jge Loot
  209.  
  210. NoLoot:
  211. mov ebx,[eax+4]
  212. sub ebx,Kami_RangeY
  213. mov edx,[eax]
  214. sub edx,Kami_RangeX
  215. call NewTeleportXY
  216.  
  217. push KEY_PRESS          // transition_state
  218. push Kami_AttackKeyType // extended_flag
  219. push Kami_AttackKey     // virtual_key
  220. call PressKey
  221.  
  222. cmp byte ptr [HoldAttack], 0
  223. je KamiExit
  224.  
  225. push KEY_UP             // transition_state
  226. push Kami_AttackKeyType // extended_flag
  227. push Kami_AttackKey     // virtual_key
  228. call PressKey
  229.  
  230. jmp KamiExit
  231.  
  232. Loot:
  233. mov esi,[TSingleton_CDropPool___ms_pInstance]
  234. mov esi,[esi+14] // item count offset (shouldnt change)
  235. cmp esi,0
  236. je TeleTopLeft
  237.  
  238. mov byte ptr [IsLooting], 1
  239.  
  240. push KEY_PRESS        // transition_state
  241. push Kami_LootKeyType // extended_flag
  242. push Kami_LootKey     // virtual_key
  243. call PressKey
  244.  
  245. mov ebx,[ItemY]
  246. mov edx,[ItemX]
  247. call NewTeleportXY
  248. jmp KamiExit
  249.  
  250. TeleTopLeft:
  251. mov byte ptr [IsLooting], 0
  252. mov edx,[TSingleton_CWvsPhysicalSpace2D___ms_pInstance]
  253. mov edx,[edx+0C] // left offset (shouldnt change)
  254. mov ebx,[TSingleton_CWvsPhysicalSpace2D___ms_pInstance]
  255. mov ebx,[ebx+10] // top offset (shouldnt change)
  256. call NewTeleportXY
  257.  
  258. KamiExit:
  259. popad
  260. jmp UpdateFunc
  261.  
  262. ItemHook:
  263. cmp [esp],PtInRectHook_ret
  264. jne PtInRect
  265. push eax
  266. mov eax,[esp+0C]
  267. mov [ItemX],eax
  268. mov eax,[esp+10]
  269. mov [ItemY],eax
  270. pop eax
  271. jmp PtInRect
  272.  
  273. pUpdateFunc:
  274. dd Kami
  275.  
  276. pPtInRect:
  277. dd ItemHook
  278.  
  279. [Disable]
  280. pUpdateFunc:
  281. dd UpdateFunc
  282.  
  283. pPtInRect:
  284. dd PtInRect
  285.  
  286. dealloc(Kami)
  287. dealloc(ItemHook)
  288. dealloc(GetMobXY)
  289. dealloc(NewTeleportXY)
  290. dealloc(PressKey)
  291. dealloc(TeleTopLeft)
  292. dealloc(ItemX)
  293. dealloc(ItemY)
  294. dealloc(HoldAttack)
  295. dealloc(IsLooting)
  296. dealloc(LootWhen)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement