Author Topic: GameBot source code  (Read 44240 times)

Offline iL

  • Administrator
  • Ogre Mage
  • *****
  • Posts: 1650
    • View Profile
Re: GameBot source code
« Reply #15 on: July 28, 2015, 03:32:29 AM »
I just forced the bot to loss and he leaves like he lost when activated. No hotkeys necessary to leave game!
I didn't work with memory values at all in this project. Only native client with keys/clicks. Very poor feedback to stealthbot, but quite working solution...
Need help to translate War2Combat to German, French, Italian, Polish or another language: http://forum.war2.ru/index.php/topic,4728.0.html
Please, contact me if you are interested in that.

Offline Delete mine too

  • Death Knight
  • *********
  • Posts: 2652
  • http://meatspin.com
    • View Profile
    • http://meatspin.com
Re: GameBot source code
« Reply #16 on: July 28, 2015, 05:06:31 PM »
I just forced the bot to loss and he leaves like he lost when activated. No hotkeys necessary to leave game!
I didn't work with memory values at all in this project. Only native client with keys/clicks. Very poor feedback to stealthbot, but quite working solution...
Well that's how I feel I don't care how you did it. You made it happen no one else did. Awesome works great!


Offline EviL~Ryu

  • (ง︡'-'︠)ง "Bitchin!" ®©℗™
  • Dragon
  • **********
  • Posts: 6059
  • "It's going to be Legen-(wait for it......)-DARY!"
    • View Profile
    • Clan EviL Official Page
Re: GameBot source code
« Reply #17 on: July 28, 2015, 05:23:08 PM »

I just forced the bot to loss and he leaves like he lost when activated. No hotkeys necessary to leave game!
I didn't work with memory values at all in this project. Only native client with keys/clicks. Very poor feedback to stealthbot, but quite working solution...

Your first mistake using a stealthbot haha, weak coding...


Sent from my Motorola DynaTAC 8000X using Tapatalk

-Administrator of Clan EviL
-Developer (Trivia Development and Analytics)

Offline Thomas29

  • Grunt
  • ***
  • Posts: 75
  • Hey hey hey, That's what I'll Say!
    • View Profile
Re: GameBot source code
« Reply #18 on: July 29, 2015, 06:11:26 PM »
I Did Not Know I Could Connect To Your Server With My Stealthbot What Do I Have To Do And What Information To Input In Order To Do That!
Eat Healthy, Stay Fit And Die Anyways.... Just Smoke Some Bud!


If I Don't Smoke Some Bud I Will Shrivel Up And Die Like A Beautiful Flower Without Water!

Offline Delete mine too

  • Death Knight
  • *********
  • Posts: 2652
  • http://meatspin.com
    • View Profile
    • http://meatspin.com
Re: GameBot source code
« Reply #19 on: July 29, 2015, 06:49:50 PM »
Use hashes and server.war2.ru

Offline {Lance}

  • Sappers
  • ******
  • Posts: 866
    • View Profile
Re: GameBot source code
« Reply #20 on: August 19, 2015, 01:00:24 PM »
Ok as promised, here is the new Stealthbot script.  It's a COMPLETE re-write from the ground up.  There is not a single line of code left from iL's bot from Stealthbot or NNCron.  What he had written was a good base, but it was really terrible as far as flexibility and extensibility.  The idea he had however,  spot on.  Using Stealthbot was definately the way to go.

Ok, so how the F does one use this thing?  Well,  here are the requirements

1.  You must be able to host already.  Either from a VPS or a machine you have access to that is WINDOWS (XP through Win8 will work, IDK about Win10,  I used Win7 and WinXP during development of the bot).  Duuh.  If you cant host, this script is NOT for you.
2.  Decent IT experience.  This is not for the faint of heart.
3.  AutoIt must be installed on the machine that will be hosting games.  There is nothing to configure, you simply need to make sure it's installed and thats it.  Stealthbot accesses Autoit's feature via the COM object that comes with Autoit
4.  2 PVPGN Accounts on server.war2.ru.  One should be called YOURNAME_HostBot and the other should be called YOURNAME_GameBot.  You can use whatever names you want, but that naming convention makes them easy for other players to spot and will know who the owners are.
5.  And finally, Stealthbot This is the heart of the Hostbot.  There are PLENTY of docs on how to setup Stealthbot for PVPGN.  Once You get your YOURNAME_HostBot working and logging in with Stealhbot, the rest is cake.

Steps,  do in this order:

1.  Setup 2 PVPGN Accounts on the RU server YOURNAME_HostBot and YOURNAME_GameBot
2.  Download and install Autoit from https://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe
3.  Download and install Stealthbot from:  http://www.stealthbot.net/sb/Development/482/StealthBotSetup.msi
4.  Open Stealthbot and you will be present with a "Profile" window.  Click "Create Profile"
5.  Give it a name,  Click ok
6.  Double Click the new profile that just showed up in the launcher
7.  Navigate to Settings->Bot Settings->General Settings and fill out the following:
    a.  Username - This is the YOURNAME_HostBot that you created in Step 1
    b.  Password - Duh, take a guess what this is for lmao.  PW for YOURNAME_HostBot
    c.  Server - type in: server.war2.ru
    d.  cdkey - type in: pvpgn
    e.  HomeChannel - Type: War2BNE     OR  You can use your own clan channel if you want.  It can be any channel really.
    f.  Bot Owner - This is your real War2 username.  It's not used in our script but it needs to be filled in none the less.
    g.  Warcraft II BNE -  MAKE SURE TO CLICK THIS BUTTON!!
8.  Navigate to Advanced Settings
    a.  Connection Method - Select "Local Hash" from the drop down
    b.  Click "Apply and Close"
9.  Navigate to Scripting->Open Script Folder
    a.  Right click anywhere in this dir and select "New Text Document" and name it "hostbot.txt"
    b.  Cut/Paste the code I have in this post into the hostbot.txt file
    c.  Modify the "Configuration" section in hostbot.txt with your YOURNAME_GameBot and YOURNAME_HostBot information.  You can also enable/disable autohosting as well as some other things.  I recommend leaving autohosting OFF until you're bot is working perfectly.  Then and only then should you enable the autohosting capabilities.
10. Close the Script Directory window
11. Navigate to Scripting->Reload Scripts
12. Click "Connect"
13. Type /msg YOURNAME_HostBot reboot

If everything went ok, then War2 "should" open and autologin to your YOURNAME_GameBot user and then wait for commands.  Use another computer to test it with.

This is my makeshift "TODO" List. 
* = 100% Complete
~ = Functional but not yet used in a bot command (Partially Complete)

* Optimize code and make it FAR more extensible/flexible/easier to use (yes, I rewrote the ENTIRE bot,  theres not a single line left from iL's old bot,  this is a complete rewrite from scratch.  The only thing that remains is iL's GPL License header lol.
* replace Timer with LongTimer (miliseconds to seconds since Timer sux ass with a 65K limit)
* replace nncron with autoit.
* create new InGame
* autohost games for new players
* add banning and kicking based on slots
~ Make Log() log to file AND the bot owner.
~ add a tVb game type
~ add a FFA game type
~ add feature to allow player to setup all the settings
~Allow any BUILT IN map to be played by giving each map an assigned # that cooresponds to the number of up/down arrows in the built in maps dir.

« Last Edit: August 19, 2015, 01:59:13 PM by {Lance} »
Dk At hall is cause I started with temple at start and didn't need the castle . Not a hack .  I wouldn't bother editing a ss btw

^---- Dellam doesnt hack!  See, even by his own admission, no hack!!  LMFAO.

Offline I hate naggers

  • Ogre Mage
  • ********
  • Posts: 2345
    • View Profile
Re: GameBot source code
« Reply #21 on: August 19, 2015, 01:18:08 PM »
~Allow any BUILT IN map to be played by giving each map an assigned # that cooresponds to the number of up/down arrows in the built in maps dir.
wouldnt it be better to have a little interface with 'browse' button, which then saves the selected map path and overwrites it in w2 registery?

Offline {Lance}

  • Sappers
  • ******
  • Posts: 866
    • View Profile
Re: GameBot source code
« Reply #22 on: August 19, 2015, 01:21:25 PM »
That's trying to make the chicken before the Egg.  Such a system first needs an Index,  that is what the index is for.  Other functions would be able to utilize it.  Whether its another function call, or some GUI.  But generally, Stealthbot scripts dont have a GUI toolkit to begin with.  One could be put together autoit but it would be rudimentary at best.
Dk At hall is cause I started with temple at start and didn't need the castle . Not a hack .  I wouldn't bother editing a ss btw

^---- Dellam doesnt hack!  See, even by his own admission, no hack!!  LMFAO.

Offline iL

  • Administrator
  • Ogre Mage
  • *****
  • Posts: 1650
    • View Profile
Re: GameBot source code
« Reply #23 on: August 19, 2015, 03:32:45 PM »
hostbot.txt
Wow, read your code, it looks really beautiful, powerful and easy to understand!
Looks like you are very experienced in VB.
Nice that you hold the whole code into stealthbot instead of splitting it to autoit.
I didn't even know that stealthbot supports COM-objects and how to use them.
I still didn't try to setup it just because i have no working environment now, i'll try it later.

I'd say the only thing i see to optimize are hardcoded values in ban and kick subs.

Also what do you think about password games? Do we need that or ban/kick is enough?

~ Make Log() log to file AND the bot owner.
Looks like logging should be supported as embedded stealthbot function, but i didn't try that...

~ add a tVb game type
~ add a FFA game type
~ add feature to allow player to setup all the settings
~Allow any BUILT IN map to be played by giving each map an assigned # that cooresponds to the number of up/down arrows in the built in maps dir.
Would be insteresting how to do that not too complicated for users. I'd say 5-7 presets (gow ef, gow f, chop tvb, etc) would also be fine.
Need help to translate War2Combat to German, French, Italian, Polish or another language: http://forum.war2.ru/index.php/topic,4728.0.html
Please, contact me if you are interested in that.

Offline {Lance}

  • Sappers
  • ******
  • Posts: 866
    • View Profile
Re: GameBot source code
« Reply #24 on: August 19, 2015, 04:16:50 PM »
Heh,  well it looks good because I've been developing for uhm, about... ya, 28 years now.  This is my FIRST VBS project btw.  So it's kinda cool that it looks good ;)  Passworded games actually function in this bot, I just dont have it enabled.  But it's easily enabled,  I've tested it and it works fine.  I just dont like pw'd games personally so I didnt add it.  But the feature is there for anyone else to use if they want to put it together.  Kick and Ban works great right now as is.  I use it in the bot that is running now to boot laggers, etc.    It's not a perfect app, but I am satisfied with the end results because its very flexible, easily modified, and easy to extend.  I have lots of examples of how to do things.  I think the coolest thing in the entire app is the Sleep() command.  VBS doesnt have a Sleep command!!!  I couldnt believe it and spent like 2 days searching for the sleep command in VBS and came to the conclusion that............. there just isnt one.  So, I used the next best thing,  Background ping and ping the localhost hahahaha.  Ya I'm sneaky like that :)  I didnt want to use Timers because everytime I used them, the app would lag and this nasty window would pop up saying "Script taking a long time to execute,  Continue/End".  But with ping, the script is not the one doing the sleeping, it's the OS instead so it doesnt lag anything and it even excepts other commands like it were multithreaded almost even though it isnt.

My main goal was to have a working bot,  but a bigger goal was to produce something that others could modify/enhance easily.  I still have some cleanup to do such as switching the ban/kick functions to use the Click() function I created.  They work as is, but they take a lot of space the way they are coded right now.  Using the utility functions I can cut that down.
« Last Edit: August 19, 2015, 04:23:53 PM by {Lance} »
Dk At hall is cause I started with temple at start and didn't need the castle . Not a hack .  I wouldn't bother editing a ss btw

^---- Dellam doesnt hack!  See, even by his own admission, no hack!!  LMFAO.

Offline iL

  • Administrator
  • Ogre Mage
  • *****
  • Posts: 1650
    • View Profile
Re: GameBot source code
« Reply #25 on: August 20, 2015, 09:57:28 AM »
Wow, first VBS project!
Your programming style is great, i still mix different styles in one project, yours is perfect.

My hostbot was just the 1-st working version that required refactoring what you did. I'd reach something like your code after 4-5 full refactorings i think. You are much more experienced programmer than me.

Oh, i didn't find your Sleep implementation firstly, i thought it's embedded VBS function, lol. Yes, great idea, i think i also used ping localhost as 1 sec sleep timeout, i don't remember my project and language where i used it...

BTW, doesn't Sleep block the bot events until it finishes? Need to test how it works...
I also had some problems with timers in my hostbot version, just forgot the details..

You even care of teamviewer handling, i just closed teamviewer and forced restart war2 after that.
You even care of left and right handed mouse.

You also implemented several reasonable states for your bot, i've not been able to do that when making it myself.

Your code inspired me to refactor my antihack backend that is also partly similar with this project: also several states to control, more friendly language for me (php), so i hope to rewrite and release antihack soon.
« Last Edit: August 20, 2015, 09:58:59 AM by iL »
Need help to translate War2Combat to German, French, Italian, Polish or another language: http://forum.war2.ru/index.php/topic,4728.0.html
Please, contact me if you are interested in that.

Offline {Lance}

  • Sappers
  • ******
  • Posts: 866
    • View Profile
Re: GameBot source code
« Reply #26 on: August 20, 2015, 11:23:55 AM »
I was at first expecting ping to affect the "Event" hooks as well.... But it didnt!  So it kinda acts like a multi-threading app even though its not.  The bot still accepts commands even while it's sleeping which is kinda weird.  But the code directly after the sleep.... never runs until the sleep finishes which is weird.  In otherwords,  it works perfectly lol.  PHP is by far my favorite language.  All of the modifications I did to the PVPGN server were all done because I put a PHP interpreter into PVPGN itself so that it could run PHP code natively.  The result was that I could code PVPGN features............ and never have to restart pvpgn.  Ever.  I think I even suggested that to you once before too.  It sure does make life so much easier without having to deal with C all the time lol.  All of the new /COMMAND commands I had,  those were all written in PHP.  Even the antihack and hardware ban features were written in PHP.  Both on the server and the client side.  The only difference is that the client side PHP was compiled into windows executable files with Winbinder (which used phc-win).  There are some new kids on the block that I want to try for that such as HHVM (HipHop for PHP by Facebook),  and some others but Winbinder is by far the best I've ever used.  Another bi-product of using PHP rather than C for PVPGN was that I only needed 1 codebase for 2 platforms (web and PVPGN).  If you havent noticed already,  I like to try to do everything I can to keep my code all in one nice little area so that it can be easily re-used ;)  In general, I like to code lots of smaller pieces of code that can be re-used rather than 1 big long massive function that does everything under the sun.
« Last Edit: August 20, 2015, 11:37:22 AM by {Lance} »
Dk At hall is cause I started with temple at start and didn't need the castle . Not a hack .  I wouldn't bother editing a ss btw

^---- Dellam doesnt hack!  See, even by his own admission, no hack!!  LMFAO.

Offline {Lance}

  • Sappers
  • ******
  • Posts: 866
    • View Profile
Re: GameBot source code
« Reply #27 on: August 31, 2015, 02:23:01 AM »
Here is a second iteration of the GameBot.  These are changes I was going to add last week but ran into a ban that caused all sorts of delays.  Anyway,  things are back to normal so here's something to chew on.

The following is sort of a changelog of the major changes/additions,  * = complete,  ! = planned,  ~ = functional but not yet implemented

* Optimize code and make it FAR more extensible/flexible/easier to use (yes, I rewrote the ENTIRE bot,  theres not a single line

left from iL's old bot,  this is a complete rewrite from scratch.  The only thing that remains is iL's GPL License header lol.
* replace Timer with LongTimer (miliseconds to seconds since Timer sux ass with a 65K limit)
* replace nncron with autoit.
* create new InGame
* autohost games for new players
* add banning based on slots
~ Make Log() log to file AND the bot owner.
* add a tVb game type
* add a FFA game type
* add feature to allow player to setup all the settings
* Allow any BUILT IN map to be played by giving each map an assigned # that cooresponds to the number of up/down arrows in the built in maps dir.

* Add a maint mode that only allows GameBotName, HostBotName, or HostBotOwner to use the bot.
* Temporarily Enable/Disable Autohosting by msging bot the "enable autohosting 5" or "disable autohosting" commands.
* Disallow Reboots when gamebot has been in a game for a short period of time, after that, reboots can take place.  Its to insure players dont reboot it to kick other people out of the game.  If bot has been in game for very long time, reboots are again allowed as it may be stuck in a game.

* Add Some new map settings. (Added GowBNE F, GOW F, Comps, etc)
* Allow people to start the bot if its an autohosted game (!TODO:  Change this to only allow people in the current game to start the game)
!make a list of admin users to protect certain commands.
!make a list of commands that can be given to certain users.
!Force Bot to rejoin Server every time it exits a game so that it doesnt have latency issues.  Make a Rejoin function to do this.
* Backspace before Enter at the vic screen will get rid of the e
~ Add announcement for caught hackers (waiting for iL to produce proper Json data)
! Add announcement for num players in bot hosted games.

-----------------------------------------------------------------------
Here are some examples of how to use the bot as a PLAYER.  These are not as userfriendly as I'd like, but I dont think it can be simplified any further.  The best plan I could come up with are "Presets".  I have 1 example of a "Preset" called "gowcomps".

The defaults of a game can by changed by sending the bot a list of commands in this order as seen below:
/msg EF_HostBot MapName Speed AutoStartTime GameType NumOfCPUs MapResources FixedOrder OnePeon GamePassword

Valid values for MapName:  gow, gowbne
Valid values for Speed: ef, f
Valid values for AutoStartTime:  1 to 15
Valid values for GameType: Melee, FFA, TvB
Valid values for  NumOfCPUs: 0 to 4 (I may increase that later)
Valid values for MapResources: High, Low, Default
Valid values for FixedOrder: Yes, No
Valid values for OnePeon: Yes, No
Valid values for Password: Anything you want.

Defaults to Gow Old EF with a Time of 5 mins
/msg EF_HostBot gow

Gow Old F with a time of 5 minutes
/msg EF HostBot gow f

Gow Old EF with a time of 3 minutes
/msg EF_HostBot gow ef 3

Old Gow on F with 0 CPUs in TVB on Low resources Format that will start in 5 Mins  (NOTE: If you try to add CPUs to a TvB game, it will tell you that you cannot do that.)
/msg EF_HostBot gow f 5 TvB 0 Low

Old Gow EF that has 2 CPUs on Low res and the game will start in 10 mins
/msg EF_HostBot gow f 5 Melee 2 Low

Gow BNE F that starts in 5 mins
/msg EF_HostBot gowbne

Gow BNE EF that starts in 5 mins
/msg EF_HostBot gowbne ef

Gow BNE EF That starts in 3 mins
/msg EF_HostBot gowbne ef 3

and so on.  There are lots of different combinations now that users have full control over pretty much all of the settings.

The 1 preset I have is this and it allows numeric argument:
Defaults to GowBNE EF with 4 CPUs and starts in 5 mins
/msg EF_HostBot gowcomps

Same as above but with only 1 CPU
/msg EF_HostBot gowcomps 1

Same as above but with only 2 CPUs
/msg EF_HostBot gowcomps 2

Same as above but with only 3 CPUs
/msg EF_HostBot gowcomps 3

Same as above but with only 4 CPUs
/msg EF_HostBot gowcomps 4
« Last Edit: August 31, 2015, 08:22:05 PM by {Lance} »
Dk At hall is cause I started with temple at start and didn't need the castle . Not a hack .  I wouldn't bother editing a ss btw

^---- Dellam doesnt hack!  See, even by his own admission, no hack!!  LMFAO.

Offline Delete mine too

  • Death Knight
  • *********
  • Posts: 2652
  • http://meatspin.com
    • View Profile
    • http://meatspin.com
Re: GameBot source code
« Reply #28 on: September 17, 2015, 05:38:58 PM »
You should look into adding memory editing in this. You could rely on map names instead of #1 to get the first map and also to have unlimited amount of maps.

Also wish we could have multiple of these bots going. I could give you the info to make the bot stay and play the game if wanted. That should make it an 8 player game again. Also tons of cool shit.

Offline Crash3r

  • Peon
  • **
  • Posts: 20
    • View Profile
Re: GameBot source code
« Reply #29 on: September 18, 2015, 12:53:05 PM »
Lance,
Thank you for writing hostbot

I have modified hostbot2 and launched PBALL_HostBot, with 2 maps so far: 60men, and 45men

I fixed a bug, when checking "Fixed Order" the next step was to hit enter to start the game, however hitting enter just unchecked Fixed Order so the game never started.

I fixed it by reordering the game setup - so it did Fixed Order then did Map Resources then hit enter to start the game.

The next thing I did is finish writing the GameTeams section so there is 1v1 (2v6), 2v2 (3v4), 3v3 (4v4), 3v4 (4v4). Game Teams for some reason Blizzard did not give it a hotkey like all the others lol! But I worked around that by first "T" for Game Type, then TAB over to Teams then DOWN to open the menu and then UP 7x to reset the settings to the top

However, it should be kept in mind that the key strokes for GameTeams selection are only correct if a 4v4 map is used, for a 3v3 map there are different options (obviously 4v4 is not an option) so the key strokes are different.

To handle this I created GameTeams names such as 31v1 - meanining the selection of 1v1 on a 3v3 map type.


In pball it was a bit more complicated than GoW because the maps are Fixed Order.
Because of Fixed Order, a different map is required for each Game Team - take for example a 1v1 60men - player 2 needs to be lined up across from player 3, but in a 2v2, player 2 and 3 need to be on the same side.

So a seperate map was created for each (thanks xXxSmeagolxXx), and presets were made for "601v1" "602v2" etc


Everything is working and I plan to launch a few other custom map bots

I just have one problem - After pball_gamebot starts the game, the game begins but is very laggy, then after about 15seconds everyone drops

In the game were hostbot and I on the same network (sep ports forwarded) and 1 other player on a different network

This happened 2 times that I tested, so far no succesful games because of it


Any ideas?

thanks
« Last Edit: September 18, 2015, 01:03:05 PM by Crash3r »