cast.mac - Spell Trainer (Updated: 12/10/2003)

A forum for you to dump all the macros you create, allowing users to use, modify, and comment on your work.

Moderator: MacroQuest Developers

User avatar
blueninja
a grimling bloodguard
a grimling bloodguard
Posts: 541
Joined: Thu Aug 28, 2003 7:03 am
Location: Göteborg, Sweden

Post by blueninja » Mon Dec 29, 2003 8:52 am

There shouldn't be a / in front of 'else'.

llama
orc pawn
orc pawn
Posts: 20
Joined: Mon Dec 29, 2003 8:13 am

Post by llama » Mon Dec 29, 2003 9:53 am

It made the trick, thanks a lot.

fryfrog
a hill giant
a hill giant
Posts: 271
Joined: Fri Jun 20, 2003 5:37 am

Post by fryfrog » Tue Dec 30, 2003 1:18 am

I am using it, and it works well. But what a huge rat's nest of /goto's :)

TheWarden
a hill giant
a hill giant
Posts: 253
Joined: Sat Dec 27, 2003 3:51 pm
Location: In your bushes...

OK, i think i fixed it...

Post by TheWarden » Tue Dec 30, 2003 6:46 pm

I get no error messages and it no longer spams for casting the spell. If you didn't know already the .mac file needs to be called "cast.mac" :)

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_ 100 

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($calc($spell("@castmcr_spellname",casttime)+$spell("@castmcr_spellname",recasttime))+$if(n,$spell("@castmcr_spellname",recasttime)<$spell("@castmcr_spellname",recoverytime),$spell("@castmcr_spellname",recoverytime),0))*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 
   } 


|check if player near 
      /if $alert(alertlistno_)==TRUE { 
         /sit 
         /echo 'Cast Macro' Player detected nearby 
         /who PC radius alertpcradius_ 
         } else { 
            /goto :no_player 
         } 
:test_player 
      /if $alert(alertlistno_)==TRUE { 
         /beep 
         /delay 50 
         /goto :test_player 
      } 
:no_player 
/stand 

/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 
   /sit 
} else { 
  /goto :no_gm 
} 
:test_gm 
/if $gm==TRUE { 
   /beep 
   /delay 50 
   /goto :test_gm 
} 
:no_gm 
/stand 

/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 
} 

/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 

| any summoned items get destroyed 
/if "$cursor(name)"~~"Summoned" { 
   /destroy 
   /delay 1s 
} 

/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
LOL, would be nice if i could actually make my own ones, im horrible at it, although i haven't tried too much.

[edit] Yuppers, works perfectly. I altered it and make one line /destroy instead of /click left destroy for convenience.

User avatar
Undies
a ghoul
a ghoul
Posts: 94
Joined: Mon Oct 20, 2003 9:12 pm

Post by Undies » Tue Jan 06, 2004 8:59 pm

the player alert used to work but a bug seems to have appeared with the } else { feature.

I fixed it it by replacing the player check with this code

Code: Select all

|check if player near
      /if $alert(alertlistno_)==TRUE { 
         /sit
         /echo 'Cast Macro' Player detected nearby 
         /who PC radius alertpcradius_
         } /else /goto :no_player
         
:test_player
      /if $alert(alertlistno_)==TRUE { 
         /beep
         /delay 50
         /goto :test_player
      }
:no_player
/stand
I also deleted the GM check routine (as being too paranoid).

PS. Personally I think this whole thing needs a major rewrite, using spell gem numbers rather than names etc but it works OK I guess.

Narces
a lesser mummy
a lesser mummy
Posts: 37
Joined: Thu Aug 07, 2003 7:50 am

Post by Narces » Tue Jan 13, 2004 2:41 pm

Using spell gem numbers has the same effect as the /cast command, only it relys on the spells being set on the right spell icons. *shrug* Seems pointless to change it.

Added Summoned Item Destroy~

Code: Select all

#event castmcr_err_cursor "Warning, you have many items waiting on your cursor."

Sub Event_castmcr_err_cursor
   :cursorloop
   /if "$cursor(name)"~~"Summoned:" /destroy
   /if "$cursor(name)"~~"Summoned:" /goto :cursorloop
/return
You can't cast with a bunch of items waiting to be put on the cursor, so this just takes care of the problem whenever it arises.

User avatar
Undies
a ghoul
a ghoul
Posts: 94
Joined: Mon Oct 20, 2003 9:12 pm

Post by Undies » Tue Jan 13, 2004 8:05 pm

It just saves on typing... no biggie.

Also summoned item destroy was already included and should have worked

Code: Select all

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

[color=cyan]| any summoned items get destroyed
/if "$cursor(name)"~~"Summoned" {
   /destroy
   /delay 1s
}[/color]

/return 
although the new suggested deletion code is more universal, rather than just looking for items that include the keyword 'summoned' I suppose... (sounds a bit dangerous if you are holding your fungus tunic!)

Zacaria
orc pawn
orc pawn
Posts: 19
Joined: Wed Dec 03, 2003 5:47 pm

Post by Zacaria » Tue Jan 13, 2004 10:03 pm

not much you can do except build an array with item id's in it :)

easy enough to implement with all mage summoned items..

kirre
orc pawn
orc pawn
Posts: 16
Joined: Wed Dec 17, 2003 1:53 am

Cast.mac w/ Player Detection Fixed.

Post by kirre » Mon Jan 26, 2004 2:57 pm

Ok so noobelite came in askin about the script, and i was using it w/o player detection but thought i would take a stab at it. Here it is fully working with player detection and all. Here ya go.

Chow
Kirre

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_ 100 

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 
   } 


