gta2 bot?

Anything to do with GTA1/GTA2 modding (tools, scripts and more).
Post Reply
gras
Jaywalker
Jaywalker
Posts: 6
Joined: 10 May 2011, 14:50
GH nick: gras

gta2 bot?

Post by gras »

Hi, I wonder, does anyone know if it's possible to program a decent bot for GTA2. One that doesn't cheat too much and basically looks like a human player as much as possible.

Also, can anyone tell me what's already out there? I know of e.g. BOT Tiny town, but if I'm not mistaken the bots in that are just GTA2 main exe bots but with some basic behavior settings scripted. Right? Is it even possible to script detailed bot behavior in a map script?

I guess the best way would be to have a program connect to a game like a human does, and then have it control its player based on what's happening in-game. I.e. a completely separate program. But how would it get info on what's happening? Would it be possible to get "in-between" the GTA2 exe and whatever graphics library it uses and "eavesdrop" that way? I have some programming experience but have no idea how GTA2 works so any help is welcome in that respect!
User avatar
Sektor
Boss
Boss
Posts: 1426
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: gta2 bot?

Post by Sektor »

All the maps with bots just use the AI coded by DMA Design. Choice of CRAP_SHOT, NORMAL_SHOT or CRACK_SHOT and what weapon they use. If you give them a rocket, they will also get a pistol for shooting close targets (annoying that you can't disable that). You can tell them to guard a certain spot but you can't control how they fight using GTA2 script. They always have infinite ammo but you can remove their weapons anytime and they will just punch.

More realistic acting AI could be made using the same techniques used to make aimbots, MTASA and cheat programs for other games. Making them perfect shots is relatively easy but making them smart is very difficult.
User avatar
elypter
Immortal
Posts: 1120
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: gta2 bot?

Post by elypter »

once again

link removed

that would make it so much easier
yur sa'nok ngeyä
gras
Jaywalker
Jaywalker
Posts: 6
Joined: 10 May 2011, 14:50
GH nick: gras

Re: gta2 bot?

Post by gras »

Sektor wrote:All the maps with bots just use the AI coded by DMA Design. Choice of CRAP_SHOT, NORMAL_SHOT or CRACK_SHOT and what weapon they use. If you give them a rocket, they will also get a pistol for shooting close targets (annoying that you can't disable that). You can tell them to guard a certain spot but you can't control how they fight using GTA2 script. They always have infinite ammo but you can remove their weapons anytime and they will just punch.
Ok, that's kind of what I thought.
Sektor wrote:More realistic acting AI could be made using the same techniques used to make aimbots, MTASA and cheat programs for other games. Making them perfect shots is relatively easy but making them smart is very difficult.
Wikipedia has an article on aimbots. I guess the graphics driver-based one is easiest here, e.g. because GTA2 has a lot of 2D objects (sprites) so if I'm lucky it's quite easy to read those off from DirectX. So prolly reading off info won't be much of a problem, but indeed making them intelligent would be truly difficult. But at least if I can succeed in making one that "knows" what's going on, that would facilitate programming better AIs for other people as well.
BenMillard
Immortal
Posts: 889
Joined: 16 May 2009, 06:14
GH nick: BenMillard
Location: London, UK
Contact:

Re: gta2 bot?

Post by BenMillard »

AI characters which shoot at other AI threats but don't shoot at players is much needed.
gras
Jaywalker
Jaywalker
Posts: 6
Joined: 10 May 2011, 14:50
GH nick: gras

Re: gta2 bot?

Post by gras »

Well, I did some testing with this. At first I thought GTA2 used directdraw, and i even wrote a ddraw.dll that GTA2 loads without complaining. This ddraw.dll just redirects every function call to the real ddraw.dll, but of course I could also have it report its activities to a bot. However, turns out that GTA2 doesn't use directdraw that much at all, but instead an own library, d3ddll.dll, designed by DMA themselves. I can easily do the same trick on that if i only knew something about which functions are in it. I.e. what arguments they take and what they return. Does anyone have info on that?
User avatar
B-$hep
Immortal
Posts: 571
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: gta2 bot?

Post by B-$hep »

gras wrote:if i only knew something about which functions are in it. I.e. what arguments they take and what they return.
I wish i could know what arguments they take, it would be awesome.
It's easy to get "all" exported functions but it's hard to figure out what parameters they require.
If EXE or DLL is compiled with debug info, then it helps a bit.
PEiD helps with that, i mean, does the EXE or DLL has the debug info or not.

If i remember correctly, then both GTA2.EXE and most (if not all) of his DLL's are compiled with debug info in them.

If you use for example IDA or Olly then you should see pretty interesting stuff in them.
Same with DMA editor.

I have looked inside of these EXE's and DLL's, found pretty neat stuff, but for me it's easier to rewrite this, than figure out each parameter, ok, maybe not so easy, anyway i haven't looked so deeply, because i didn't need it so badly. I was just curious how they did this.

For example DMA editor: Bapi.dll (bitmap API) contains some interesting drawing code.
I even tried once, init the DLL and call the functions in it, because IDA almost showed me full source, but i lost my interest.
You can drop Bapi.dll to Notepad and see the functions in it, if you scroll down.

I am also software cracker (ie. reverse engineer), i even was in one team (2005-2006).
So, as you understand i just couldn't resist looking into different EXE's and DLLs i have on my HDD :)

I do it whenever i have time or i wish to.
Always wear safety glasses while programming.
gras
Jaywalker
Jaywalker
Posts: 6
Joined: 10 May 2011, 14:50
GH nick: gras

Re: gta2 bot?

Post by gras »

Yeah I used all of the tools you mentioned :D

I don't think GTA2.exe is compiled in debug mode; although there is some info if you look with OllyDbg. Haven't found anything about the d3ddll.dll functions though.

I'm a little confused though - when I analyze GTA2.exe with a tool like PEiD, dependency walker or PE Explorer, they all give a list of dll files that doesn't include d3ddll.dll. However, when I monitor the files used by GTA2.exe using Process Monitor, it comes up with d3ddll.dll (and with ddraw.dll, but it apparently uses only one function in it). Same thing happens with the DMA map editor: according to the analyzers, it uses some standard windows files plus Bapi.dll, but according to Process Monitor it accesses files like D3DPoly.dll inside its DLL subfolder. (btw those dll's are thankfully compiled in debug mode... if only d3ddll.dll was!) But... how do these processes "hide" that they use those dll's? Am I missing something?

edit: hmm, on 2nd view, maybe with IDA I might be able to do something with d3ddll. I'll have a look at it tomorrow.

edit2: ah! I found out I was analyzing GTA2.exe with a 64 bit tool; when I used the 32 bit version, it was able to profile the exe and come up with the correct DLL's. So at least that mystery is solved ;)
gras
Jaywalker
Jaywalker
Posts: 6
Joined: 10 May 2011, 14:50
GH nick: gras

Re: gta2 bot?

Post by gras »

Well, getting the function parameters is basically impossible. So much for that I guess :(

Does anyone have any information? Otherwise I think I will give this up for now.
User avatar
B-$hep
Immortal
Posts: 571
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: gta2 bot?

Post by B-$hep »

Giving up is not a winning strategy.

What i did with DMA editor, is that i executed it in Olly and looked the function calls.
I mean: what it calls from particular DLL, then by looking what parameters are pushed into stack, it should be possible to figure out the params and their types.

I know it's not so easy and it can't be done fast.


When i messed with these things i didn't give up, i just lost my interest. I thought that figuring things out in these DLL's and EXEs makes creating map editor easier (or something like that).

I will try with Bapi.dll again.
I must have the Delphi sources somewhere on CD's, of the test project, that tried to init the DLL and call some functions.

Then maybe i can dig something out from the d3ddll also.
Always wear safety glasses while programming.
User avatar
Vike the Hube
Hitman
Hitman
Posts: 145
Joined: 28 Feb 2010, 22:34
GH nick: vike

Re: gta2 bot?

Post by Vike the Hube »

PM me and I'll send you my IDA database for GTA2. There's a bunch of named functions but I sort of got stuck on the graphics functions. But I did find a bunch of data; I'm pretty sure I found player positions.
Post Reply