syntax: /macro cast <target> <spell 1,skill type> <spell 2,skill type> <spell 3,skill type> <spell 4,skill type> <spell 5,skill type>
example: /macro cast myself "spirit of wolf,alt" "courage,abj"
You must memorize the spells you want to use yourself, this will not do it for you, this is so it can be used in the new UI.
You can get help on how to use it by calling the macro without any parameters... "/macro cast"
Features:
-Casts what ever spells you tell it to until your skill for that casting type is maxxed out for your level cap.
-Very robust casting system, will cast through interrupts, fizzles and any error that can really occur, it lets you know if anything drastic goes wrong, it'll end the macro and tell you why...
-Casts until your OOM and then meditates and starts all over again
-Automatically calculates the required delay for casts and recasts
-Supports upto 9 different spells (although only 5 required due to only 5 skill types)
-GM detection
-unimplemented player detection, it's all coded in and ready to work but there is a problem with the way it works, I didn't want to keep using /target to see if a PC was in range, so I used a PC alert but it picks up yourself, and I can't find anyway to make the alerts ignore yourself, it checks to see if any PC with a vowel in their name is within a range, so there is a chance that it might miss people, but I couldn't find anyone without a vowel in their name, so it should be pretty reliable.
http://macroquest2.com/phpBB2/viewtopic.php?t=1583
Code: Select all
#event castmcr_err_oom "Insufficient Mana to cast this spell!"
#event castmcr_err_range "Your target is out of range, get closer!"
#event castmcr_err_fizzle "Your spell fizzles!"
#event castmcr_err_interrupt "Your spell is interrupted."
#event castmcr_err_recovered "You haven't recovered yet..."
#event castmcr_err_standing "You must be standing to cast a spell."
#event castmcr_err_target "You must first select a target for this spell!"
#event castmcr_err_cannotsee "You cannot see your target."
#event castmcr_err_recovery "Spell recovery time not yet met."
#event castmcr_err_memorized "You do not seem to have that spell memorized."
#define spellmaxskill_ 235
#define alertlistno_ 9
#define alertpcradius_ 250
Sub Main
/declare castmcr_parametercur global
/declare castmcr_spellidno global
/declare castmcr_spellname global
/declare castmcr_spelltype global
/declare castmcr_spellcycle global
/declare castmcr_spellmaxskill global
/declare castmcr_spellskillabj global
/declare castmcr_spellskillalt global
/declare castmcr_spellskillcon global
/declare castmcr_spellskillevo global
/declare castmcr_spellskilldiv global
/declare castmcr_spellnull global
/declare castmcr_parameter0 global
/declare castmcr_parameter1 global
/declare castmcr_parameter2 global
/declare castmcr_parameter3 global
/declare castmcr_parameter4 global
/declare castmcr_parameter5 global
/declare castmcr_parameter6 global
/declare castmcr_parameter7 global
/declare castmcr_parameter8 global
/declare castmcr_parameter9 global
/declare castmcr_castingchecktimer timer
/if "@Param0"!~"Param0" /varset castmcr_parameter0 "@Param0"
/if "@Param1"!~"Param1" /varset castmcr_parameter1 "@Param1"
/if "@Param2"!~"Param2" /varset castmcr_parameter2 "@Param2"
/if "@Param3"!~"Param3" /varset castmcr_parameter3 "@Param3"
/if "@Param4"!~"Param4" /varset castmcr_parameter4 "@Param4"
/if "@Param5"!~"Param5" /varset castmcr_parameter5 "@Param5"
/if "@Param6"!~"Param6" /varset castmcr_parameter6 "@Param6"
/if "@Param7"!~"Param7" /varset castmcr_parameter7 "@Param7"
/if "@Param8"!~"Param8" /varset castmcr_parameter8 "@Param8"
/if "@Param9"!~"Param9" /varset castmcr_parameter9 "@Param9"
/call castmcr_casting
/alert clear alertlistno_
/return
Sub castmcr_casting
/if n $strlen("@castmcr_parameter1")==0 {
/call castmcr_instructions
/return
}
/varset castmcr_parametercur 0
/alert clear alertlistno_
/alert add alertlistno_ pc radius alertpcradius_ a
/alert add alertlistno_ pc radius alertpcradius_ e
/alert add alertlistno_ pc radius alertpcradius_ i
/alert add alertlistno_ pc radius alertpcradius_ o
/alert add alertlistno_ pc radius alertpcradius_ u
/if "@castmcr_parameter0"==#current /goto :castmcr_loop
/target "@castmcr_parameter0"
:castmcr_loop
/if $target()==FALSE {
/echo 'Cast Macro' No valid target, ending macro
/call castmcr_endmacro
}
/call castmcr_spellset
/call castmcr_spellskills
/call castmcr_spellmemorized
/if n $return==1 /goto :castmcr_loop
/if n @castmcr_spellnull==1 {
/echo 'Cast Macro' Macro Ended - Skills:
/echo 'Cast Macro' Alteration ($char(skill,alteration)/@castmcr_spellmaxskill)
/echo 'Cast Macro' Abjuration ($char(skill,abjuration)/@castmcr_spellmaxskill)
/echo 'Cast Macro' Conjuration ($char(skill,conjuration)/@castmcr_spellmaxskill)
/echo 'Cast Macro' Divination ($char(skill,divination)/@castmcr_spellmaxskill)
/echo 'Cast Macro' Evocation ($char(skill,evocation)/@castmcr_spellmaxskill)
/return
}
/call castmcr_spellcast
/goto :castmcr_loop
/return
Sub castmcr_spellset
/varadd castmcr_parametercur 1
/if n $int(@castmcr_parametercur)==1 /call castmcr_spellidset "@castmcr_parameter1"
/if n $int(@castmcr_parametercur)==2 /call castmcr_spellidset "@castmcr_parameter2"
/if n $int(@castmcr_parametercur)==3 /call castmcr_spellidset "@castmcr_parameter3"
/if n $int(@castmcr_parametercur)==4 /call castmcr_spellidset "@castmcr_parameter4"
/if n $int(@castmcr_parametercur)==5 /call castmcr_spellidset "@castmcr_parameter5"
/if n $int(@castmcr_parametercur)==6 /call castmcr_spellidset "@castmcr_parameter6"
/if n $int(@castmcr_parametercur)==7 /call castmcr_spellidset "@castmcr_parameter7"
/if n $int(@castmcr_parametercur)==8 /call castmcr_spellidset "@castmcr_parameter8"
/if n $int(@castmcr_parametercur)==9 /call castmcr_spellidset "@castmcr_parameter9"
/if n $int(@castmcr_parametercur)>=10 /varset castmcr_spellnull 1
/varset castmcr_spellname "$left($calc($strlen("@castmcr_spellidno")-4),"@castmcr_spellidno")"
/varset castmcr_spelltype $right(3,"@castmcr_spellidno")
/varset castmcr_spellcycle $calc($calc($calc($spell("@castmcr_spellname",casttime)+$if(n,$spell("@castmcr_spellname",recasttime)<$spell("@castmcr_spellname",recoverytime),$spell("@castmcr_spellname",recoverytime),$spell("@castmcr_spellname",recasttime)))*10)+5)
/if n $int($calc($char(level)*5+5))<=spellmaxskill_ /varset castmcr_spellmaxskill $int($calc($char(level)*5+5))
/if n $int($calc($char(level)*5+5))>=spellmaxskill_ /varset castmcr_spellmaxskill spellmaxskill_
/call castmcr_spelltype
/return
Sub castmcr_spellcast
/stand
/echo 'Cast Macro' Casting: "@castmcr_spellname" to raise "@castmcr_spelltype" from skill level "$char(skill,"@castmcr_spelltype")" to "@castmcr_spellmaxskill" (level cap)
:castmcr_spellcastloop
/if n $char(skill,@castmcr_spelltype)>=@castmcr_spellmaxskill {
/echo 'Cast Macro' "@castmcr_spelltype" cap reached.
/return
}
| /if $alert(alertlistno_)==TRUE {
| /echo 'Cast Macro' Player detected nearby, pausing for 5 seconds and trying again.
| /delay 50
| /goto :castmcr_spellcastloop
| }
/if $gm==TRUE {
/echo 'Cast Macro' A GM or Guide has been detected in the zone, the macro will be paused and the screen filled with '/who all' information, the macro will resume when the zone is clear of GM/Guides
/who all
/goto :castmcr_spellcastloop
}
/call castmcr_castingcheck
/goto :castmcr_spellcastloop
/return
Sub castmcr_spellskills
/varset castmcr_spellskillabj $char(skill,abjuration)
/varset castmcr_spellskillalt $char(skill,alteration)
/varset castmcr_spellskillcon $char(skill,conjuration)
/varset castmcr_spellskillevo $char(skill,evocation)
/varset castmcr_spellskilldiv $char(skill,divination)
/return
Sub castmcr_instructions
/echo 'Cast Macro' Usage: /macro cast <target> <spell one,skill type> <spell two,skill type> <spell three,skill type> <spell four,skill type> <spell five,skill type>
/echo 'Cast Macro' Usage: skill types: Abjuration (abj); Alteration (alt); Conjuration (con); Divination (div); Evocation (evo)
/echo 'Cast Macro' Usage: example: /macro cast "player's corpse" "spirit of wolf,alt" "blessing of aegolism,abj" "invisibility versus undead,div" "summon drink,con" "burst of flame,evo"
/echo 'Cast Macro' Usage: The best target's for casting skill ups are player corpses with plenty of time left on their expiration timer, alternatively use 'myself' to target yourself.
/echo 'Cast Macro' Usage: You can have the macro use your current target by entering "#current" for your target, e.g. /macro cast #current "spirit of wolf,alt"
/echo 'Cast Macro' Usage: You must have your spells memorized prior to running this macro, it will not memorize them for you, this macro works in the new UI because of this.
/return
Sub Event_castmcr_err_oom
/if n $char(mana,pct)==100 {
/echo 'Cast Macro' Your mana pool is too small to cast "@castmcr_spellname", ending macro
/call castmcr_endmacro
}
/stand
/sit
:castmcr_medloop
/if n $char(mana,pct)==100 {
/stand
/return
}
/delay 10
/goto :castmcr_medloop
/return
Sub Event_castmcr_err_range
/echo 'Cast Macro' no target in range, ending macro.
/call castmcr_endmacro
/return
Sub Event_castmcr_err_fizzle
/return 1
Sub Event_castmcr_err_interrupt
/return 1
Sub Event_castmcr_err_recovered
/return 1
Sub Event_castmcr_err_target
/target @castmcr_parameter0
/return 1
Sub Event_castmcr_err_standing
/stand
/return 1
Sub Event_castmcr_err_powerful
/echo 'Cast Macro' Your target is too low level, please select a new target, preferably level 42+, ending macro.
/call castmcr_endmacro
/return 1
Sub Event_castmcr_err_cannotsee
/echo 'Cast Macro' You are unable to see your target, please select a new target, ending macro.
/call castmcr_endmacro
/return 1
Sub Event_castmcr_err_memorized
/echo 'Cast Macro' "@castmcr_spellname" has become unavailable, please check your spell list and restart the macro, ending macro.
/call castmcr_endmacro
/return 1
Sub Event_castmcr_err_recovery
/return 1
Sub castmcr_resetreturn
/return 0
Sub castmcr_spelltype
/if "@castmcr_spelltype"=="alt" {
/varset castmcr_spelltype Alteration
/return
}
/if "@castmcr_spelltype"=="abj" {
/varset castmcr_spelltype Abjuration
/return
}
/if "@castmcr_spelltype"=="con" {
/varset castmcr_spelltype Conjuration
/return
}
/if "@castmcr_spelltype"=="div" {
/varset castmcr_spelltype Divination
/return
}
/if "@castmcr_spelltype"=="evo" {
/varset castmcr_spelltype Evocation
/return
}
/echo 'Cast Macro' invalid skill type entered, please check the macro parameters, type "/macro cast" for help, ending macro.
/call castmcr_endmacro
/return 1
Sub castmcr_spellidset
/if "@Param0"~~UNDEFINED {
/varset castmcr_spellnull 1
/return
}
/varset castmcr_spellidno "@Param0"
/return
Sub castmcr_castingcheck
:castmcr_castingloop
/varset castmcr_castingchecktimer @castmcr_spellcycle
/call castmcr_resetreturn
/cast "@castmcr_spellname"
:castmcr_castingcheckloop
/doevents
/if n $return>=1 /goto :castmcr_castingloop
/if @castmcr_castingchecktimer!=0 /goto :castmcr_castingcheckloop
/return
Sub castmcr_spellmemorized
/call castmcr_resetreturn
/if n @castmcr_spellnull==1 /return
/if n $char(gem,"@castmcr_spellname")==0 {
/echo 'Cast Macro' Spell "@castmcr_spellname" not memorized, please check the macro parameters, type "/macro cast" for help, moving to next in list.
/return 1
}
/return
Sub castmcr_endmacro
/alert clear alertlistno_
/stand
/sit
/endmacro
/return