|check if player near 
      /if $alert(alertlistno_)==TRUE { 
         /sit 
         /echo 'Cast Macro' Player detected nearby 
         /who PC radius alertpcradius_ 
         } else { 
            /goto :no_player 
         } 
:test_player 
      /if $alert(alertlistno_)==TRUE { 
         /beep 
         /delay 50 
         /goto :test_player 
      } 
:no_player 
/stand 

/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 
   /sit 
} else { 
  /goto :no_gm 
} 
:test_gm 
/if $gm==TRUE { 
   /beep 
   /delay 50 
   /goto :test_gm 
} 
:no_gm 
/stand 

/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 
} 

/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 

| any summoned items get destroyed 
/if "$cursor(name)"~~"Summoned" { 
   /click left destroy 
|   /delay 1s 
} 

/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 

kirre
orc pawn
orc pawn
Posts: 16
Joined: Wed Dec 17, 2003 1:53 am

Cast.mac w/ Player Detection Fixed.

Post by kirre » Mon Jan 26, 2004 2:58 pm

Ok so noobelite came in askin about the script, and i was using it w/o player detection but thought i would take a stab at it. Here it is fully working with player detection and all. Here ya go.

Chow
Kirre

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_ 100 

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 
   } 


|check if player near 
      /if $alert(alertlistno_)==TRUE { 
         /sit 
         /echo 'Cast Macro' Player detected nearby 
         /who PC radius alertpcradius_ 
         } else { 
            /goto :no_player 
         } 
:test_player 
      /if $alert(alertlistno_)==TRUE { 
         /beep 
         /delay 50 
         /goto :test_player 
      } 
:no_player 
/stand 

/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 
   /sit 
} else { 
  /goto :no_gm 
} 
:test_gm 
/if $gm==TRUE { 
   /beep 
   /delay 50 
   /goto :test_gm 
} 
:no_gm 
/stand 

/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 
} 

/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 

| any summoned items get destroyed 
/if "$cursor(name)"~~"Summoned" { 
   /click left destroy 
|   /delay 1s 
} 

/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 

grampsironlung
decaying skeleton
decaying skeleton
Posts: 1
Joined: Wed Jan 28, 2004 3:25 pm

only casts spell once

Post by grampsironlung » Wed Jan 28, 2004 3:28 pm

hello , I am new to this and am having difficulty getting this macro to work. I type syntax as shown, but it will only cast the spell One time. It doesnt give any errors, just ceases to cast any more spells. Any suggestions?
Thanks in advance.

Sdksnowboy
orc pawn
orc pawn
Posts: 11
Joined: Mon Jan 19, 2004 9:06 pm

Post by Sdksnowboy » Sun Feb 01, 2004 1:55 am

I found that when I run this macro on my 31 Necro It works Perfectly, but when I run it on my 65 BL It does as the previous posted said, Casts once and halts. Im not super good at coding so I wasnt able to find the error just by browsing thru. Just found it odd that it worked for one class/level and not another.

Gumby
a ghoul
a ghoul
Posts: 99
Joined: Sat Jan 24, 2004 5:27 pm

Post by Gumby » Sun Feb 01, 2004 2:09 am

llama wrote: Ending macro: } and { seen on the same line without an else present.
Cast.mac @ 136 (castmcr_spellcast): } /else {
Cast.mac @ 95 (castmcr_casting): /call castmcr_spellcast
Cast.mac @ 51 (main): /call castmcr_casting
Cleared the following: Timers Vars Array
Current macro has ended
-------------------------

I looked through it lots of times, but I cannot find the error...
The '/' in front of the else is an error. I briefly searched through the above file and saw it in at least two palces... / starts a command; else a qualifier not a command in and of itself. Removing the '/' should correct the issue.

G

alphashade
decaying skeleton
decaying skeleton
Posts: 2
Joined: Sun Feb 01, 2004 3:14 pm

Post by alphashade » Sun Feb 01, 2004 3:15 pm

Maybe I'm missing something, but Player alert dont work for me, I copied the above macro text and edited the extra spaces and line breaks....

When someone comes within radius i get these:

-------------------------
[MQ2) "Cast Macro" Player detected neraby

list of player nearby
there are 2 players in.....

Ending macro: } and { seen on the same line without an else present.
Cast.mac @ 136 (castmcr_spellcast): } /else {
Cast.mac @ 95 (castmcr_casting): /call castmcr_spellcast
Cast.mac @ 51 (main): /call castmcr_casting
Cleared the following: Timers Vars Array
Current macro has ended

I have the Same Exact problem? Any ideas how to remedy this?

alphashade
decaying skeleton
decaying skeleton
Posts: 2
Joined: Sun Feb 01, 2004 3:14 pm

Post by alphashade » Sun Feb 01, 2004 3:16 pm

OOPS forgot about the second page I fixed it ;)