Advertisement
Guest User

screipt help

a guest
Aug 30th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.68 KB | None | 0 0
  1. -- ##########################################################
  2. -- # -- CONFIGURATION FILE -- #
  3. -- # Please edit this config to match your needs #
  4. -- # Copyright © 2016 imMigno #
  5. -- ##########################################################
  6.  
  7.  
  8. -- The Bot will stop when your whole team achieve that level.
  9. StopLevel = 100
  10.  
  11. -- Once the pokemon hit that level, it will stop switching and fighting by himself.
  12. SwapCap = 70
  13.  
  14. -- Map specific configurations
  15. -- Please insert the Mapnames of your Leveling routine
  16. Pokecenter = "Pokecenter Blackthorn"
  17. City = "Blackthorn City"
  18. Map1 = "Dragons Den Entrance"
  19. Map2 = ""
  20. Map3 = ""
  21. Map4 = ""
  22. Map5 = ""
  23. LevelLocation = "Dragons Den"
  24.  
  25. -- Please choose the method of moving on your Level Location : "Grass", "Water" or "Rectangle".
  26. LevelSpot = "Water"
  27.  
  28. -- Modify below only if you're using Rectangle as movement method.
  29. minX = 3
  30. minY = 15
  31. maxX = 7
  32. maxY = 18
  33.  
  34.  
  35. name = "Universal ExpShare"
  36. author = "imMigno"
  37.  
  38. description = [[
  39. This script will automaticly level the weakest Pokemon on your Team with your strongest
  40. and checks if booth of them are usable ! ]]
  41.  
  42. dofile "config.lua"
  43.  
  44. function onStart()
  45. log(" ")
  46. log("=========== WELCOME | START ============")
  47. log("Welcome to the Universal ExpSharing by imMigno")
  48. log("Version 2.0.6 | Updated: 08-29-2016 | 01.00 AM")
  49. log("====================================")
  50. log(" ")
  51.  
  52. path = 0
  53. trapped = false
  54.  
  55. if Map1 ~= "" then
  56. path = path + 1
  57. end
  58. if Map2 ~= "" then
  59. path = path + 1
  60. end
  61. if Map3 ~= "" then
  62. path = path + 1
  63. end
  64. if Map4 ~= "" then
  65. path = path + 1
  66. end
  67. if Map5 ~= "" then
  68. path = path + 1
  69. end
  70. end
  71.  
  72. -- Config -> LevelSpot
  73. function getLevelSpot()
  74. if LevelSpot == "Grass" then
  75. moveToGrass()
  76. elseif LevelSpot == "Water" then
  77. moveToWater()
  78. elseif LevelSpot == "Rectangle" then
  79. moveToRectangle(minX, minY, maxX, maxY)
  80. end
  81. end
  82.  
  83. -- Shortcut -> GoToPokecenter
  84. function healPokemon()
  85. if path == 0 and City == "" and Pokecenter == LevelLocation then
  86. getHealed()
  87. elseif path == 0 then
  88. if getMapName() == LevelLocation then
  89. moveToMap(City)
  90. elseif getMapName() == City then
  91. moveToMap(Pokecenter)
  92. elseif getMapName() == Pokecenter then
  93. getHealed()
  94. end
  95. elseif path == 1 then
  96. if getMapName() == LevelLocation then
  97. moveToMap(Map1)
  98. elseif getMapName() == Map1 then
  99. moveToMap(City)
  100. elseif getMapName() == City then
  101. moveToMap(Pokecenter)
  102. elseif getMapName() == Pokecenter then
  103. getHealed()
  104. end
  105. elseif path == 2 then
  106. if getMapName() == LevelLocation then
  107. moveToMap(Map2)
  108. elseif getMapName() == Map2 then
  109. moveToMap(Map1)
  110. elseif getMapName() == Map1 then
  111. moveToMap(City)
  112. elseif getMapName() == City then
  113. moveToMap(Pokecenter)
  114. elseif getMapName() == Pokecenter then
  115. getHealed()
  116. end
  117. elseif path == 3 then
  118. if getMapName() == LevelLocation then
  119. moveToMap(Map3)
  120. elseif getMapName() == Map3 then
  121. moveToMap(Map2)
  122. elseif getMapName() == Map2 then
  123. moveToMap(Map1)
  124. elseif getMapName() == Map1 then
  125. moveToMap(City)
  126. elseif getMapName() == City then
  127. moveToMap(Pokecenter)
  128. elseif getMapName() == Pokecenter then
  129. getHealed()
  130. end
  131. elseif path == 4 then
  132. if getMapName() == LevelLocation then
  133. moveToMap(Map4)
  134. elseif getMapName() == Map4 then
  135. moveToMap(Map3)
  136. elseif getMapName() == Map3 then
  137. moveToMap(Map2)
  138. elseif getMapName() == Map2 then
  139. moveToMap(Map1)
  140. elseif getMapName() == Map1 then
  141. moveToMap(City)
  142. elseif getMapName() == City then
  143. moveToMap(Pokecenter)
  144. elseif getMapName() == Pokecenter then
  145. getHealed()
  146. end
  147. elseif path == 5 then
  148. if getMapName() == LevelLocation then
  149. moveToMap(Map5)
  150. elseif getMapName() == Map5 then
  151. moveToMap(Map4)
  152. elseif getMapName() == Map4 then
  153. moveToMap(Map3)
  154. elseif getMapName() == Map3 then
  155. moveToMap(Map2)
  156. elseif getMapName() == Map2 then
  157. moveToMap(Map1)
  158. elseif getMapName() == Map1 then
  159. moveToMap(City)
  160. elseif getMapName() == City then
  161. moveToMap(Pokecenter)
  162. elseif getMapName() == Pokecenter then
  163. getHealed()
  164. end
  165. end
  166. end
  167.  
  168. -- Shortcut -> GoToLevelLocation
  169. function moveToDestination()
  170. -- walk to Destination
  171. -- No City & LevelLocation == Pokecenter
  172. if path == 0 and City == "" and Pokecenter == LevelLocation then
  173. if getMapName() == LevelLocation then
  174. getLevelSpot()
  175. else
  176. getHealed()
  177. end
  178.  
  179. -- Path of no City between Pokecenter and LevelSpot
  180. elseif path == 0 and City == "" then
  181. if getMapName() == Pokecenter then
  182. moveToMap(LevelLocation)
  183. elseif getMapName() == LevelLocation then
  184. getLevelSpot()
  185. end
  186. -- Path of 0 Maps between City and LevelSpot
  187. elseif path == 0 then
  188. if getMapName() == Pokecenter then
  189. moveToMap(City)
  190. elseif getMapName() == City then
  191. moveToMap(LevelLocation)
  192. elseif getMapName() == LevelLocation then
  193. getLevelSpot()
  194. end
  195. -- Path of 1 Maps between City and LevelSpot
  196. elseif path == 1 then
  197. if getMapName() == Pokecenter then
  198. moveToMap(City)
  199. elseif getMapName() == City then
  200. moveToMap(Map1)
  201. elseif getMapName() == Map1 then
  202. moveToMap(LevelLocation)
  203. elseif getMapName() == LevelLocation then
  204. getLevelSpot()
  205. end
  206. -- Path of 2 Maps between City and LevelSpot
  207. elseif path == 2 then
  208. if getMapName() == Pokecenter then
  209. moveToMap(City)
  210. elseif getMapName() == City then
  211. moveToMap(Map1)
  212. elseif getMapName() == Map1 then
  213. moveToMap(Map2)
  214. elseif getMapName() == Map2 then
  215. moveToMap(LevelLocation)
  216. elseif getMapName() == LevelLocation then
  217. getLevelSpot()
  218. end
  219. -- Path of 3 Maps between City and LevelSpot
  220. elseif path == 3 then
  221. if getMapName() == Pokecenter then
  222. moveToMap(City)
  223. elseif getMapName() == City then
  224. moveToMap(Map1)
  225. elseif getMapName() == Map1 then
  226. moveToMap(Map2)
  227. elseif getMapName() == Map2 then
  228. moveToMap(Map3)
  229. elseif getMapName() == Map3 then
  230. moveToMap(LevelLocation)
  231. elseif getMapName() == LevelLocation then
  232. getLevelSpot()
  233. end
  234. -- Path of 4 Maps between City and LevelSpot
  235. elseif path == 4 then
  236. if getMapName() == Pokecenter then
  237. moveToMap(City)
  238. elseif getMapName() == City then
  239. moveToMap(Map1)
  240. elseif getMapName() == Map1 then
  241. moveToMap(Map2)
  242. elseif getMapName() == Map2 then
  243. moveToMap(Map3)
  244. elseif getMapName() == Map3 then
  245. moveToMap(Map4)
  246. elseif getMapName() == Map4 then
  247. moveToMap(LevelLocation)
  248. elseif getMapName() == LevelLocation then
  249. getLevelSpot()
  250. end
  251. -- Path of 5 Maps between City and LevelSpot
  252. elseif path == 5 then
  253. if getMapName() == Pokecenter then
  254. moveToMap(City)
  255. elseif getMapName() == City then
  256. moveToMap(Map1)
  257. elseif getMapName() == Map1 then
  258. moveToMap(Map2)
  259. elseif getMapName() == Map2 then
  260. moveToMap(Map3)
  261. elseif getMapName() == Map3 then
  262. moveToMap(Map4)
  263. elseif getMapName() == Map4 then
  264. moveToMap(Map5)
  265. elseif getMapName() == Map5 then
  266. moveToMap(LevelLocation)
  267. elseif getMapName() == LevelLocation then
  268. getLevelSpot()
  269. end
  270. end
  271. end
  272.  
  273. function getHealed()
  274. if getMapName() == "Indigo Plateau Center" then
  275. talkToNpcOnCell(4, 22)
  276.  
  277. elseif getMapName() == "Seafoam B4F" then
  278. pushDialogAnswer(1)
  279. pushDialogAnswer(1)
  280. talkToNpcOnCell(59, 13)
  281.  
  282. else
  283. usePokecenter()
  284. end
  285. end
  286.  
  287. function onPathAction()
  288.  
  289. trapped = false
  290.  
  291. if getTeamSize() == 2 then
  292. if isPokemonUsable(1) and isPokemonUsable(2) and getPokemonHealthPercent(2) >= 15 then
  293. if isTeamRangeSortedByLevelAscending(1, 2) then
  294. if getPokemonLevel(1) >= StopLevel and getPokemonLevel(2) >= StopLevel then
  295. log(" ")
  296. log("============ FINISHED LEVELING ============")
  297. log("The StopLevel has been reached, Bot stopped")
  298. log("===========================================")
  299. fatal(" ")
  300. else
  301. moveToDestination()
  302. end
  303. else
  304. return sortTeamRangeByLevelAscending(1, 2)
  305. end
  306. else
  307. healPokemon()
  308. end
  309.  
  310. elseif getTeamSize() == 3 then
  311. if isPokemonUsable(1) and isPokemonUsable(2) and isPokemonUsable(3) and getPokemonHealthPercent(3) >= 15 then
  312. if isTeamRangeSortedByLevelAscending(1, 3) then
  313. if getPokemonLevel(1) >= StopLevel and getPokemonLevel(2) >= StopLevel and getPokemonLevel(3) >= StopLevel then
  314. log(" ")
  315. log("============ FINISHED LEVELING ============")
  316. log("The StopLevel has been reached, Bot stopped")
  317. log("===========================================")
  318. fatal(" ")
  319. else
  320. moveToDestination()
  321. end
  322. else
  323. return sortTeamRangeByLevelAscending(1, 3)
  324. end
  325. else
  326. healPokemon()
  327. end
  328.  
  329. elseif getTeamSize() == 4 then
  330. if isPokemonUsable(1) and isPokemonUsable(2) and isPokemonUsable(3) and isPokemonUsable(4) and getPokemonHealthPercent(4) >= 15 then
  331. if isTeamRangeSortedByLevelAscending(1, 4) then
  332. if getPokemonLevel(1) >= StopLevel and getPokemonLevel(2) >= StopLevel and getPokemonLevel(3) >= StopLevel and getPokemonLevel(4) >= StopLevel then
  333. log(" ")
  334. log("============ FINISHED LEVELING ============")
  335. log("The StopLevel has been reached, Bot stopped")
  336. log("===========================================")
  337. fatal(" ")
  338. else
  339. moveToDestination()
  340. end
  341. else
  342. return sortTeamRangeByLevelAscending(1, 4)
  343. end
  344. else
  345. healPokemon()
  346. end
  347.  
  348. elseif getTeamSize() == 5 then
  349. if isPokemonUsable(1) and isPokemonUsable(2) and isPokemonUsable(3) and isPokemonUsable(4) and isPokemonUsable(5) and getPokemonHealthPercent(5) >= 15 then
  350. if isTeamRangeSortedByLevelAscending(1, 5) then
  351. if getPokemonLevel(1) >= StopLevel and getPokemonLevel(2) >= StopLevel and getPokemonLevel(3) >= StopLevel and getPokemonLevel(4) >= StopLevel and getPokemonLevel(5) >= StopLevel then
  352. log(" ")
  353. log("============ FINISHED LEVELING ============")
  354. log("The StopLevel has been reached, Bot stopped")
  355. log("===========================================")
  356. fatal(" ")
  357. else
  358. moveToDestination()
  359. end
  360. else
  361. return sortTeamRangeByLevelAscending(1, 5)
  362. end
  363. else
  364. healPokemon()
  365. end
  366.  
  367. elseif getTeamSize() == 6 then
  368. if isPokemonUsable(1) and isPokemonUsable(2) and isPokemonUsable(3) and isPokemonUsable(4) and isPokemonUsable(5) and isPokemonUsable(6) and getPokemonHealthPercent(6) >= 15 then
  369. if isTeamRangeSortedByLevelAscending(1, 6) then
  370. if getPokemonLevel(1) >= StopLevel and getPokemonLevel(2) >= StopLevel and getPokemonLevel(3) >= StopLevel and getPokemonLevel(4) >= StopLevel and getPokemonLevel(5) >= StopLevel and getPokemonLevel(6) >= StopLevel then
  371. log(" ")
  372. log("============ FINISHED LEVELING ============")
  373. log("The StopLevel has been reached, Bot stopped")
  374. log("===========================================")
  375. fatal(" ")
  376. else
  377. moveToDestination()
  378. end
  379. else
  380. return sortTeamRangeByLevelAscending(1, 6)
  381. end
  382. else
  383. healPokemon()
  384. end
  385.  
  386. else
  387. log(" ")
  388. log("=========== FATAL ERROR LOG ===========")
  389. log("You need atleast 2 Pokemon in your Team")
  390. log(" - ExpSharing destoyed - ")
  391. log("=======================================")
  392. fatal(" ")
  393. end
  394. end
  395.  
  396. function onBattleAction()
  397. -- Shiny support
  398. if isWildBattle() and isOpponentShiny() then
  399. if getUsablePokemonCount() == 2 and getPokemonHealthPercent(2) >= 15 then
  400. if getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 2) and getPokemonHealthPercent(2) >= 15 and getPokemonLevel(1) >= SwapCap then
  401. if useItem("Ultra Ball") or useItem("Great Ball") or useItem("Pokeball") or attack() or run() or sendUsablePokemon() then
  402. return
  403. end
  404. elseif getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 2) and getPokemonHealthPercent(2) >= 15 and getPokemonLevel(1) < SwapCap then
  405. sendPokemon(2)
  406. elseif getActivePokemonNumber() == 2 and isTeamRangeSortedByLevelAscending(1, 2) and getPokemonHealthPercent(2) >= 15 then
  407. if useItem("Ultra Ball") or useItem("Great Ball") or useItem("Pokeball") or attack() or run() or sendUsablePokemon() then
  408. return
  409. end
  410. end
  411.  
  412. elseif getUsablePokemonCount() == 3 and getPokemonHealthPercent(3) >= 15 then
  413. if getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 3) and getPokemonHealthPercent(3) >= 15 and getPokemonLevel(1) >= SwapCap then
  414. if useItem("Ultra Ball") or useItem("Great Ball") or useItem("Pokeball") or attack() or run() or sendUsablePokemon() then
  415. return
  416. end
  417. elseif getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 3) and getPokemonHealthPercent(3) >= 15 and getPokemonLevel(1) < SwapCap then
  418. sendPokemon(3)
  419. elseif getActivePokemonNumber() == 3 and isTeamRangeSortedByLevelAscending(1, 3) and getPokemonHealthPercent(3) >= 15 then
  420. if useItem("Ultra Ball") or useItem("Great Ball") or useItem("Pokeball") or attack() or run() or sendUsablePokemon() then
  421. return
  422. end
  423. end
  424. elseif getUsablePokemonCount() == 4 and getPokemonHealthPercent(4) >= 15 then
  425. if getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 4) and getPokemonHealthPercent(4) >= 15 and getPokemonLevel(1) >= SwapCap then
  426. if useItem("Ultra Ball") or useItem("Great Ball") or useItem("Pokeball") or attack() or run() or sendUsablePokemon() then
  427. return
  428. end
  429. elseif getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 4) and getPokemonHealthPercent(4) >= 15 and getPokemonLevel(1) < SwapCap then
  430. sendPokemon(2)
  431. elseif getActivePokemonNumber() == 4 and isTeamRangeSortedByLevelAscending(1, 4) and getPokemonHealthPercent(4) >= 15 then
  432. if useItem("Ultra Ball") or useItem("Great Ball") or useItem("Pokeball") or attack() or run() or sendUsablePokemon() then
  433. return
  434. end
  435. end
  436. elseif getUsablePokemonCount() == 5 and getPokemonHealthPercent(5) >= 15 then
  437. if getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 5) and getPokemonHealthPercent(5) >= 15 and getPokemonLevel(1) >= SwapCap then
  438. if useItem("Ultra Ball") or useItem("Great Ball") or useItem("Pokeball") or attack() or run() or sendUsablePokemon() then
  439. return
  440. end
  441. elseif getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 5) and getPokemonHealthPercent(5) >= 15 and getPokemonLevel(1) < SwapCap then
  442. sendPokemon(2)
  443. elseif getActivePokemonNumber() == 5 and isTeamRangeSortedByLevelAscending(1, 5) and getPokemonHealthPercent(5) >= 15 then
  444. if useItem("Ultra Ball") or useItem("Great Ball") or useItem("Pokeball") or attack() or run() or sendUsablePokemon() then
  445. return
  446. end
  447. end
  448. elseif getUsablePokemonCount() == 6 and getPokemonHealthPercent(6) >= 15 then
  449. if getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 6) and getPokemonHealthPercent(6) >= 15 and getPokemonLevel(1) >= SwapCap then
  450. if useItem("Ultra Ball") or useItem("Great Ball") or useItem("Pokeball") or attack() or run() or sendUsablePokemon() then
  451. return
  452. end
  453. elseif getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 6) and getPokemonHealthPercent(6) >= 15 and getPokemonLevel(1) < SwapCap then
  454. sendPokemon(6)
  455. elseif getActivePokemonNumber() == 6 and isTeamRangeSortedByLevelAscending(1, 6) and getPokemonHealthPercent(6) >= 15 then
  456. if useItem("Ultra Ball") or useItem("Great Ball") or useItem("Pokeball") or attack() or run() or sendUsablePokemon() then
  457. return
  458. end
  459. end
  460. end
  461.  
  462. elseif isWildBattle() and not isOpponentShiny() then
  463. -- Battle Action
  464. -- 2 Pokemon Usable
  465. if getUsablePokemonCount() == 2 and getPokemonHealthPercent(2) >= 15 then
  466. if getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 2) and getPokemonHealthPercent(2) >= 15 and getPokemonLevel(1) >= SwapCap then
  467. if trapped == true then
  468. return attack() or sendUsablePokemon()
  469. else
  470. return attack() or sendUsablePokemon() or sendAnyPokemon() or run()
  471. end
  472. elseif getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 2) and getPokemonHealthPercent(2) >= 15 and getPokemonLevel(1) < SwapCap then
  473. if trapped == true then
  474. return attack or sendUsablePokemon()
  475. else
  476. sendPokemon(2)
  477. log(" ")
  478. log("Your ".. getPokemonName(1) .. " has been switched with ".. getPokemonName(2))
  479. log(" ")
  480. end
  481. elseif getActivePokemonNumber() == 2 and isTeamRangeSortedByLevelAscending(1, 2) and getPokemonHealthPercent(2) >= 15 then
  482. return attack() or run() or sendUsablePokemon() or sendAnyPokemon()
  483. else
  484. if trapped == true then
  485. return attack() or sendUsablePokemon()
  486. else
  487. return run() or sendUsablePokemon() or sendAnyPokemon() or attack()
  488. end
  489. end
  490.  
  491. -- 3 Pokemon Usable
  492. elseif getUsablePokemonCount() == 3 and getPokemonHealthPercent(3) >= 15 then
  493. if getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 3) and getPokemonHealthPercent(2) >= 15 and getPokemonLevel(1) >= SwapCap then
  494. if trapped == true then
  495. return attack() or sendUsablePokemon()
  496. else
  497. return attack() or sendUsablePokemon() or sendAnyPokemon() or run()
  498. end
  499. elseif getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 3) and getPokemonHealthPercent(3) >= 15 and getPokemonLevel(1) < SwapCap then
  500. if trapped == true then
  501. return attack or sendUsablePokemon()
  502. else
  503. sendPokemon(3)
  504. log(" ")
  505. log("Your ".. getPokemonName(1) .. " has been switched with ".. getPokemonName(3))
  506. log(" ")
  507. end
  508. elseif getActivePokemonNumber() == 3 and isTeamRangeSortedByLevelAscending(1, 3) and getPokemonHealthPercent(3) >= 15 then
  509. return attack() or run() or sendUsablePokemon() or sendAnyPokemon()
  510. else
  511. if trapped == true then
  512. return attack() or sendUsablePokemon()
  513. else
  514. return run() or sendUsablePokemon() or sendAnyPokemon() or attack()
  515. end
  516. end
  517.  
  518. -- 4 Pokemon Usable
  519. elseif getUsablePokemonCount() == 4 and getPokemonHealthPercent(4) >= 15 then
  520. if getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 4) and getPokemonHealthPercent(2) >= 15 and getPokemonLevel(1) >= SwapCap then
  521. if trapped == true then
  522. return attack() or sendUsablePokemon()
  523. else
  524. return attack() or sendUsablePokemon() or sendAnyPokemon() or run()
  525. end
  526. elseif getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 4) and getPokemonHealthPercent(4) >= 15 and getPokemonLevel(1) < SwapCap then
  527. if trapped == true then
  528. return attack or sendUsablePokemon()
  529. else
  530. sendPokemon(4)
  531. log(" ")
  532. log("Your ".. getPokemonName(1) .. " has been switched with ".. getPokemonName(4))
  533. log(" ")
  534. end
  535. elseif getActivePokemonNumber() == 4 and isTeamRangeSortedByLevelAscending(1, 4) and getPokemonHealthPercent(4) >= 15 then
  536. return attack() or run() or sendUsablePokemon() or sendAnyPokemon()
  537. else
  538. if trapped == true then
  539. return attack() or sendUsablePokemon()
  540. else
  541. return run() or sendUsablePokemon() or sendAnyPokemon() or attack()
  542. end
  543. end
  544.  
  545. -- 5 Pokemon Usable
  546. elseif getUsablePokemonCount() == 5 and getPokemonHealthPercent(5) >= 15 then
  547. if getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 5) and getPokemonHealthPercent(2) >= 15 and getPokemonLevel(1) >= SwapCap then
  548. if trapped == true then
  549. return attack() or sendUsablePokemon()
  550. else
  551. return attack() or sendUsablePokemon() or sendAnyPokemon() or run()
  552. end
  553. elseif getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 5) and getPokemonHealthPercent(5) >= 15 and getPokemonLevel(1) < SwapCap then
  554. if trapped == true then
  555. return attack or sendUsablePokemon()
  556. else
  557. sendPokemon(5)
  558. log(" ")
  559. log("Your ".. getPokemonName(1) .. " has been switched with ".. getPokemonName(5))
  560. log(" ")
  561. end
  562. elseif getActivePokemonNumber() == 5 and isTeamRangeSortedByLevelAscending(1, 5) and getPokemonHealthPercent(5) >= 15 then
  563. return attack() or run() or sendUsablePokemon() or sendAnyPokemon()
  564. else
  565. if trapped == true then
  566. return attack() or sendUsablePokemon()
  567. else
  568. return run() or sendUsablePokemon() or sendAnyPokemon() or attack()
  569. end
  570. end
  571.  
  572. -- 6 Pokemon usable
  573. elseif getUsablePokemonCount() == 6 and getPokemonHealthPercent(6) >= 15 then
  574. if getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 6) and getPokemonHealthPercent(2) >= 15 and getPokemonLevel(1) >= SwapCap then
  575. if trapped == true then
  576. return attack() or sendUsablePokemon()
  577. else
  578. return attack() or sendUsablePokemon() or sendAnyPokemon() or run()
  579. end
  580. elseif getActivePokemonNumber() == 1 and isTeamRangeSortedByLevelAscending(1, 6) and getPokemonHealthPercent(6) >= 15 and getPokemonLevel(1) < SwapCap then
  581. if trapped == true then
  582. return attack or sendUsablePokemon()
  583. else
  584. sendPokemon(6)
  585. log(" ")
  586. log("Your ".. getPokemonName(1) .. " has been switched with ".. getPokemonName(6))
  587. log(" ")
  588. end
  589. elseif getActivePokemonNumber() == 6 and isTeamRangeSortedByLevelAscending(1, 6) and getPokemonHealthPercent(6) >= 15 then
  590. return attack() or run() or sendUsablePokemon() or sendAnyPokemon()
  591. else
  592. if trapped == true then
  593. return attack() or sendUsablePokemon()
  594. else
  595. return run() or sendUsablePokemon() or sendAnyPokemon() or attack()
  596. end
  597. end
  598. else
  599. if trapped == true then
  600. return attack() or sendUsablePokemon()
  601. else
  602. return run() or sendUsablePokemon() or sendAnyPokemon() or attack()
  603. end
  604. end
  605. end
  606. end
  607.  
  608. function onBattleMessage(wild)
  609. if stringContains(wild, "wrapped") or stringContains(wild, "You can not switch this Pokemon") or stringContains(wild, "You failed to run away") or stringContains(wild, "You can not run away") then
  610. trapped = true
  611. end
  612. end
  613.  
  614. function onLearningMove(moveName, pokemonIndex)
  615. local ForgetMoveName
  616. local ForgetMoveTP = 9999
  617. for moveId=1, 4, 1 do
  618. local MoveName = getPokemonMoveName(pokemonIndex, moveId)
  619. if MoveName == nil or MoveName == "cut" or MoveName == "surf" or MoveName == "rock smash" or MoveName == "rocksmash" then
  620. else
  621. local CalcMoveTP = math.modf((getPokemonMaxPowerPoints(pokemonIndex,moveId) * getPokemonMovePower(pokemonIndex,moveId))*(math.abs(getPokemonMoveAccuracy(pokemonIndex,moveId)) / 100))
  622. if CalcMoveTP < ForgetMoveTP then
  623. ForgetMoveTP = CalcMoveTP
  624. ForgetMoveName = MoveName
  625. end
  626. end
  627. end
  628. log("==== Learning new Move ====")
  629. log(" ")
  630. log("[Learned] ".. moveName)
  631. log("[Forgot ] ".. ForgetMoveName)
  632. log(" ")
  633. log("===========================")
  634. return ForgetMoveName
  635. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement