Jump to content

Error when trying "Attack Now" for TH Snipe (DEBUG INCLUDED)


Recommended Posts

I encountered the following AU3 error message when I tried to "Attack Now" for TH Snipe using original MyBot v4.2.3 (without any modification such as additional Mods)

---------------------------

AutoIt Error

---------------------------

Line 310  (File "C:\Users\...\MyBot-4.2.3\COCBot\functions\Search\VillageSearch.au3"):

If $OptBullyMode = 0 And $OptTrophyMode = 0 And $iChkMeetTH[$iMatchMode] = 0 And $iChkMeetTHO[$iMatchMode] = 0 And $chkATH = 1 Then

If $OptBullyMode = 0 And $OptTrophyMode = 0 And ^ ERROR

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

---------------------------

Please let me know how to fix this problem, and it'd be appreciated if you apply its debug to the next version of MyBot.

[solution] by @monkeyhunter

https://mybot.run/forums/thread-11102-post-94107.html#pid94067

Link to post
Share on other sites

One of user said in a different thread that the following code (by replacing $iMatchMode to $pMatchMode) might be solution for the issue.


If $OptBullyMode = 0 And $OptTrophyMode = 0 And $iChkMeetTH[$pMatchMode] = 0 And $iChkMeetTHO[$pMatchMode] = 0 And $chkATH = 1 Then

At first, it seems working, but later the other user reported that he encountered following error message.

---------------------------

AutoIt Error

---------------------------

Line 310 (File "C:\Users\...\MyBot-4.2.3\COCBot\functions\Search\VillageSearch.au3"):

If $OptBullyMode = 0 And $OptTrophyMode = 0 And $iChkMeetTH[$iMatchMode] = 0 And $iChkMeetTHO[$iMatchMode] = 0 And $chkATH = 1 Then

If $OptBullyMode = 0 And $OptTrophyMode = 0 And $iChkMeetTH[^ ERROR

Error: Variable used without being declared.

---------------------------

Any idea how to resolve this issue?

Link to post
Share on other sites

This is the original code:

If $OptBullyMode = 0 And $OptTrophyMode = 0 And $iChkMeetTH[$iMatchMode] = 0 And $iChkMeetTHO[$iMatchMode] = 0 And $chkATH = 1 Then

The error the other user seems to face is the one you had before you made the modification. Is it working for you?

This seems like a problem with Attack Now and attack combos. The bot doesn't know if it should attack the bot as a TH snipe or as a dead base.

Link to post
Share on other sites

This is the original code:

If $OptBullyMode = 0 And $OptTrophyMode = 0 And $iChkMeetTH[$iMatchMode] = 0 And $iChkMeetTHO[$iMatchMode] = 0 And $chkATH = 1 Then

The error the other user seems to face is the one you had before you made the modification. Is it working for you?

This seems like a problem with Attack Now and attack combos. The bot doesn't know if it should attack the bot as a TH snipe or as a dead base.

Thank you for your concern about this issue and your response as well.

The initial issue raised by me was caused by the original MyBot v4.2.3 without any modification. (i.e. it had the code you posted when I tested and I posted this thread based on it.) Also the files for debug were prepared based on MyBot v4.2.3 without any modification.

The modified code was proposed by user @kyo1980 and he told me that it worked for him. But other user @bloodymaster reported that he encountered a different error with the modified code, which might mean that the code proposed by @kyo1980 is not a proper solution.

So, I'm still curious how to solve the current issue with "original" MyBot v4.2.3 without any modification.

Link to post
Share on other sites

Weird error. Nothing obvious from debug. I can not repeat the bug.

Without adding some debug statements to code to learn value of $iMatchMode and the contents of $iChkMetTH[] variable that is causing error is difficult to fix?

Code that has error is to display the TH attack log message to user. Maybe work around code is possible. You can try?

Autoit processes If/then code with "AND" in left to right order and stops processing when it reaches False. If add a check for when "attack now" pressed it can skip the code causing the error?

Place "$bBtnAttackNowPressed = False And" in front of "$OptBullyMOde = 0" like this on line 310:

 If $bBtnAttackNowPressed = False And $OptBullyMode = 0 And $OptTrophyMode = 0 And $iChkMeetTH[$iMatchMode] = 0 And $iChkMeetTHO[$iMatchMode] = 0 And $chkATH = 1 Then 

If the Attack button control properly sets the $iMatchMode to $TS, then this might work. If $iMatchMode is not set properly, then the attack will fail and you see other errors.

Link to post
Share on other sites

Weird error.  Nothing obvious from debug.  I can not repeat the bug.

Without adding some debug statements to code to learn value of $iMatchMode and the contents of $iChkMetTH[] variable that is causing error is difficult to fix?

Code that has error is to display the TH attack log message to user.  Maybe work around code is possible.  You can try?

Autoit processes If/then code with "AND" in left to right order and stops processing when it reaches False.  If add a check for when "attack now" pressed it can skip the code causing the error?

Place "$bBtnAttackNowPressed = False And" in front of "$OptBullyMOde = 0" like this on line 310:

 If $bBtnAttackNowPressed = False And $OptBullyMode = 0 And $OptTrophyMode = 0 And $iChkMeetTH[$iMatchMode] = 0 And $iChkMeetTHO[$iMatchMode] = 0 And $chkATH = 1 Then 

If the Attack button control properly  sets the $iMatchMode to $TS' date=' then this might work.  If $iMatchMode is not set properly, then the attack will fail and you see other errors.

[/quote']

I strongly agree with you that this issue is quite weird. But you can easily repeat the bug with the following settings when you press the button "TH Snipe!" for outside TH. (All other settings are remained default.)

zfDHEsu.pngkYjzGwn.pngIs6tDny.pngGSeDkTv.png

And I tried the same after including "$bBtnAttackNowPressed = False And " infront of "$OptBullyMode = 0" as you suggested and I could see the following error message.

---------------------------

AutoIt Error

---------------------------

Line 310  (File "C:\Users\...\MyBot-4.2.3\MyBot-4.2.3\COCBot\functions\Search\VillageSearch.au3"):

If $bBtnAttackNowPressed = False And $OptBullyMode = 0 And $OptTrophyMode = 0 And $iChkMeetTH[$iMatchMode] = 0 And $iChkMeetTHO[$iMatchMode] = 0 And $chkATH = 1 Then

If $bBtnAttackNowPressed = False And $OptBullyMode = 0 And $OptTrophyMode = 0 And ^ ERROR

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

---------------------------

Link to post
Share on other sites

Think i tripped on error.

$iChkMeetTH[] & $iChkMeetTH0[] is only 2 variable locations, and when $TS (TH Snipe) is set by button it needs to be 3. Source of error is that the GUI has user attack settings for 2 modes (integer index 0-1), yet the $iMatchMode for attack types can be 5 values (integer index 0-4).

Solution is to change line 187 in GlobalVariables.au3 to add 1 more storage location to the variables:


Global $iChkEnableAfter[$iModeCount], $iCmbMeetGE[$iModeCount], $iChkMeetDE[$iModeCount], $iChkMeetTrophy[$iModeCount], $iChkMeetTH[$iModeCount+1], $iChkMeetTHO[$iModeCount+1], $iChkMeetOne[$iModeCount], $iCmbTH[$iModeCount], $iChkWeakBase[$iModeCount]

(your line number may be slightly different, it is line 162 in Ezeck MOD)

Didn't test, but likely fix error?

Could also change the declaration for $iModeCount = 2 to be 3 or 5 on line 111, but no reason to have all the variables larger?

Code that posts TH attack log immediately following might need to change, but will leave the complete fix for the developers to implement.

Ciao!

Link to post
Share on other sites

Think i tripped on error.

$iChkMeetTH[]  & $iChkMeetTH0[] is only 2 variable locations' date=' and when $TS (TH Snipe) is set by button it needs to be 3.  Source of error is that the GUI has user attack settings for 2 modes (integer index 0-1), yet the $iMatchMode for attack types can be 5 values (integer index 0-4).  

Solution is to change line 187 in GlobalVariables.au3 to add 1 more storage location to the variables:


Global $iChkEnableAfter[$iModeCount], $iCmbMeetGE[$iModeCount], $iChkMeetDE[$iModeCount], $iChkMeetTrophy[$iModeCount], $iChkMeetTH[$iModeCount+1], $iChkMeetTHO[$iModeCount+1], $iChkMeetOne[$iModeCount], $iCmbTH[$iModeCount], $iChkWeakBase[$iModeCount]

(your line number may be slightly different, it is line 162 in Ezeck MOD)

Didn't test, but likely fix error?    

Could also change the declaration for $iModeCount = 2 to be 3 or 5 on line 111, but no reason to have all the variables larger?

Code that posts TH attack log immediately following might need to change,  but will leave the complete fix for the developers to implement.

Ciao!

[/quote']

Thank you very much, Mr. @monkeyhunter !! Now it's completely working fine for me.

Link to post
Share on other sites
×
×
  • Create New...