I've created a (very) simple battleloop for a game that is intended to work as follows:
1) Press F3
2) If an ability is available, send the designated key
3) If it's not available, check the next ability and so on.
Availability is determined via a pixelsearch.
What is working: all pixelsearches work and the first ability, if its available, always fires when F3 is pressed.
What isn't working: the Attack() function doesn't move through the different abilities, it only fires off the first one ("Ability1").
I'm very new to scripting/programming so appreciate any advice as I'm sure I've missed something really basic. I'm not looking to optimise the battleloop for now, just to get this sequence working after which I'll start optimising it for actual gameplay.
Code: Select all
F3::
Attack() ;;Returns the key for the first available ability
{
If Available("Ability1")
{
Send, 1
Sleep, 25
Return 1
}
Else If Available("Ability2")
{
Send, 3
Sleep, 25
Return 1
}
Else If Available("Ability3")
{
Send, 4
Sleep, 25
Return 1
}
Else If Available("Ability4")
{
Send, 4
Sleep, 25
Return 2
}
Return 0
}
Available(Ability) ;;checks if the ability passed from Attack() is available (off timer) and returns a 1 if it is.
{
If Ability = Ability1
CoordMode, Pixel, Window
PixelSearch, FoundX, FoundY, 1119, 1308, 1160, 1336, 0x97834A, 80, Fast RGB
If ErrorLevel = 0
{
Return 1
}
Else If Ability = Ability2
CoordMode, Pixel, Window
PixelSearch, FoundX, FoundY, 1236, 1316, 1271, 1344, 0xCB8665, 80, Fast RGB
If ErrorLevel = 0
{
Return 1
}
Else If Ability = Ability3
CoordMode, Pixel, Window
PixelSearch, FoundX, FoundY, 1294, 1316, 1327, 1349, 0xA27E4F, 80, Fast RGB
If ErrorLevel = 0
{
Return 1
}
Else If Ability = Ability4
CoordMode, Pixel, Window
PixelSearch, FoundX, FoundY, 1294, 1316, 1327, 1349, 0xA27E4F, 80, Fast RGB
If ErrorLevel = 0
{
Return 1
}
Return 0
}