mrmin123 / kancolle-auto

Kantai Collection (Kancolle) bot/automation tool - DEPERECATED - see kcauto-kai:
https://github.com/mrmin123/kcauto-kai
54 stars 22 forks source link

Resupply All Error #397

Open Danielosama opened 6 years ago

Danielosama commented 6 years ago

Environment details

Issue

The issue can be seen in the following image : image

As you can see, the resupply all button acts as if the mouse is hovering it, yet it isn't. I'm not sure what happens, but sometimes the mouse seems to go too fast. It happens quite often, but at random. Some days it will happens 2/3 times in a row, and some days not happen at all.

Console log (if applicable)

[2017-09-21 23:59:01] Navigating to resupply screen with 0 sidestep(s)!
[log] CLICK on L(359,242)@S(0)[0,0 1357x846] (578 msec)
[2017-09-21 23:59:18] Non-catbomb script crash, or catbomb script crash w/ unsupported Viewer!
FindFailed: resupply_all.png: (11x16) seen at (391, 152) with 1.00 in S(0)[0,0 1357x846] E:Y, T:3.0
  Line 2718, in file Region.java

[error] script [ C:\SikuliX\kancolle_auto.sikuli ] stopped with error in line 542
[error] FindFailed ( resupply_all.png: (11x16) seen at (391, 152) with 1.00 in S(0)[0,0 1357x846] E:Y, T:3.0 )
[error] --- Traceback --- error source first
line: module ( function ) statement
585: util (  pattern_generator )     m = match(r'M\[\d+\,\d+ (\d+)x(\d+)\]', str(find(pic)))
159: main (  resupply )     check_and_click(global_regions['fleet_flags_main'], pattern_generator(global_regions['fleet_flags_main'], Pattern('resupply_all.png').exact()), expand_areas('fleet_id'))
257: main (  sortie_action )     resupply()
478: main (  kancolle_auto_wrapper )     sortie_action()
540: main (  <module> )     kancolle_auto_wrapper()
[error] --- Traceback --- end --------------
mrmin123 commented 6 years ago

Could you try adding this line before the check_and_click on L159 of kancolle_auto.py?:

rejigger_mouse(kc_window, 50, 750, 0, 100)
Danielosama commented 6 years ago

Alright I give up. I've tried to add the line in 4 different ways, but the script always crashes as soons as I launch it. I think I just don't know how to do it properly, mind showing me how?

mrmin123 commented 6 years ago

I can't test this since I'm away from my primary rig, but it should look like this (whitespace is important):

                        sleep_fast()
                        while_count += 1
                        while_count_checker(kc_window, settings, while_count)
                rejigger_mouse(kc_window, 50, 750, 0, 100)
                check_and_click(global_regions['fleet_flags_main'], pattern_generator(global_regions['fleet_flags_main'], Pattern('resupply_all.png').exact()), expand_areas('fleet_id'))
                sleep_fast()
        log_success("Done resupplying!")

Note that the middle line is the addedline

mrmin123 commented 6 years ago

You might also need to add the kc_window variable to the imported globals at the beginning of the resupply() method (L141):

def resupply():
    global kc_window, fleet_needs_resupply, settings
    log_msg("Lets resupply fleets!")

(middle line is modified line)

Danielosama commented 6 years ago

Thanks, I've successfully added the lines now, script works. Will update if the problem ever appears again.

Danielosama commented 6 years ago

Well, it happened again:

exampleagain

You can see the mouse near the resources, yet the resupply all again acts as if it was hovering it. I should note that I don't think this has ever happened when I used the script on my main PC, but ever since I use it on the VM, it has happened quite often.

[2017-09-27 02:38:54] Lets resupply fleets!
[2017-09-27 02:38:56] Navigating to resupply screen with 1 sidestep(s)!
[log] CLICK on L(402,431)@S(0)[0,0 1357x846] (579 msec)
[log] CLICK on L(303,231)@S(0)[0,0 1357x846] (610 msec)
[2017-09-27 02:39:21] Non-catbomb script crash, or catbomb script crash w/ unsupported Viewer!
FindFailed: resupply_all.png: (11x16) seen at (391, 152) with 1.00 in S(0)[0,0 1357x846] E:Y, T:3.0
  Line 2718, in file Region.java

[error] script [ C:\SikuliX\kancolle_auto.sikuli ] stopped with error in line 543
[error] FindFailed ( resupply_all.png: (11x16) seen at (391, 152) with 1.00 in S(0)[0,0 1357x846] E:Y, T:3.0 )
[error] --- Traceback --- error source first
line: module ( function ) statement
585: util (  pattern_generator )     m = match(r'M\[\d+\,\d+ (\d+)x(\d+)\]', str(find(pic)))
160: main (  resupply )     check_and_click(global_regions['fleet_flags_main'], pattern_generator(global_regions['fleet_flags_main'], Pattern('resupply_all.png').exact()), expand_areas('fleet_id'))
258: main (  sortie_action )     resupply()
479: main (  kancolle_auto_wrapper )     sortie_action()
541: main (  <module> )     kancolle_auto_wrapper()
[error] --- Traceback --- end --------------

Here is the console log.

mrmin123 commented 6 years ago

Unfortunately that's more of an issue with the VM environment than with the script, and I have very little control over that. If you're intent on the VM method, the alternative method I could think of is to manually move the mouse to the location, and then trigger a click event. This DOES has its own set of own possible points of failures, however, and wouldn't be a foolproof way to conduct the resupply action.

I can come up with a code snippet for you to try but it's pretty late where I am right now so it'll have to wait a day or two.

Danielosama commented 6 years ago

Don't worry about it, I'm not in a hurry or anything. The issue was pretty random to begin with, some days it wouldn't happen at all, and some days it'd happen 2/3 times in a row. It does seems to happen less with the new line added, so there is that. Thanks for all the help, if you ever come up with a code snippet I'll be happy to try it :)

mrmin123 commented 6 years ago

Could you download the latest master branch and give that a spin?

Danielosama commented 6 years ago

Sure thing. I should add one thing, the issue only happens when resupplying the first fleet, because since my last message I've been using the script doing nothing but expeditions and I've had no problems at all.