Page 1 of 2

Auto analyse free aug slot and find compatible/best in bank

Posted: Thu Sep 08, 2016 6:07 pm
by moguay
The latest draft code to help find more quickly the best augment your equipment not increased.

Code: Select all

#define MAX_AUG_SLOTS 10
/echo inc to analyse Inventory and find the best Aug
/for i 0 to 20
     /call MissingAugs ${InvSlot[${i}].Name}
/next i

Sub MissingAugs(string SLOTNAME)

    /declare x int local
    /declare range int local ${Me.Inventory[${SLOTNAME}].Augs}

    /declare bct_command string local bcaa

    /for x 1 to ${range}
        /if (!${Bool[${Me.Inventory[${SLOTNAME}].Item[${x}]}]}) {
            /docommand /${echo} -[${Me.Name}]: ${SLOTNAME} missing Slot:${Cr}${x}${Cx} - Type:${Cr}${Me.Inventory[${SLOTNAME}].AugSlot${x}}${Cx}
            /call BankFind "" "${SLOTNAME}" "Augmentation" ${Me.Inventory[${SLOTNAME}].AugSlot${x}}
        }
    /next x

/return

Sub BankFind(string strFindName, string strFindSlot, string strFindType, int strAugType)

    /declare i int local
    /declare e int local
    /declare itemName string local
    /declare itemScore int local
    /declare itemReturn string local
    /declare itemBestReturn string local

    /for i 1 to 24
        /if (${Me.Bank[${i}].Container}) {
            /for e 1 to ${Me.Bank[${i}].Container}
                /varset itemName ${Me.Bank[${i}].Item[${e}]}
                /if (${Select[${Me.Class.ShortName},WAR,SHD,PAL]})                  /varcalc itemScore (${FindItemBank[${itemName}].AC} * ${FindItemBank[${itemName}].HP}) / 10
                /if (${Select[${Me.Class.ShortName},ROG,BER,BRD,MNK,RNG,BST]})      /varcalc itemScore (${FindItemBank[${itemName}].AC} * ${FindItemBank[${itemName}].HP}) / 10
                /if (${Select[${Me.Class.ShortName},DRU,ENC,MAG,WIZ,NEC,CLR,SHM]})  /varcalc itemScore (${FindItemBank[${itemName}].Mana} * ${FindItemBank[${itemName}].HP}) / 10

                |   Item Class                                              && Item Type
                /if (${FindItemBank[${itemName}].WornSlot[${strFindSlot}]} && ${FindItemBank[${itemName}].Type.Equal[${strFindType}]}) {
                    /if (${strAugType} && ${FindItemBank[${itemName}].Type.Equal[Augmentation]}) {
                        /call AugType ${FindItemBank[${itemName}].AugType} ${strAugType}
                        /if (${Macro.Return}) {
                            /call strArrayArg "${itemReturn}" "${itemName}" "|"
                            /varset itemReturn ${Macro.Return}
                            /if (!${itemBestReturn.Length} || ${itemScore} > ${itemBestReturn.Arg[2,|]}) /varset itemBestReturn ${itemName}|${itemScore}
                        }
                    } else {
                        /call strArrayArg "${itemReturn}" "${itemName}" "|"
                        /varset itemReturn ${Macro.Return}
                        /if (!${itemBestReturn.Length} || ${itemScore} > ${itemBestReturn.Arg[2,|]}) /varset itemBestReturn ${itemName}|${itemScore}
                    }
                }
               
                /if (${itemName.Find[${strFindName}]}) /docommand /${echo} [${Me.Bank[${i}].Item[${e}]}] -> (${Me.Bank[${i}]}] -> BankSlot${i} -> PackSlot${e})
            /next e
        } else /if (${Me.Bank[${i}].ID}) {
            /varset itemName ${Me.Bank[${i}]}
            /if (${Select[${Me.Class.ShortName},WAR,SHD,PAL]})                  /varcalc itemScore (${FindItemBank[${itemName}].AC} * ${FindItemBank[${itemName}].HP}) / 10
            /if (${Select[${Me.Class.ShortName},ROG,BER,BRD,MNK,RNG,BST]})      /varcalc itemScore (${FindItemBank[${itemName}].AC} * ${FindItemBank[${itemName}].HP}) / 10
            /if (${Select[${Me.Class.ShortName},DRU,ENC,MAG,WIZ,NEC,CLR,SHM]})  /varcalc itemScore (${FindItemBank[${itemName}].Mana} * ${FindItemBank[${itemName}].HP}) / 10
           
            |   Item Class                                              && Item Type
            /if (${FindItemBank[${itemName}].WornSlot[${strFindSlot}]} && ${FindItemBank[${itemName}].Type.Equal[${strFindType}]}) {
                /if (${strAugType} && ${FindItemBank[${itemName}].Type.Equal[Augmentation]}) {
                    /call AugType ${FindItemBank[${itemName}].AugType} ${strAugType}
                    /if (${Macro.Return}) {
                        /call strArrayArg "${itemReturn}" "${itemName}" "|"
                        /varset itemReturn ${Macro.Return}
                        /if (!${itemBestReturn.Length} || ${itemScore} > ${itemBestReturn.Arg[2,|]}) /varset itemBestReturn ${itemName}|${itemScore}
                    }
                } else {
                    /call strArrayArg "${itemReturn}" "${itemName}" "|"
                    /varset itemReturn ${Macro.Return}
                    /if (!${itemBestReturn.Length} || ${itemScore} > ${itemBestReturn.Arg[2,|]}) /varset itemBestReturn ${itemName}|${itemScore}
                }
            }
           
            /if (${itemName.Find[${strFindName}]}) /docommand /${echo} [${Me.Bank[${i}]}] -> (BankSlot${i})
        }
    /next i
   
    /docommand /${echo} -BankFind: Best:<${itemBestReturn}> -> (${itemReturn})
   
/return ${itemReturn}

Sub strArrayArg(string strArrayArg, string strAdd, strSeparator)
    /if (!${strArrayArg.Length}) {
        /varset strArrayArg ${strAdd}
    } else {
        /varset strArrayArg ${strArrayArg}${strSeparator}${strAdd}
    }
/return ${strArrayArg}

Sub AugType(int bitTotal, int typeSearch)
   | /declare bitTotal int local 133
   /declare augTypes[MAX_AUG_SLOTS] int local
   /declare i int local 1
   /declare augType int local 1

   :loop
      /if (${bitTotal} <= 0) {
         /if (!${slot}) {
            /echo No augs
         } else {
            /return FALSE
         }
         | Done
      } else /if (${bitTotal} == 1) {
         | Found a type 1
         /varset augTypes[${i}] 1
         | Done
      } else /if (${bitTotal} == 2) {
         | Found the type!
         /varcalc augTypes[${i}] ${augType} + 1
         | Done
      } else {
         /if (${Math.Calc[${bitTotal} % 2]} == 1) {
            | We found one of multiple types...
            /varset augTypes[${i}] ${augType}
            /varcalc bitTotal ${bitTotal} - 1
            /varcalc i ${i} + 1
         }
         /if (${bitTotal} != 2) {
            /varcalc bitTotal ${bitTotal} / 2
            /varcalc augType ${augType} + 1
         }
         /goto :loop
      }

   /for i 1 to MAX_AUG_SLOTS
      /if (${augTypes[${i}]} > 0) {
        /if (${typeSearch}) {
            /if (${augTypes[${i}]} == ${typeSearch}) /return TRUE
        } else {
            /echo Aug${i}: ${augTypes[${i}]}
        }
      }
   /next i

/return FALSE

Re: Auto analyse free aug slot and find compatible/best in bank

Posted: Fri Sep 09, 2016 5:03 pm
by moguay
Adding a new function getAugBank() for auto get from bank the HOH augments which can be equipped on the inventory equipment.

8KB of code to delve into the Bottomless Bag, and so now a lot of time saved :P

Code: Select all

#define MAX_AUG_SLOTS 10
/echo inc to analyse Inventory and find the best Aug
/for i 0 to 20
     /call MissingAugs ${InvSlot[${i}].Name}
/next i

Sub MissingAugs(string SLOTNAME)

    /declare x int local
    /declare range int local ${Me.Inventory[${SLOTNAME}].Augs}

    /declare bct_command string local bcaa

    /for x 1 to ${range}
        /if (!${Bool[${Me.Inventory[${SLOTNAME}].Item[${x}]}]}) {
            | /docommand /${bct_command} //docommand /${echo} -[${Me.Name}]: ${SLOTNAME} missing Slot:${Cr}${x}${Cx} - Type:${Cr}${Me.Inventory[${SLOTNAME}].AugSlot${x}}${Cx}
            /if (${broadcast}==1) ${broadcastMsg} [${Me.Name}]: ${SLOTNAME} missing Slot:${Cr}${x}${Cx} - Type:${Cr}${Me.Inventory[${SLOTNAME}].AugSlot${x}}${Cx}
            /call BankFind "" "${SLOTNAME}" "Augmentation" ${Me.Inventory[${SLOTNAME}].AugSlot${x}}
        }
    /next x

/return

Sub BankFind(string strFindName, string strFindSlot, string strFindType, int strAugType)

    /declare i int local
    /declare e int local
    /declare itemName string local
    /declare itemScore int local
    /declare itemReturn string local
    /declare itemBestReturn string local

    /for i 1 to 24
        /if (${Me.Bank[${i}].Container}) {
            /for e 1 to ${Me.Bank[${i}].Container}
                /varset itemName ${Me.Bank[${i}].Item[${e}]}
                /if (${Select[${Me.Class.ShortName},WAR,SHD,PAL]})                  /varcalc itemScore (${FindItemBank[${itemName}].AC} * ${FindItemBank[${itemName}].HP}) / 10
                /if (${Select[${Me.Class.ShortName},ROG,BER,BRD,MNK,RNG,BST]})      /varcalc itemScore (${FindItemBank[${itemName}].AC} * ${FindItemBank[${itemName}].HP}) / 10
                /if (${Select[${Me.Class.ShortName},DRU,ENC,MAG,WIZ,NEC,CLR,SHM]})  /varcalc itemScore (${FindItemBank[${itemName}].Mana} * ${FindItemBank[${itemName}].HP}) / 10

                |   Item Class                                              && Item Type
                /if (${FindItemBank[${itemName}].WornSlot[${strFindSlot}]} && ${FindItemBank[${itemName}].Type.Equal[${strFindType}]}) {
                    /if (${strAugType} && ${FindItemBank[${itemName}].Type.Equal[Augmentation]}) {
                        /call AugType ${FindItemBank[${itemName}].AugType} ${strAugType}
                        /if (${Macro.Return}) {
                            | Auto get HOH Aug
                            /if ((${itemName.Find[Radiant ]} || ${itemName.Find[Glowing ]})) {
                                /call getAugBank "${itemName}"
                                /return
                            }
                           
                            | EqWindow Report
                            /call strArrayArg "${itemReturn}" "${itemName}" "|"
                            /varset itemReturn ${Macro.Return}
                            /if (!${itemBestReturn.Length} || ${itemScore} > ${itemBestReturn.Arg[2,|]}) /varset itemBestReturn ${itemName}|${itemScore}
                        }
                    } else {
                        | EqWindow Report
                        /call strArrayArg "${itemReturn}" "${itemName}" "|"
                        /varset itemReturn ${Macro.Return}
                        /if (!${itemBestReturn.Length} || ${itemScore} > ${itemBestReturn.Arg[2,|]}) /varset itemBestReturn ${itemName}|${itemScore}
                    }
                }
               
                | /if (${itemName.Find[${strFindName}]}) /docommand /${echo} [${Me.Bank[${i}].Item[${e}]}] -> (${Me.Bank[${i}]}] -> BankSlot${i} -> PackSlot${e})
            /next e
        } else /if (${Me.Bank[${i}].ID}) {
            /varset itemName ${Me.Bank[${i}]}
            /if (${Select[${Me.Class.ShortName},WAR,SHD,PAL]})                  /varcalc itemScore (${FindItemBank[${itemName}].AC} * ${FindItemBank[${itemName}].HP}) / 10
            /if (${Select[${Me.Class.ShortName},ROG,BER,BRD,MNK,RNG,BST]})      /varcalc itemScore (${FindItemBank[${itemName}].AC} * ${FindItemBank[${itemName}].HP}) / 10
            /if (${Select[${Me.Class.ShortName},DRU,ENC,MAG,WIZ,NEC,CLR,SHM]})  /varcalc itemScore (${FindItemBank[${itemName}].Mana} * ${FindItemBank[${itemName}].HP}) / 10
           
            |   Item Class                                              && Item Type
            /if (${FindItemBank[${itemName}].WornSlot[${strFindSlot}]} && ${FindItemBank[${itemName}].Type.Equal[${strFindType}]}) {
                /if (${strAugType} && ${FindItemBank[${itemName}].Type.Equal[Augmentation]}) {
                    /call AugType ${FindItemBank[${itemName}].AugType} ${strAugType}
                    /if (${Macro.Return}) {
                        | Auto get HOH Aug
                        /if ((${itemName.Find[Radiant ]} || ${itemName.Find[Glowing ]})) {
                            /call getAugBank "${itemName}"
                            /return
                        }
                   
                        | EqWindow Report
                        /call strArrayArg "${itemReturn}" "${itemName}" "|"
                        /varset itemReturn ${Macro.Return}
                        /if (!${itemBestReturn.Length} || ${itemScore} > ${itemBestReturn.Arg[2,|]}) /varset itemBestReturn ${itemName}|${itemScore}
                    }
                } else {
                    | EqWindow Report
                    /call strArrayArg "${itemReturn}" "${itemName}" "|"
                    /varset itemReturn ${Macro.Return}
                    /if (!${itemBestReturn.Length} || ${itemScore} > ${itemBestReturn.Arg[2,|]}) /varset itemBestReturn ${itemName}|${itemScore}
                }
            }
           
            | /if (${itemName.Find[${strFindName}]}) /docommand /${echo} [${Me.Bank[${i}]}] -> (BankSlot${i})
        }
    /next i
   
    /if (${broadcast}==1) ${broadcastMsg} [BankFind] Best:<${itemBestReturn}> -> (${itemReturn})
   
/return ${itemReturn}

Sub getAugBank(string strAugName)

    /call CheckCursor

    /if (!${Me.FreeInventory}) /return
   
    /declare strBankerName string local Stex
    /if (!${Spawn[NPC =${strBankerName}].ID}) /return
   
   
    /target id ${Spawn[NPC =${strBankerName}].ID}
    /delay 5 (${Target.ID} == ${Spawn[NPC =${strBankerName}].ID})

    /call InternalMoveToTimed ${Spawn[id ${Target.ID}].Y} ${Spawn[id ${Target.ID}].X} 5s
    /if (!${Macro.Return}) {
        /if (${broadcast}==1) ${broadcastMsg} [getAugBank] >>> ** Moving Problem ** <<<
        /return
    }
   
    /call openBags

    /nomodkey /click right target
    /delay 10
   
    /itemnotify ${FindItemBank[${strAugName}].InvSlot} leftmouseup
    /delay 1s (${Window[QuantityWnd].Open} || ${Cursor.ID})
    /if (${Window[QuantityWnd].Open}) /nomodkey /notify QuantityWnd QTYW_Accept_Button leftmouseup

    /delay 1s (${Cursor.ID})
    /call CheckCursor
   
    /if (${broadcast}==1) ${broadcastMsg} [AugBankToInventory]: <${strAugName}>

/return

Sub strArrayArg(string strArrayArg, string strAdd, strSeparator)
    /if (!${strArrayArg.Length}) {
        /varset strArrayArg ${strAdd}
    } else {
        /varset strArrayArg ${strArrayArg}${strSeparator}${strAdd}
    }
/return ${strArrayArg}

Sub AugType(int bitTotal, int typeSearch)
   | /declare bitTotal int local 133
   /declare augTypes[MAX_AUG_SLOTS] int local
   /declare i int local 1
   /declare augType int local 1

   :loop
      /if (${bitTotal} <= 0) {
         /if (!${slot}) {
            /echo No augs
         } else {
            /return FALSE
         }
         | Done
      } else /if (${bitTotal} == 1) {
         | Found a type 1
         /varset augTypes[${i}] 1
         | Done
      } else /if (${bitTotal} == 2) {
         | Found the type!
         /varcalc augTypes[${i}] ${augType} + 1
         | Done
      } else {
         /if (${Math.Calc[${bitTotal} % 2]} == 1) {
            | We found one of multiple types...
            /varset augTypes[${i}] ${augType}
            /varcalc bitTotal ${bitTotal} - 1
            /varcalc i ${i} + 1
         }
         /if (${bitTotal} != 2) {
            /varcalc bitTotal ${bitTotal} / 2
            /varcalc augType ${augType} + 1
         }
         /goto :loop
      }

   /for i 1 to MAX_AUG_SLOTS
      /if (${augTypes[${i}]} > 0) {
        /if (${typeSearch}) {
            /if (${augTypes[${i}]} == ${typeSearch}) /return TRUE
        } else {
            /echo Aug${i}: ${augTypes[${i}]}
        }
      }
   /next i

/return FALSE

Re: Auto analyse free aug slot and find compatible/best in bank

Posted: Wed Sep 14, 2016 6:00 pm
by moguay
Coding finish and integrate, with only 3 command to manage all alt.

Items, Armor quest Items and now augs Features :
- bag cleaner - bag to bank items transfer
- bag cleaner - give craft items to specific crafter toon
- ~new~ augs analysis (include melee, caster optimize) -new-
    ~new~ get hoh, quest augs - from bank if not in bag
    ~new~ buy hoh type16 augs - auto buy 10kGp augs to the npc
    ~new~ craft hoh augs - get from bank/bag, auto request need marble to other toons and make the final turn to the npc
    ~new~ report - the best and all unique aug which can be forged in equipement
- loot augs - if necessary or if no by auto sharing between alt

Very useful due to equipments rotation in the final tier
And this in order to help you understand the process used.

I think the game experience would have been much better for some of us with some biggest bag or a quest to make augments sealer for example.

Re: Auto analyse free aug slot and find compatible/best in bank

Posted: Sun Oct 02, 2016 2:40 pm
by Mikimaru
looks very interesting, but im having an issue, when i try to run it. it keeps saying subroutine main wasnt found... am i being stupid on something or missing anything?

Re: Auto analyse free aug slot and find compatible/best in bank

Posted: Mon Oct 03, 2016 6:21 pm
by moguay
No :P i publish function or Idea, and must be implanted in your macro. They are not a standalone macro.
Because used with other function, (looting, trade, buy... in this case) can be become magic for everyday use.

I have build for you a standalone version: https://github.com/moguay/mq2-thf-macro/blob/master/Standalone%20Macro/FindAug.mac

Re: Auto analyse free aug slot and find compatible/best in bank

Posted: Sun Oct 09, 2016 7:51 pm
by moguay
Updated standalone macro https://github.com/moguay/mq2-thf-macro ... indAug.mac
- add score augmentation
- add old aug analysis
- add auto get HOH aug from bank

I have also simplify the terminal return:
The [Missing Aug] status is if no aug found
The [Bad Aug] status is if the equiped aug is below the Hoh aug

NB: for the standalone function, i not have implemented the auto sort/clear/transfer items in bag, and turn/buy to npc.
because i use an personal advanced search item mq2 plugin and need to modify your mq2

