Sign in to follow this  
Followers 0
Vinx

Diablo2 - Hostile Detection

12 posts in this topic

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.

Share this post


Link to post
Share on other sites



If I am reading that correctly, take out the quotes around the hex number

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by Vinx

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by amanda089

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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? :P

Share this post


Link to post
Share on other sites

$pix = PixelSearch(749, 18, 755, 24, 0x530D05, 20)

Share this post


Link to post
Share on other sites

#8 ·  Posted (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? :P

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 by Azu

Share this post


Link to post
Share on other sites

$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?

Share this post


Link to post
Share on other sites

Hi, check my post above, it tells you how to get it working even if the color is a slightly different shade.

Share this post


Link to post
Share on other sites

#11 ·  Posted (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 by gatsbysamericandream

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0