PetBuffCheck + SelfBuffCheck

Joined
Jun 7, 2007
Messages
816
Reaction score
3
Points
18
In an effort to share with the community, here are some essential subs i wrote to help in my macros ...... enjoy .. feedback and not flames welcome.

These subs are exactly what they say.

Checks your pet's buffs and your self buffs... if the duration is less than 3 minutes, it attempts to load the spell if not already loaded, and cast it.

Quite useful for afk xping.

assumes you are using spell_routines.inc or mq2cast

UPDATE: 12-8-2009
1) Original subs have been updated. I have updated this to re-mem the original spell back into the spell gem.
(Example: Buff spell "Galanty Rk. II" is about to wear off, that spell is not currently memmed, sub will load "Galantry RK. II" into your gem slot, cast it, then re-mem the original spell you had memmed in that slot before the sub activated.

2) Additional declare of "/declare SpellGemNum int [value]" required to set the default gem slot to mem buff into.
(Example: /declare SpellGemNum int 8 .... will set gem slot 8 as the gem slot to load the buff slot into.)

3) Added 2 new subs for WORN OFF events for others in group and pets, these are triggered by in game "worn off" messages and will actively recast buffs you have cast on others as they ware off. Same routine is used to restore original spell in gemslot if the sub needs to mem the worn off buff spell in a gemslot / then return the original spell to the gem slot.
These two event subs come in handy in case your single/group buffs drop off of a group member and need to be recast or you missed the 3 minute mark for self and pet buffs waring off because you were in a long combat routine.

Enjoy ... and as always constructive feedback is appreciated.


SUB: SelfBuffCheck
Requires global declaration of: /declare SpellGemNum int [value]
Requires global declaration of: /declare CastDelay int [value]

Code:
|-------------------------------------------------------------------------------- 
|SUB: SelfBuffCheck
|-------------------------------------------------------------------------------- 
Sub SelfBuffCheck 

  /echo Checking my self buff durations.
  
  /echo --------------------------------------------------------------------
  
  /declare TempGemName string "${Me.Gem[${SpellGemNum}].Name}"
  /declare TempID      int inner
  /varset  TempID      ${Target.ID}
              
  /declare BuffID int local 0 
     
     /for BuffID 1 to 30 

     |/echo BUFFID/NAME=(${BuffID}/${Me.Buff[${BuffID}].Name}])

      /if (${Me.Buff[${BuffID}].ID} && ${Me.Buff[${BuffID}].Duration}<35) {
      
          /if (!${Me.Gem[${Me.Buff[${BuffID}].Name}]} && ${Me.Book[${Me.Buff[${BuffID}].Name}]}) {
                                         
              /if (${Me.Gem[${SpellGemNum}].Name.NotEqual[NULL]}) {
                  |/echo Have (${Me.Gem[${SpellGemNum}].Name}) memmed in slot:(${SpellGemNum}).
              }              

              |/echo Memming (${Me.Buff[${BuffID}].Name}) in slot (${SpellGemNum}).              
              /memspell ${SpellGemNum} "${Me.Buff[${BuffID}].Name}"
              
              :WaitForSelfBuffReady
              /if (!${Me.Gem[${Me.Buff[${BuffID}].Name}]} || !${Me.SpellReady[${Me.Buff[${BuffID}].Name}]}) {
                  /delay 10
                  /goto :WaitForSelfBuffReady
              }
          } 
          
          /echo -- Less then (${Me.Buff[${BuffID}].Duration}) Ticks left on (${Me.Buff[${BuffID}].Name})                                                
          /if ((${Me.CurrentMana}>${Spell[${Me.Buff[${BuffID}].Name}].Mana}) && (${Me.Gem[${Me.Buff[${BuffID}].Name}]}) && (${Me.SpellReady[${Me.Buff[${BuffID}].Name}]})) { 
              /squelch /target ${Me.CleanName}
              /delay 15 ${Target.CleanName.Equal[${Me.CleanName}]}
              /delay 15
              /varcalc CastDelay 2*${Spell[${Me.Buff[${BuffID}].Name}].RecoveryTime}                                               
              /call cast "${Me.Buff[${BuffID}].Name}" gem${Me.Gem[${Me.Buff[${BuffID}].Name}]} ${CastRetryTime}
              /delay ${CastDelay}s  
              /doevents
          }                  
          
      } else {      
          /if (${Me.Buff[${BuffID}].ID}>0) /echo ++ (${Me.Buff[${BuffID}].Name}) has (${Me.Buff[${BuffID}].Duration}) tics left.     
      }
   
      /next BuffID   

      /if (${String[${TempGemName}].NotEqual[NULL]}) {
          |/echo Restoring (${TempGemName}) in slot (${SpellGemNum}).
          /memspell ${SpellGemNum} "${TempGemName}"
      }      
      
   /echo --------------------------------------------------------------------
      
  /echo Done checking buff durations.
   
  /if (${TempID}) { 
      /target id ${TempID}
      /delay 30
  } else {
     /squelch /target clear
  }

/doevents 
   
/return
|--------------------------------------------------------------------------------


SUB: PetBuffCheck
Requires global declaration of: /declare SpellGemNum int [value]
Requires global declaration of: /declare CastDelay int [value]


Code:
|-------------------------------------------------------------------------------- 
|SUB: PetBuffCheck
|-------------------------------------------------------------------------------- 
Sub PetBuffCheck 

  /echo Checking pet's buff durations.
  
  /echo --------------------------------------------------------------------

  /declare TempGemName string "${Me.Gem[${SpellGemNum}].Name}"
  /declare TempID      int inner
  /varset  TempID      ${Target.ID}   

  /squelch /target ${Me.Pet.CleanName}
  /delay 15 ${Target.ID}==${Me.Pet.ID}
  /delay 15

  /declare BuffID int local 0 
  /for BuffID 1 to 30
  
  |/echo BUFFID/NAME=(${BuffID}/${Target.Buff[${BuffID}].Name}])
      
      /if (${Target.Buff[${BuffID}].ID} && ${Target.BuffDuration[${BuffID}]}<35) {
          
          /if (!${Me.Gem[${Target.Buff[${BuffID}].Name}]} && ${Me.Book[${Target.Buff[${BuffID}].Name}]}) {
                            
              /if (${Me.Gem[${SpellGemNum}].Name.NotEqual[NULL]}) {
                  |/echo Have (${Me.Gem[${SpellGemNum}].Name}) memmed in slot:(${SpellGemNum}).
              }              

              |/echo Memming (${Target.Buff[${BuffID}].Name}) in slot (${SpellGemNum}).                          
              /memspell ${SpellGemNum} "${Target.Buff[${BuffID}].Name}"
                            
              :WaitForPetBuffReady
              /if (!${Me.Gem[${Target.Buff[${BuffID}].Name}]} || !${Me.SpellReady[${Target.Buff[${BuffID}].Name}]}) {
                  /delay 10
                  /goto :WaitForPetBuffReady
              }
          }
          
          /echo -- Less then (${Target.BuffDuration[${BuffID}]}) Ticks left on (${Target.Buff[${BuffID}].Name})                          
          /if ((${Me.CurrentMana}>${Spell[${Target.Buff[${BuffID}].Name}].Mana}) && (${Me.Gem[${Target.Buff[${BuffID}].Name}]}) && (${Me.SpellReady[${Target.Buff[${BuffID}].Name}]})) {
              /varcalc CastDelay 2*${Spell[${Target.Buff[${BuffID}].Name}].RecoveryTime}                                               
              /call cast "${Target.Buff[${BuffID}].Name}" gem${Me.Gem[${Target.Buff[${BuffID}].Name}]} ${CastRetryTime}
              /delay ${CastDelay}s  
              /doevents
          }
      } else {      
          /if (${Target.Buff[${BuffID}].ID}>0) /echo ++ (${Target.Buff[${BuffID}].Name}) has (${Target.BuffDuration[${BuffID}]}) tics left.          
      }   
      
  /next BuffID         

  /if (${String[${TempGemName}].NotEqual[NULL]}) {
      |/echo Restoring (${TempGemName}) in slot (${SpellGemNum}).
      /memspell ${SpellGemNum} "${TempGemName}"
  }  

  /echo --------------------------------------------------------------------
      
  /echo Done checking pet's buff durations.
   
  /if (${TempID}) { 
      /target id ${TempID}
      /delay 30
  } else {
     /squelch /target clear
  }

/doevents
   
/return
|--------------------------------------------------------------------------------


SUB: Event_Worn_off
Requires global declaration of: /declare SpellGemNum int [value]
Requires global declaration of: /declare CastDelay int [value]
Requires Event Trigger definition of: #Event Worn_off "Your #1# spell has worn off of #2#."

