autoban
This commit is contained in:
parent
24f5275079
commit
0a598543cd
|
@ -11,6 +11,7 @@ private:
|
|||
ScreenShot* screen;
|
||||
Matcher acceptmatcher;
|
||||
Matcher arrowmatcher;
|
||||
Matcher banmatcher;
|
||||
Matcher::Match lastacceptmatch;
|
||||
XInputSimulator& sim;
|
||||
|
||||
|
@ -31,6 +32,7 @@ private:
|
|||
State state = State::LOBBY;
|
||||
|
||||
void checkForGame();
|
||||
void checkForBan();
|
||||
void performClick(uint32_t nr);
|
||||
void enterSearch(const std::string& text);
|
||||
void pickFirst(const std::string& search);
|
||||
|
|
|
@ -61,6 +61,28 @@ void LolAutoAccept::checkForGame() {
|
|||
lastacceptmatch = mat;
|
||||
}
|
||||
|
||||
void LolAutoAccept::checkForBan() {
|
||||
cv::Mat img;
|
||||
screen->take(img);
|
||||
|
||||
cv::resize(img, img, cv::Size(ScreenShot::DEFAULTWIDTH, ScreenShot::DEFAULTHEIGHT));
|
||||
|
||||
Matcher::Match mat = banmatcher.match(img);
|
||||
if(mat.doesMatch) {
|
||||
Log::info << "Ban state";
|
||||
|
||||
if(!ban.empty())
|
||||
pickFirst(ban);
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(800));
|
||||
|
||||
// click "ban"
|
||||
performClick(4);
|
||||
|
||||
state = State::BAN;
|
||||
}
|
||||
}
|
||||
|
||||
void LolAutoAccept::performClick(uint32_t nr) {
|
||||
inputs.setOffset(screen->getXOffset(), screen->getYOffset());
|
||||
inputs.setScale(screen->getXScale(), screen->getYScale());
|
||||
|
@ -94,12 +116,13 @@ void LolAutoAccept::pickFirst(const std::string& search) {
|
|||
performClick(3); // first champion
|
||||
}
|
||||
|
||||
LolAutoAccept::LolAutoAccept() : acceptmatcher("imgs/Accept.png"), arrowmatcher("imgs/arrowdown.png"), sim(XInputSimulator::getInstance()) {
|
||||
LolAutoAccept::LolAutoAccept() : acceptmatcher("imgs/Accept.png"), arrowmatcher("imgs/arrowdown.png"), banmatcher("imgs/ban.png"), sim(XInputSimulator::getInstance()) {
|
||||
// click positions in 1280x720 scale
|
||||
inputs.addPoint({0, 0}); // zero zero
|
||||
inputs.addPoint({645, 560}); // accept game
|
||||
inputs.addPoint({775, 105}); // search box
|
||||
inputs.addPoint({380, 160}); // first champ
|
||||
inputs.addPoint({638, 608}); // pick champ
|
||||
}
|
||||
|
||||
void LolAutoAccept::setPrePick(const std::string& prePick) {
|
||||
|
@ -139,6 +162,8 @@ void LolAutoAccept::run() {
|
|||
case State::LOBBY:
|
||||
checkForGame();
|
||||
break;
|
||||
case State::PREPICK:
|
||||
checkForBan();
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ int main(int argc, const char** argv) {
|
|||
LolAutoAccept lolaa;
|
||||
|
||||
lolaa.setPrePick("morgana");
|
||||
lolaa.setBan("swain");
|
||||
|
||||
lolaa.run();
|
||||
|
||||
|
|
|
@ -119,6 +119,8 @@ void ScreenShot::take(cv::Mat& cv_img) {
|
|||
if (init)
|
||||
init = false;
|
||||
|
||||
updateAttrib();
|
||||
|
||||
XShmGetImage(display, window, ximg, 0, 0, 0x00ffffff);
|
||||
cv_img = cv::Mat(wattrib.height, wattrib.width, CV_8UC4, ximg->data);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue