Vinx Posted August 29, 2006 Share Posted August 29, 2006 Hey there. I'm playing Hardcore on Diablo 2 and I'm extremely annoyed by the TPPKers. I started making a counter-script for these TPPKers. The idea is to detect the hostile box in the top-right corner, and if so, create a TP and go to town instantly. The TP part I don't have trouble with, so I'll simply replace that function with a msgbox for the code I'm having trouble with. I'm not getting any errors, it's simply not finding the Hostile box in the Top-right corner. I just started AutoIt today, but I am fluent in VB and C/C++, so its trivial at best. Please let me know what I'm doing wrong, as I'm still not use to the syntax just yet. While 1 if winactive("D2Loader") Then $pix = PixelSearch(749, 18, 755, 24, "0x530D05") if not @error = 1 then msgbox(0, "Yay!", "You're hostiled and correctly detected!") EndIf EndIf sleep(10) Wend So to explain, I have functions in the script that get called upon, but this is the script-loop that simply keeps checking for a Hostile once every 10 milliseconds, I believe. I'm pretty sure I have the coordinates down, as well as the color pixel I'm searching for which is a dark red. Thanks in advance for any solutions you can find, Vinx. Link to comment Share on other sites More sharing options...
amanda089 Posted August 29, 2006 Share Posted August 29, 2006 If I am reading that correctly, take out the quotes around the hex number Link to comment Share on other sites More sharing options...
Vinx Posted August 29, 2006 Author Share Posted August 29, 2006 (edited) Current Code now: While 1 if winactive("D2Loader") Then $pix = PixelSearch(749, 18, 755, 24, 0x530D05) if not @error = 1 then msgbox(0, "Yay!", "You're hostiled and correctly detected!") EndIf EndIf sleep(10) Wend Still not working. Do the coordinates look right? The problem that confused me is that for the function PixelSearch, the arguments are (Left, Top, Right, Bottom). Anyone who knows the mathematic formula for a rectangle knows its X1, Y1, X2, Y2, which are corners. Top can be both top corners, etc...so I got confused. So, let me know if I guessed it right or those are in the wrong order. Edit: Also, I tested to see if the line [if winactive("D2Loader") Then] works by removing the search condition inside: While 1 if winactive("D2Loader") Then msgbox(0, "Game Detected!", "You're now in Diablo 2.") EndIf sleep(10) Wend The above code works, so it's the Pixel Checking that's not working, as suspected. Edited August 29, 2006 by Vinx Link to comment Share on other sites More sharing options...
amanda089 Posted August 29, 2006 Share Posted August 29, 2006 (edited) the coords are from 0, 0 (being top left corner) use Au3Info.exe in the autoit folder to get the location for the mouse. Example output from Au3Info.exe>>>>>>>>>>> Mouse Details <<<<<<<<<<< Screen: X: 252 Y: 173 Edited August 29, 2006 by amanda089 Link to comment Share on other sites More sharing options...
Vinx Posted August 29, 2006 Author Share Posted August 29, 2006 the coords are from 0, 0 (being top left corner) use Au3Info.exe in the autoit folder to get the location for the mouse. Example output from Au3Info.exe>>>>>>>>>>> Mouse Details <<<<<<<<<<< Screen: X: 252 Y: 173 Ok good, that's what I did, and that's how I got all 4 numbers; by doing the WindowInfo thing twice, getting the top left corner, and the bottom right corner. Link to comment Share on other sites More sharing options...
Vinx Posted August 29, 2006 Author Share Posted August 29, 2006 Another problem is that the Hostile box in the top-right corner is semi-transparent, so it could be like 20 different shades of red. Also, I noticed that the script I have only checks when I activate the game window to the front, not while it's running already active. What do I do? Link to comment Share on other sites More sharing options...
amanda089 Posted August 29, 2006 Share Posted August 29, 2006 $pix = PixelSearch(749, 18, 755, 24, 0x530D05, 20) Link to comment Share on other sites More sharing options...
Azu Posted August 29, 2006 Share Posted August 29, 2006 (edited) Another problem is that the Hostile box in the top-right corner is semi-transparent, so it could be like 20 different shades of red. Also, I noticed that the script I have only checks when I activate the game window to the front, not while it's running already active. What do I do? Hi, if it's transparent and there are a bunch of different shades, try converting the hex number to decimal and doing something like this. If it's not transparent and it's the same every time then use the much less CPU intensive solution in the post above. dim $pixelarray[99999999] $decimal=Put the exact decimal for the color here $decimal-=$decimal/10 for $a=1 to ($decimal/5) $pixelarray[$a] = $decimal+$a next for $a=1 to $pixelarray[0] if PixelSearch(749, 18, 755, 24, $pixelarray[$a]) then global $b=1 next if $b=1 then msgbox(0, "OMG!", "1337 hax.") endif This will work within a 10% variation of the decimal, I think. Edited August 29, 2006 by Azu Link to comment Share on other sites More sharing options...
Vinx Posted August 29, 2006 Author Share Posted August 29, 2006 $pix = PixelSearch(749, 18, 755, 24, 0x530D05, 20) Didn't work. Does anyone who plays or played Diablo 2 know a different, and more static approach to detecting a Hostile player? Or perhaps could someone point me in the direction of learning to hook a VB/C++ application to detect it? Link to comment Share on other sites More sharing options...
Azu Posted August 30, 2006 Share Posted August 30, 2006 Hi, check my post above, it tells you how to get it working even if the color is a slightly different shade. Link to comment Share on other sites More sharing options...
gatsbysamericandream Posted August 30, 2006 Share Posted August 30, 2006 (edited) take out the '= 1'. You also have the wrong number of parameters for your message box Should look like this: While 1 if winactive("D2Loader") Then $pix = PixelSearch(749, 18, 755, 24, 0x530D05) if not @error then msgbox(0, "Yay!", "You're hostiled and correctly detected!",60) EndIf EndIf sleep(10) Wend Edited August 30, 2006 by gatsbysamericandream Link to comment Share on other sites More sharing options...
Vinx Posted August 30, 2006 Author Share Posted August 30, 2006 take out the '= 1'. You also have the wrong number of parameters for your message box Should look like this: While 1 if winactive("D2Loader") Then $pix = PixelSearch(749, 18, 755, 24, 0x530D05) if not @error then msgbox(0, "Yay!", "You're hostiled and correctly detected!",60) EndIf EndIf sleep(10) Wend Neither having the = 1 or the ,60 there would matter. It works either way. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now