Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2020
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. F6::
  2.  
  3. /*
  4.  *  !!! ENTER PARTY JOBS BELOW !!!
  5.  *
  6.  *  The script will take into account your composition when Guarding in battle. It will go by the slowest growing job in the party.
  7.  *  To be as efficient as possible, group jobs with similar growth speed together (eg: White Mage, Black Mage, Evoker, Magus).
  8.  *
  9.  *  If a party member is a Thief or a Scholar, you must:
  10.  *   1. Put it in the back row (you should put everyone in the back row anyway.
  11.  *   2. Give it the Mini status.
  12.  *   3. Make sure you do NOT have both in the same party.
  13.  *  The script will use the Attack command for these two jobs. If you don't set them up as instructed, the script may not function properly.
  14.  *
  15.  *  If a slot is left blank or is invalid, the script will not start.
  16.  *
  17.  *  Valid jobs:
  18.  *  Freelancer, Warrior, Monk, White Mage, Black Mage, Red Mage, Thief, Ranger, Knight,
  19.  *  Scholar, Geomancer, Viking, Dragoon, Dark Knight, Evoker, Bard, Black Belt, Magus,
  20.  *  Devout, Summoner, Sage, Ninja, Onion Knight
  21.  *
  22.  *  Here is an example of a party composition:
  23.  *  
  24.  *  party:=[]
  25.  *  party[0]:= "Freelancer"
  26.  *  party[1]:= "Thief"
  27.  *  party[2]:= "Ranger"
  28.  *  party[3]:= "Sage"
  29.  *
  30.  *  Enter yours below
  31. */
  32.  
  33. party:=[]
  34. party[0]:= "Evoker"
  35. party[1]:= "White Mage"
  36. party[2]:= "Evoker"
  37. party[3]:= "Scholar"
  38.  
  39. /*
  40.  *  Do not make any changes below this point, unless you know what you are doing
  41. */
  42.  
  43. jobGrowthValues:= {}
  44. jobGrowthValues["Scholar"]:= 24
  45. jobGrowthValues["Freelancer"]:= 20
  46. jobGrowthValues["Thief"]:= 20
  47. jobGrowthValues["Bard"]:= 18
  48. jobGrowthValues["Dragoon"]:= 16
  49. jobGrowthValues["Warrior"]:= 14
  50. jobGrowthValues["Monk"]:= 14
  51. jobGrowthValues["Ranger"]:= 14
  52. jobGrowthValues["Black Belt"]:= 14
  53. jobGrowthValues["Geomancer"]:= 14
  54. jobGrowthValues["Dark Knight"]:= 14
  55. jobGrowthValues["Viking"]:= 14
  56. jobGrowthValues["Red Mage"]:= 12
  57. jobGrowthValues["Summoner"]:= 12
  58. jobGrowthValues["Ninja"]:= 12
  59. jobGrowthValues["Knight"]:= 12
  60. jobGrowthValues["White Mage"]:= 10
  61. jobGrowthValues["Magus"]:= 10
  62. jobGrowthValues["Devout"]:= 10
  63. jobGrowthValues["Sage"]:= 10
  64. jobGrowthValues["Black Mage"]:= 10
  65. jobGrowthValues["Evoker"]:= 10
  66. jobGrowthValues["Onion Knight"]:= 8
  67.  
  68. currentState:= "corridor"
  69. direction:= "goingRight"
  70.  
  71. ; All pixel values for the battle screen
  72. button1X:= 229
  73. button1Y:= 356
  74. button2X:= 229
  75. button2Y:= 413
  76. button3X:= 229
  77. button3Y:= 471
  78.  
  79. lootButtonX:= 722
  80. lootButtonY:= 73
  81.  
  82. ; Check for valid party compositions
  83. if(!jobGrowthValues.hasKey(party[0]) || !jobGrowthValues.hasKey(party[1]) || !jobGrowthValues.hasKey(party[2]) || !jobGrowthValues.hasKey(party[3])) {
  84.     MsgBox, "At least one party member has an invalid job. Script will not start."
  85.     ExitApp
  86. }
  87.  
  88. ; Check for Thief & Scholar both in party. AHK really doesn't have an elegant way to check if an array contains something.
  89. if(party[0] == "Thief" || party[1] == "Thief" || party[2] == "Thief" || party[3] == "Thief") {
  90.     if(party[0] == "Scholar" || party[1] == "Scholar" || party[2] == "Scholar" || party[3] == "Scholar") {
  91.         MsgBox, "Thief and Scholar are both in the party. Script will not start."
  92.         ExitApp
  93.     }
  94. }
  95.  
  96. ; Calculate number of turns per battle
  97. turnCount:= Ceil(100/Min(jobGrowthValues[party[0]], jobGrowthValues[party[1]], jobGrowthValues[party[2]], jobGrowthValues[party[3]]))
  98.  
  99. Loop {
  100.     if(currentState == "corridor") {
  101.         MouseClick, Left, 360, 260, 1, 0            ; Clear any held presses, wipe all pixel variables
  102.         wallRight:= ""
  103.         wallLeft:= ""
  104.         screenCenter:= ""
  105.         Sleep, 100
  106.        
  107.         if(direction == "goingRight") {
  108.             ; Start going right
  109.             MouseClick, Left, 360, 260, 1, 0, D
  110.             MouseMove, 400, 260
  111.         }
  112.         if(direction == "goingLeft") {
  113.             ; Start going left
  114.             MouseClick, Left, 360, 260, 1, 0, D
  115.             MouseMove, 310, 260
  116.         }
  117.        
  118.        
  119.         if(direction=="goingRight") {                                       ; Scan for right end of tunnel, or battle
  120.             while(wallRight != "0x000000" && screenCenter != "0xFFFFFF") {
  121.                 PixelGetColor, wallRight, 650, 250
  122.                 PixelGetColor, screenCenter, 380, 250
  123.             }
  124.             if(screenCenter == "0xFFFFFF") {
  125.                 currentState:= "battle"
  126.             } else {
  127.                 direction:= "goingLeft"
  128.                 wallLeft:= ""
  129.             }
  130.             continue
  131.         }
  132.         if(direction=="goingLeft") {                                        ; Scan for left end of tunnel, or battle
  133.             while(wallLeft != "0x000000" && screenCenter != "0xFFFFFF") {
  134.                 PixelGetColor, wallLeft, 35, 250
  135.                 PixelGetColor, screenCenter, 380, 250
  136.             }
  137.             if(screenCenter == "0xFFFFFF") {
  138.                 currentState:= "battle"
  139.             } else {
  140.                 direction:= "goingRight"
  141.                 wallRight:= ""
  142.             }
  143.             continue
  144.         }
  145.        
  146.         Sleep, 250
  147.     }
  148.    
  149.     if(currentState == "battle") {
  150.         MouseClick, Left, 360, 260, 1, 0            ; Clear any held presses, wipe all pixel variables
  151.         command1:= ""
  152.         command2:= ""
  153.         command3:= ""
  154.         lootButton:= ""
  155.        
  156.         ; Guard turnCount times
  157.  
  158.         Loop, %turnCount% {
  159.             while(!(command1 == "0xADAAAD" && command2 == "0xADAAAD" && command3 == "0xADAAAD")) {  ; Wait until all three command button borders are present
  160.                 PixelGetColor, command1, button1X, button1Y
  161.                 PixelGetColor, command2, button2X, button2Y
  162.                 PixelGetColor, command3, button3X, button3Y
  163.                
  164.                 PixelGetColor, lootButton, lootButtonX, lootButtonY     ; Failsafe for the rare case where the enemies die early due to a Scholar/Thief
  165.                 if(lootButton=="0xF7F7F7") {
  166.                     Goto, LootLabel
  167.                 }
  168.             }
  169.             command1:= ""
  170.             command2:= ""
  171.             command3:= ""
  172.            
  173.             Loop, 4 {
  174.                 if(party[A_Index-1] == "Thief" || party[A_Index-1] == "Scholar") {      ; If a Scholar/Thief, use Attack instead. NOTE: This will kill lone enemies before turnCount is reached, in some cases.
  175.                     MouseClick, Left, button1X-50, button1Y
  176.                     Sleep, 300
  177.                     MouseClick, Left, button1X-50, button1Y
  178.                     Sleep, 1000
  179.                 } else {
  180.                     MouseClick, Left, button3X-50, button3Y
  181.                     Sleep, 1000
  182.                 }
  183.             }
  184.             MouseMove, 360, 260
  185.         }
  186.        
  187.         while(!(command1 == "0xADAAAD" && command2 == "0xADAAAD" && command3 == "0xADAAAD")) {      ; Wait until all three command button borders are present
  188.             PixelGetColor, command1, button1X, button1Y
  189.             PixelGetColor, command2, button2X, button2Y
  190.             PixelGetColor, command3, button3X, button3Y
  191.         }
  192.        
  193.         ; Attack with everyone
  194.         Loop, 4 {
  195.                 MouseClick, Left, button1X-50, button1Y
  196.                 Sleep, 300
  197.                 MouseClick, Left, button1X-50, button1Y
  198.                 Sleep, 1000
  199.         }
  200.         MouseMove, 360, 260
  201.        
  202.         LootLabel:
  203.             ; Wait for the loot/xp button to appear
  204.             while(lootButton != "0xF7F7F7") {
  205.                 PixelGetColor, lootButton, lootButtonX, lootButtonY
  206.             }
  207.            
  208.             ; Press it until it vanishes
  209.             while(lootButton == "0xF7F7F7") {
  210.                 MouseClick, Left, 722, 73
  211.                 Sleep, 1000
  212.                 PixelGetColor, lootButton, lootButtonX, lootButtonY
  213.             }
  214.            
  215.        
  216.         currentState:= "corridor"
  217.         Sleep, 3000
  218.     }
  219. }
  220.  
  221. Return
  222.  
  223.  
  224. F8::Reload
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement