SHARE
TWEET

Untitled

a guest Jun 24th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #cs
  2. ===============================================================================
  3. Nostale woodcutter by Merutochan (v.1.9)
  4. merutochan@gmail.com
  5.  
  6. V.1.9 MAJOR CHANGES:
  7.  
  8. - Attempting bugfix:
  9.   - Added exception for durability check
  10.  
  11.  
  12. ===============================================================================
  13. #ce
  14.  
  15. ; INCLUDES ;
  16. #include <GuiEdit.au3>
  17. #include <GUIConstantsEx.au3>
  18. #include <WindowsConstants.au3>
  19.  
  20. ; Hotkey To quit
  21. hotkeyset("{ESC}", "quit")
  22. ; Set options for Mouse and Pixels
  23. Autoitsetoption("PixelCoordMode", 2)
  24. Autoitsetoption("MouseCoordMode", 2)
  25.  
  26. ; Ask some important sh*t
  27. Do
  28.    $coupon = inputbox("Insert", "Current coupons:")
  29.    If @error == 1 Then
  30.       Exit
  31.    EndIf
  32. until $coupon <> ""
  33.  
  34. Do
  35.    $produzione = inputbox("Insert", "Current production points:")
  36.    If @error == 1 Then
  37.       Exit
  38.    EndIf
  39. until $produzione <> ""
  40.  
  41. Do
  42.    $friend = inputbox("Insert", "Friend position in friend list:")
  43.    If @error == 1 Then
  44.       Exit
  45.    EndIf
  46. until $friend <> ""
  47.  
  48. ; CONSTANTS
  49. Const $LEFT = 430
  50. Const $RIGHT = 465
  51.  
  52. ; printLog() prints a log in the LOG file
  53. Func printLog(ByRef $string)
  54.    FileWrite($log, $string)
  55. EndFunc
  56.  
  57. ; calibratePositions() returns the correct calibration of the screen offset
  58. Func calibratePositions()
  59.    $text = ("- INFO - - Calibration ready."&@CRLF)
  60.    printLog($text)
  61.    winwaitactive("NosTale")
  62.    $YONE_ARRAY = PixelSearch($RIGHT,370,$LEFT,400,0xDFA83C)
  63.    while @error
  64.       $YONE_ARRAY = PixelSearch($RIGHT,370,$LEFT,400,0xDFA83C)
  65.    WEnd
  66.    $text = ("- INFO - - Calibration completed. Y = "&$YONE_ARRAY[1]&@CRLF)
  67.    printLog($text)
  68.   return $YONE_ARRAY[1]
  69. EndFunc
  70.  
  71. ; pTime() prints time in the GUI output edit
  72. Func pTime()
  73.    $text = ("[" & @hour & ":" & @min & ":" & @sec & "] - ")
  74.    printLog($text)
  75. EndFunc
  76.  
  77. ; printInit() prints some initial informations in the GUI output edit
  78. Func printInit()
  79. $text = (""& _
  80. "=========================================================================="& _
  81. @CRLF)
  82. printLog($text)
  83. $text = (""& _
  84. "========             .Nostale   Moon   Farming   Bot.             ========"& _
  85. @CRLF)
  86. printLog($text)
  87. $text = (""& _
  88. "========                          v.1.9                           ========"& _
  89. @CRLF)
  90. printLog($text)
  91. $text = (""& _
  92. "========                  provided by Merutochan                  ========"& _
  93. @CRLF)
  94. printLog($text)
  95. $text = (""& _
  96. "========                  (merutochan@gmail.com)                  ========"& _
  97. @CRLF)
  98. printLog($text)
  99. $text = (""& _
  100. "========                                                          ========"& _
  101. @CRLF)
  102. printLog($text)
  103. $text = (""& _
  104. "=========================================================================="& _
  105. @CRLF)
  106. printLog($text)
  107. $text = ("========                       "&@MDAY&"/"&@MON&"/"&@YEAR& _
  108. "                         ========" &@CRLF)
  109. printLog($text)
  110.  
  111. $text = ("Coupons: "&$coupon&" - Production points: "&(20-$cicli)*100&@CRLF)
  112. printLog($text)
  113. EndFunc
  114.  
  115. ; quit() closes the bot
  116. Func quit()
  117.    If (GUICtrlRead($v) == $GUI_CHECKED) Then
  118.       pTime()
  119.       $text = ("- INFO - - Closing bot...")
  120.       printLog($text)
  121.    EndIf
  122.    FileClose($log)
  123.    Exit
  124. EndFunc
  125.  
  126. ; midnightCheck() checks If midnight is near and stops the minigame for a while
  127. Func midnightCheck()
  128.    If (@hour == 23 and @min > 55) then
  129.       $midnight = True
  130.       If (GUICtrlRead($v) == $GUI_CHECKED) Then
  131.          pTime()
  132.          $text = ("- INFO - - Midnight check." & 60 - @min & _
  133.          " minutes remaining..." & @CRLF)
  134.          printLog($text)
  135.       EndIf
  136.       While @min <> 1
  137.          sleep(500)
  138.       WEnd
  139.       $text = ("========                       "&@MDAY&"/"&@MON&"/"&@YEAR& _
  140. "                         ========" &@CRLF)
  141.       printLog($text)
  142.       $timer = TimerInit()
  143.       $midnight = False
  144.       return True
  145.    Else
  146.       return False
  147.    EndIf
  148. EndFunc
  149.  
  150. ; restartReward() restarts the minigame clicking for a lv. 5 reward
  151. Func restartReward()
  152.    MouseClick("left", 620, $YONE+45)
  153.    sleep(500)
  154.    MouseClick("left", 640, $YONE+54)
  155.    If (GUICtrlRead($v) == $GUI_CHECKED) Then
  156.       pTime()
  157.       $text = ("- INFO - - Obtained lv. 5 reward." & @CRLF)
  158.       printLog($text)
  159.       sleep(500)
  160.    EndIf
  161.  
  162.    ; MIDNIGHT CHECK ;
  163.    If (midnightCheck() == True) Then
  164.       restartMinigame()
  165.       $cicli = 0
  166.    Else
  167.  
  168.       MouseClick("left", 450, $YONE+78)
  169.       sleep(1000)
  170.       MouseClick("left", 465, $YONE+160)
  171.       sleep(1000)
  172.  
  173.       $cicli += 1
  174.  
  175.       ; CHECK FOR DURABILITY
  176.       If(Pixelgetcolor(660, $YONE+26) == "") Then
  177.          pTime()
  178.          $text = ("- ERROR - Stalling." & @CRLF)
  179.          printLog($text)
  180.          Mouseclick('left', 660, $YONE+ 36)
  181.          Return
  182.       EndIf
  183.  
  184.    EndIf
  185. EndFunc
  186.  
  187. ; restartNoReward() restarts the minigame avoiding any reward
  188. Func restartNoReward()
  189.    pTime()
  190.    $text = ("- INFO - - No reward was obtained." & @CRLF)
  191.    printLog($text)
  192.    If (midnightCheck() == True) then
  193.       restartMinigame()
  194.       $cicli = 0
  195.    Else
  196.       MouseClick("left", 410, $YONE+46)
  197.       sleep(500)
  198.       MouseClick("left", 465, $YONE+160)
  199.    EndIf
  200. EndFunc
  201.  
  202. ; refillProductionPoints() uses coupons to fill 2000 production points
  203. Func refillProductionPoints()
  204.    If (GUICtrlRead($v) == $GUI_CHECKED) Then
  205.       pTime()
  206.       $text = ("- INFO - - Production points will now be recharged." & @CRLF)
  207.       printLog($text)
  208.    EndIf
  209.    $j=0
  210.    While $j<4
  211.       MouseClick("left", 35, $YONE-319, 2)
  212.       sleep(500)
  213.       MouseClick("left", 470, $YONE+21, 1)
  214.       sleep(500)
  215.       $j+=1
  216.       $coupon-=1
  217.    WEnd
  218.    $cicli = 0
  219.    ; Click on messenger window to put on top again
  220.    Mouseclick('left', 175, $YONE+276)
  221.  
  222.    If (GUICtrlRead($v) == $GUI_CHECKED) Then
  223.       pTime()
  224.       $text = ("- INFO - - Used coupons to recharge production points." &@CRLF)
  225.       printLog($text)
  226.    EndIf
  227. EndFunc
  228.  
  229. ; refillDurabilityPoints()
  230. Func refillDurabilityPoints()
  231.    MouseClick('left',510, $YONE-60)
  232.    sleep(500)
  233.    MouseClick('left',505, $YONE-27)
  234.    sleep(500)
  235.    MouseClick("left", 535, $YONE+127)
  236.    sleep(500)
  237.    $position = PixelSearch(340, $YONE+21 , 685, $YONE+24 , 0xFF3527, 2)
  238.    sleep(500)
  239.    if not @error Then
  240.       MouseClickDrag("left", $position[0], $YONE+21 , 685, $YONE+21)
  241.       sleep(500)
  242.       MouseClick("left", 445, $YONE+111)
  243.    Endif
  244.    sleep(5500)
  245.    MouseClick("left", 595, $YONE+161)
  246.    sleep(500)
  247.    MouseClick("left", 645, $YONE+141)
  248.    sleep(500)
  249. EndFunc
  250.  
  251. ; restartMinigame() restarts the minigame with a few clicks
  252. Func restartMinigame()
  253.    pTime()
  254.    If (GUICtrlRead($v) == $GUI_CHECKED) Then
  255.       $text = ("- INFO - - Restarting minigame..." & @CRLF)
  256.       printLog($text)
  257.    EndIf
  258.    MouseClick('left',510, $YONE-59)
  259.    sleep(500)
  260.    MouseClick('left',510, $YONE-29)
  261.    sleep(500)
  262.    MouseClick('left',430, $YONE+136)
  263.    sleep(500)
  264.  
  265.    ; CHECK FOR DURABILITY
  266.    If(Pixelgetcolor(660, $YONE+26) == "") Then
  267.      pTime()
  268.      $text = ("- ERROR - - Durability terminated. Stalling." & @CRLF)
  269.      printLog($text)
  270.      Mouseclick('left', 660, $YONE+ 36)
  271.      Return
  272.   EndIf
  273.  
  274.    MouseClick('left',475, $YONE+161)
  275.  
  276.    If (GUICtrlRead($v) == $GUI_CHECKED) Then
  277.       pTime()
  278.       $text = ("- INFO - - Minigame restarted." & @CRLF)
  279.       printLog($text)
  280.    EndIf
  281. EndFunc
  282.  
  283. Func refillandbacktoMini()
  284.    pTime()
  285.    $text = ("- INFO - - Going back to own's miniland to refill durability." & @CRLF)
  286.    printLog($text)
  287.    ; Go out of the miniland if still there,
  288.    ; otherwise just move randomly
  289.    MouseClick('left', 883, $YONE-319)
  290.    sleep(25000)
  291.    ; Stop player from moving eventually
  292.    Mouseclick('left', 500, $YONE+111)
  293.    sleep(1000)
  294.    ; Go to own's miniland
  295.    Mouseclick('left', 917, $YONE-249)
  296.    sleep(10000)
  297.    ; Coordinate minigame
  298.    Mouseclick('left',890, $YONE-260)
  299.    sleep(10000)
  300.    ; Refill Durability
  301.    refillDurabilityPoints()
  302.    ; Go out of miniland
  303.    MouseClick('left', 883, $YONE-319)
  304.    sleep(10000)
  305.    Mouseclick('left', 925, $YONE-259)
  306.    sleep(5000)
  307.    ; Click selected friend to go to his miniland
  308.    MouseClick('left', 220, $YONE-49+(20*$friend))
  309.    sleep(7000)
  310.    ; Coordinate minigame
  311.    Mouseclick('left',890, $YONE-260)
  312.    sleep(10000)
  313. EndFunc
  314.  
  315. ; checkInactivity() restarts the bot if there were >5 minutes of inactivity
  316. Func checkInactivity()
  317.    $t_diff = TimerdIff($timer)
  318.    If ($t_diff >= (60 * 5 * 1000) and $midnight=False) Then
  319.       pTime()
  320.       $text = ("- ERROR - - Bot has been inactive for " & _
  321.       $t_diff / 1000 &" seconds." & @CRLF)
  322.       printLog($text)
  323.       pTime()
  324.       $text = ("- INFO - - Attempting to go back into the miniland..." & @CRLF)
  325.       printLog($text)
  326.       refillandbacktoMini()
  327.       restartMinigame()
  328.       $timer = TimerInit()
  329.    EndIf
  330. EndFunc
  331.  
  332. ; actualBot() is the actual bot, will press keys when triggered
  333. Func actualBot()
  334.  
  335.    ; Left
  336.    PixelSearch($RIGHT, $YONE-1, $LEFT, $YONE+1, 0xDFA83C)
  337.    If not @error then
  338.       ControlSend("NosTale", "", "", "{left}")
  339.    EndIf
  340.  
  341.    ;Right
  342.    PixelSearch($RIGHT, $YTWO-1, $LEFT, $YTWO+1, 0xDFA83C)
  343.    If not @error then
  344.       ControlSend("NosTale", "", "", "{right}")
  345.    EndIf
  346.  
  347. EndFunc
  348.  
  349. ; =============================================================================
  350. ; Initialize variables
  351. $checkventik = 0
  352. $i = 0
  353. $color = 0
  354. $timer = TimerInit()
  355. $go = 1 ; this one was for a useless feature
  356. $flaggity = 0
  357. $midnight = False
  358.  
  359. ; Do the math, dummy!
  360. $cicli = (2000 - $produzione) / 100
  361.  
  362. $ciclidicicli = 0
  363.  
  364. ; GUI ;
  365. $GUI = GUICreate("NOMOFA v.1.9", 225, 90)
  366. $v = GUICtrlCreateCheckbox ("Verbose Output", 5, 5)
  367. GUICtrlSetState($v, $GUI_CHECKED)
  368. $repair = GUICtrlCreateCheckbox("Repair durability", 120, 5)
  369. GUICtrlSetState($repair, $GUI_CHECKED)
  370. Guictrlcreatelabel("Created by Merutochan.",5, 58)
  371. Guictrlcreatelabel("Death to this cancerous game.",5,73)
  372. Guictrlcreatelabel("ESC to quit.", 165, 73)
  373. ; Display the GUI.
  374. GUISetState(@SW_SHOW, $GUI)
  375.  
  376. $log = FileOpen("LOG - "&@HOUR&"."&@MIN&" "&@MDAY&"-"&@MON&"-"&@YEAR&".txt", 10)
  377.  
  378. ; Display some stuff
  379. printInit()
  380.  
  381. ; Calibrate
  382. Const $YONE = calibratePositions()
  383. Const $YTWO = $YONE + 104
  384.  
  385. ; =============================================================================
  386.  
  387. ; Main program cycle
  388. ; When the loops are still under 20, the program calls the Function actualBot()
  389. While ($coupon>0 & $cicli <20)
  390.    While $cicli < 20
  391.       ; If the flag is set to 0 and we check that the game still hasn't ended
  392.       If (($checkventik == 0) and ($color <> "9852835")) and ($go == 1) then
  393.          ; Each 300 cycles...
  394.          While $i < 300
  395.             actualBot()
  396.             $i+=1
  397.          WEnd
  398.          $i = 0
  399.          ; ...it also seeks for the yellow pixel for the 2 of the
  400.          ; '20,000' goal mark.
  401.          $checkventik_c = PixelgetColor(457, $YONE-183)
  402.          ; When it is found, it means that we have enough score points.
  403.          If $checkventik_c == "16765440" then
  404.             ; Set flag to 1
  405.             $checkventik = 1
  406.          EndIf
  407.          ; Check this color to know if the game finished without enough points
  408.          $color = Pixelgetcolor(620, $YONE+45)
  409.  
  410.       ; If the flag was checked
  411.       ElseIf (($checkventik == 1) and ($go == 1)) then
  412.          ; Keep on checking If the game has ended
  413.          While($color <> "9852835")
  414.             sleep(500)
  415.             $color = Pixelgetcolor(620, $YONE+45)
  416.          WEnd
  417.          ; At this point the game has ended and we have to get the reward
  418.          restartReward()
  419.          $timer = TimerInit()
  420.          If (GUICtrlRead($v) == $GUI_CHECKED) Then
  421.             pTime()
  422.             $text = ("- INFO - - Remaining production points: " & _
  423.             2000 - ($cicli * 100) & @CRLF)
  424.             printLog($text)
  425.          EndIf
  426.          $checkventik = 0
  427.          $color = 0
  428.       ; If ... the flag wasn't checked but the game ended anyway...
  429.       ElseIf ($go == 1) then
  430.          sleep(500)
  431.          ; Check one last time if for any reason the 20'000 mark was missed
  432.          $checkventik_c = Pixelgetcolor(606, $YONE-10)
  433.          If $checkventik_c == "16765440" Then
  434.             restartReward()
  435.          ; Or else we have to restart without getting the reward
  436.          Else
  437.             restartNoReward()
  438.          EndIf
  439.          $timer = TimerInit()
  440.          If (GUICtrlRead($v) == $GUI_CHECKED) Then
  441.             pTime()
  442.             $text = ("- INFO - - Remaining production points: " & _
  443.             2000 - ($cicli * 100) & @CRLF)
  444.             printLog($text)
  445.          EndIf
  446.          $checkventik = 0
  447.          $color = 0
  448.       EndIf
  449.  
  450.       ; Check inactivity
  451.       checkInactivity()
  452.    WEnd
  453.  
  454.    ; Increase count of cycles before filling durability
  455.    If (GUICtrlRead($repair) == $GUI_CHECKED) Then
  456.       $ciclidicicli+=1
  457.    endif
  458.  
  459.    If (GUICtrlRead($v) == $GUI_CHECKED) Then
  460.       pTime()
  461.       $text = ("- INFO - - Production points have terminated." & @CRLF)
  462.       printLog($text)
  463.    EndIf
  464.    ; After the twenty loops we have to recharge production points
  465.    sleep(500)
  466.    MouseClick("left", 645, $YONE+31)
  467.    sleep(500)
  468.    MouseClick("left", 595, $YONE+71)
  469.    sleep(500)
  470.  
  471. ; If we still have coupons we have to use 4 of them
  472.    If ($coupon>0) Then
  473.       ; Repair Durability each 7 cycles
  474.       If ((GUICtrlRead($repair) == $GUI_CHECKED) and ($ciclidicicli==7)) Then
  475.          refillandbacktoMini()
  476.          $ciclidicicli = 0
  477.       EndIf
  478.       ; Refill coupon
  479.       refillProductionPoints()
  480.       ; Restart minigame
  481.       restartMinigame()
  482.    EndIf
  483.  
  484. WEnd
  485.  
  486. ; No more coupons!
  487. pTime()
  488. $text = ("- INFO - - Coupons have terminated." & @CRLF)
  489. printLog($text)
  490.  
  491. ; Wait to be killed
  492. While 1
  493. Switch GUIGetMsg()
  494.    Case $GUI_EVENT_CLOSE, $idClose
  495.       Exit
  496. EndSwitch
  497. WEnd
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top