Pet, clear that trash! (mage pet script to clear trash mobs)
Posted: Sun Mar 27, 2011 10:04 am
Created a macro to get pet to kill all the trash I do not want around me within pet attack range.
NB! It seems the pet has a max queue on pet attack. So sometimes it'll stop responding to new /pet attack's. To clear just do a pet back off again.
Usage:
Macro:
NB! It seems the pet has a max queue on pet attack. So sometimes it'll stop responding to new /pet attack's. To clear just do a pet back off again.
Usage:
Code: Select all
/macro MacroName "target1|target2|target3|..." MaxRange
example:
/macro AttackTrash "lizard|skeleton|beetle|bear|orc" 250
Code: Select all
Sub Main
/echo Input: ${Param0} ${Param1}
/declare targ string local
/declare maxdist int local
/declare maxdistold int local
/declare dist int local
/declare i int local
/declare maxdisttotal int local
/declare targetid int local
/varset targ ${Param0}
/varset maxdisttotal ${Param1}
/varset maxdist 0
/call SplitString tmp_tmp "${targ}" "|"
/declare iCount int local
/varcalc maxdist ${maxdisttotal}
:TryAgainTotal
/varset maxdistold ${maxdist}
/varcalc maxdist ${maxdist}-50
/for iCount 1 to ${tmp_tmp.Size}
/varset i 0
/varset targ ${tmp_tmp[${iCount}]}
|/echo icount: ${iCount} - ${targ}
|/echo DistanceChecking: ${maxdist}-${maxdistold}
:TryAgain
/varcalc i ${i}+1
|/echo ${i} - ${targ} - ${NaearestSpawn[${i},${targ}].ID}
/varset targetid ${NearestSpawn[${i},${targ}].ID}
/varset dist ${Spawn[id ${targetid}].Distance}
/if ( ${targetid}==0 ) /goto :Ferdig
/if ( ${dist}>${maxdistold} ) /goto :Ferdig
/if ( ${NearestSpawn[${i},${targ}].Type.Equal[Corpse]} ) /goto :TryAgain
|/echo ${maxdist}>${dist}>${maxdistold} - tid: ${targetid} - [${targ}] corpse: ${NearestSpawn[${i},${targ}].Type.Equal[Corpse]}
|/echo TryAgain ${targetid}
/if ( ${targetid}>0 ) {
/if ( ${dist}>${maxdistold} || ${dist}<${maxdist} ) /goto :TryAgain
/target id ${targetid}
/delay 1
/if ( ${Target.ID} == ${targetid} ) {
|/echo Judging: ${Target.Name} - ${Target.ID} - Range: ${dist}
/if ( !${Target.Type.Equal[Corpse]} && ${dist}<${maxdistold} && ${dist}>${maxdist} ) {
/echo Pet Attack: ${Target.Name} - ${Target.ID} - Range: ${dist}
/pet attack
}
}
/delay 1
/if ( ${dist}<${maxdistold} ) /goto :TryAgain
}
:Ferdig
/next iCount
/if ( ${maxdist} >= 0 ) /goto :TryAgainTotal
/echo Done!
/return
|----------------------------------------------------------------------------
|SUB: SplitString - A generic string splitter.
|----------------------------------------------------------------------------
Sub SplitString(string varname, string inputstring, string splitter)
|/echo varname: "${varname}", inputstring: "${inputstring}", splitter: "${splitter}"
/declare i int local
/declare stringcnt int local
|If there was not 3 params sent, return
/if (!${Defined[splitter]} ) {
/if (!${Defined[${varname}]}) {
/declare ${varname}[1] string outer
} else {
/deletevar ${varname}
/declare ${varname}[1] string outer
}
/varset ${varname}[1]
/return
}
|The normal splitter. Splitter string is just 1 in length.
/if (${splitter.Length}==1) {
/varcalc stringcnt ${inputstring.Count["${splitter}"]} + 1
/if (!${Defined[${varname}]}) {
/declare ${varname}[${stringcnt}] string outer
} else {
/deletevar ${varname}
/declare ${varname}[${stringcnt}] string outer
}
/for i 1 to ${stringcnt}
/varset ${varname}[${i}] ${inputstring.Token[${i},"${splitter}"]}
/next i
} else {
|The TOKEN method on string does not support splitters of length>1
/declare tmp string local
/varset tmp ${inputstring}
/declare i2 int local
:FindCount
/if ( ${tmp.Find["${splitter}"]} ) {
/varset i ${tmp.Find["${splitter}"]}
/varset tmp ${tmp.Left[${Math.Calc[${i}-1]}]}${tmp.Right[${Math.Calc[${tmp.Length}-${i}-${splitter.Length} +1]}]}
/varcalc stringcnt ${stringcnt} + 1
/if ( ${tmp.Find["${splitter}"]} ) /goto :FindCount
}
/varcalc stringcnt ${stringcnt} + 1
/if (!${Defined[${varname}]}) {
/declare ${varname}[${stringcnt}] string outer
} else {
/deletevar ${varname}
/declare ${varname}[${stringcnt}] string outer
}
|Find the parts.
/varset tmp ${inputstring}
/for i 1 to ${stringcnt}
/if ( ${tmp.Find["${splitter}"]} ) {
/varset i2 ${tmp.Find["${splitter}"]}
/varset ${varname}[${i}] ${tmp.Left[${Math.Calc[${i2}-1]}]}
/varset tmp ${tmp.Right[${Math.Calc[${tmp.Length}-${i2}-${splitter.Length} +1]}]}
} else {
/varset ${varname}[${i}] ${tmp}
}
/next i
}
/return