Grepolis bot (Now with attack option)

02/18/2010 12:59 Unghiutza#61
Utharnl will it be difficult to make some NPC attacking options ?
02/18/2010 14:05 Utharnl#62
Quote:
Originally Posted by sonzomerta View Post
in bot directory find settings.txt

one line of text shows following:
Code:
user;pass;1;en.grepolis.com;en.grepolis.com;en3.grepolis.com;True;debug.txt;settings.txt
It seems the first listing for English (en.grepolis.com) has to be the main login server,
then you add a number for the world you wish to load (gamma = en3, alpha = en1, the testing server is zz1 but not tested this with it).
That's indeed how it works. Not sure if you made a typo but you have to change your settings to:

Code:
user;pass;1;en.grepolis.com;en3.grepolis.com;True;debug.txt;settings.txt
You had included "en.grepolis.com" twice.


@Unghiutza
Not sure if it's difficult but i'm going to look at it next week. Then I will know more.
02/18/2010 16:45 Mumak#63
I'm still can't log.

My settings:
Quote:
ThaRealiestJEDI;*******;1;pl.grepolis.com;pl1.grep olis.com;True;debug.txt;settings.txt
It may be wine slow server?

//
Sory, I do mistake in my nick. It's work :D

btw, can you do small change. Can it minimize to bar where clock is in windows. I don't know how it's called :P
02/18/2010 18:48 Utharnl#64
That shouldn't be a problem, will add it next version
02/20/2010 08:16 srialmaster#65
@Utharnl

Can you change the Time Code from

private int m_TimerLoginDelay = 60000;//ms

to:

private int m_TimerLoginDelay = 720000;//ms

This should allow the users to have a timer up to 5hours instead of 1.

Also,
Can you add this:

/*
* Update resources on gui
*/
Wood.production = #Wood;
Stone.production = #Stone;
Iron.production = #Iron;
private void updateGUIResources()

{
label_WoodNr.Text = m_Towns[m_CurrentTown].Wood"("Wood.production"/h)";
label_StoneNr.Text = m_Towns[m_CurrentTown].Stone"("Stone.production"/h)";
label_IronNr.Text = m_Towns[m_CurrentTown].Iron"("Iron.production"/h)";
label_StorageNr.Text = m_Towns[m_CurrentTown].Storage;
}
******
I think from the source that #Wood/#Stone/#Iron are the variable from the server for production per hour.

This is from page source of Senate:

PopupFactory.addTexts({
wood_production : "<h4>Wood</h4>Production per hour: 190<br />This island yields less wood than the others.",
stone_production : "<h4>Rock</h4>Production per hour: 195",
iron_production : "<h4>Silver coins</h4>Production per hour: 198<br />The mountains on this island have enormous silver deposits, which means that your silver mine can extract more silver.",
favor_production : "<h4>Favor</h4><ul><li>Athena: 116 - Production per hour: 2.6</li></ul>"
});

$("#wood").setPopup("wood_production");
$("#stone").setPopup("stone_production");
$("#iron").setPopup("iron_production");



-Nate
02/20/2010 11:13 Utharnl#66
Quote:
Originally Posted by srialmaster View Post
@Utharnl

Can you change the Time Code from

private int m_TimerLoginDelay = 60000;//ms

to:

private int m_TimerLoginDelay = 720000;//ms

This should allow the users to have a timer up to 5hours instead of 1.
Hey Nate the variable m_TimerLoginDelay is used for something else. It's the timer used to reconnect to the server when you are disconnected. It's still code i'm working on, it doesn't yet always work.

I know what you mean though, I will change it in the next version.
Here's a temporarily solution you can use:

Code:
(settings.cs)
/*
 * Constructor
 */ 
public Settings()
{
  InitializeComponent();
  setLoadedSettings();
  this.numericUpDownTimer.Maximum = 300;//Minutes
}
Will add the production rate also in the next version.

~Uthar
02/20/2010 19:09 dbtuga#67
Hey. I need help in pt server.
i just cant login..any ideas?
02/20/2010 22:48 srialmaster#68
Quote:
Originally Posted by Utharnl View Post
Hey Nate the variable m_TimerLoginDelay is used for something else. It's the timer used to reconnect to the server when you are disconnected. It's still code i'm working on, it doesn't yet always work.

I know what you mean though, I will change it in the next version.
Here's a temporarily solution you can use:

Code:
(settings.cs)
/*
 * Constructor
 */ 
