turn in "Dark Reign Token" to Limann

Discussion in 'Macros' started by Casai, Sep 25, 2023.

  1. Casai

    Casai Orc Legionnaire

    Messages:
    109
    slightly moded turn in macro from creamo
    Code:
    ;/bc items by the name of ${itemname} I still have them
    ;/FindItem "Dark Reign Token"
    Sub Main
       
       :start
       /call preparetotrade
       /call closebagswindows
       /delay 10
       /call toggleinvbags
       /call targetnpc
       /call turnin "Dark Reign Token" 1
       /call toggleinvbags
       /call freecursor
       
    /return
    
    Sub preparetotrade
       /twist off
       /delay 1
       /twist off
       /delay 5
    /return
    
    
    Sub closebagswindows
           /keypress esc
           /keypress esc
           /keypress esc
           /keypress esc
           /delay 1
           /keypress esc
           /keypress esc
           /keypress esc
           /keypress esc
           /delay 1
           /keypress esc
           /keypress esc
           /keypress esc
           /keypress esc
           /delay 1
    /return
    
    Sub toggleinvbags
       /delay 5
       /keypress I
       /delay 11
       /keypress SHIFT+B
       /delay 2
    /return
    
    Sub targetnpc
       /if (${Zone.ID} == 27) {
           /echo I'm in Lavastorm
           /tar "Wayfarers Mercenary Limann"
           /if (${Target.Distance}>150 || !${Target.ID}) {
               /echo Limann is > 150 or untargetable
               /tar "Xeib Darkskies"
               /if (${Target.Distance}>150) {
                   /echo both Xeib and Limann too far away
                   /target clear
                   /return
               }
           }
       }
       /delay 2
    /return
    
    Sub freecursor
       /declare c int local 0
       :fcursor
       /delay 5
       /if (${Cursor.ID}) {
           /autoinv
           /delay 5
           /echo did autoinv
       }
       /if (!${Cursor.ID}) {
           /return
       }
       /varcalc c ${c}+1
       /if (${c}>5) {
           /bc couldnt clear cursor
           /return
       }
       
       
       /goto :fcursor
    /return
    
    
    Sub turnin (itemname, itemcount)
       /declare i int local 0
       
       :Loop
       /call freecursor
         
    
        /if (!${FindItem[${itemname}].ID}) {
           ;all good no item
           /echo dont have the ${itemname}
            /return
        }
        /if (${FindItem[${itemname}].InvSlot.Pack}) {
            /if (!${Window[${FindItem[${itemname}].InvSlot.Pack.Name}].Open}) {
                /itemnotify ${FindItem[${itemname}].InvSlot.Pack.Name} rightmouseup
                /delay 5s ${Window[${FindItem[${itemname}].InvSlot.Pack.Name}].Open}
            }
            /if (!${Window[${FindItem[${itemname}].InvSlot.Pack.Name}].Open}) {
                /echo ERROR: Timeout trying to open a pack.
                /return
            }
        }
       
        /ctrl /itemnotify ${FindItem[${itemname}].InvSlot} leftmouseup
        /delay 10s ${Cursor.ID}
        /if (!${Cursor.ID}) {
            /echo ERROR: Timeout trying to place an item at cursor.
            /return
        }
       
        /click left target
        /delay 10s ${Window[GiveWnd].Open}
        /if (!${Window[GiveWnd].Open}) {
            /echo ERROR: Timeout trying to open GiveWnd.
            /return
        }
           
       
       
    
        /notify GiveWnd GVW_Give_Button leftmouseup
        /delay 10s !${Window[GiveWnd].Open}
        /if (${Window[GiveWnd].Open}) {
            /echo ERROR: Timeout trying to close GiveWnd.
            /return
        }
       
       /if (!${Cursor.ID}) {
           /bc turned in ${itemname}
           /return
       }
    
       /varcalc i ${i}+1
       /if (${i}>5) {
           /bc have item but something went wrong
           /return
       }
       
        /goto :Loop
       
    
       
    /return
    
     
    Last edited: Sep 28, 2023