; Reagent Restocker ;============================================ ; Configuration ;============================================ set %Font 3 ; Font type for messages set %FontColor 49 ; Font color for messages set %ContainerID EAASJMD ; Object ID of restock container set %RegBag CKF ; Object type of regbag in backpack set %Reagents KUF_JUF_KZF_JZF_MZF_WZF_RZF_SZF ; Reagents set %ReagentAmount 75 ; Number of each reagent wanted set %Destock #FALSE ; Set to #TRUE to destock regs over desired value set %ActionDelay 12 ; Delay between actions set %DragDelay 9 ; Delay between dragging reagents ;============================================ ; End Configuration ;============================================ ;Initialize variables set #LPC 1000 set %Bag #BACKPACKID set %FoundContainer #FALSE ;Search for the restock container finditem %ContainerID C if #FINDCNT > 0 set %Container #FINDID finditem %ContainerID G_2 if #FINDCNT > 0 set %Container #FINDID if %Container = N/A ;Throw error if restock container can't be found { event exmsg #CHARID %Font %FontColor Can't find restock container! Halting. halt } ;Open the restock container and backpack set #LOBJECTID %Container event macro 17 wait %ActionDelay event macro 8 7 wait %ActionDelay ;Search for regbag in backpack finditem %RegBag C_ , #BACKPACKID if #FINDCNT > 0 { ;Regbag found, open it set %Bag #FINDID set #LOBJECTID %Bag event macro 17 wait %ActionDelay } else ;Regbag missing, use main backpack instead event exmsg #CHARID %Font %FontColor Can't find regbag! Using main backpack. ;Repeat from here if necessary Drag: set %repeat #FALSE ;Initialize the reagent values to the needed amount gosub ListIndexCount %Reagents for %i 1 #RESULT { gosub ListIndex %Reagents %i set % . #RESULT %ReagentAmount } ;Subtract the reagents already in the regbag finditem %Reagents C_ , %Bag if #FINDCNT > 0 { for #FINDINDEX 1 #FINDCNT set % . #FINDTYPE % . #FINDTYPE - #FINDSTACK } ;Drag missing reagents to backpack gosub ListIndexCount %Reagents for %i 1 #RESULT { gosub ListIndex %Reagents %i finditem #RESULT C_ , %ContainerID if #FINDCNT > 0 && % . #FINDTYPE > 0 { exevent drag #FINDID % . #FINDTYPE exevent dropc %Bag set %repeat #TRUE wait %DragDelay } if %Destock && % . #FINDTYPE < 0 { finditem #RESULT C_ , %Bag set %amount -1 * % . #FINDTYPE exevent drag #FINDID %amount exevent dropc %ContainerID set %repeat #TRUE wait %DragDelay } } ;Repeat until no more reagents are needed if %repeat goto Drag event exmsg #CHARID %Font %FontColor Restock complete! halt ;============================================ sub ListIndex set %1 _ , %1 , _ str pos %1 _ %2 set %ListIndex_start #STRRES + 1 set %2 %2 + 1 str pos %1 _ %2 set %ListIndex_end #STRRES - %ListIndex_start str mid %1 %ListIndex_start %ListIndex_end return #STRRES sub ListIndexCount set %ListIndexCount_blank if %1 = %ListIndexCount_blank return 0 str count %1 _ return #STRRES + 1