public Settings()
{
  InitializeComponent();
  setLoadedSettings();
  this.numericUpDownTimer.Maximum = 300;//Minutes
}
Will add the production rate also in the next version.

~Uthar
Code:
(town.cs)
class Town
    {
        private String m_TownID = "";
        private Queue<String[]> m_BuildingQueue = new Queue<String[]>();
        private List<Building> m_Buildings = new List<Building>();
        private String[] m_IngameBuildingQueue = new String[] { "", "", "", "", "", "", "" };//Not realy dynamic... but it works
        private String m_Wood = "0";
        private String m_Stone = "0";
        private String m_Iron = "0";
        private String m_Storage = "0";
How can I make it here where I can add an If Then statement to load m_QueueFile?

I added these so far:

Code:
(settings.cs)
public partial class Settings : Form
    {
        private String m_UserName = "";
        private String m_Password = "";
        private String m_Timer = "1";
        private String m_MainServer = "";
        private String m_Server = "";
        private String m_DebugFile = "debug.txt";
        private String m_SettingsFile = "settings.txt";
        private String m_TranslationFile = "translation.txt";
        private String m_QueueFile = "queue.txt";

****************************

 public String QueueFile
        {
            get { return m_QueueFile; }
            set { m_QueueFile = value; }
        }

****************************

//Methods
        private void updateSettings()
        {
            m_UserName = textBoxUserName.Text;
            m_Password = textBoxPassword.Text;
            m_Timer = numericUpDownTimer.Value.ToString();
            m_MainServer = textBoxMainServer.Text;
            m_Server = textBoxServer.Text;
            m_DebugOn = checkBoxDebugMode.Checked;
            m_DebugFile = textBoxDebugFile.Text;
            m_SettingsFile = textBoxSettingsFile.Text;
            m_QueueFile = textBoxQueueFile.Text;
        }

        public void setLoadedSettings()
        {
            textBoxUserName.Text = m_UserName;
            textBoxPassword.Text = m_Password;
            numericUpDownTimer.Value = decimal.Parse(m_Timer);
            textBoxMainServer.Text = m_MainServer;
            textBoxServer.Text = m_Server;
            checkBoxDebugMode.Checked = m_DebugOn;
            textBoxDebugFile.Text = m_DebugFile;
            textBoxSettingsFile.Text = m_SettingsFile;
            textBoxQueueFile.Text = m_QueueFile;
        }
I used to program in C++ a long time ago, so I thought trying to help out with this project with you could help me learn C# too. It's been almost 9 years since I worked with C++.

One other thing.... A logout option.....
Code:
/*
         * Log out from the game server
         */
        private void logOut()
        {
            try
            {
                m_State = "logout";
                loadSettingsRequest();

                setStatusBar("Logging Out");

                String l_Url = "http://" + m_Settings.MainServer + "/start?action=logout";
                                
            }
            catch (Exception e)
            {
                debug(e.Message);
            }
        }
Is this possible?

-Nate
02/21/2010 00:56 Utharnl#69
Quote:
Originally Posted by dbtuga View Post
Hey. I need help in pt server.
i just cant login..any ideas?
Could you check your settings.txt?
Your server settings should look like pt.grepolis.com;pt1.grepolis.com
Or maybe there's a small typo in your username or password?

The last time I checked the pt server is just a few days ago. There weren't any problems then with the login.

@srialmaster
Nice to hear that you want to learn some C#

But it's a bit difficult to let someone else add things. If you add something new there's a big chance you have to update some old code as well.

But the logout code is almost correct.
Code:
String l_Url = "http://" + m_Settings.MainServer + "/start?action=logout";
Uri l_Uri = new Uri(l_Url);
m_HtmlHandler.DownloadStringAsync(l_Uri);
We need also a new state for this. m_State = "logout" for example.
You can handle this state in the method: client_DownloadStringCompleted

I'm not really sure yet if we need this function though. Because if you exit the bot and login with your browser the session you had with the bot is gone.

To save the building queue is some more work. The settings you added for queue text file looks correct.
To save/load this text file you need to know the townid and the building names for in the queue (the dev name (first line in translation.txt) not the local).
Form1.cs is the main class and knows every object so you have to create a new method there.
Remember you can only load the queue when you are logged in and townid is known.

There are probably some more things that you need to check but it's already too late to think of them.

I think I will work alone on this bot for the time being. But you can always come with ideas or questions about the code.


~Uthar
02/21/2010 05:23 srialmaster#70
Quote:
Originally Posted by Utharnl View Post
Could you check your settings.txt?
Your server settings should look like pt.grepolis.com;pt1.grepolis.com
Or maybe there's a small typo in your username or password?

The last time I checked the pt server is just a few days ago. There weren't any problems then with the login.

@srialmaster
Nice to hear that you want to learn some C#

But it's a bit difficult to let someone else add things. If you add something new there's a big chance you have to update some old code as well.

But the logout code is almost correct.
Code:
String l_Url = "http://" + m_Settings.MainServer + "/start?action=logout";
Uri l_Uri = new Uri(l_Url);
m_HtmlHandler.DownloadStringAsync(l_Uri);
We need also a new state for this. m_State = "logout" for example.
You can handle this state in the method: client_DownloadStringCompleted

I'm not really sure yet if we need this function though. Because if you exit the bot and login with your browser the session you had with the bot is gone.

To save the building queue is some more work. The settings you added for queue text file looks correct.
To save/load this text file you need to know the townid and the building names for in the queue (the dev name (first line in translation.txt) not the local).
Form1.cs is the main class and knows every object so you have to create a new method there.
Remember you can only load the queue when you are logged in and townid is known.

There are probably some more things that you need to check but it's already too late to think of them.

I think I will work alone on this bot for the time being. But you can always come with ideas or questions about the code.


~Uthar
The reason for the logout script is to make it where I can login with the browser, make any actions I want to and not have to restart the bot. This is just to make a quick fix for the queue until we can make a queue txt file to save the queue.

Basically:

Login
Build your queue
Start
(maybe add a pause here)
Logout
Do what you want in the browser, then logout on browser
Login
(un-pause the bot) and it keeps going.

Right now I am working 10hours/day and will go to 12hours/day next month for 3 weeks. Then, I will have more time to dig into this. I just thought I could give a hand in adding features with this....modulation. I worked on the Form1.cs earlier, but didn't save it. I know what you mean about adding the m_statement for the txt file. As far as adding the Logout to the menu, I can do that too. I will add the logout feature tonight and try it. Hopefully, I can login, make some queues, logout, attack some towns/farms, login and let the bot run while I sleep and at work the next day.
02/21/2010 10:25 srialmaster#71
I tried setting up some of the references for the queue.txt file. Also, I tried adding the Logout feature.....but it's not working....

I have attached my current files for the coding.

-Nate
02/21/2010 22:56 Utharnl#72
The login method triggers a sequence of methods.
-Looking for town
-Getting building data
-Creating new Town object with this data

So if you call login again after you logged out it will overwrite all the current town data, also your building queue.

I think we can better skip the logout function and only make a relogin function. (If you login on your browser it will logout the bot). The new relogin function must then only connect to the server and don't update the town info.

At the moment I'm first updating a few things on my Empire Craft bot and after that I'm going to work on this one.

Todo list is getting bigger and bigger for grepolis, have this planned so far:
-Show resource production
-Minimize to tray icon
-Attack farmers
-Reconnect to server
-Bigger timer
02/22/2010 13:11 srialmaster#73
Quote:
Originally Posted by Utharnl View Post
The login method triggers a sequence of methods.
-Looking for town
-Getting building data
-Creating new Town object with this data

So if you call login again after you logged out it will overwrite all the current town data, also your building queue.

I think we can better skip the logout function and only make a relogin function. (If you login on your browser it will logout the bot). The new relogin function must then only connect to the server and don't update the town info.

At the moment I'm first updating a few things on my Empire Craft bot and after that I'm going to work on this one.

Todo list is getting bigger and bigger for grepolis, have this planned so far:
-Show resource production
-Minimize to tray icon
-Attack farmers
-Reconnect to server
-Bigger timer
Prioritize:
1.Minimize to tray icon
2.Show resource production
3.Bigger timer
4.Reconnect to server
5.Attack farmers

I think this would be the easiest order. :)

I wish I was of help more.

Also, on relogin, it needs to update resource and production/hour only. It could just load the queue txt.

-Nate
02/22/2010 14:10 Unghiutza#74
Nooo, the attack farmers should be the 1st, cuz it the hardest, and after you get finished with it it would be like a weight off of your shoulders... :)

If you make the option to attack farmers could u make one to attack other polis aswell ? ... it would be coordinate based..
02/23/2010 12:10 mumbumbe#75
Super Vielen Dank.