jglim / gunbound-server

Emulator for GunBound Thor's Hammer gameserver
MIT License
98 stars 41 forks source link

Would love to add an AI component to play with bots - is it possible? #1

Open leethobbit opened 4 years ago

leethobbit commented 4 years ago

Hi,

First of all, thank you so much for the huge amount of GB information shared here! Secondly, I am only a little experienced in RE and development. I managed to bypass encryption and create a login server emulator for Path of Exile but I'm still quite fresh. Do you have any opinions on how hard it would be to add a simple AI system to the game so you could play solo against some bots?

jglim commented 4 years ago

Hi!

It might be an uphill task, though not impossible.

Some background.. The gameserver mostly acts as a directory service, to set up peer-to-peer networks between individual game clients. When game clients enter a room, the gameserver announces the network details of other game client peers. From here on, the game clients mostly communicate and manage the gameplay themselves, with the room keybearer as the authority.

Communications are directly between clients, typically over UDP. If there are issues with UDP, the clients will switch over to TCP, using the gameserver as a relay (via tunnel 45XX packets).

There is an entire set of P2P commands that are managed purely between clients (000X, 400X, 8XXX, CXXX, FXXX). These manage functions like in-game chat, turn management, animations, movements, firing shots, respawns, drops etc. , which the gameserver does not handle at all)

Bot emulation With the above context, if you intend to emulate a "player" as a bot, you will also need to emulate the entire P2P section. P2P uses a different encryption method, packet layout, checksum and sequence. I believe that getting a emulated bot to "exist" in a game (chat, move around, pass turn) is very doable.

The harder part would be getting the bot to shoot; in my limited understanding, when a shot is fired, the client sends (among other things):

  1. Shot origin (x/y)
  2. Shot type (1/2 or SS)
  3. Absolute firing angle
  4. Firing power
  5. Array of explosion points

To find the array of explosion points, you will need to first develop the "perfect" aimbot to find where the projectile hits the land/player. Gunbound clients synchronize their map states (e.g. which regions are destroyed) by subtracting the explosion points from the map.

If there are discrepancies with the trajectory calculation, your bot's map and the player's actual map will appear different and open up another can of issues.


I hope this comment will not discourage you, rather I hope it shows you where the potential obstacles are. Perhaps a start would be to develop an aimbot, which should also be quite a gratifying experience (please use it responsibly!). Thanks for your interest in Gunbound and this project :^)