Initial commit

This commit is contained in:
2024-02-24 20:00:46 -05:00
commit a41fe3cd9f
5 changed files with 216 additions and 0 deletions

71
main.go Normal file
View File

@@ -0,0 +1,71 @@
package main
import (
"flag"
"fmt"
"math/rand"
"os"
"os/signal"
"syscall"
"github.com/go-vgo/robotgo"
)
const helpText = "A simple command line tool for automatically calling in strategems in HellDivers 2"
const exampleText = "Example for Expendable Anti-Tank: autostrat.exe -combo=ssawd -cooldown=70"
func main() {
combo := flag.String("combo", "", "The direction combination of keys needed to call in a statagem (wsad not arrows or directions)")
cooldown := flag.Int("cooldown", 0, "The cooldown of the statagem in seconds")
help := flag.Bool("help", false, "Prints this message")
flag.Parse()
if *help {
fmt.Println(helpText)
fmt.Println(exampleText)
flag.PrintDefaults()
} else {
if *combo == "" {
fmt.Println("Error: combo flag cannot be empty")
fmt.Println(exampleText)
flag.PrintDefaults()
return
}
if *cooldown == 0 {
fmt.Println("Error: cooldown flag cannot be empty")
fmt.Println(exampleText)
flag.PrintDefaults()
return
}
go AutoCallStratagems(*combo, *cooldown*1000+1000)
done := make(chan os.Signal, 1)
signal.Notify(done, syscall.SIGINT, syscall.SIGTERM)
fmt.Println("Blocking, press ctrl+c to continue...")
<-done
}
}
func AutoCallStratagems(combo string, cooldown int) {
exit := false
const min = 3
const max = 14
//Wait for exit signal or loop forever
for !exit {
//Toggle start modifier
robotgo.KeyToggle("ctrl", "down")
robotgo.MilliSleep(rand.Intn(max-min) + min)
for _, key := range combo {
robotgo.KeyTap(string(key))
robotgo.MilliSleep(rand.Intn(max-min) + min)
}
fmt.Println("Calling down another stratagem for freedom!")
robotgo.KeyToggle("ctrl", "up")
robotgo.MilliSleep(cooldown)
}
}