Advertisement
Guest User

LL Advanced Training 2.0

a guest
Aug 24th, 2015
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.40 KB | None | 0 0
  1. if(t ~= nil) then -- if script is already running then
  2. timer_setEnabled(t, false) -- stop the script
  3. object_destroy(t)
  4. t = nil
  5. end
  6.  
  7. if(attachtimer ~= nil) then -- if script is already running then
  8. timer_setEnabled(t, false) -- stop the script
  9. object_destroy(t)
  10. t = nil
  11. end
  12.  
  13. errorOnLookupFailure(false) -- wont throw a shitload of errors when not in a match
  14.  
  15. --[[----------------------------------------------------------------------------
  16. Variables
  17. --]]----------------------------------------------------------------------------
  18. tickrate = 50 -- How often main() is called in milliseconds. 50ms is once every 3 frames.
  19. attachrate = 5000 -- How often CE will attempt to attach to the LL process.
  20.  
  21. injectcountdown = -1
  22. hotkeycooldown = 0
  23. cooldown = 0 -- Reduces by 1 every tick. Hotkeys can not be used if cooldown > 0
  24. freezeballspeed = false -- When true, ball speed can not change.
  25. infspecialmeter = false -- When true, special meter will always be full
  26. frozenspeed = 0 -- the value that ballspeed will be frozen to
  27.  
  28. editmode = true
  29. ballstateonhit = 5
  30. anglemode = "no repeat"
  31. p2directionmode = "saved"
  32. endwait = 1200
  33. p2spawndirection = 0
  34. balldirection = 0
  35.  
  36. ResetServeHotkey = 200
  37. SpawnCorpseHotkey = 200
  38. EditModeHotkey = 200
  39. NeutralAttackHotkey = 200
  40.  
  41. --[[----------------------------------------------------------------------------
  42. Addresses
  43. --]]----------------------------------------------------------------------------
  44. ballx = '[ballcoords]+18'
  45. bally = '[ballcoords]+1c'
  46. ballexists = '[ballstate]+1d'
  47. ballspeed = '[ballstate]+12c'
  48. balltag = '[ballstate]+130'
  49. ballxspeed = '[ballstate]+13c'
  50. ballyspeed = '[ballstate]+140'
  51. ballstate = '[ballstate]+144'
  52. serveresettimer = '[ballstate]+178'
  53. servelowertimer = '[ballstate]+17c'
  54.  
  55. p1specialmeter = '[p1state]+150'
  56. p1respawntimer = '[p1state]+14c'
  57.  
  58. p2direction = '[p2state]+4'
  59. p2exists = '[p2state]+1d'
  60. p2floats = '[p2state]+1e'
  61. p2state = '[p2state]+134'
  62. p2respawntimer = '[p2state]+14c'
  63.  
  64. p2xcoord = '[p2coords]+18'
  65. p2ycoord = '[p2coords]+1c'
  66.  
  67. servespawnx = '[ballrespawn]+12c'
  68. stagexorigin = '[stagebase]+1c'
  69. stagexsize = '[stagebase]+24'
  70. --[[----------------------------------------------------------------------------
  71. Gets addresses for various memory regions using code injection
  72. --]]----------------------------------------------------------------------------
  73. function getAddresses()
  74. autoAssemble([[
  75. aobscanmodule(ball_inject_point,lethalleague.exe,8B 81 CC 00 00 00 8B 50 70 8B 86 A8 02 00 00 57)
  76. aobscanmodule(dev_inject_point,lethalleague.exe,8D 8E 80 00 00 00 FF 15 ?? ?? ?? ?? 8B 08 89 8E 90 00 00 00)
  77. aobscanmodule(stage_inject_point,lethalleague.exe,BB 01 00 00 00 89 45 FC 8B 87 A4 00 00 00 DB 45 FC)
  78. aobscanmodule(charselect_p_inject_point,lethalleague.exe,8B F1 8B 4E 10 57 E8 ?? ?? ?? ?? 8B 8E 98 00 00 00 8B 01)
  79. aobscanmodule(player_inject_point,lethalleague.exe,8B F1 8B 46 70 8B 88 CC 00 00 00 8B 51 70 8B 86 9C 02 00 00)
  80. aobscanmodule(reset_inject_point,lethalleague.exe,8D 8D 28 FF FF FF 68 ?? ?? ?? ?? 51 E8 ?? ?? ?? ?? 83 C4 08 50 E8 ?? ?? ?? ?? 83 C4 08 50 E8 ?? ?? ?? ?? 83 C4 08 39 5E 30)
  81. aobscanmodule(ballrespawn_inject_point,lethalleague.exe,89 8E F0 00 00 00 8B 5D 08 83 BF 10 01 00 00 08)
  82.  
  83. registersymbol(ball_inject_point)
  84. registersymbol(ballrespawn_inject_point)
  85. registersymbol(dev_inject_point)
  86. registersymbol(stage_inject_point)
  87. registersymbol(charselect_p_inject_point)
  88. registersymbol(player_inject_point)
  89. registersymbol(reset_inject_point)
  90.  
  91. alloc(code,1024)
  92. label(ball_code)
  93. label(ball_return)
  94. label(dev_code)
  95. label(dev_return)
  96. label(stage_code)
  97. label(stage_return)
  98. label(charselect_p_code)
  99. label(charselect_p_end)
  100. label(charselect_p_return)
  101. label(player_code)
  102. label(player_code_notp1base)
  103. label(player_end)
  104. label(player_return)
  105. label(reset_code)
  106. label(reset_return)
  107. label(ballrespawn_code)
  108. label(ballrespawn_return)
  109.  
  110. globalalloc(ballbase, 4)
  111. globalalloc(ballcoords, 4)
  112. globalalloc(ballstate, 4)
  113. globalalloc(ballrespawn, 4)
  114. globalalloc(devbase, 4)
  115. globalalloc(stagebase, 4)
  116. globalalloc(charselect_p1, 4)
  117. globalalloc(charselect_p2, 4)
  118. globalalloc(charselect_p3, 4)
  119. globalalloc(charselect_p4, 4)
  120. globalalloc(charselect_currentplayer, 4)
  121. globalalloc(p1base, 4)
  122. globalalloc(p2base, 4)
  123. globalalloc(p3base, 4)
  124. globalalloc(p4base, 4)
  125. globalalloc(currentplayer, 4)
  126. globalalloc(p1coords, 4)
  127. globalalloc(p2coords, 4)
  128. globalalloc(p3coords, 4)
  129. globalalloc(p4coords, 4)
  130. globalalloc(p1state, 4)
  131. globalalloc(p2state, 4)
  132. globalalloc(p3state, 4)
  133. globalalloc(p4state, 4)
  134.  
  135. code:
  136. int 3
  137. int 3
  138. int 3
  139. int 3
  140. ball_code:
  141. mov eax,[ecx+000000CC]
  142. mov [ballbase],esi
  143. mov esi,[esi+14]
  144. mov [ballcoords],esi
  145. mov esi,[ballbase]
  146. mov esi,[esi+194]
  147. mov [ballstate],esi
  148. mov esi,[ballbase]
  149. jmp ball_return
  150. ballrespawn_code:
  151. mov [esi+000000F0],ecx
  152. mov [ballrespawn],esi
  153. jmp ballrespawn_return
  154. dev_code:
  155. lea ecx,[esi+00000080]
  156. mov [devbase],esi
  157. jmp dev_return
  158. stage_code:
  159. mov ebx,00000001
  160. mov [stagebase],ecx
  161. jmp stage_return
  162. charselect_p_code:
  163. mov esi,ecx
  164. mov ecx,[esi+10]
  165. push eax
  166. push ecx
  167. mov eax,[charselect_currentplayer]
  168. mov ecx,10
  169. mul ecx
  170. mov [charselect_p1+eax],esi
  171. mov eax,[charselect_currentplayer]
  172. inc al
  173. cmp al,04
  174. jb charselect_p_end
  175. mov al,00
  176. charselect_p_end:
  177. mov [charselect_currentplayer],al
  178. pop ecx
  179. pop eax
  180. jmp charselect_p_return
  181. player_code:
  182. mov esi,ecx
  183. mov eax,[esi+70]
  184. push eax
  185. push ebx
  186. push ecx
  187. mov eax,[currentplayer]
  188. cmp [p1base],esi
  189. jne player_code_notp1base
  190. mov al,00
  191. mov [currentplayer],al
  192. player_code_notp1base:
  193. mov ecx,10
  194. mul ecx
  195. mov [p1base+eax],esi
  196. mov ebx,[esi+14]
  197. mov [p1coords+eax],ebx
  198. mov ebx,[esi+194]
  199. mov [p1state+eax],ebx
  200. mov eax,[currentplayer]
  201. inc al
  202. cmp al,04
  203. jb player_end
  204. mov al,00
  205. player_end:
  206. mov [currentplayer],al
  207. pop ecx
  208. pop ebx
  209. pop eax
  210. jmp player_return
  211. reset_code:
  212. lea ecx,[ebp-000000D8]
  213. mov [ballbase],00000000
  214. mov [ballstate],00000000
  215. mov [ballcoords],00000000
  216. mov [ballrespawn],00000000
  217. mov [stagebase],00000000
  218. mov [charselect_p1],00000000
  219. mov [charselect_p2],00000000
  220. mov [charselect_p3],00000000
  221. mov [charselect_p4],00000000
  222. mov [charselect_currentplayer],00000000
  223. mov [p1base],00000000
  224. mov [p2base],00000000
  225. mov [p3base],00000000
  226. mov [p4base],00000000
  227. mov [currentplayer],00000000
  228. mov [p1coords],00000000
  229. mov [p2coords],00000000
  230. mov [p3coords],00000000
  231. mov [p4coords],00000000
  232. mov [p1state],00000000
  233. mov [p2state],00000000
  234. mov [p3state],00000000
  235. mov [p4state],00000000
  236. jmp reset_return
  237.  
  238. ball_inject_point:
  239. jmp ball_code
  240. nop
  241. ball_return:
  242.  
  243. ballrespawn_inject_point:
  244. jmp ballrespawn_code
  245. nop
  246. ballrespawn_return:
  247.  
  248. dev_inject_point:
  249. jmp dev_code
  250. nop
  251. dev_return:
  252.  
  253. stage_inject_point:
  254. jmp stage_code
  255. stage_return:
  256.  
  257. charselect_p_inject_point:
  258. jmp charselect_p_code
  259. charselect_p_return:
  260.  
  261. player_inject_point:
  262. jmp player_code
  263. player_return:
  264.  
  265. reset_inject_point:
  266. jmp reset_code
  267. nop
  268. reset_return:
  269. ]])
  270. end
  271. --[[----------------------------------------------------------------------------
  272. Injects into neutral attack functions and defines 4 variables
  273. forceattack: Set to 1 to set "forcedplayer" to do a neutral attack
  274. forcedplayer: Set to 0 for p1, 1 for p2, etc
  275. aimdown: set to 1 and forcedplayer will aim their next attack down
  276. aimup: set to 1 and forcedplayer will aim their next attack up (down takes priority)
  277. --]]----------------------------------------------------------------------------
  278. function hookNeutralAttack()
  279. autoAssemble([[
  280. aobscanmodule(nattack_inject_point,lethalleague.exe,FF D2 8B CE 84 C0 74 0B 6A 00 E8 ?? ?? ?? ?? 5E C2 04 00)
  281. aobscanmodule(aimdown_inject_point,lethalleague.exe,FF D2 84 C0 74 40 8B 87 ?? ?? ?? ?? 80 78 1E 00)
  282. aobscanmodule(aimdown_extrajump,lethalleague.exe,8B 17 8B 82 B0 00 00 00 6A 00 8B CF FF D0 84 C0 74 11)
  283. aobscanmodule(aimup_inject_point,lethalleague.exe,FF D0 84 C0 74 11 8B 8F 74 02 00 00 89 0E 8B 97)
  284. aobscanmodule(aimup_extrajump,lethalleague.exe,5F 8B C6 5E 5B 5D C2 08 00 55 8B EC 53 56 57 8B)
  285. registersymbol(nattack_inject_point)
  286. registersymbol(aimdown_inject_point)
  287. registersymbol(aimdown_extrajump)
  288. registersymbol(aimup_inject_point)
  289. registersymbol(aimup_extrajump)
  290.  
  291. alloc(ncode,1024)
  292. label(nattack_code)
  293. label(nattack_end)
  294. label(nattack_return)
  295. label(aimdown_code)
  296. label(aimdown_end)
  297. label(aimdown_return)
  298. label(aimup_code)
  299. label(aimup_end)
  300. label(aimup_return)
  301.  
  302. globalalloc(forceattack, 4)
  303. globalalloc(forcedplayer, 4)
  304. globalalloc(aimdown, 4)
  305. globalalloc(aimup, 4)
  306.  
  307. ncode:
  308. int 3
  309. int 3
  310. int 3
  311. int 3
  312. nattack_code:
  313. call edx
  314. mov ecx,esi
  315. push ebx
  316. push eax
  317. mov eax,[forcedplayer]
  318. mov ebx, 10
  319. mul ebx
  320. cmp ecx,[p1base+eax]
  321. pop eax
  322. pop ebx
  323. jne nattack_end
  324. cmp [forceattack],01
  325. jne nattack_end
  326. mov al,01
  327. mov [forceattack],00
  328. nattack_end:
  329. test al,al
  330. jmp nattack_return
  331. aimdown_code:
  332. call edx
  333. cmp [aimdown],01
  334. jne aimdown_end
  335. mov al,01
  336. mov [aimdown],0
  337. aimdown_end:
  338. test al,al
  339. je aimdown_extrajump
  340. jmp aimdown_return
  341. aimup_code:
  342. call eax
  343. cmp [aimup],01
  344. jne aimup_end
  345. mov al,01
  346. mov [aimup],0
  347. aimup_end:
  348. test al,al
  349. je aimup_extrajump
  350. jmp aimup_return
  351.  
  352. nattack_inject_point:
  353. jmp nattack_code
  354. nop
  355. nattack_return:
  356.  
  357. aimdown_inject_point:
  358. jmp aimdown_code
  359. nop
  360. aimdown_return:
  361.  
  362. aimup_inject_point:
  363. jmp aimup_code
  364. nop
  365. aimup_return:
  366. ]])
  367. end
  368. --[[----------------------------------------------------------------------------
  369. This function is called whenever a hotkey togglebox is clicked.
  370. If a togglebox is toggled on, it will set hotkeycooldown to 25. This will
  371. dissalow any other togglebox from being toggled on until main() is called 25 times.
  372. If the togglebox is on already and is toggled off manually, it will set
  373. hotkeycooldown to 0 so that another togglebox can be toggled immediately.
  374. --]]----------------------------------------------------------------------------
  375. function hotkeyToggleBoxChange(sender)
  376. -- if the box is toggled on and no other box is toggled on
  377. if sender.getState() == 1 and hotkeycooldown == 0 then
  378. hotkeycooldown = 25 -- no box can be toggled on for 25 ticks
  379. -- if the box is toggled on, and another box is already toggled on
  380. elseif sender.getState() == 1 and hotkeycooldown ~= 0 then
  381. sender.setState(0) -- toggle the box back off
  382. -- if the box is toggled off before the hotkeycooldown runs out
  383. elseif sender.getState() == 0 and hotkeycooldown ~= 0 then
  384. hotkeycooldown = 0 -- set hotkeycooldown to 0 so other boxes can be toggled
  385. end
  386. end
  387. --[[----------------------------------------------------------------------------
  388. This function will run once for every togglebox every time main() is called.
  389. Returns the VK code of a hotkey if the togglebox is waiting for a key. If
  390. the hotkeycooldown gets to 0, it will toggle it off and clear the caption.
  391. --]]----------------------------------------------------------------------------
  392. function checkHotkey(togglebox, previousHotkey)
  393. -- if the togglebox is not toggled
  394. if togglebox.getState() == 0 then
  395. return previousHotkey
  396. -- if the togglebox is toggled on and the hotkeycooldown is still ticking down
  397. elseif togglebox.getState() == 1 and hotkeycooldown ~= 0 then
  398. togglebox.setCaption("[waiting]") -- indicate that it is waiting for a keypress
  399. key = getKeyPress() -- get the VK code of the key that is pressed
  400. if key ~= nil then -- if a key is pressed
  401. cooldown = 5 -- set the cooldown to 20 so the hotkey isnt activated right as its binded.
  402. hotkeycooldown = 0 -- free up other boxes to be toggled
  403. togglebox.setState(0) -- untoggle the box
  404. if key == 27 then -- if the key is 27 (ESC key)
  405. togglebox.setCaption("[click to bind]") -- clear the caption
  406. return 200 -- end the function, clear the keybind (200 is not a valid VK code)
  407. end
  408. togglebox.setCaption(convertKeyComboToString(key)) -- set the boxes caption to the key pressed
  409. return key -- return the key so it can be used elsewhere in the script
  410. else return previousHotkey -- don't change the hotkey
  411. end
  412. -- if the togglebox is toggled on and the hotkeycooldown runs out
  413. elseif togglebox.getState() == 1 and hotkeycooldown == 0 then
  414. togglebox.setState(0) -- toggle the box off
  415. togglebox.setCaption("[click to bind]") -- restore the "[click to bind]" caption
  416. return 200 -- end the function, clear the keybind (200 is not a valid VK code)
  417. end
  418. end
  419. --[[----------------------------------------------------------------------------
  420. Returns the Virtual-Key Code of a key that is pressed when this function is
  421. called. If multiple keys are pressed, then it will return the one with the lower
  422. Virtual-Key Code. http://wiki.cheatengine.org/index.php?title=Virtual-Key_Code
  423. --]]----------------------------------------------------------------------------
  424. function getKeyPress()
  425. vk = 3 -- start at 3 so left and right mouse button arent bindable
  426. while vk <= 165 do -- end at 165 becase its the last VK code
  427. if isKeyPressed(vk) then return vk end
  428. vk = vk + 1
  429. end
  430. end
  431. --[[----------------------------------------------------------------------------
  432. This function resets the ball to the serve position
  433. --]]----------------------------------------------------------------------------
  434. function resettoserve()
  435. writeBytes(getAddress(ballstate), 14) -- sets the ballstate to respawn mode
  436. writeInteger(getAddress(serveresettimer), 300000) -- skips the wait to respawn
  437. sleep(200) -- wait 200ms before lowering the ball
  438. writeInteger(getAddress(servelowertimer), 140000) -- lowers the ball early
  439. end
  440. --[[----------------------------------------------------------------------------
  441. This function kills p2 to spawn a corpse, and then instantly respawns and moves
  442. p2 back to the position they were at previously with the same orientation.
  443. --]]----------------------------------------------------------------------------
  444. function spawnCorpse()
  445. --Despawns the ball so it doesnt get in the way of corpse combos, but checks if
  446. --you are in training mode first. So you can't accidentally despawn the ball in
  447. --training mode. Reading a P2 value is an easy way to check if you are in training mode
  448. --because p2 is not in training mode.
  449. --Toggling edit mode in versus mode will bring the ball back
  450. if readBytes(getAddress(p2direction)) ~= nil then
  451. writeBytes(getAddress(ballexists), 0)
  452. end
  453.  
  454. --save position and direction p2 is facing so that he can be respawned to his
  455. --previous position right after he dies.
  456. c_savedp2direction = readInteger(getAddress(p2direction))
  457. c_savedp2xcoord = readInteger(getAddress(p2xcoord))
  458. c_savedp2ycoord = readInteger(getAddress(p2ycoord))
  459.  
  460. writeInteger(getAddress(p2state), 3) --kill p2 to spawn a corpse
  461. writeInteger(getAddress(p2respawntimer), 200000) --skip the respawn wait for p2
  462.  
  463. sleep(50) --wait 6 frames to give time for p2 to spawn
  464.  
  465. --move p2 back to the saved coordinates and facing the right direciton.
  466. writeInteger(getAddress(p2xcoord), c_savedp2xcoord)
  467. writeInteger(getAddress(p2ycoord), c_savedp2ycoord)
  468. writeInteger(getAddress(p2direction), c_savedp2direction)
  469. --makes p2 float so we can get corpses spawned from the air.
  470. writeBytes(getAddress(p2floats), 1)
  471. end
  472. --[[----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  473. Spawns p2
  474. Parameters
  475. x: xcoord of p2
  476. y: ycoord of p2
  477. dir: direction p2 is facing, 1 = right, 0 = left
  478. floats: controls if p2 falls or not. 1 = p2 floats, 0 = p2 falls
  479. --]]----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  480. function spawnP2(x, y, dir, floats)
  481. writeInteger(getAddress(p2xcoord), x)
  482. writeInteger(getAddress(p2ycoord), y)
  483. writeBytes(getAddress(p2direction), dir)
  484. writeBytes(getAddress(p2floats), floats)
  485. writeBytes(getAddress(p2exists), 1)
  486. end
  487. --[[----------------------------------------------------------------------------
  488. This function resets the ball to the serve position fast
  489. --]]----------------------------------------------------------------------------
  490. function fastresettoserve()
  491. writeBytes(getAddress(ballstate), 14) -- sets the ballstate to respawn mode
  492. writeInteger(getAddress(serveresettimer), 300000) -- skips the wait to respawn
  493. sleep(20) -- wait 200ms before lowering the ball
  494. writeInteger(getAddress(servelowertimer), 164892) -- lowers the ball early
  495. end
  496. --[[----------------------------------------------------------------------------
  497. --]]----------------------------------------------------------------------------
  498. function toggleEditMode()
  499.  
  500. if editmode then
  501. editmode = false
  502. writeBytes(getAddress(p2exists), 0) -- p2 dissapears
  503. writeBytes(getAddress(ballexists), 0) -- ball dissapears
  504. --save coordinates and direction for p2
  505. savedp2xcoord = readInteger(getAddress(p2xcoord))
  506. savedp2ycoord = readInteger(getAddress(p2ycoord))
  507. savedp2direction = readInteger(getAddress(p2direction))
  508.  
  509.  
  510. elseif not editmode then
  511. editmode = true
  512. spawnP2(savedp2xcoord, savedp2ycoord, savedp2direction, 1)
  513. writeBytes(getAddress(ballexists), 1)
  514. writeInteger(getAddress(p1respawntimer), 0)
  515. writeInteger(getAddress(p2respawntimer), 0)
  516. fastresettoserve()
  517. end
  518.  
  519. end
  520. --[[----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  521. Chooses the direction p2 will face on ball hit depending on the p2directionmode
  522. Parameters
  523. dir: The direction p2 was facing on the previous hit
  524. Return Value: New direction of p2 (1 = right, 0 = left)
  525. --]]----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  526. function chooseP2Direction(dir)
  527. if p2directionmode == "random" then return math.random(0,1) -- p2spawndirection is randomized (0 or 1)
  528. elseif p2directionmode == "saved" then return savedp2direction -- p2spawndirection uses the savedp2direction
  529. elseif p2directionmode == "cycle" then -- p2spawndirection cycles from 1 to 0
  530. if dir == 0 then
  531. return 1
  532. elseif dir == 1 then
  533. return 0
  534. end
  535. end
  536. end
  537. --[[----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  538. Chooses the direction of the ball depending on the anglemode
  539. Parameters
  540. dir: the direction of the ball on the previous hit
  541. Return Value: New direction of the ball (-1 = down, 0 = straight, 1 = up)
  542. --]]----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  543. function chooseBallDirection(dir)
  544. if anglemode == "no repeat" then -- Gets a random direction, but never repeats the last direction.
  545. old = dir
  546. while dir == old do -- while the direction is still the same as the last direction
  547. dir = math.random(-1, 1) -- get a random direction
  548. end
  549. return dir
  550. elseif anglemode == "cycle" then -- Cycles through directions.
  551. if dir == 0 then return 1
  552. elseif dir == 1 then return -1
  553. elseif dir == -1 then return 0
  554. end
  555. elseif anglemode == "random" then return math.random(-1, 1)
  556. elseif anglemode == "up" then return 1 -- Direction is always up.
  557. elseif anglemode == "straight" then return 0 -- Direction is always straight.
  558. elseif anglemode == "down" then return -1 -- Direction is always down.
  559. end
  560. end
  561. --[[----------------------------------------------------------------------------
  562. --]]----------------------------------------------------------------------------
  563. function hitBall(p2x, p2y, p2dir, balldir, state)
  564.  
  565. spawnP2(p2x, p2y, p2dir, 1)
  566. if balldir == 1 then --if ball direction is up
  567. writeBytes(getAddress("aimup"), 1) -- set symbol aimup to 1
  568. elseif balldir == -1 then --if ball direction is down
  569. writeBytes(getAddress("aimdown"), 1) -- set symbol aimdown to 1
  570. end
  571. writeBytes(getAddress("forcedplayer"), 1) -- set the player that attacks to p2
  572. writeBytes(getAddress("forceattack"), 1) -- forces player to attack
  573. --moves ball into p2's hitbox
  574. writeInteger(getAddress(ballx), readInteger(getAddress(p2xcoord)))
  575. writeInteger(getAddress(bally), readInteger(getAddress(p2ycoord)))
  576.  
  577. writeBytes(getAddress(ballstate), state) -- set the ball state
  578. writeBytes(getAddress(ballexists), 1)
  579.  
  580. sleep(50) -- wait for the ball to get hit
  581.  
  582. oldballx = readInteger(getAddress(ballx)) --
  583. while oldballx == readInteger(getAddress(ballx)) do -- wait for the ball to start moving
  584. sleep(50)
  585. end
  586. sleep(250) -- wait a bit longer for p2 to return to neutral state
  587. writeBytes(getAddress(p2exists), 0) -- despawn p2
  588. sleep(endwait) -- give more time for the ball to move
  589. writeBytes(getAddress(ballexists), 0) -- despawn the ball
  590.  
  591. end
  592. --[[----------------------------------------------------------------------------
  593. This function is called when the "Infinite Special Meter" checkbox is changed.
  594. It changes the infspecialmeter boolean to true when it is checked, and false
  595. when unchecked.
  596. --]]----------------------------------------------------------------------------
  597. function ISCheckBoxChange(sender)
  598. if sender.getState() == 1 then
  599. infspecialmeter = true
  600. else
  601. infspecialmeter = false
  602. end
  603. end
  604. --[[----------------------------------------------------------------------------
  605. This function is called when the "Freeze Ballspeed" checkbox is changed. When
  606. checked it changes the freezeballspeed boolean to true and saves the current
  607. ballspeed so we know what to freeze it to. If it is unchecked then it changes
  608. the freezeballspeed boolean to false.
  609. --]]----------------------------------------------------------------------------
  610. function FBCheckBoxChange(sender)
  611. if sender.getState() == 1 then
  612. freezeballspeed = true
  613. frozenspeed = readInteger(getAddress(ballspeed))
  614. else
  615. freezeballspeed = false
  616. end
  617. end
  618. --[[----------------------------------------------------------------------------
  619. This function is called when the "Remove Corpse Combo Limit" checkbox is changed.
  620. When the checkbox is checked, the limit is removed. When it is unchecked the
  621. limit is not removed.
  622. --]]----------------------------------------------------------------------------
  623. function RCLCheckBoxChange(sender)
  624. if sender.getState() == 1 then
  625. autoAssemble([[
  626. aobScanModule(corpselimit,lethalleague.exe,83 B8 54 01 00 00 05)
  627. corpselimit:
  628. cmp dword ptr [eax+00000154],-01
  629. ]])
  630. elseif sender.getState() == 0 then
  631. autoAssemble([[
  632. aobScanModule(corpselimit,lethalleague.exe,83 B8 54 01 00 00 FF)
  633. corpselimit:
  634. cmp dword ptr [eax+00000154],5
  635. ]])
  636. end
  637. end
  638. --[[----------------------------------------------------------------------------
  639. This function is called with the Angle Mode combo box is changed. It gets the
  640. current index of the combo box and sets the anglemode variable to the
  641. corresponding mode.
  642. --]]----------------------------------------------------------------------------
  643. function AMComboBoxChange(sender)
  644. i = sender.getItemIndex()
  645. if i == 0 then anglemode = "no repeat"
  646. elseif i == 1 then anglemode = "random"
  647. elseif i == 2 then anglemode = "cycle"
  648. elseif i == 3 then anglemode = "up"
  649. elseif i == 4 then anglemode = "straight"
  650. elseif i == 5 then anglemode = "down"
  651. end
  652. end
  653. --[[----------------------------------------------------------------------------
  654. This function is called with the Direction Mode combo box is changed. It gets the
  655. current index of the combo box and sets the p2directionmode variable to the
  656. corresponding mode.
  657. --]]----------------------------------------------------------------------------
  658. function DMComboBoxChange(sender)
  659. i = sender.getItemIndex()
  660. if i == 0 then p2directionmode = "saved"
  661. elseif i == 1 then p2directionmode = "random"
  662. elseif i == 2 then p2directionmode = "cycle"
  663. end
  664. end
  665. --[[----------------------------------------------------------------------------
  666. This function is called with the Hitpause Mode combo box is changed. It gets the
  667. current index of the combo box and sets the ballstateonhit variable to the
  668. corresponding value.
  669. --]]----------------------------------------------------------------------------
  670. function HMComboBoxChange(sender)
  671. i = sender.getItemIndex()
  672. if i == 0 then ballstateonhit = 5 --ballstate 5 is a neutral attack
  673. elseif i == 1 then ballstateonhit = 10 --ballstate 10 is bunted
  674. end
  675. end
  676. --[[----------------------------------------------------------------------------
  677. This function is called when the text in the end wait edit box is changed.
  678. --]]----------------------------------------------------------------------------
  679. function EWEditChange(sender)
  680. text = getProperty(sender, "Text") -- get the "Text" property of the text box
  681. if text == "" then -- if the text box is empty (has been cleared by the user)
  682. endwait = 0 -- set the endwait to 0
  683. setProperty(sender, "Text", endwait) -- set the text to the endwait (0)
  684. elseif tonumber(text) == nil then -- if the text can not be converted to a number
  685. setProperty(sender, "Text", endwait) -- roll back the change (only numbers can be used in the box)
  686. elseif tonumber(text) > 100000 then -- if editmode is greater than 100000 (100 seconds)
  687. setProperty(sender, "Text", endwait) -- roll back the change (above 100 seconds is not allowed)
  688. else -- if the text box isnt empty and can be converted to a number
  689. endwait = tonumber(text) -- set the new endwait
  690. end
  691. end
  692. --[[----------------------------------------------------------------------------
  693. This function is called when the Serve Position radio group is changed.
  694. It gets the index of the radio group and then calculates and sets the x coordinate
  695. of the serve spawn position.
  696. --]]----------------------------------------------------------------------------
  697. function ServePosChangeBounds(sender)
  698. leftwall = readInteger(getAddress(stagexorigin)) -- get the x coord of the left wall
  699. width = readInteger(getAddress(stagexsize)) -- get the width of the stage
  700. rightwall = leftwall + width -- get the x coord of the right wall
  701. i = sender.getItemIndex()
  702. if i == 0 then -- if the serve position is set to "Left Wall"
  703. -- write the x coord for the left wall serve position
  704. -- (xcoord of the left wall + 25% of the width of the stage + 50px) * 2^16
  705. writeInteger(getAddress(servespawnx), (leftwall + (width * 0.25) + 50) * 2^16)
  706. elseif i == 1 then -- if the serve position is set to "Mid Stage"
  707. -- write the x coord for middle of the stage
  708. -- (xcoord of the left wall + 50% of the width of the stage) * 2^16
  709. writeInteger(getAddress(servespawnx), (leftwall + (width * 0.5)) * 2^16)
  710. elseif i == 2 then -- if the serve position is set to "Right Wall"
  711. -- write the x coord for the right wall serve position
  712. -- (xcoord of the right wall - 25% of the width of the stage - 50px) * 2^16
  713. writeInteger(getAddress(servespawnx), (rightwall - (width * 0.25) - 50) * 2^16)
  714. end
  715. end
  716. --[[----------------------------------------------------------------------------
  717. This function is called when the "About" button is clicked. It displays the
  718. about message
  719. --]]----------------------------------------------------------------------------
  720. function AboutClick()
  721. showMessage("LL Advanced Training 2.0 created by Smellyhobo101 for Lethal Leauge 1.0.7.12. Check the readme for usage instructions.")
  722. end
  723. --[[----------------------------------------------------------------------------
  724. This function is called when the "Close" button is clicked. It closes CE.
  725. --]]----------------------------------------------------------------------------
  726. function CloseClick()
  727. closeCE()
  728. return caFree
  729. end
  730. --[[----------------------------------------------------------------------------
  731. Attempts to attach to the lethal leauge process. Runs every 5000ms. If it attaches
  732. sucessfully it will then run getAddresses() and hookNeutralAttack() the next
  733. time the function is called.
  734. --]]----------------------------------------------------------------------------
  735. function attach()
  736. -- Get the Process ID of the Lethal Leauge process
  737. GameID = getProcessIDFromProcessName("LethalLeague.exe")
  738.  
  739. -- If Lethal League is running AND CE is not attached to the right process
  740. if GameID ~= nil and GameID ~= getOpenedProcessID() then
  741. openProcess("LethalLeague.exe") -- Attach to the LL process
  742. injectcountdown = 20 -- run injection stuff after 20 main() ticks (1 second)
  743. end
  744. end
  745. --[[----------------------------------------------------------------------------
  746. This is the main function. Is is called every 50ms.
  747. --]]----------------------------------------------------------------------------
  748. function main()
  749.  
  750. -- when the inject countdown reaches 0
  751. if injectcountdown == 0 then
  752. -- Call injection stuff
  753. getAddresses()
  754. hookNeutralAttack()
  755. injectcountdown = -1 -- Don't inject the next time
  756. end
  757.  
  758. --reduce the cooldowns by 1 every tick until they are 0
  759. if cooldown > 0 then cooldown = cooldown - 1 end
  760. if hotkeycooldown > 0 then hotkeycooldown = hotkeycooldown - 1 end
  761. if injectcountdown > 0 then injectcountdown = injectcountdown - 1 end
  762.  
  763. --if the ball speed is currently frozen, then set it to the frozenspeed
  764. if freezeballspeed then writeInteger(getAddress(ballspeed), frozenspeed) end
  765.  
  766. --if infspecialmeter is true, then set the special meter to 4 bars.
  767. if infspecialmeter then writeInteger(getAddress(p1specialmeter), 6553600) end
  768.  
  769. --when editmode is off make p1 and p2 respawn immediately
  770. if not editmode then
  771. writeInteger(getAddress(p1respawntimer), 200000)
  772. writeInteger(getAddress(p2respawntimer), 200000)
  773. end
  774.  
  775. -- Checks for changes to any of the hotkeys
  776. ResetServeHotkey = checkHotkey(AdvancedTraining.RSToggleBox, ResetServeHotkey)
  777. SpawnCorpseHotkey = checkHotkey(AdvancedTraining.SCToggleBox, SpawnCorpseHotkey)
  778. EditModeHotkey = checkHotkey(AdvancedTraining.EMToggleBox, EditModeHotkey)
  779. NeutralAttackHotkey = checkHotkey(AdvancedTraining.NAToggleBox, NeutralAttackHotkey)
  780.  
  781. if cooldown == 0 then --if the cooldown is 0
  782. if isKeyPressed(SpawnCorpseHotkey) and editmode then
  783. spawnCorpse() --spawn a corpse from p2
  784. cooldown = 5
  785. elseif isKeyPressed(ResetServeHotkey) then
  786. resettoserve() --Reset the ball to the serve position
  787. writeInteger(getAddress(p1specialmeter), 0) --reset p1's special meter
  788. cooldown = 5
  789. elseif isKeyPressed(EditModeHotkey) then
  790. toggleEditMode()
  791. cooldown = 5
  792. elseif isKeyPressed(NeutralAttackHotkey) and not editmode then
  793. p2spawndirection = chooseP2Direction(p2spawndirection)
  794. balldirection = chooseBallDirection(balldirection)
  795. hitBall(savedp2xcoord, savedp2ycoord, p2spawndirection, balldirection, ballstateonhit)
  796. end
  797. end
  798. end
  799. --[[----------------------------------------------------------------------------
  800.  
  801. --]]----------------------------------------------------------------------------
  802.  
  803. form_show(AdvancedTraining) -- show the mod window
  804.  
  805. AdvancedTraining.OnClose = CloseClick -- A tutorial said to do this. I don't know why.
  806.  
  807. t = createTimer(nil, false) -- create a Timer object and assign it to variable t.
  808.  
  809. timer_onTimer(t, main) -- When the timer ticks, call the function main
  810. timer_setInterval(t, tickrate) -- Sets the tickrate of the timer in milliseconds
  811. timer_setEnabled(t, true) -- Turns the timer on
  812.  
  813. attach_timer = createTimer(nil, false) -- create a Timer object and assign it to variable t.
  814. timer_onTimer(attach_timer, attach) -- When the timer ticks, call the function attach
  815. timer_setInterval(attach_timer, attachrate) -- Sets the interval of the timer in milliseconds
  816. timer_setEnabled(attach_timer, true) -- Turns the timer on
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement