Detect Attack Mouse
Detect Attack Mouse
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?
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?
- 3cmSailorfuku
- Posts: 354
- Joined: Mon Jan 21, 2008 6:25 pm
Re: Detect Attack Mouse
You can do this by using Cheat Engine, somewhere here is a tutorial how to find an andress and the pointer to it.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?
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.
- Administrator
- Site Admin
- Posts: 5329
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Detect Attack Mouse
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:
0x12345678 is an array of 4 byte pointers to monsters.
Then, the monster struct looks like this:
So, you read the array (0x12345678) and copy the contents it into a Lua table
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.
Now, lets copy it into a Lua table of monsters:
Now you can perform the distance formula on each monster in monsterTable to find the closest monster to you, for example.
This code was untested and wrote only for example purposes. It may contain a few errors
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
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
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
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
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
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
Re: Detect Attack Mouse
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?
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?
- 3cmSailorfuku
- Posts: 354
- Joined: Mon Jan 21, 2008 6:25 pm
Re: Detect Attack Mouse
No, you wan't to get the mousestate (Attackcursor or Normalcursor), if you found the point with CE,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?
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?
Re: Detect Attack Mouse
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?
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?
- 3cmSailorfuku
- Posts: 354
- Joined: Mon Jan 21, 2008 6:25 pm
Re: Detect Attack Mouse
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;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?
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.
Who is online
Users browsing this forum: No registered users and 1 guest