Capture of this new function :

Re: Auto analyse free aug slot and find compatible/best in bank

Posted: Tue Oct 11, 2016 11:43 am
by moguay
I have pull on git a new function to auto buy Augmentation Solvent from the Guild Merchant.

To used this new function you need to move near the augment sealer/merchant and launch the mac with the force argument

Code: Select all

/mac findaug force

Change list:
    - new buy solvent
    - add Augment Name in term (after the Slot/type and Score)
    - some small fix
    - add Turbo tweak (if you want more faster you need to used mq2turbo.dll and set in your .mac #turbo 40 for example)
If 2x or 4x more calculations per tic ... it improves a lot of thing. For more information contact me, because this is not the subject and to say there is.

Re: Auto analyse free aug slot and find compatible/best in bank

Posted: Tue Oct 11, 2016 8:16 pm
by Mikimaru
looks awesome and thanks for making it a macro. haven't had the chance to use it yet, but ill give it a try tonight.

Re: Auto analyse free aug slot and find compatible/best in bank

Posted: Tue Oct 11, 2016 10:57 pm
by moguay
Augs management is a real challenge for each Tier evolv, a big time eater.

It allowed me to replace the majority of my augs on my alts in record time.
So what I publish is only a part if my workflow.

I think for this to be really nice, you need a automatic storage of bags before the augs analysis.

Re: Auto analyse free aug slot and find compatible/best in bank

Posted: Sat Oct 15, 2016 8:38 pm
by moguay
Now i have code a new plugin to perform a better function to make a scoring, in order to have a better differentiation between classes.
The goal being to enable automatic transfers in the bag augs that are more efficient than those equipped, which previously was only a proposal in a terminal.

To make this, i have enable some hidden TLO inaccessible in MQ2 and make a new FindItem to search all available items in the bag, bank, sealed or not.
Therefore necessary to do a bit of C ++ for the brave.
( the new TLO is : BaseDmg, BackstabDmg and manage AugRestrictions )

I have try too integrate in the calculation the worm effect but for the moment it not possible.

In short, here is the proposal by augs calculating and the new arithmetic by class,

Code: Select all

/if (${Select[${Me.Class.ShortName},SHD]})             /return ${Math.Calc[(${AC}   * 5) + (${HP} * 1) + (${BaseDmg}  * 5) + (${SpellDmg} * 5) + (${HealAmnt} * 5)]}
/if (${Select[${Me.Class.ShortName},ROG]})             /return ${Math.Calc[(${AC}   * 5) + (${HP} * 1) + (${BaseDmg}  * 5) + (${BackDmg}  * 5)]}
/if (${Select[${Me.Class.ShortName},WAR,ROG,BER,MNK]}) /return ${Math.Calc[(${AC}   * 5) + (${HP} * 1) + (${BaseDmg}  * 5)]}
/if (${Select[${Me.Class.ShortName},BRD,RNG,BST]})     /return ${Math.Calc[(${AC}   * 5) + (${HP} * 1) + (${BaseDmg}  * 5) + (${SpellDmg} * 5) + (${HealAmnt} * 5)]}
/if (${Select[${Me.Class.ShortName},ENC,MAG,WIZ,NEC]}) /return ${Math.Calc[(${MANA} * 1) + (${HP} * 1) + (${SpellDmg} * 5)]}
/if (${Select[${Me.Class.ShortName},CLR,SHM,DRU]})     /return ${Math.Calc[(${MANA} * 1) + (${HP} * 1) + (${HealAmnt} * 5)]}
/if (${Select[${Me.Class.ShortName},PAL]})             /return ${Math.Calc[(${AC}   * 5) + (${HP} * 1) + (${BaseDmg}  * 5) + (${HealAmnt} * 5)]}
/if (${Select[${Me.Class.ShortName},DRU]})             /return ${Math.Calc[(${MANA} * 1) + (${HP} * 1) + (${HealAmnt} * 5) + (${HealAmnt} * 5)]}