Screeps: World Guide

How To Make A Simple Qt/C++ Game Analyst Software(no Grunt usage) for Screeps: World

How To Make A Simple Qt/C++ Game Analyst Software(no Grunt usage)

Overview

Heres a simple way to create a simple game analyst software important thing to know here basic Qt/C++ & basic game knowledge, if not i suggest you to take a small tuto on how to use qt & do game tutorial theres also good newbies guide already existing i prefered those made by th_pion 🙂

Creation of the qt project

First step is to create a qt project, open qt then click on new project and create a normal qt widget application.

Once you have select Application->Qt Widgets Application, click on choose at the bottom right of the window.Its gonna ask you to name the the project me i called Monitoring_Tuto.

We almost there guys & girls after we have to select our dev kit wich its the compiler that we gonna use for me i use MinGW 32bit (but you can use the one you use to).

Click next & setup the class of your main window for me i leave it like it is already.

Click next & after finish as we dont need a sub project you could but not for now, once you have click on finish the real work gone to start so for now thats what everyone should see.

Editing the mainwindow.ui

This step is the most funny parts thats where we design our application.
double-click on the mainwindow.ui .

Once , we double-clicked on mainwindow.ui our working space should look like this.

now we want to remove the extra flawflaw thats is provide by the creation project,
remove all the highlighted part in the following image by right click then delete or simply select
the item the press delete on your keyboard.


i got the highlight master certification Rolfing.

Alright now you should have removed 3 extra flawfy thing

  • Menu Bar
  • Main Tool Bar
  • Status Bar

And now our ui should look as more then normal as following.

Now we can add object to our ui as its a tutorial we gonna only add one data to analyse lets say we want to analyse our controller level we gonna need:

  • one progress bar
  • one text label

All the objects are in the left tab you can drag & drop those mentioned above in the list
we want this kind of look.

It only left renaming objects and modificate them a bit for this part of the tuto, select the progress bar by one click
then rename it to Controller_Level_progressBar in the left tab, in the following image the object name is underlined in red .

in the same left tab at the bottom in the green zone.

Change the maximum to 8 since theres just 8 level of controller
and change the value to 0 instead of 24.

last ui edit its the text label double-click on the object and change the text to “controller level:”
we have done our ui works now lets look at the result before keeping up, you should all have the same result as the following image.

Now we are ready to script a bit in the next chapter.

Editing mainwindow.h

Edit mainwindow.h is pretty simple lets start.
Double-click on the right tab mainwindow.h , our outter space work should be as the following image.

as you should know how to use c++ , include the following headers

  • #include <QtCore>
  • #include <QtGui>

Once the headers are include we want to create 2 function for that we gonna have to add private slots , we need.

  • Queud() ;
  • Read_Data() ;

Hmmmm what the ♥♥♥♥ is that :O where it go , how i do , dont worry the following image contain the result you should have if not make your mainwindow.h according to the image

Editing mainwindow.cpp

Heres the big deal for me to find the words for you to script this and to understand , as im not the most communicativ person i wish i did it well.
Alright im stopping crying, double-click on mainwindow.cpp , here whats our work space should look like.

We need to include 2 headers.

  • QTimer /*this header its for queud processing */
  • QFileDialog /*this header its for read/write file in our case read*/

We need 1 global variable called controller_level

  • int controller_level = 0 ;

We need 2 function Queud & Read_Data that we earlier declared in the mainwindow.h

  • Queud() { … }
  • Read_Data() { … }

lets take a pause and look at our mainwindow.cpp , you should have the same result as the following image.

In the function Queud add the following script.

In the function Read_Data add the following script.

Here we declared a variable CL that contain controller_level path that we gonna have to manage ourself to generate from the game but no worry we gone to cover this in the following chapters

e.g “C:/Users/Client/AppData/Local/Screeps/scripts/screeps.com/tutorial-2/” this is the folder of the simulation room
e.g “C:/Users/Client/AppData/Local/Screeps/scripts/screeps.com/default/” this is the folder of the pvp servers when you play on screeps official server

we have almost finish our application now we want to modificate only one thing in our mainwindow.cpp the following image show us where we have to look in our mainwindow.cpp

Just after ui->setupUi(this) ; we want to add.

  • Queud() ; /* that the line that call the queud */

Once this done here what should like our mainwindow.cpp as the following image make sure that you have the same result.

In the next chapter we cover the compilation of our software

Compiling our software

To compile your Qt(cute) project you will have to click on the windows button(windows 7 never use 8 or higher).
Then click on all programs select qt folder click on the folder according to your qt version for me its 5.9.2 & select your compiler according to the one you choose when we setup the project for me Qt 5.9.2 for Desktop (MinGW 5.3.0 32 bit)

or simple search in seaking bar in the windows button panel for Qt 5.9.2 for Desktop (MinGW 5.3.0 32 bit) (dont forget it depend on your setup)

once you launch your compiler it should open a cmd as the following image.

Leave the cmd there for the moment we need to give a first build before , return to your qt window where is the current project , click on debug the select release at the bottom left it will spawn a tab as the following image.

After Click on the small hammer located at the same place , and there you go your build its done.
Now return to the cmd that we opened , (note : you need to know where its your qt project on your computer) for me e.g C:UsersClientDocumentsQT_Projectbuild-Monitoring_Tuto-Desktop_Qt_5_9_2_MinGW_32bit-Releaserelease

Type the following line then press enter.
cd C:UsersClientDocumentsQT_Projectbuild-Monitoring_Tuto-Desktop_Qt_5_9_2_MinGW_32bit-Releaserelease

Type again the following content then press enter
windeployqt.exe –quick .

You should have this result if not contact me compiling differ on version.

You are done hehe for this part now we have to upgrade our spawn script in game in the next chapter you can launch our app but it will not work since the game doesnt generate file lonely.
You suppose to have this app when you launch the executable Monitoring_Tuto.exe.

Spawn code to use to log the data

To connect the software to the local game we have to generate a log
file.
Theres 2 path to output the file that our software gonna read wich one depend if you play in simulation or in pvp.

Type the following in you main.js from the game or how you like.


here you go all its done the software read the file while the main.js write to it the requested data
🙂 happy screepting (note: that to log data you have to be running the game if you want to use it without the game you would need to setup a grunt usage & rework path of the software to access to screeps servers files thats where your script are running while you sleeping and dont play but they are updated when with ours in our pc when game launch)

SteamSolo.com