Jump to content
  • Advertisement
Sign in to follow this  
Eralp

Need ideas to start

This topic is 3044 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been thinking of writing a helper program for a game. I mean it should be looking for monsters with lower health and select them to attack. But I dont know how to approach.
There are healthbars above monsters, my first idea is to take a screenshot and process it. But it is too vague because healthbars might override sometimes.

Other idea is something I am not familiar with..I don't even know if this is possible but what about hooking into memory and functions of the game and get the data I want from there?

I have no idea how to attack though. It should right click on the monster.I am not sure if right clicking right below the healthbar would work.

It is not an online game or kind of that.So I don't think there are many security things to make this project harder.

Language is not a problem I can do this project with C++ C# or VB.net according to the approach I'll take. If I'll hook into memory I'd probably should use c++ i.e.

Thanks

Share this post


Link to post
Share on other sites
Advertisement
Using screenshots could work, but it will be damn memory and cpu intensive if this is a real-time game. Hooking the memory is the way usually used. In fact, there's already a program for nearly every commercial games out there. They are called trainers and are often released by pirate groups because the method to do them is similar to those of cracks. Of course, I personally don't know how.

On another note, there was a thread here not long ago about doing this for Starcraft and Diablo2.

[Edited by - Dunge on July 18, 2010 12:52:23 AM]

Share this post


Link to post
Share on other sites
It's pretty easy to take a fast screenshot with GDI, should be workable for real time without issue. Select a memory DC into a DIB section then blit the game DC to your memory DC. Your DIB section will have a pointer to the raw data now which you can manipulate however.

#include <Windows.h>

DWORD* bits = NULL; // :\

COLORREF ReadPixel(int x, int y);

int main()
{
BITMAPINFO bi = { 0 };

bi.bmiHeader.biSize = sizeof(BITMAPINFO);
bi.bmiHeader.biWidth = 1440;
bi.bmiHeader.biHeight = -900; //top down
bi.bmiHeader.biPlanes = 1;
bi.bmiHeader.biBitCount = 32;

HDC hdc = GetDC(0); //0 is the entire screen
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP hDib = CreateDIBSection(hdc, &bi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, hDib);

//hdcMem is the destination, hdc is the source
BitBlt(hdcMem, 0, 0, 1440, 900, hdc, 0, 0, SRCCOPY);

//we have all the pixel data now, to access it, just make a pointer to it.
COLORREF c = ReadPixel(0, 0);


//don't forget to release the DCs and stuff, i'm sure you can manage this on your own
return 0;
}

COLORREF ReadPixel(int x, int y)
{
DWORD* p = bits + (y * 1440 + x); //y * width + x
return *p;
}


Trainers are a pretty far cry from cracks though. If you want to use memory, get comfortable with the Windows debugging functions, namely WriteProcessMemory() / ReadProcessMemory(). The reverse engineering is up to you.

Share this post


Link to post
Share on other sites
I couldn't make this picture seen in the forum but here is the link.
http://img833.imageshack.us/img833/1766/healthbars.png

I started the project I am now able to examine pixels and it is fast enough for me at the moment.
But as you can see the healthbars don't contain only one type of pixel so I don't know how to move on. I thought about counting the black pixels from right to get the health of the monster but I realized that the healthbars have slightly different widths.
I've been thinking of some kind of blending algorithm which might make things clearer.
So what can you suggest me to do?
Thanks.

Ps: color of the healthbars begin to turn red when hitpoints go down

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!