Advertisement
Guest User

Spiky's DS Map Editor automatic level raising macro

a guest
Feb 4th, 2016
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; #### Raise Pokemon level ####
  2. ; Trainer Pokemon & Wild Pokemon
  3.  
  4. ; == Description ==
  5. ; you can set your own percentage values, edit variables 'p1'-'p6' or 'percent'
  6. ; Alt + 1 for raising trainer pokemon levels
  7. ; Alt + 2 for raising wild pokemon levels
  8. ; Shift + 0 tells the script to stop, in order to continue hit Ctrl + Shift + 0 and the corresponding shortcut again (Alt + 1 or Alt + 2)
  9.  
  10. ; == Usage ==
  11. ; - Trainers -
  12. ; 1) open 'Trainer Editor', select first trainer where you want to start
  13. ; 2) hit Alt + 1 to start automatic routine of raising pokemon levels of ALL trainers
  14. ; 3) hit Shift + 0 (spam it, works better) as soon as the last trainer is being edited
  15. ;    ATTENTION: the script will keep going until you manually stop it. If it reaches the last trainer in the list,
  16. ;    it will continue to raise his pokemon levels infinitely (until all are 100)
  17. ; - Wild Pokemon -
  18. ; 1) open 'Wild Pokemon Editor'
  19. ; 2) hit Alt + 2 to start automatic routine of raising ALL wild pokemon levels
  20. ; 3) hit Shift + 0 (spam it, works better) as soon as the last area is being edited
  21. ;    ATTENTION: the script will keep going until you manually stop it. If it reaches the last area in the list,
  22. ;    it will continue to raise the pokemon levels infinitely (until all are 100)
  23.  
  24. ; set default values
  25. defValTrainer := 20
  26. defValWild := 23
  27.  
  28. i := 1
  29. Loop, 6
  30. {
  31.     p%i% := defValTrainer
  32.     i := i + 1
  33. }
  34.  
  35. pWild := defValWild
  36.  
  37. ; ==== GUI ====
  38. Gui, Add, GroupBox, x12 y110 w240 h200 , raise levels by `% depending on team size
  39. Gui, Font, S12, Verdana
  40. Gui, Add, Text, x202 y130 w20 h20 , `%
  41. Gui, Add, Text, x202 y160 w20 h20 , `%
  42. Gui, Add, Text, x202 y190 w20 h20 , `%
  43. Gui, Add, Text, x202 y220 w20 h20 , `%
  44. Gui, Add, Text, x202 y250 w20 h20 , `%
  45. Gui, Add, Text, x202 y280 w20 h20 , `%
  46. Gui, Add, Text, x202 y320 w20 h20 , `%
  47. Gui, Font, S10, Verdana
  48. Gui, Add, Text, x12 y10 w240 h90 , Set your custom percentage values. You can set different values for different team sizes. The entire opponent's team is raised by the percentage you enter.
  49. Gui, Add, Text, x22 y130 w120 h20 , has 1 Pokemon
  50. Gui, Add, Text, x22 y160 w120 h20 , has 2 Pokemon
  51. Gui, Add, Text, x22 y190 w120 h20 , has 3 Pokemon
  52. Gui, Add, Text, x22 y220 w120 h20 , has 4 Pokemon
  53. Gui, Add, Text, x22 y250 w120 h20 , has 5 Pokemon
  54. Gui, Add, Text, x22 y280 w120 h20 , has 6 Pokemon
  55. Gui, Add, Text, x22 y320 w120 h20 , wild Pokemon
  56. Gui, Add, Edit, x152 y130 w40 h20 vp1, %p1%
  57. Gui, Add, Edit, x152 y160 w40 h20 vp2, %p2%
  58. Gui, Add, Edit, x152 y190 w40 h20 vp3, %p3%
  59. Gui, Add, Edit, x152 y220 w40 h20 vp4, %p4%
  60. Gui, Add, Edit, x152 y250 w40 h20 vp5, %p5%
  61. Gui, Add, Edit, x152 y280 w40 h20 vp6, %p6%
  62. Gui, Add, Edit, x152 y320 w40 h20 vpWild, %pWild%
  63. Gui, Add, Button, x152 y350 w70 h30, Help
  64. Gui, Add, Button, x42 y350 w80 h30, OK
  65. ; Generated using SmartGUI Creator 4.0
  66. Gui, Show, xCenter yCenter h402 w267, Automatic Level Raising
  67. Return
  68.  
  69. ButtonHelp:
  70.     MsgBox,, Help, == Usage ==`n- Trainers -`n1) open 'Trainer Editor' in Spiky's DS Map Editor, select first trainer where you want to start`n2) hit Alt + 1 to start automatic routine of raising Pokemon levels of ALL trainers`n3) hit Shift + 0 (spam it, works better) as soon as the last trainer is being edited`n`n- Wild Pokemon -`n1) open 'Wild Pokemon Editor' in Spiky's DS Map Editor`n2) hit Alt + 2 to start automatic routine of raising ALL wild Pokemon levels`n3) hit Shift + 0 (spam it, works better) as soon as the last area is being edited`n`nATTENTION: the script will keep going until you manually stop it. If it reaches the last trainer/wild Pokemon area in the list, it will continue to raise the Pokemon levels infinitely (until all are 100)`n`n== Hotkeys ==`nAlt + 1 - raise trainer's Pokemon levels`nAlt + 2 - raise wild Pokemon levels`nAlt + 3 - check the currently set and active percentage values`nShift + 0 - stop script `nCtrl + Shift + 0 - continue script (press Alt + 1 or Alt + 2 again)`n`nAfter you have set your values, hit OK to submit them. Afterwards, you can use the hotkeys in Spiky's DS Map Editor.
  71. return
  72.  
  73. ButtonOK:
  74.     Gui, Submit, NoHide
  75.    
  76.     ; set default values if empty strings were submitted
  77.     defaultSetNote := ""
  78.     submittedEmpty := false
  79.    
  80.     ; Pokemon 1-6
  81.     i := 1
  82.     Loop, 6
  83.     {
  84.         if (p%i% = "")
  85.         {
  86.             p%i% := defValTrainer
  87.             submittedEmpty := true
  88.         }
  89.         i := i + 1
  90.     }
  91.    
  92.     ; wild Pokemon
  93.     if (pWild = "")
  94.     {
  95.         pWild := defValWild
  96.         submittedEmpty := true
  97.     }
  98.    
  99.     if (submittedEmpty)
  100.         defaultSetNote := "NOTE: You submitted empty values, they were set to the default value!`n`n"
  101.    
  102.     MsgBox,, Values set!, %defaultSetNote%You're set!`nPress the hotkeys (Alt + 1 or Alt + 2) in Spiky's DS Map Editor`nto start the automatic routine!
  103. return
  104.  
  105. GuiClose:
  106. ExitApp
  107. ; ==== GUI end ====
  108.  
  109.  
  110.  
  111. ; === Script ===
  112. ; 'clipboard' is a reserved global variable from AutoHotkey that contains the current clipboard value
  113. ; sleep (wait in milliseconds) in between certain steps works better
  114.  
  115. stop := false
  116.  
  117. ; Shift + 0 - stop
  118. +0::stop := true
  119. ; Ctrl + Shift + 0 - continue
  120. ^+0::stop := false
  121.  
  122. ; Alt + 3 - check active/set percentage values
  123. !3::
  124.     MsgBox,, Value Check, has 1 PKMN: %p1%`%`nhas 2 PKMN: %p2%`%`nhas 3 PKMN: %p3%`%`nhas 4 PKMN: %p4%`%`nhas 5 PKMN: %p5%`%`nhas 6 PKMN: %p6%`%`nWild Pokemon: %pWild%`%
  125. return
  126.  
  127. ; Alt + 1 - raise trainer pokemon levels
  128. !1::
  129.     if WinActive("ahk_exe SDSME.exe")
  130.     {
  131.         ; raise pokemon levels by percentage, depending on how many pokemon a trainer has (allows more fine tuning)
  132.         while !stop
  133.         {
  134.             pokeCount := countPokemon()
  135.             percent := p%pokeCount%     ; get according percentage value dynamically
  136.             ;percent := 20              ; set static percentage value for all cases equally
  137.            
  138.             Loop, %pokeCount%
  139.             {
  140.                 addTrainerLevel(percent) ; raise levels
  141.                 sleep, 25
  142.                
  143.                 if (pokeCount > 1)
  144.                 {
  145.                     nextPokemon()   ; select next pokemon
  146.                     sleep, 25
  147.                 }
  148.             }
  149.            
  150.             saveTrainer()
  151.             sleep, 25
  152.             nextTrainer()
  153.             sleep, 50
  154.         }
  155.     }
  156. return
  157.  
  158. ; Alt + 2 - raise wild pokemon levels
  159. !2::
  160.     if WinActive("ahk_exe SDSME.exe")
  161.     {
  162.         X := 460
  163.        
  164.         while !stop
  165.         {
  166.             Y := 123
  167.             Loop, 12        ; always 12
  168.             {
  169.                 addWildLevel(pWild, X, Y)
  170.                 Y := Y + 27
  171.                 sleep, 10
  172.             }
  173.            
  174.             saveWild()
  175.             sleep, 25
  176.             nextArea()
  177.         }
  178.     }
  179. return
  180.  
  181.  
  182.  
  183.  
  184. ; get current level and add percentage
  185. addWildLevel(percent, X, Y)
  186. {
  187.     Click %X%, %Y%, 2       ; double click
  188.     sleep, 25
  189.     Send, ^c                ; copy current level into clipboard
  190.     sleep, 25
  191.     cache := clipboard
  192.     ; always round up
  193.     result := ceil(cache * (percent / 100)) + cache
  194.     clipboard := result
  195.     sleep, 25
  196.     Send, ^v                ; paste new level from clipboard
  197. }
  198.  
  199. ; select next area in 'Wild Pokemon Editor'
  200. nextArea()
  201. {
  202.     Click 135, 50
  203.     sleep, 25
  204.     send, {down}
  205.     sleep, 25
  206.     send, {enter}
  207.     sleep, 25
  208. }
  209.  
  210. ; counts trainer pokemon by clicking through pokemon tabs
  211. ; returns pokemon amount
  212. countPokemon()
  213. {
  214.     pokemon := 0
  215.     exists := true
  216.     X := 22
  217.    
  218.     while exists
  219.     {
  220.         exists := pokemonExists(X, 215)
  221.         if (exists)
  222.             pokemon := pokemon + 1
  223.         X := X + 66
  224.     }
  225.    
  226.     Click 50, 215       ; click on first pokemon tab of trainer
  227.    
  228.     return pokemon
  229. }
  230.  
  231. ; checks if a pokemon tab exists at X, Y coordinates by checking color at mouse position after clicking
  232. ; white = exists, any other color = doesn't exist
  233. pokemonExists(X, Y)
  234. {
  235.     ret := false
  236.     Click %X%, %Y%
  237.     PixelGetColor color, X, Y
  238.     if (color = "0xFFFFFF") ; = white
  239.         ret := true
  240.     sleep, 10
  241.    
  242.     return ret
  243. }
  244.  
  245. ; get current level and add percentage
  246. addTrainerLevel(percent)
  247. {
  248.     Click 175, 255, 2       ; double click
  249.     sleep, 25
  250.     Send, ^c                ; copy current level into clipboard
  251.     sleep, 25
  252.     cache := clipboard
  253.     ; always round up
  254.     result := ceil(cache * (percent / 100)) + cache
  255.     clipboard := result
  256.     sleep, 25
  257.     Send, ^v                ; paste new level from clipboard
  258. }
  259.  
  260. ; select next pokemon
  261. nextPokemon()
  262. {
  263.     send, {LCtrl down} {Tab} {LCtrl up}     ; send Ctrl + Tab
  264. }
  265.  
  266. ; click 'Trainer Editor' save button
  267. saveTrainer()
  268. {
  269.     Click 390, 350
  270.     sleep, 25
  271.     Click 390, 350      ; click save button 2 times with a small delay, works better
  272. }
  273.  
  274. ; click 'Wild Pokemon Editor' save button
  275. saveWild()
  276. {
  277.     Click 800, 520
  278.     sleep, 25
  279.     Click 800, 520      ; click save button 2 times with a small delay, works better
  280. }
  281.  
  282. ; select next trainer
  283. nextTrainer()
  284. {
  285.     Click 195, 50
  286.     sleep, 25
  287.     send, {down}
  288.     sleep, 25
  289.     send, {enter}
  290.     sleep, 25
  291.     Click 50, 215       ; click on first pokemon tab of trainer
  292. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement