Worum geht’s?
Ich stelle kurz und knackig meinen in AutoIt 3 programmierten aktiven Bot für das Browserspiel Swords and Souls vor. Dieser ist hauptsächlich dafür da, Arena-Stages zu farmen. Außerdem nutzt er aktiv (und clever) alle Skills, leert regelmäßig die Bank, tauscht Kleeblätter ein, kauft EXP und speichert zwischendurch. Er könnte also ohne Probleme über Stunden durchlaufen und den Charakter damit verbessern.
Funktionen
Steuerung durch Shortcuts:
- Shift+Alt+A – In der Arena kämpfen
- Shift+Alt+M – Bank leeren und Kleeblätter eintauschen
- Shift+Alt+O – Zurück zur Übersicht gehen, um andere Funktionen zu nutzen
- Shift+Alt+H – Diese Hilfe noch einmal zeigen
- Shift+Alt+X / ESC – Programm beenden
Farmingpausen mit:
- Speichern
- Gold von der Bank einsammeln
- Kleeblätter eintauschen
- Erfahrung für Gold kaufen (erst nach dem Besiegen des Endgegners möglich)
Cleveres Skillsystem:
- Priorität 1: Heilen (Skill 5): nur wenn HP unter 40%
- Priorität 2: Schildschlag (Skill 2): in Bosskämpfen immer benutzen, bei normalen Gegnern nur wenn dessen HP > 25%
- Priorität 3: Schutzschild (Skill 4): immer wenn möglich
- Priorität 4: Gift (Skill 3): in Bosskämpfen immer benutzen, bei normalen Gegnern nur wenn dessen HP > 50%
- Priorität 5: Hack’n’Slay (Skill 6): in Bosskämpfen immer benutzen, bei normalen Gegnern nur wenn dessen HP > 50%
- Priorität 6: Doppelangriff (Skill 1): in Bosskämpfen immer benutzen, bei normalen Gegnern nur wenn dessen HP > 25%
Screenshots
Die Einrichtung muss direkt nach dem Start geschehen und erfolgt durch einen Klick auf den obersten linkesten Pixel des Spielfensters:

Das Browserfenster muss so groß sein, dass das Spiel komplett angezeigt wird. Am Anfang werden in einem Hilfedialog alle Funktionen gelistet:

In der Arena wird zuerst das Level für das Farming gewählt, anschließend noch ob das Pausenfeature genutzt werden soll und schon legt der Bot los:


Video
Download und Code
Hier gibts den Bot als Download für 32/64bit Windows und, falls jemand den Bot weiterentwickeln oder anpassen möchte, den kompletten Code 1:1.

swords-and-souls-bot.exe (32bit)
swords-and-souls-bot_x64.exe (64bit)
Code anzeigenDen Code könnt ihr bequem mit den Links/Rechts Pfeiltasten horizontal bewegen.
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=swords-and-souls-bot.ico
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_Res_Description=AutoIt Bot for the browsergame "Swords and Souls", developed by Hannes Schurig in 2016
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_Res_LegalCopyright=Hannes Schurig
#AutoIt3Wrapper_Res_Language=1031
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Misc.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>
AutoItSetOption("SendKeyDelay", 40)
AutoItSetOption("SendKeyDownDelay", 40)
AutoItSetOption("MouseClickDelay", 40)
AutoItSetOption("WinTitleMatchMode", 2)
AutoItSetOption("MouseCoordMode", 1)
$noCoords = True
Local $ol[2]
$i = 0 ; fight counter
$survival = False
Local $levelcoords[2] = [0,0]
$clickCriticals = True
$pauseFarming = True
$pauseFarmingAfterXMatches = 2
HotKeySet("{Esc}", "exitnow") ; ESC
HotKeySet("+!x", "exitnow") ; Shift+Alt+X
HotKeySet("+!a", "arenaFight") ; Shift+Alt+A
HotKeySet("+!m", "museum") ; Shift+Alt+M
HotKeySet("+!o", "overview") ; Shift+Alt+O
HotKeySet("+!h", "help") ; Shift+Alt+H
Func exitnow()
Exit
EndFunc
; prepare
WinActivate("Swords")
Sleep(300)
MsgBox($MB_TOPMOST + $MB_SETFOREGROUND + $MB_DEFBUTTON1 + $MB_ICONINFORMATION + $MB_OK,"Ecke oben links anklicken","Klicke in den obersten linkesten Pixel des Spiels.")
While $noCoords
If _IsPressed("01") Then
$ol = MouseGetPos()
ConsoleWrite("####### Koords: " & $ol[0] & " " & $ol[1] & @CRLF)
$noCoords = False
EndIf
WEnd
If checkSingleCoordWithColor($ol[0]+578, $ol[1]+400, 0xB65D52) Then
ConsoleWrite("####### Location: Map Overview" & @CRLF)
MsgBox($MB_TOPMOST + $MB_SETFOREGROUND + $MB_DEFBUTTON1 + $MB_ICONINFORMATION + $MB_OK, "Deine Position", "Du befindest dich in der Übersichtskarte.")
EndIf
If checkSingleCoordWithColor($ol[0]+394, $ol[1]+460, 0x745818) Then
ConsoleWrite("####### Location: Museum" & @CRLF)
MsgBox($MB_TOPMOST + $MB_SETFOREGROUND + $MB_DEFBUTTON1 + $MB_ICONINFORMATION + $MB_OK, "Deine Position", "Du befindest dich im Museum.")
EndIf
If checkSingleCoordWithColor($ol[0]+66, $ol[1]+64, 0xC8B05E) Then
ConsoleWrite("####### Location: Arena" & @CRLF)
MsgBox($MB_TOPMOST + $MB_SETFOREGROUND + $MB_DEFBUTTON1 + $MB_ICONINFORMATION + $MB_OK, "Deine Position", "Du befindest dich in der Arena.")
EndIf
help()
Func help()
MsgBox($MB_TOPMOST + $MB_SETFOREGROUND + $MB_DEFBUTTON1 + $MB_ICONINFORMATION + $MB_OK, "Hilfe", "Du kannst folgende Shortcuts nutzen:" & @CRLF & _
"Shift+Alt+A - In der Arena kämpfen" & @CRLF & _
"Shift+Alt+M - Bank leeren und Kleeblätter eintauschen" & @CRLF & _
"Shift+Alt+O - Zurück zur Übersicht gehen, um andere Funktionen zu nutzen" & @CRLF & _
"Shift+Alt+H - Diese Hilfe noch einmal zeigen" & @CRLF & _
"Shift+Alt+X / ESC - Programm beenden" & @CRLF & _
"Dies ist ein Maus/Tastatur-Bot. Der PC ist, während der Bot läuft, nicht direkt benutzbar.")
EndFunc
Func overview()
; force-go to overview map
While Not checkSingleCoordWithColor($ol[0]+578, $ol[1]+400, 0xB65D52)
MouseClick("left", $ol[0]+25, $ol[1]+20,1)
Sleep(800)
WEnd
EndFunc
Func arenaFight()
; check for overview map
If checkSingleCoordWithColor($ol[0]+578, $ol[1]+400, 0xB65D52) Then
; go to arena
MouseClick("left",$ol[0]+235, $ol[1]+165,1)
; check for arena
ElseIf checkSingleCoordWithColor($ol[0]+66, $ol[1]+64, 0xC8B05E) Then
; continue
Else
; force-go to overview map
While Not checkSingleCoordWithColor($ol[0]+578, $ol[1]+400, 0xB65D52)
MouseClick("left", $ol[0]+25, $ol[1]+20,1)
Sleep(800)
WEnd
; go to arena
MouseClick("left",$ol[0]+235, $ol[1]+165,1)
EndIf
; level input
$level = InputBox("Welches Level?", "Bitte gib das Level ein, dass gefarmt werden soll." & @CRLF & _
"Möglich Eingaben sind '1' - '30', 'survival' und 'final'", "", " M", 280, 150)
If $level > 0 And $level <= 10 Then
$levelcoords[0] = $ol[0] + 119 + (($level - 1)*62)
$levelcoords[1] = $ol[1] + 292
ElseIf $level > 10 And $level <= 20 Then
$levelcoords[0] = $ol[0] + 97 + (($level - 11)*66)
$levelcoords[1] = $ol[1] + 334
ElseIf $level > 20 And $level <= 30 Then
$levelcoords[0] = $ol[0] + 75 + (($level - 21)*71)
$levelcoords[1] = $ol[1] + 392
ElseIf $level = "final" Then
$levelcoords[0] = $ol[0] + 489
$levelcoords[1] = $ol[1] + 482
ElseIf $level = "survival" Then
$levelcoords[0] = $ol[0] + 339
$levelcoords[1] = $ol[1] + 456
$survival = True
Else
MsgBox($MB_TOPMOST + $MB_SETFOREGROUND + $MB_DEFBUTTON1 + $MB_ICONERROR + $MB_OK, "Falsche Eingabe", "Die Eingabe konnte nicht verwertet werden." & @CRLF & _
"Der Bot setzt sich zurück, anschließend kannst Du erneut den Arena-Modus starten.")
; force-go to overview map
While Not checkSingleCoordWithColor($ol[0]+578, $ol[1]+400, 0xB65D52)
MouseClick("left", $ol[0]+25, $ol[1]+20,1)
Sleep(800)
WEnd
Sleep(1000)
Return
EndIf
If $levelcoords[0] == 0 Then
MsgBox($MB_TOPMOST + $MB_SETFOREGROUND + $MB_DEFBUTTON1 + $MB_ICONERROR + $MB_OK, "Unerwarteter Fehler", "Der Bot setzt sich zurück, anschließend kannst Du erneut den Arena-Modus starten.")
; force-go to overview map
While Not checkSingleCoordWithColor($ol[0]+578, $ol[1]+400, 0xB65D52)
MouseClick("left", $ol[0]+25, $ol[1]+20,1)
Sleep(800)
WEnd
Sleep(1000)
Return
EndIf
; pause farming regulary after some matches - save, grab income, turn in cloverleafs frequently, get exp for gold?
$save = MsgBox($MB_TOPMOST + $MB_SETFOREGROUND + $MB_DEFBUTTON1 + $MB_ICONQUESTION + $MB_YESNO, "Farming mit Pausen?", "Soll der Bot während des Farmens weitere hilfreiche Aufgaben übernehmen? Folgende Aufgaben würde der Bot alle " & $pauseFarmingAfterXMatches & " Matches ebenfalls übernehmen:" & @CRLF & _
"- Speichern" & @CRLF & _
"- Gold von der Bank einsammeln" & @CRLF & _
"- Kleeblätter eintauschen" & @CRLF & _
"- Erfahrung für Gold kaufen (erst nach dem Besiegen des Endgegners möglich)", "", " M")
If $save = $IDYES Then
$pauseFarming = True
Else
$pauseFarming = False
EndIf
; arena:
while 1
WinActivate("Swords")
Sleep(1200)
; ------------- MANAGING MATCHES --------------------------------------------------
; lost/survival done, retry
If checkSingleCoordWithColor($ol[0] + 351, $ol[1] + 326, 0x5A3D1D) Then
MouseClick("left",$ol[0] + 351, $ol[1] + 326, 1)
$i += 1
EndIf
; survival start
If $survival And checkSingleCoordWithColor($ol[0]+292, $ol[1]+175, 0x938D6F) Then
; click survival
MouseClick("left", $levelcoords[0], $levelcoords[1], 1)
Sleep(500)
; click "start"
MouseClick("left", $levelcoords[0], $levelcoords[1], 1)
Sleep(1500)
EndIf
; survival ended, "ok"
If $survival And checkSingleCoordWithColor($ol[0] + 426, $ol[1] + 448, 0x5D3F1D) Then
MouseClick("left", $ol[0] + 426, $ol[1] + 448, 1)
Sleep(1000)
EndIf
; final ended, scarecrow talk
If checkSingleCoordWithColor($ol[0] + 360, $ol[1] + 511, 0xE6DFC7) Then
MouseClick("left", $ol[0] + 360, $ol[1] + 511, 1)
Sleep(1000)
EndIf
; normal match start
If checkSingleCoordWithColor($ol[0]+292, $ol[1]+175, 0x938D6F) Then
MouseClick("left", $levelcoords[0], $levelcoords[1], 1)
EndIf
; normal match finished, continue
If checkSingleCoordWithColor($ol[0]+378, $ol[1]+454, 0xFFFFFF) Then
MouseClick("left", $ol[0]+378, $ol[1]+454, 1)
$i += 1
EndIf
; ------------- FIGHTING --------------------------------------------------
; Skill 5 - Healing
; check if available
If checkSingleCoordWithColor($ol[0]+490, $ol[1]+560, 0xFFE7C1) Then
; just use if u're below 50% health
If checkSingleCoordWithColor($ol[0]+284, $ol[1]+453, 0x730520) Then
; enough health
Else
Send("5")
EndIf
EndIf
; Skill 2
; check if available
If checkSingleCoordWithColor($ol[0]+306, $ol[1]+565, 0xFFE7C1) Then
; if in boss battle - use it anytime
If checkCoordRangeWithColor($ol[0]+404, $ol[1]+451, $ol[0]+442, $ol[1]+469, 0xFFD23E) Then
Send("2")
Else
; if not: only if enemy health 25% or more
If checkSingleCoordWithColor($ol[0]+485, $ol[1]+453, 0x730520) Then
Send("2")
EndIf
EndIf
EndIf
; Skill 4
; if available
If checkSingleCoordWithColor($ol[0]+430, $ol[1]+560, 0xFFE7C1) Then
Send("4")
EndIf
; Skill 3 - Poison
If checkSingleCoordWithColor($ol[0]+369, $ol[1]+552, 0xFFE7C1) Then
; if in boss battle - use it anytime
If checkCoordRangeWithColor($ol[0]+404, $ol[1]+451, $ol[0]+442, $ol[1]+469, 0xFFD23E) Then
Send("3")
Else
; if not: only if enemy health 50% or more
If checkSingleCoordWithColor($ol[0]+515, $ol[1]+453, 0x730520) Then
Send("3")
EndIf
EndIf
EndIf
; Skill 6 - Slashing
If checkSingleCoordWithColor($ol[0]+548, $ol[1]+561, 0xFFE7C1) Then
; if in boss battle - use it anytime
If checkCoordRangeWithColor($ol[0]+404, $ol[1]+451, $ol[0]+442, $ol[1]+469, 0xFFD23E) Then
Send("6")
Else
; if not: only if enemy health 50% or more
If checkSingleCoordWithColor($ol[0]+515, $ol[1]+453, 0x730520) Then
Send("6")
EndIf
EndIf
EndIf
; Skill 1
; if available
If checkSingleCoordWithColor($ol[0]+249, $ol[1]+559, 0xFFE7C1) Then
; if in boss battle - use it anytime
If checkCoordRangeWithColor($ol[0]+404, $ol[1]+451, $ol[0]+442, $ol[1]+469, 0xFFD23E) Then
Send("1")
Else
; if not: only if enemy health 25% or more
If checkSingleCoordWithColor($ol[0]+485, $ol[1]+453, 0x730520) Then
Send("1")
EndIf
EndIf
EndIf
; ------------- REST --------------------------------------------------
; save every 5th fight
If $pauseFarming And $i >= $pauseFarmingAfterXMatches Then
Sleep(1000)
; force-go to overview map
While Not checkSingleCoordWithColor($ol[0]+578, $ol[1]+400, 0xB65D52)
MouseClick("left", $ol[0]+25, $ol[1]+20,1)
Sleep(800)
WEnd
museum()
expForGold()
; go to arena
MouseClick("left",$ol[0]+235, $ol[1]+165,1)
$i = 0
Sleep(1000)
EndIf
WEnd
EndFunc
Func museum()
; force-go to overview map
While Not checkSingleCoordWithColor($ol[0]+578, $ol[1]+400, 0xB65D52)
MouseClick("left", $ol[0]+25, $ol[1]+20,1)
Sleep(800)
WEnd
; go to museum
MouseClick("left",$ol[0]+329, $ol[1]+459, 1)
Sleep(1000)
; get cash
MouseClick("left",$ol[0]+479, $ol[1]+431, 1)
Sleep(1000)
; auto-invest clovers if u're in the room and have some
While checkSingleCoordWithColor($ol[0]+651, $ol[1]+311, 0xE8E5C2)
MouseClick("left",$ol[0]+651, $ol[1]+311,1)
MouseMove($ol[0]+551, $ol[1]+211, 1)
Sleep(2000)
WEnd
Sleep(1000)
; get cash again
MouseClick("left",$ol[0]+479, $ol[1]+431, 1)
Sleep(1000)
; force-go to overview map
While Not checkSingleCoordWithColor($ol[0]+578, $ol[1]+400, 0xB65D52)
MouseClick("left", $ol[0]+25, $ol[1]+20,1)
Sleep(800)
WEnd
Sleep(1000)
EndFunc
Func expForGold()
; force-go to overview map
While Not checkSingleCoordWithColor($ol[0]+578, $ol[1]+400, 0xB65D52)
MouseClick("left", $ol[0]+25, $ol[1]+20,1)
Sleep(800)
WEnd
; go to shop
MouseClick("left",$ol[0]+528, $ol[1]+213, 1)
Sleep(1000)
For $x = 1 To 30 Step +1
MouseClick("left",$ol[0]+396, $ol[1]+548,1)
Sleep(300)
Next
; force-go to overview map
While Not checkSingleCoordWithColor($ol[0]+578, $ol[1]+400, 0xB65D52)
MouseClick("left", $ol[0]+25, $ol[1]+20,1)
Sleep(800)
WEnd
Sleep(1000)
EndFunc
Func training()
; this feature is not ready yet
Return
; check for overview map
If Not checkSingleCoordWithColor($ol[0]+578, $ol[1]+400, 0xB65D52) Then
MsgBox($MB_TOPMOST + $MB_SETFOREGROUND + $MB_DEFBUTTON1 + $MB_ICONINFORMATION + $MB_OK, "Übersichtskarte", "Bitte gehe in die Übersichtskarte, um die Botfunktionen zu starten.")
Return
EndIf
;training crit:
While 1
If checkSingleCoordWithColor(685, 382, 0xffffff) Then
MouseClick("left")
Sleep(700)
MouseClick("left")
$i +=1
ContinueLoop
EndIf
If checkSingleCoordWithColor(789, 381, 0xffffff) Then
MouseClick("left")
Sleep(700)
MouseClick("left")
$i +=1
ContinueLoop
EndIf
If $i>50 Then
; quit crit training
MouseClick("left", $ol[0]+25, $ol[1]+20, 1)
Sleep(5000)
; quit training room & go to map
MouseClick("left", 298, 123, 1)
Sleep(3000)
; go to training room
MouseClick("left", 673, 415, 1)
Sleep(3000)
$i = 0
; start crit training
MouseClick("left", 872, 147, 1)
Sleep(3000)
EndIf
WEnd
; training attack:
While 1
If Not checkSingleCoordWithColorV(326, 455, 0xCC9362, 3) Then
Send("{LEFT}")
ContinueLoop
EndIf
If Not checkSingleCoordWithColorV(560, 466, 0xAD794C, 4) Then
Send("{RIGHT}")
ContinueLoop
EndIf
If Not checkSingleCoordWithColorV(563, 541, 0x926743, 3) Then
Send("{Down}")
ContinueLoop
EndIf
If Not checkSingleCoordWithColorV(511, 373, 0xCF996B, 3) Then
Send("{Up}")
ContinueLoop
EndIf
If Not checkSingleCoordWithColorV(322, 424, 0xD4A57D, 3) Then
Send("{LEFT}")
ContinueLoop
EndIf
WEnd
EndFunc
Func checkSingleCoordWithColor($x, $y, $color)
Return IsArray(PixelSearch($x-3, $y-3, $x+3, $y+3, $color, 3))
EndFunc
Func checkSingleCoordWithColorV($x, $y, $color, $variation)
Return IsArray(PixelSearch($x-3, $y-3, $x+3, $y+3, $color, $variation))
EndFunc
Func checkCoordRangeWithColor($x1, $y1, $x2, $y2, $color)
Return IsArray(PixelSearch($x1-3, $y1-3, $x2+3, $y2+3, $color, 3))
EndFunc
; keep-alive for shotcuts
while 1
sleep(100000000)
WEnd
