First time scripting need help (WoW related)

Ask gaming related questions (AHK v1.1 and older)
ShasVa
Posts: 3
Joined: 13 Dec 2017, 00:10

First time scripting need help (WoW related)

13 Dec 2017, 00:26

I've successfully made my first AHK for World of Warcraft. Currently I'm testing it on the game's PTR server, and it works. However it could use some much-needed refinement. I have two priority questions I need answers to.

1) How can I have the script run only when I'm in combat, and not run when I'm out of combat? Say I tab-target a mob, the script runs, the mob dies, the script pauses. <- That!

2) In conjunction with the above, is there a way to detect when I'm in or out of combat? This is the key to making the script work perfectly.

My script is below. Feel free to (constructively) critique it. It's just a first go. The X Y coordinates are based on my monitor's configuration and won't work for anyone else...probably!!

Code: Select all

#IfWinActive, World of Warcraft
Loop  
{
    PixelSearch, FoundX, FoundY, 647, 628, 701, 681, 0xFF0000, 50, Fast RGB  ; Charge
	if ErrorLevel = 0
	{
	Send, 1
	Sleep, 250
	}
    PixelSearch, FoundX, FoundY, 649, 630, 702, 681, 0xC89016, 50, Fast RGB  ; Collosus Smash
	if ErrorLevel = 0
	{
	Send, 6
	Sleep, 250
	}
    PixelSearch, FoundX, FoundY, 651, 630, 699, 679, 0x4D4968, 50, Fast RGB  ; Mortal Strike
	if ErrorLevel = 0
	{
	Send, 5
	Sleep, 250
	}
    PixelSearch, FoundX, FoundY, 649, 627, 701, 682, 0x6E3189, 50, Fast RGB  ; Slam
	if ErrorLevel = 0
	{
	Send, 4
	Sleep, 250
	}
    PixelSearch, FoundX, FoundY, 649, 629, 701, 682, 0x216163, 50, Fast RGB  ; Warbreaker
	if ErrorLevel = 0
	{
	Send, 9
	Sleep, 250
	}
    PixelSearch, FoundX, FoundY, 649, 627, 701, 678, 0xE70000, 50, Fast RGB  ; Execute
	if ErrorLevel = 0
	{
	Send, x
	Sleep, 250
	}
}
return

0::
Suspend
Pause,,1
return
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: First time scripting need help (WoW related)

13 Dec 2017, 01:03

Look for the combat indicator (crossed swords on nameplate) either with imagesearch, pixelsearch or pixelgetcolor

Put that check in loop and only execute your pixelsearches if the combat indicator is found.
ShasVa
Posts: 3
Joined: 13 Dec 2017, 00:10

Re: First time scripting need help (WoW related)

13 Dec 2017, 03:03

Where in my current script would I put this new entry?

Can I make the script start in a paused state? Currently it tries to execute even when I'm not in combat.

Sorry. Just trying to get my script just right. :)
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: First time scripting need help (WoW related)

13 Dec 2017, 13:00

Note:
#IfWinActive, World of Warcraft
Creates context-sensitive hotkeys and hotstrings. Such hotkeys perform a different action (or none at all) depending on the type of window that is active or exists.
You could add a hotkey to start the loop and then the above would apply to it.Currently its only used on the pause hotkey 0::.


Example:

Code: Select all

Loop
{
    PixelSearch,,, 647, 628, 701, 681, 0xFF0000, 50, Fast RGB  ; Check if in combat here
    if (ErrorLevel = 0)
    {
        PixelSearch,,, 647, 628, 701, 681, 0xFF0000, 50, Fast RGB  ; Charge
        if (ErrorLevel = 0)
        {
            Send, 1
            Sleep, 250
        }
        PixelSearch,,, 649, 630, 702, 681, 0xC89016, 50, Fast RGB  ; Collosus Smash
        if (ErrorLevel = 0)
        {
            Send, 6
            Sleep, 250
        }
        PixelSearch,,, 651, 630, 699, 679, 0x4D4968, 50, Fast RGB  ; Mortal Strike
        if (ErrorLevel = 0)
        {
            Send, 5
            Sleep, 250
        }
        PixelSearch,,, 649, 627, 701, 682, 0x6E3189, 50, Fast RGB  ; Slam
        if (ErrorLevel = 0)
        {
            Send, 4
            Sleep, 250
        }
        PixelSearch,,, 649, 629, 701, 682, 0x216163, 50, Fast RGB  ; Warbreaker
        if (ErrorLevel = 0)
        {
            Send, 9
            Sleep, 250
        }
        PixelSearch,,, 649, 627, 701, 678, 0xE70000, 50, Fast RGB  ; Execute
        if (ErrorLevel = 0)
        {
            Send, x
            Sleep, 250
        }    
    }
    Sleep 16    ; small sleep to prevent high cpu usage when not in combat
}
return
Foundx and Foundy can be removed since you are not going to use them.

HTH
ShasVa
Posts: 3
Joined: 13 Dec 2017, 00:10

Re: First time scripting need help (WoW related)

16 Dec 2017, 21:25

Thanks for your help Xtra, but Blizzard have seen fit to ban my 7th WoW license. Not forever, but for long enough. So, yeah, can't exactly test my AHK script now.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 45 guests