29988122 / Fate-Grand-Order_Lua

Fate Grand Order auto battle script - no root needed, for Android use only
MIT License
289 stars 95 forks source link

[NA] Auto Support Selection ignores supports before the first wipe #304

Open MatheusOPP opened 4 years ago

MatheusOPP commented 4 years ago

I've been trying to use the script to farm the currently ongoing NA lotto. It's mostly working nicely, but when it goes to the support screen to choose a new support, it always ignores whatever shows up on the screen before the first wipe, which means it effectively ignores the two first supports in the list. For example, my settings are like this:

--AutoSupportSelection
Support_SelectionMode = "preferred"
Support_SwipesPerUpdate = 5
Support_MaxUpdates = 99
Support_FallbackTo = "manual"
Support_FriendsOnly = 0
Support_FriendNames = ""
Support_PreferredServants = "waver4.png, waver3.png, waver2.png, waver1.png"
Support_PreferredCEs = "*merry_sheep.png"

This should select any Waver with MLB Merry Sheep. Sometimes a Waver with MLB Merry Sheep appears in the first two slots, but it doesn't ever get selected, instead the scripts ignores it and swipes down. After the swipe, if there's a Waver with MLB Merry Sheep there, it works as intended. But it never selects the first two supports, even after it refreshes the results if it doesn't find any below, it STILL ignores the first two supports.

I hope you can fix this.

Edit: Sometimes, a "default region being returned" error also pops up, if this helps somehow.

Skyjersey commented 4 years ago

Changing the value in line 311 in support.lua from 0.8 to 0.7 seems to fixed the issue for me.

MatheusOPP commented 4 years ago

Changing the value in line 311 in support.lua from 0.8 to 0.7 seems to fixed the issue for me.

This seems to have worked for me as well.

reconman commented 4 years ago

Is this still an issue? I have recently corrected the regions in the support selection script.

izekblz commented 4 years ago

This still is an issue on my phone (using AnkuLua as a service, without daemon). I've tried debugging it and it seems that script won't see first supports from initial screen (before any scrolls). I've deleted all the scrolling bits from select and looping only the search part with toast to indicate if it was indeed running, it sat in a loop for a minute not finding anything. However, after a manual small movement it instantly indicated one of the first two supports and started quest. This led me to conclusion that initial movement is required for some reason, so i wrote a quick bandaid fix which doesn't seem to break anything, but takes 3-5 extra seconds on each support update (requires three extra scrolls (which could be made smaller than in my example) to get going) Also swiping down and then back to the top didn't work for some reason (it still couldn't find first supports after it), so problem probably isn't in the lack of movement

I've added those lines to the game.lua

game.SUPPORT_HOTFIX_SWIPE_START_CLICK = Location(35,1190)
game.SUPPORT_HOTFIX_SWIPE_BOTTOM_CLICK = Location(35,1000)
game.SUPPORT_HOTFIX_SWIPE_END_CLICK = Location(35,1170)
game.SUPPORT_HOTFIX_SWIPE_TOP_CLICK = Location(35,1220)

(SUPPORT_HOTFIX_SWIPE_BOTTOM_CLICK second coordinate could be increased, but I'm not sure at which point it will start registering it as a click and not swipe, so i left it at that)

Added function for short initial movement to support.lua

suppStartHotfix = function()
    local touchActions = {
        { action = "touchDown", target = game.SUPPORT_HOTFIX_SWIPE_START_CLICK },
        { action = "touchMove", target = game.SUPPORT_HOTFIX_SWIPE_BOTTOM_CLICK },
        { action =      "wait", target = 0.4 },
        { action = "touchMove", target = game.SUPPORT_HOTFIX_SWIPE_END_CLICK },
        { action =      "wait", target = 0.4 },
        { action =   "touchUp", target = game.SUPPORT_HOTFIX_SWIPE_END_CLICK },
        { action =      "wait", target = 0.5 } 
    }

    setManualTouchParameter(5, 2)
    manualTouch(touchActions)
end

Also added function which resets scroll to it's initial position (without this all servants after first 2 won't be detected)

afterSwipeFix = function()
    local touchActions = {
        { action = "touchDown", target = game.SUPPORT_HOTFIX_SWIPE_END_CLICK },
        { action = "touchMove", target = game.SUPPORT_HOTFIX_SWIPE_TOP_CLICK },
        { action =      "wait", target = 0.4 },
        { action =   "touchUp", target = game.SUPPORT_HOTFIX_SWIPE_TOP_CLICK },
        { action =      "wait", target = 1 } 
    }

    setManualTouchParameter(10, 1)
    manualTouch(touchActions)
end

Call suppStartHotfix with condition numberOfSwipes == 0 and afterSwipeFix with condition that checks if it was already called in this support screen update, all in the selectPreferred function, which would look like this:

selectPreferred = function(searchMethod)
    local numberOfSwipes = 0
    local numberOfUpdates = 0

    while (true)
    do
        if numberOfSwipes == 0 then
            suppStartHotfix()
            fixSwipe = 0
        end

        local result, support = searchVisible(searchMethod)

        if fixSwipe == 0 then
            fixSwipe = 1
            afterSwipeFix()
        end

        if result == "ok" then
                ...

Replicated this issue on 2 other phones also using AnkuLua as a service without daemon, sadly I can't get AnkuLua to work with daemon on any of the phones so I'm not sure, but I guess this issue could be specific to not using daemon.

It is incredibly poor fix but it works in all the cases i could think of, maybe you could rewrite and implement it