Detect Attack Mouse

Ask questions about cheating in any games you would like. Does not need to pertain to MicroMacro.
Post Reply
Message
Author
cokelat70
Posts: 14
Joined: Mon Nov 17, 2008 7:37 am

Detect Attack Mouse

#1 Post by cokelat70 » Mon Dec 22, 2008 9:34 am

Hello,

I have a game without autotarget, like shaiya did 'tab' button.
Is there something I can do to detect mouse state change,
I mean when my mouse over the monster usually the mouse change to "attack" state, but how to get that mouse change?
ImageImage

User avatar
3cmSailorfuku
Posts: 354
Joined: Mon Jan 21, 2008 6:25 pm

Re: Detect Attack Mouse

#2 Post by 3cmSailorfuku » Mon Dec 22, 2008 3:55 pm

cokelat70 wrote:Hello,

I have a game without autotarget, like shaiya did 'tab' button.
Is there something I can do to detect mouse state change,
I mean when my mouse over the monster usually the mouse change to "attack" state, but how to get that mouse change?
You can do this by using Cheat Engine, somewhere here is a tutorial how to find an andress and the pointer to it.
Basically you can start by hovering over a monster and look for an unkown value and keep filtern it.
But most game's either use 1=Attack Cursor 0=Normal State. In Last Chaos there's even a struct containing
the complete Monster Information if you hover over a Monster, like Level, HP etc.

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Detect Attack Mouse

#3 Post by Administrator » Mon Dec 22, 2008 9:06 pm

You might also not need to target this way. You could potentially find a pointer to an array of monsters near you, then access information out of this (say, coordinates, name, level, etc.) of each specific monster. Then, you take the pointer to that monster and write it into your target address. I realize that was a mouth-full, and probably confused you.

Lets, for example, say that there is an array in the game holding a few monsters like so:

Code: Select all

[0x12345678 + 0x0] = 0x2A34D200
[0x12345678 + 0x4] = 0x3CF20D00
[0x12345678 + 0x8] = 0x2AFA9F00
[0x12345678 + 0xC] = 0x2A45A100
[0x12345678 + 0x10] = 0x0  // NULL terminated
0x12345678 is an array of 4 byte pointers to monsters.

Then, the monster struct looks like this:

Code: Select all

0x2A34D200:
  0x0 - int, HP
  0x4 - int, max HP
  0x8 - int, MP
  0xC - int, max MP

  0x10 - float, X position
  0x14 - float, Y position
So, you read the array (0x12345678) and copy the contents it into a Lua table

Code: Select all

local monsterPointerTable = {};
local readval = 0;
while(true) do
  readval = memoryReadInt(myProc, 0x12345678);
  if( readval == 0 ) then
    -- We reached the end of our array
    break;
  end
end
Now, we can construct an actual table of duplicate monster structs in our Lua script. First, let's create a class to handle data storage and updating.

Code: Select all

CMonster = class(
  function (self, ptr) -- constructor
    self.Address = ptr;
    self.Level = 0;
    self.HP = 0;
    self.MaxHP = 1; -- good to prevent division by zero
    self.MP = 0;
    self.MaxMP = 1; -- see above
    self.Xpos = 0.0;
    self.Ypos = 0.0;

    if( self.Address ) then self:update(); end; -- We were given an address, so read info
  end
);

function CMonster:update()
  -- All information on this struct is read ass offsets from the address to this monster.
  self.HP = memoryReadInt(myProc, self.Address + 0x0);
  self.MaxHP = memoryReadInt(myProc, self.Address + 0x4);
  self.MP = memoryReadInt(myProc, self.Address + 0x8);
  self.MaxMP = memoryReadInt(myProc, self.Address + 0xC);

  self.Xpos = memoryReadFloat(myProc, self.Address + 0x10);
  self.Ypos = memoryReadFloat(myProc, self.Address + 0x14);
end
Now, lets copy it into a Lua table of monsters:

Code: Select all

-- Assume monsterTable is a globally accessible table. First, lets destroy any old data in it.
monsterTable = {}; -- Cleared.

-- Copy all the available information out of the game on each monster, store it into monsterTable
for i,v in pairs(monsterPointerList) do
  local tmp = CMonster(v);
  table.insert(monsterTable, tmp);
end
Now you can perform the distance formula on each monster in monsterTable to find the closest monster to you, for example.

Code: Select all

local closestMonster = nil;
local lastDist = 9999;

function distance(x1, y1, x2, y2)
  return math.sqrt( (y2-y1)*(y2-y1) + (x2-x1)*(x2-x1) );
end

for i,v in pairs(monsterList) do
  local thisDist = distance(player.Xpos, player.Ypos, v.Xpos, v.Ypos);
  if( thisDist < lastDist ) then
    closestMonster = v;
    lastDist = thisDist;
  end;
end

if( closestMonster == nil ) then
  -- no monsters found.
else
 -- closestMonster is now a CMonster of the closest monster to the player.
end

This code was untested and wrote only for example purposes. It may contain a few errors

cokelat70
Posts: 14
Joined: Mon Nov 17, 2008 7:37 am

Re: Detect Attack Mouse

#4 Post by cokelat70 » Tue Dec 23, 2008 9:17 am

Thanks,

I got more question,
@3cmSailorfuku, I see, but if I use CE doesn't it make my mouse state change to normal state, not in attack mode?

@Administrator, If I get like you said, x and y coord of monster and get the closest monster, how to attack it, I mean pixel ratio and coord in world game different, I have try to get ratio for my game 32:1 but it's not really accurate, also monster always move?
ImageImage

User avatar
3cmSailorfuku
Posts: 354
Joined: Mon Jan 21, 2008 6:25 pm

Re: Detect Attack Mouse

#5 Post by 3cmSailorfuku » Tue Dec 23, 2008 9:54 am

cokelat70 wrote:Thanks,

I got more question,
@3cmSailorfuku, I see, but if I use CE doesn't it make my mouse state change to normal state, not in attack mode?

@Administrator, If I get like you said, x and y coord of monster and get the closest monster, how to attack it, I mean pixel ratio and coord in world game different, I have try to get ratio for my game 32:1 but it's not really accurate, also monster always move?
No, you wan't to get the mousestate (Attackcursor or Normalcursor), if you found the point with CE,
you can use it in your bot or for what you intended it to. It just eliminates the need of having to use GetPixel.

I don't think Elverion (Why did you rename yourself to Administrator anyway lol) really meant the Coordinates of a monster,
but the Monster ID on the server. You need to insert that ID into the adress that's
pointing to what Monster you have currently choosen as Target.
Most games aren't that easy though and you'd need to call the function in a hook, to attack a mob.
Though his method is probably easier to accomplish if you fail at calling.
In Last Chaos its easy, because they were supernice to leave the functions name <3

What game are you thinking of?

cokelat70
Posts: 14
Joined: Mon Nov 17, 2008 7:37 am

Re: Detect Attack Mouse

#6 Post by cokelat70 » Wed Dec 24, 2008 8:30 am

I'm trying to make a general bot game, without knowing address or offset, 'cause some games use HackShield or other to protect from using CE but still allow to hook.
But using getPixel or PixelSearch is not good choice, some game really hard to make different between monster and land.
So I try to use something like get Cursor ID like AutoIt, but the bad thing is only happen with common window GUI, it will return unknown value for game,
I think maybe something we can do with DirectX that can give return value about cursor state, it would be nice, have try looking at MSDN but not lucky?
ImageImage

User avatar
3cmSailorfuku
Posts: 354
Joined: Mon Jan 21, 2008 6:25 pm

Re: Detect Attack Mouse

#7 Post by 3cmSailorfuku » Wed Dec 24, 2008 9:37 am

cokelat70 wrote:I'm trying to make a general bot game, without knowing address or offset, 'cause some games use HackShield or other to protect from using CE but still allow to hook.
But using getPixel or PixelSearch is not good choice, some game really hard to make different between monster and land.
So I try to use something like get Cursor ID like AutoIt, but the bad thing is only happen with common window GUI, it will return unknown value for game,
I think maybe something we can do with DirectX that can give return value about cursor state, it would be nice, have try looking at MSDN but not lucky?
Yes alot of games who have HackShield, Xtrap etc are allowing wrappers (Or they simply can't detect them), it might even work that way. And also depending if its a Hardware or Software Cursor you might not find it in AutoIt. Anyway, if it's a texture that is being applied as a cursor you could define this in your wrapper, most likely in endscene or rather DP/DIP if you don't love memory leaks;

if(texnum == 145732158746) //The unique Texnum you found with your logging function.
return S_OK; //Attack Cursor has been detected. Put your bot function in here. S_OK would remove that texture btw.

regarding Directx though, I would suggest you going to Gamedeception. They have plenty of tutorials there.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests