CotH Macro

Discussion in 'Macros' started by Jibekn, Aug 16, 2022.

  1. Jibekn

    Jibekn Orc Pawn

    Messages:
    32
    My new coth macro, will scale to any number of toons.

    Usage: /bcaa //mac coth MageName
    (save code as coth.mac in macros folder)

    Features:
    Pearl check/count warnings
    Class/Level sanity check
    EQBC Feedback
    Zone/Distance Checks
    Med when LOM
    Will restart e3 when done (Can supply a non e3 restarting version)
    Todo list on it:
    AA Ability support
    Multi Mage support, including prioritizing the nth mage and having it continue cothing others.

    Any feedback will be appreciated.

    Code:
    |Written by Nuurph for PEQ Server, required non base ,MQ2 plugins: mq2netbots 
    |todo: aa usage, multimage support, black parameter check
    #warning
    #turbo 5
    #Event GInvite "#*# invites you to join a group."
    #Event eOOP "#*#!>!>!> OUT OF PEARLS <!<!<!#*#"
    Sub Main(sMage)
        |everyone running the mecro needs to be ungrouped
        /raiddisband
        /disband
        /delay 5
        /declare iCount int local 0
        /declare iDone int local 0
        /declare iPAlert int local 0
        :mainloop
        |am I the coht mage? if yes start inviting and summoning
        /if (${Me.ID} == ${Spawn[${sMage}].ID}) {
            |class check
            /if (${Me.Class.Name.NotEqual[Magician]} || ${Me.Level} <= 55) {
                /bc I have been designated the CotH Mage, but Im not a mage, or I'm not high enough level.
                /mac e3
            }
            /if (!${Me.SpellReady[Call of the Hero]}) {
                /bc Memorizing Call of the Hero, Standby.
                /memorize "Call of the Hero" 8
                /delay 17s ${Me.SpellReady[Call of the Hero]}
            }
            |pearl checking
            /if (${FindItemCount[=Pearl]} <= 250 && ${FindItemCount[=Pearl]} >= 100 && ${iPAlert} == 0) {
                /bc >>>ALERT<<< I have less than 250 Pearls remaining, You may want to refill my supply soon.
                /varset iPAlert 1
            }
            /if (${FindItemCount[=Pearl]} <= 100 && ${FindItemCount[=Pearl]} >= 50 && ${iPAlert} == 0) {
                /bc >>>WARNING<<< I have less than 100 Pearls remaining, I should be refilled very soon!
                /varset iPAlert 1
            }
            /if (${FindItemCount[=Pearl]} <= 50 && ${FindItemCount[=Pearl]} >= 1 && ${iPAlert} == 0) {
                /bc >>>CRITICAL WARNING<<< I have less than 50 Pearls remaining, I may not be able to complete the current task!
                /beep
                /delay 5
                /beep
                /delay 5
                /beep
                /varset iPAlert 1
            }
            /for iCount 1 to ${Int[${Math.Calc[${Ini[CotHTracker.ini,CotH].Count[|]}-1]}]}
                |loop through the ini, inviting, then CotHing
                /if (${Ini[CotHTracker.ini,CotH,${Ini[CotHTracker.ini,CotH].Token[${iCount},|]}]} == 1) {
                    |have I run out of pearls?
                    /if (${FindItemCount[=Pearl]} == 0) {
                        /echo !>!>!> OUT OF PEARLS <!<!<! CotH Macro will now shutdown. Please restock me and try again.
                        /beep
                        /delay 5
                        /beep
                        /delay 5
                        /beep
                        /mac e3
                    }
                    /bc Inviting ${Ini[CotHTracker.ini,CotH].Token[${iCount},|]} for CotH
                    /invite ${Ini[CotHTracker.ini,CotH].Token[${iCount},|]}
                    /delay 6s
                    /target ${Spawn[group ${Ini[CotHTracker.ini,CotH].Token[${iCount},|]}]}
                    /delay 3s
                    |fix for targeting pet
                    /target id ${Target.Master.ID}
                    /delay 1s
                    |zone/distance check
                    /if (${Int[${Target.Distance3D}]} <= 100) {
                        /bc ${Target.Name} is within 100 Units across all axis. I am bypassing this charecter, please CotH manually if I am in error.
                        /ini "CotHTracker.ini" "CotH" "${Ini[CotHTracker.ini,CotH].Token[${iCount},|]}" "0"
                        /goto :next
                    }
                    /if (!${NetBots[${Ini[CotHTracker.ini,CotH].Token[${iCount},|]}].InZone}) {
                        /bc ${Ini[CotHTracker.ini,CotH].Token[${iCount},|]} is vot in the same zone. Skipping.
                        /ini "CotHTracker.ini" "CotH" "${Ini[CotHTracker.ini,CotH].Token[${iCount},|]}" "0"
                        /goto :next
                    }
                    /if (${Me.CurrentMana} < (${Spell[Call of the Hero].Mana} + 150)) {
                        /if (!${Me.Sitting}) /sit
                        /delay 60s ${Me.CurrentMana} > (${Spell[Call of the Hero].Mana} + 150)
                    }
                    /casting "Call of the Hero" -maxtries|5
                    /delay 16s ${Cast.Status.Equal[I]}
                    /bc I have CotH'd ${Ini[CotHTracker.ini,CotH].Token[${iCount},|]}
                    /ini "CotHTracker.ini" "CotH" "${Ini[CotHTracker.ini,CotH].Token[${iCount},|]}" "0"
                    /delay 15s ${Me.SpellReady[Call of the Hero]}
                    /varset iDone 0
                } else {
                    /varset iDone ${Math.Calc[${iDone}+1]} 
                    /if (${iDone} == 1500) {
                        /bc CotH should be complete, shutting down macro.
                        /delay 5s
                        /mac e3
                    }
                }
            :next
            /next iCount
        } else {
            |im not the mage doing CotH, drop group, add myself to the ini file and wait.
            /ini "CotHTracker.ini" "CotH" "${Me.Name}" "1"
            :waitloop
            /delay 1s
            /doevents OOP
            /doevents GInvite
            /goto :waitloop
        }
        /goto :mainloop   
    /return
    |Accept group invite from the mage
    Sub Event_GInvite
        /invite
        /delay 2s
        /doevents GInvite flush
        /delay 25s
        /disband
        /delay 5s
        /mac e3
    /return
    Sub Event_OOP
        /disband
        /doevents OOP flush
        /delay 5s
        /mac e3
    /return
    
    Update:
    Fixed Pearl Check
    Added raid disband

    Update #2:
    Bug fixes
     
    Last edited: Aug 20, 2022
  2. Tharsis

    Tharsis Orc Legionnaire

    Messages:
    143
    Maybe it's too late to think straight, but your pearl counting statements all have "greater than or equal to" while the messages say "less than."
     
  3. Jibekn

    Jibekn Orc Pawn

    Messages:
    32
    thank ya. fixing.
     
  4. ultrax

    ultrax Chetari Dominator

    Messages:
    435
    /alt act 7050 is the AA cast
     
  5. Jibekn

    Jibekn Orc Pawn

    Messages:
    32
    Good to know, I should have a final version done with Multi Mage support and AA usage soon, and I want to change the current code to run off spell IDs.

    I will need help testing those 2 features however as I only run 1 mage who doesn't yet have the AA.
     
  6. Jibekn

    Jibekn Orc Pawn

    Messages:
    32
    Updated, fixed bug with target attempt not waiting until CotH toon has accepted invite. Also fixed a bug with Distance check and zone check. Also fixed a bug where a pet class's pet was CotH(Attempted) instead of the master.
     
    Last edited: Aug 20, 2022