Code:
|-------------------------------------------------------------------------------- 
|SUB: Event_Worn_off
|-------------------------------------------------------------------------------- 
Sub Event_Worn_off(string Line, string mybuffspell, string mybufftarget)

  /declare TempGemName string "${Me.Gem[${SpellGemNum}].Name}"
  /declare TempID      int inner
  /varset  TempID      ${Target.ID}
  
  /echo - Buff (${mybuffspell}) has worn off on ${mybufftarget}.

  /if (!${Me.Gem[${mybuffspell}]} && ${Me.Book[${mybuffspell}]}) {

      /if (${Me.Gem[${SpellGemNum}].Name.NotEqual[NULL]}) {
          |/echo Have (${Me.Gem[${SpellGemNum}].Name}) memmed in slot:(${SpellGemNum}).
      }              

      |/echo Memming (${mybuffspell}) in slot (${SpellGemNum}).                          
      /memspell ${SpellGemNum} "${mybuffspell}"

      :WaitForWornOffReady
      /if (!${Me.Gem[${mybuffspell}]} || !${Me.SpellReady[${mybuffspell}]}) {
  	  /delay 10
	  /goto :WaitForWornOffReady
      }
  }

  /if ((${Me.CurrentMana}>${Spell[${mybuffspell}].Mana}) && (${Me.Gem[${mybuffspell}]}) && (${Me.SpellReady[${mybuffspell}]})) {
      /target ${Me.Pet.CleanName}
      /delay 15 ${Target.ID}==${mybufftarget.ID}
      /delay 15
      /varcalc CastDelay 2*${Spell[${mybuffspell}].RecoveryTime}                                                
      /call cast "${mybuffspell}" gem${Me.Gem[${mybuffspell}]} ${CastRetryTime} 
      /delay ${CastDelay}s 
      /doevents                         
  }  

  /if (${String[${TempGemName}].NotEqual[NULL]}) {
      |/echo Restoring (${TempGemName}) in slot (${SpellGemNum}).
      /memspell ${SpellGemNum} "${TempGemName}"
  } 

  /if (${TempID}) { 
      /target id ${TempID}
      /delay 1s
  } else {
      /squelch /target clear
  }  
  
  /doevents

/return
|--------------------------------------------------------------------------------


SUB: Event_Worn_off_Pet
Requires global declaration of: /declare SpellGemNum int [value]
Requires global declaration of: /declare CastDelay int [value]
Requires Event Trigger definition of: #Event Worn_off_Pet "Your pet's #1# spell has worn off."


Code:
|-------------------------------------------------------------------------------- 
|SUB: Event_Worn_off_Pet
|-------------------------------------------------------------------------------- 
Sub Event_Worn_off_Pet(string Line, string mybuffspell)

  |--- Pet Buff Exceptions
  /if (${mybuffspell.Equal[Prism Skin]}) /return
  /if (${mybuffspell.Equal[Theft of Essence]}) /return
  |--- Pet Buff Exceptions

  /declare TempGemName string "${Me.Gem[${SpellGemNum}].Name}"
  /declare TempID      int inner
  /varset  TempID      ${Target.ID}
  
  /echo - Pet buff (${mybuffspell}) has worn off on ${Me.Pet.CleanName}.  
  
  /if (!${Me.Gem[${mybuffspell}]} && ${Me.Book[${mybuffspell}]}) {
  
      /if (${Me.Gem[${SpellGemNum}].Name.NotEqual[NULL]}) {
          |/echo Have (${Me.Gem[${SpellGemNum}].Name}) memmed in slot:(${SpellGemNum}).
      }              

      |/echo Memming (${mybuffspell}) in slot (${SpellGemNum}).                          
      /memspell ${SpellGemNum} "${mybuffspell}"

      :WaitForWornOffPetReady
      /if (!${Me.Gem[${mybuffspell}]} || !${Me.SpellReady[${mybuffspell}]}) {
  	  /delay 10
	  /goto :WaitForWornOffPetReady
      }
  }

  /if ((${Me.CurrentMana}>${Spell[${mybuffspell}].Mana}) && (${Me.Gem[${mybuffspell}]}) && (${Me.SpellReady[${mybuffspell}]})) {
      /target ${Me.Pet.CleanName}
      /delay 15 ${Target.ID}==${Me.Pet.ID}
      /delay 15
      /varcalc CastDelay 2*${Spell[${mybuffspell}].RecoveryTime}                                                
      /call cast "${mybuffspell}" gem${Me.Gem[${mybuffspell}]} ${CastRetryTime} 
      /delay ${CastDelay}s 
      /doevents                         
  }  

  /if (${String[${TempGemName}].NotEqual[NULL]}) {
      |/echo Restoring (${TempGemName}) in slot (${SpellGemNum}).
      /memspell ${SpellGemNum} "${TempGemName}"
  } 

  /if (${TempID}) { 
      /target id ${TempID}
      /delay 1s
  } else {
      /squelch /target clear
  }  
  
  /doevents

/return
|--------------------------------------------------------------------------------
 
Last edited:
bump

Updated the original subs and added two more useful ones, bump for the community.

I have way too much time on my hands, if anyone is in need of specific sub routines and aren't that creative/skilled at coding them.. send me a PM with details and I will be happy to try and write it for you or modify an existing sub i already have to fit your specific needs.

I have written hundreds of tailor made subs for use within my own macros so chances are I already have something that you are looking for... and if not.. can easily make one for you.

Just trying to help out the community ( smile )