e3_CorpseSummoning.inc

Discussion in 'E3' started by Casai, Aug 30, 2018.

  1. Casai

    Casai Orc Legionnaire

    Messages:
    109
    this is new version updated March 2021
    only from west guild lobby
    Code:
    |------------------------------------------------------------------------------------|
    |- e3_Macro_CorpseSummoning.inc v1.0 ( originally designed to work with e3.mac )    -|
    |- Written by Killians of PEQ                                                        -|
    |------------------------------------------------------------------------------------|
    |- Contains functions to automatically use the corpse summoners in the guild lobby.    -|
    |------------------------------------------------------------------------------------|
    #event UseCorpseSummoner "<#1#> Summon Corpses"
    #event UseCorpseSummoner "[#1#] Summon Corpses"
    SUB event_UseCorpseSummoner(line, ChatSender)
       /if (!${checkEventArgs[${ChatSender},${line},UZR,""]}) /return
        /declare itemCount int local
        /declare SoulStoneCost string outer ${Macro.Return.Arg[2,_]}
        /declare SoulStoneToUse string outer ${Macro.Return.Arg[1,_]}
        /declare count_i int outer
        |/declare merchantTotal int outer
       | Check to see if you need to summon a corpse
        /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} >= 27) {
           /echo Looks like i have all my gear, so i don't need to summon a corpse.
           /RETURN
        }
        |check If I'm in The Guild Lobby.
        /if (${Zone.ID} == 344) {
           /echo I'm in The Guild Lobby
        } else {
           /echo I'm not in The Guild Lobby end corpse summon
           /echo you have to be in WEST Guild Lobby for this to work
           /return
        }
       /if (${Spawn[${Me}'s].ID}) {
           /echo I already have a corpse here rez or loot it first
           /return
       }
        /debuffsoff
       /stand
       /cleanup
       /delay 11
       /cleanup
          
       }
       :clearcursor1
       /if (${Cursor.ID} ) {
           /autoinv
           /goto :clearcursor1
       }
        /call find_Soulstone
       /echo stone:${SoulStoneToUse} cost:${SoulStoneCost}
       :beginagain
       /if (${FindItemCount[${SoulStoneToUse}]}) {
           /goto :continuegotstone
       }
        /call runtomiddlepoint
        /call movetobanker
        /call getmoneyfrombanker
       /if (${Me.Platinum} >= ${SoulStoneCost}) {
           /goto :continuegotmoney
       } else {
           /goto :beginagain
       }
       :continuegotmoney
       /echo mypp ${Me.Platinum} > cost:${SoulStoneCost}
        /call runtomiddlepoint
        /call movetocomponentsven
        /call buysoulstone
       /if (${FindItemCount[${SoulStoneToUse}]}) {
           /goto :continuegotstone
       } else {
           /goto :beginagain
       }
       :continuegotstone
        /call runtomiddlepoint
        /call movetosummoner
        /call summon_Corpse
       :clearcursor2
       /if (${Cursor.ID} ) {
           /autoinv
           /goto :clearcursor2
       }
       /if (!${FindItemCount[${SoulStoneToUse}]}) {
           /goto :continuegotcorpse
       } else {
           /goto :beginagain
       }
       :continuegotcorpse
        /call runtomiddlepoint
       /call moverezerstobodies
    /RETURN
    
    
    SUB AvoidStuck
       /delay 1s
       /keypress back hold
       /delay 4
       /keypress back
       /keypress strafe_left hold
       /delay 7
       /keypress strafe_left
       /keypress up hold
       /delay 4
       /keypress up
       /delay 5
    
    
    /return
    
    
    
    SUB find_Soulstone
        /if (${Me.Level} <= 20) {
            /varset SoulStoneToUse Minor Soulstone
            /varset SoulStoneCost 12
        } else /if (${Me.Level} > 20 && ${Me.Level} <= 30) {
            /varset SoulStoneToUse Lesser Soulstone
            /varset SoulStoneCost 28
        } else /if (${Me.Level} > 30 && ${Me.Level} <= 40) {
            /varset SoulStoneToUse Soulstone
            /varset SoulStoneCost 55
        } else /if (${Me.Level} > 40 && ${Me.Level} <= 50) {
            /varset SoulStoneToUse Greater Soulstone
            /varset SoulStoneCost 87
        } else /if (${Me.Level} > 50 && ${Me.Level} <= 55) {
            /varset SoulStoneToUse Faceted Soulstone
            /varset SoulStoneCost 120
        } else /if (${Me.Level} > 55 && ${Me.Level} <= 70) {
            /varset SoulStoneToUse Pristine Soulstone
            /varset SoulStoneCost 165
        } else /if (${Me.Level} > 70 && ${Me.Level} <= 75) {
            /varset SoulStoneToUse Glowing Soulstone
            /varset SoulStoneCost 265
        } else /if (${Me.Level} > 75 && ${Me.Level} <= 80) {
            /varset SoulStoneToUse Prismatic Soulstone
            /varset SoulStoneCost 425
        } else /if (${Me.Level} > 80 && ${Me.Level} <= 85) {
            /varset SoulStoneToUse Iridescent Soulstone
            /varset SoulStoneCost 530
        } else /if (${Me.Level} > 85 && ${Me.Level} <= 90) {
            /varset SoulStoneToUse Phantasmal Soulstone
            /varset SoulStoneCost 635
        } else /if (${Me.Level} > 90 && ${Me.Level} <= 95) {
            /varset SoulStoneToUse Luminous Soulstone
            /varset SoulStoneCost 750
        } else /if (${Me.Level} > 95 && ${Me.Level} <= 100) {
            /varset SoulStoneToUse Coalescent Soulstone
            /varset SoulStoneCost 865
        }
    
    /RETURN ${SoulStoneToUse}_${SoulStoneCost}
    
    
    SUB summon_Corpse(SoulStoneToUse)
        :tarpriest
       /Target "A Priest of Luclin"
       |/target ID 55
        /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.
                    }
                }
            }
        }
       :stashcursoitem
       /if (${Cursor.ID} ) {
           /autoinv
           /goto :stashcursoitem
       }
       /if (${FindItemCount[${SoulStoneToUse}]}) /goto :tarpriest
    /RETURN
    
    
    SUB buysoulstone
       /declare buyfailedcount int local
       /varset buyfailedcount 0
       /if (${FindItemCount[${SoulStoneToUse}]}) {
           /RETURN
       }
       :tardisciple
       /cleanup
       /delay 5
       /cleanup
       /delay 5
       /Target "A Disciple of Luclin"
       |/target ID 56
       /if (!${Target.ID}) {
           /goto :tardisciple
       }
       :opendisciplewindow
       /click right target
       /delay 10 ${Window[MerchantWnd].Open}
       /if (!${Window[MerchantWnd].Open}) {
           /goto :opendisciplewindow
       }
       /if (${Window[MerchantWnd].Child[ItemList].List[=${SoulStoneToUse},2]}) {
           /delay 22
       } else {
           /delay 11
           /goto :opendisciplewindow
           /varcalc buyfailedcount ${buyfailedcount} + 1
           /if (${buyfailedcount} > 6) {
                   /goto :tardisciple
           }
       }
       /varset buyfailedcount 0
       /nomodkey /notify MerchantWnd ItemList listselect ${Window[MerchantWnd].Child[ItemList].List[=${SoulStoneToUse},2]}
       /delay 11
       /if (!${FindItemCount[${SoulStoneToUse}]}) /notify MerchantWnd MW_Buy_Button leftmouseup
       /delay 11
       /if (!${FindItemCount[${SoulStoneToUse}]}) {
           /cleanup
           /goto :tardisciple
       } else {
       /nomodkey /notify MerchantWnd MW_Done_Button leftmouseup
       }
    
       /if (${FindItemCount[${SoulStoneToUse}]}) {
           /echo soulstone in inventory
           /RETURN
       }
       /goto :tardisciple
    /RETURN
    
    
    
    SUB movetosummoner
       /echo moving to summoner
       /declare movefailedcount int local
       /varset movefailedcount 0
       :movetosummonerloop
       /moveto loc 321 270
       /echo retry move attempt ${movefailedcount}
       /varcalc movefailedcount ${movefailedcount} + 1
       /delay 1s
       /if (${movefailedcount} > 5) {
                   /call AvoidStuck
                   /delay 2s
       }
       /if (${movefailedcount} > 11) {
                   /call runtomiddlepoint
                   /delay 1s
                   /varset movefailedcount 0
                   /goto :movetosummonerloop
       }
    
       /Target "A Priest of Luclin"
       |/target id 55
       /stick 8
       /delay 5
       /keypress forward
       /delay 1
       /if (${Target.Distance} < 9) {
           /keypress forward
           /delay 1
           /echo moved to summoner
           /return
       }
    
       /goto :movetosummonerloop
    /RETURN
    
    SUB moverezerstobodies
       /if (!${Me.Class.ShortName.Equal[CLR]}) /RETURN
      
       /declare movefailedcount int local
       /varset movefailedcount 0
       /delay 5s
       /echo moving CLERICS to summoner
       :moveclericsloop
       /moveto loc 321 270
       /echo retry move attempt ${movefailedcount}
       /varcalc movefailedcount ${movefailedcount} + 1
       /delay 1s
       /if (${movefailedcount} > 5) {
                   /call AvoidStuck
                   /delay 7s
       }
       /if (${movefailedcount} > 11) {
                   /call runtomiddlepoint
                   /delay 1s
                   /varset movefailedcount 0
                   /goto :moveclericsloop
       }
    
       /Target "A Priest of Luclin"
       |/target id 55
       /stick 8
       /delay 5
       /keypress forward
       /delay 1
       /if (${Target.Distance} < 9) {
           /keypress forward
           /delay 1
           /echo moved CLERICS to summoner
           /return
       }
    
       /goto :moveclericsloop
    /RETURN
    
    SUB movetocomponentsven
       /if (${FindItemCount[${SoulStoneToUse}]}) {
           /RETURN
       }
       /echo moving to disciple
       /declare movefailedcount int local
       /varset movefailedcount 0
       :movetocomponentsvenloop
       /echo retry move attempt ${movefailedcount}
       /varcalc movefailedcount ${movefailedcount} + 1
       /moveto loc 350 191
       /delay 1s
       /if (${movefailedcount} > 5) {
                   /call AvoidStuck
                   /delay 7s
       }
       /if (${movefailedcount} > 11) {
                   /call runtomiddlepoint
                   /delay 1s
                   /varset movefailedcount 0
                   /goto :movetocomponentsvenloop
       }
       /varcalc movefailedcount ${movefailedcount} + 1
       /Target "A Disciple of Luclin"
       |/target ID 56
       /stick 8
       /delay 5
       /keypress forward
       /delay 1
       /if (${Target.Distance} < 9) {
           /keypress forward
           /delay 1
           /echo moved to disciple
           /return
       }
    
       /goto :movetocomponentsvenloop
    /RETURN
      
    SUB movetobanker
       /if (${Me.Platinum} >= ${SoulStoneCost}) {
           /RETURN
       }
       /if (${FindItemCount[${SoulStoneToUse}]}) {
           /RETURN
       }
       /declare movefailedcount int local
       /varset movefailedcount 0
       /echo moving to banker
       :movetobankerloop
       /echo retry move attempt ${movefailedcount}
       /varcalc movefailedcount ${movefailedcount} + 1
       /moveto loc 477 190
       /delay 1s
       /if (${movefailedcount} > 5) {
                   /call AvoidStuck
                   /delay 7s
       }
       /if (${movefailedcount} > 11) {
                   /call runtomiddlepoint
                   /delay 1s
                   /varset movefailedcount 0
                   /goto :movetobankerloop
       }
    
       /Target "A Shrewd Banker"
       |/target ID 65
       /stick 8
       /delay 5
       /keypress forward
       /delay 1
       /if (${Target.Distance} < 9) {
           /keypress forward
           /delay 1
           /echo moved to banker
           /return
       }
    
       /goto :movetobankerloop
    /RETURN
    
    SUB getmoneyfrombanker
       /if (${Me.Platinum} >= ${SoulStoneCost}) {
       /RETURN
       }
       /if (${FindItemCount[${SoulStoneToUse}]}) {
       /RETURN
       }
       :startwithdraw
       /Target "A Shrewd Banker"
       |/target ID 65
       /if (${Target.ID}) {
           |got a target
       } else {
           /goto :startwithdraw
       }
       :openbanker
       /if (!${Window[BigBankWnd].Open}) {
       /click right target
       } else {
       /goto :openbanker
       }
       :ammountofplat
       /if (!${Window[QuantityWnd].Open}) {
           /notify BigBankWnd BIGB_Money0 leftmouseup
           }
           /delay 5 ${Window[QuantityWnd].Open}
           /for count_i 1 to 9
               /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 3
           /next count_i
           /notify QuantityWnd QTYW_Accept_Button leftmouseup
           /delay 2
           /autoinventory
       else {
       /echo QuantityWnd is open
       }
       /if (${Me.Platinum} < ${SoulStoneCost}) {
       /goto :startwithdraw
       }
    /RETURN
    
    SUB runtomiddlepoint
       :loopmiddlep
       /moveto loc 400 250
       |/echo ${Math.Distance[400,250,1]}
       /if (${Math.Distance[400,250,1]} < 20) {
           /echo all done moved to middle
           /RETURN
       } else {
           /delay 5
           /goto :loopmiddlep
       }
    /RETURN
    
    SUB corpseSummon_Setup
    /call iniToVarV "${advSettings_Ini},Debug,Debug CorpseSummoning (On/Off)" Debug_CorpseSummoning bool outer
    /RETURN
    |-----------------------------------------
    SUB corpseSummon_MacroSettings
        /call WriteToIni "${advSettings_Ini},Debug,Debug CorpseSummoning (On/Off)" Off
        /call WriteToIni "${genSettings_Ini},Corpse Summoning,Loot After Summoning (On/Off)" Off
    /RETURN
    |-----------------------------------------
    SUB corpseSummon_CharacterSettings
    /RETURN
    |-----------------------------------------
    Sub corpseSummon_Aliases
        /squelch /alias /summoncorpses /bc Use Corpse Summoner
        /squelch /alias /summoncorpse /echo Use Corpse Summoner
    /return
    |-----------------------------------------
    Sub corpseSummon_Background_Events
        /doevents UseCorpseSummoner
    /return
    
    
     
    Last edited: Mar 10, 2021
  2. Hive

    Hive Froglok Krup Watcher

    Messages:
    340
    After I used Claudelamont's fix posted here it has always worked well for me. Sometimes my clerics will crash if I don't /mac e3 on them before /aerez, but other than that I haven't had a problem since this fix.
     
    Last edited: Feb 16, 2020
  3. Casai

    Casai Orc Legionnaire

    Messages:
    109
    I know that default one had big drawbacks left more than half of the toons stuck at different points of the script.
    mine so far does it 100% for me. used it twice
    doesnt get extra cash from the bank doesnt run around if not needed and if restarted will not do extra steps - checks for cash and if stone is already there.
    it also makes sure that toon actually moved to the npcs as it suppose to

    need to write in there to check that there is money in the bank and find out what causing background something messages.
     
  4. apollo

    apollo Protector of Zek

    Messages:
    503
    I just stop melodies and do a /bcaa //mac e3 prior to using this, let my toons rebuff, and then it works fine.

    The only issue I've run into is that ${Me.Platinum} doesn't seem to like large numbers. It seems to recognize 6-figure numbers and below, but once you tip into 7-figures it just reads back as zero and spits out the "I don't have enough money to buy a soulstone" message.
     
  5. Hive

    Hive Froglok Krup Watcher

    Messages:
    340
    First world problems amirite?
     
    • Like Like x 1
  6. Drogerin

    Drogerin GM Staff Member

    Messages:
    703
    I just go with efficiency and wait til next day and summon with corpse guy in shadow rest lol
     
    • Like Like x 1
  7. apollo

    apollo Protector of Zek

    Messages:
    503
    Hah, my point was more that it worked flawlessly for me after restarting E3 save for that one little glitch, but looking back I can see how it could be construed as being a little boastful. Not my intent; that plat hiccup is the only glitch I've run into using summoncorpses (again, provided you restart - Wait4Rez and such does tend to mess with its functionality it seems)
     
  8. apollo

    apollo Protector of Zek

    Messages:
    503
    I'm not confident that calling it a day/night after one wipe just to wait on Shadowrest is really that "efficient" haha ;)
     
  9. Hive

    Hive Froglok Krup Watcher

    Messages:
    340
    Lol I'm just messing around, Apollo. :D
     
  10. Casai

    Casai Orc Legionnaire

    Messages:
    109
    updated
     
  11. Casai

    Casai Orc Legionnaire

    Messages:
    109
    updated
     
  12. Casai

    Casai Orc Legionnaire

    Messages:
    109
    updated
     
  13. Hive

    Hive Froglok Krup Watcher

    Messages:
    340
    Don't forget to update it for the new inventory slots!
    Code:
     |--Search packslots.
           /for count_i 1 to 8
    Should be 1 to 10 now, ya? Unless I'm bad at reading, which is entirely possible! Maybe not the only spot either I didn't go through the whole thing =D
     
  14. cream

    cream GM Staff Member

    Messages:
    239
    on e3 post inv slot addition:
    /for count_i 1 to ${numInventorySlots}
     
    • Like Like x 1
  15. Casai

    Casai Orc Legionnaire

    Messages:
    109
    did it. updated
     
    • Creative Creative x 1
  16. Major Headache

    Major Headache Orc Pawn

    Messages:
    6
  17. Hive

    Hive Froglok Krup Watcher

    Messages:
    340
    If you were talking about the link in my post I've updated it.
     
  18. Major Headache

    Major Headache Orc Pawn

    Messages:
    6
  19. Casai

    Casai Orc Legionnaire

    Messages:
    109
    improved summoning can call it version 2.0
    code is in the first post
     
    • Like Like x 1
  20. Casai

    Casai Orc Legionnaire

    Messages:
    109
    /target id
    id seems to have changed thought they were static so reverted to normal targeting
    code is in the first post