Lobby West side - Corpse Summoning

Discussion in 'Macros' started by ultrax, Apr 26, 2022.

  1. ultrax

    ultrax Chetari Dominator

    Messages:
    435
    Setup to summon corpses on the west side of the lobby. Posted version is for lvl70 chars.
    Adjust these (2) for your level:
    • the amount to take out of the bank <SoulStoneCost>
    • the soulstone to buy <SoulStoneToUse>

    /declare SoulStoneCost string outer 165
    /declare SoulStoneToUse string outer Pristine Soulstone

    Code:
    | 1/12/2022
    | Auto Corpse Summon in Guild Lobby
    
    #turbo 40
    
    Sub Main
    /echo Guild Lobby Corpse Summoner Started
    
    ||||||Main Loop|||||||||||||||||||||
    :MainLoop
    
    | move to Center
        /moveto loc 420, 250
        /delay 20 ${MoveTo.Moving}
        /delay 150 ${MoveTo.Stopped}
    
        /delay ${Math.Rand[60]}
    | Check to see if you need to summon a corpse by item count
        /declare retryTimer timer outer 30s
        /declare itemCount int local
        /declare SoulStoneCost string outer 165
        /declare SoulStoneToUse string outer Pristine Soulstone
        /declare HaveSoulStone int outer
        /varset  HaveSoulStone 0
        /declare count_i int outer
        /declare merchantTotal int outer
        /varset count_i 0
        
        /for count_i 1 to 30
        /if (${Bool[${InvSlot[${count_i}].Item}]}) /varcalc itemCount ${itemCount} + 1
        /next count_i
    
        /if (${itemCount} >= 10) {
        /echo Looks like i have all my gear, so i don't need to summon a corpse.
        /endmacro
        }
    
    | If I'm in The Guild Lobby.
        /if (${Zone.ID} == 344) {
        /echo I'm in The Guild Lobby
        } else {
        /echo Not in the Guild Lobby, ending...
        /endmacro
        }
        
    | Move to Banker
        :movetobankerloop
        /moveto loc 477 190
        /delay 5s
        /if (${Math.Distance[477,190,2]} < 16) {
        :bankercloser
        /Target "A Shrewd Banker"
        /stick 8
        /delay 2s
        /if (${Target.Distance} < 9) {
        /keypress forward
        /echo moved to banker
        }    else {
        /goto :bankercloser
        }
        } else {
        /goto :movetobankerloop
        }
    
        /delay ${Math.Rand[60]}
    | Make Banker Withdrawl
        :startwithdraw
        /Target ="A Shrewd Banker" npc
        /if (${Target.ID}) {
        |got a target
        } else {
        /delay 5
        /goto :startwithdraw
        }
        :openbanker
        /if (!${Window[BigBankWnd].Open}) {
        /click right target
        } else {
        /delay 5
        /goto :openbanker
        }
        :ammountofplat
        /if (!${Window[QuantityWnd].Open}) {
        /notify BigBankWnd BIGB_Money0 leftmouseup
        }
        /delay 5 ${Window[QuantityWnd].Open}
        /for count_i 1 to 10
            /keypress backspace chat
            /delay 3
        /next count_i
        /varset count_i 0
        /for count_i 1 to ${SoulStoneCost.Length}
            /keypress ${SoulStoneCost.Mid[${count_i},1]} chat
            /delay 5
        /next count_i
        /notify QuantityWnd QTYW_Accept_Button leftmouseup
        /delay 7
        /autoinventory
        /delay 7
        /if (${Me.Platinum} < ${SoulStoneCost}) {
        /goto :startwithdraw
        }
        /delay 3s
    | move to Center
        /delay 1s
        /moveto loc 420, 250
        /delay 20 ${MoveTo.Moving}
        /delay 150 ${MoveTo.Stopped}   
        /delay ${Math.Rand[60]}
    | move to Merchant
        /delay 1s
        /moveto loc 352, 194
        /delay 20 ${MoveTo.Moving}
        /delay 150 ${MoveTo.Stopped}
        /delay ${Math.Rand[60]}
    | Buy soulstone
        :tardisciple
        /Target "A Disciple of Luclin"
        /if (${Target.ID}) {
        |got a target
        } else {
        /delay 5
        /goto :tardisciple
        }
        
        :opendisciplewindow
        /click right target
        /delay 10 ${Window[MerchantWnd].Open}
        /delay 1s
        /if (!${Window[MerchantWnd].Open}) {
        /delay 5
        /goto ::opendisciplewindow
        } else {
        /echo ERROR: Failed to open the soulstone merchant.
        }
        /varset merchantTotal -1
        
        :populateMerchant
        /if (${merchantTotal}!=${Window[MerchantWnd].Child[ItemList].Items}) {
        /varset merchantTotal ${Window[MerchantWnd].Child[ItemList].Items}
        /delay 9
        /goto :populateMerchant
        }
        
        /nomodkey /notify MerchantWnd ItemList listselect ${Window[MerchantWnd].Child[ItemList].List[=${SoulStoneToUse},2]}
        /delay 9
        /if (!${FindItemCount[${SoulStoneToUse}]}) /notify MerchantWnd MW_Buy_Button leftmouseup
        /delay 9
    
        /nomodkey /notify MerchantWnd MW_Done_Button leftmouseup
        
        /delay ${Math.Rand[60]}
    | move to Summoner
        /delay 1s
        /moveto loc 460, 292
        /delay 20 ${MoveTo.Moving}
        /delay 150 ${MoveTo.Stopped}
        /delay ${Math.Rand[60]}
        
    /call summon_Corpse ${SoulStoneToUse}
    
    | move to just away from Summoner for rezzing
        /delay 1s
        /moveto loc 446, 263
        /delay 20 ${MoveTo.Moving}
        /delay 150 ${MoveTo.Stopped}
    
    /bct all Ready for Rez    ...
    /endmacro
    /return
    /endmacro
    
    
    
    
    SUB summon_Corpse(SoulStoneToUse)
        :tarpriest
        /Target "A Priestess of Luclin"
        /if (${Target.ID}) {
        |got a target
        } else {
        /goto :tarpriest
        }
        /declare e int local
        /varset count_i 0
        
        :summonCorpse
        /if (${Spawn[${Me}'s].ID}) /goto :check_ForCorpse
        |---Open InventoryWindow.
        /if (!${Window[InventoryWindow].Open}) /nomodkey /keypress i
        /delay 10 ${Window[InventoryWindow].Open}
        |---If my inventory is not open.
        /if (!${Window[InventoryWindow].Open}) {
        |---If there is still time, retry.
            /if (${retryTimer}) {
            /goto :summonCorpse
            |---Else, announce to user.
            } else {
            /echo ERROR: Failed to open my inventory.
            }
        |---Else, if my inventory is open.
        } else {
        |--Search packslots.
            /for count_i 1 to ${numInventorySlots}
            |---If the item in the packslot is a soulstone, pick it up.
            /if (!${Me.Inventory[pack${count_i}].Container} && ${SoulStoneToUse.Equal[${Me.Inventory[pack${count_i}]}]}) {
            /itemnotify pack${count_i} leftmouseup
            } else {
            |---If the item in the packslot is a container, search it.
            /for e 1 to ${Me.Inventory[pack${count_i}].Container}
            /if (${SoulStoneToUse.Equal[${Me.Inventory[pack${count_i}].Item[${e}]}]}) {
            /if (!${Window[pack${count_i}].Open}) /itemnotify pack${count_i} rightmouseup
            /delay 1s ${Window[pack${count_i}].Open}
            /itemnotify in pack${count_i} ${e} leftmouseup
            }
            /next e
            }
            /next count_i
            |---Check that the soulstone was picked up.
            /if (!${Cursor.ID}) {
            |---If there is still time, retry.
                /if (${retryTimer}) {
                /goto :summonCorpse
                |---Else, announce to user.
                } else {
                /echo ERROR: Failed to pick up my soulstone.
                }
            |---Else, if the soulstone was picked up.
            } else {
                |----Open trade with the corpse summoner.
                /click left target
                /delay 10 ${Window[GiveWnd].Open}
                |---If the GiveWnd did not open.
                /if (!${Window[GiveWnd].Open}) {
                |---If there is still time, retry.
                    /if (${retryTimer}) {
                    /goto :summonCorpse
                    |---Else, announce to user.
                    } else {
                    /echo ERROR: Failed to open the give window.
                    }
                |---Else, if the give window is open.
                } else {
                |---Give the soulstone to the corpse summoner.
                /delay 5
                /notify GiveWnd GVW_Give_Button leftmouseup
                /delay 10 !${Window[GiveWnd].Open}
                |---If the GiveWnd did not open
    
                    /if (${Window[GiveWnd].Open} || ${FindItemCount[=${SoulStoneToUse}]}) {
                    |---If there is still time, retry.
                        /if (${retryTimer}) {
                        /goto :summonCorpse
                        |---Else, announce to user.
                        } else {
                        /echo ERROR: Failed to complete the trade.
                        }
                    |---Else, if the give window is open.
                    } else {
                    :check_ForCorpse
                    |---Loot your summoned corpse.
                    /delay 3s ${Spawn[${Me}'s].ID}
                    /if (!${Spawn[${Me}'s].ID}) /echo ERROR: My corpse did not appear.
                    }
                }
            }
        }
    /RETURN