Closed ImPulsefire closed 7 years ago
You'd mainly be looking at GrepolisBot.java.
It depends on how you'd want to implement it really. You can store the attack's arrival time in the Town class. The previous bot just looked at the current time and the arrival time every time it cycled through the towns and if it was less than the time to initialize the militia then it would send the request for militia. This is the simple and easy way to go about it, but it does make you seem extremely bot-like.
Unlike the other bot, my bot has the ability to listen in on every XHR request that's sent by grepolis. So you can listen in on when attacks are actually being sent and to what city along with the arrival time the second that they happen. There should also be a notification for when an attack is canceled. This will give you extra options to make you not seem as if you're a bot. You can create a thread that'll execute after 10 mins (I think that's the time they have to cancel) and cancel the thread if the attack is canceled.
The above also requires a more advanced approach. It'd require threads to execute in a human-like manner alongside with the actual bot (if it was running, it'd pause the bot, switch to the town, enlist the militia, and then switch back to where it previously was)
Ok thanks I will try it later because I have something that I find more important : I would like to disable the bot at certain hours like the old bot could. I checked on internet a way to do it but I don't find anything. Can you help me ?
The internet isn't going to help because the majority of the bot client is coded by me; you have to know java. You also have to question whether you want to use the server time (from grepolis) or machine time (the current machine).
If you want to use the server time, you'll have to grab _srvtime from the http requests and convert it to the actual time (it uses unix time). Pausing the bot is as simple as calling the command I coded to do it, pauseBot(). You should also consider breaking out of the main bot thread when it is paused so that when it resumes later it isn't starting off on some random city.
The old bot coded pictures and had tooltips for 30min intervals if I remember correctly. This can be achieved in java as well by using a lot of jLabels.
Hello how can I add auto militia when an attack is incoming ? I know Http request but I don't know in which files I must add it.