Spell casting help for a newb

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

bzt
a lesser mummy
a lesser mummy
Posts: 77
Joined: Fri Oct 10, 2003 3:39 pm

Spell casting help for a newb

Post by bzt » Fri Oct 10, 2003 3:49 pm

Ok, so I put

Code: Select all

|Plazmic + 1 line change by Imperfect 

|** SpellCast.mac 
** This will cast a spell reliably for you... 
** Usage: 
** /call Cast "spellname" 
** It will return the following values: 
** CAST_SUCCESS 
** CAST_UNKNOWNSPELL 
** CAST_OUTOFMANA 
** CAST_OUTOFRANGE 
** CAST_CANNOTSEE 
** CAST_STUNNED 
** CAST_RESISTED 
** 
** New Vars Modification 
** Plazmic's no globals needed version 
**| 

|Oct 9, 2003 - Updated to work with new vars and $casting() - gf 


#event Fizzle "Your spell fizzles!" 
#event Interrupt "Your casting has been interrupted!" 
#event Interrupt "Your spell is interrupted." 
#event Recover "You haven't recovered yet..." 
#event Recover "Spell recovery time not yet met." 
#event Resisted "You target resisted the " 
#event OutOfMana "Insufficient Mana to cast this spell!" 
#event OutOfRange "Your target is out of range, get closer!" 
#event NoLOS "You cannot see your target." 
#event Stunned "You cannot cast while stunned" 
#event Standing "You must be standing to cast a spell" 
#event Collapse "Your gate is too unstable, and collapses." 


#define CAST_SUCCESS 0 
#define CAST_UNKNOWNSPELL 1 
#define CAST_RESTART 2 
#define CAST_OUTOFMANA 3 
#define CAST_OUTOFRANGE 4 
#define CAST_CANNOTSEE 5 
#define CAST_STUNNED 6 
#define CAST_RESISTED 7 

Sub Cast(SpellName) 
  /if n $char(gem,"@SpellName")==0 /return CAST_UNKNOWNSPELL 
  :StartCast 
  /if n $char(gem,"@SpellName")<0 /call WaitForRefresh "@SpellName" 
  /cast "@SpellName" 

  :WaitCast 
     /call ClearReturnValue 
     /doevents Fizzle 
     /doevents Interrupt 
     /doevents Recover 
     /doevents Standing 
     /doevents OutOfRange 
     /doevents OutOfMana 
     /doevents NoLOS 
     /doevents Resisted 
     /if n $return==CAST_RESTART /goto :StartCast 
     /if n $return>=CAST_RESTART /return $return 

  /if "$char(casting)"=="TRUE" /goto :WaitCast 

/return CAST_SUCCESS 

Sub WaitForRefresh(SpellName) 
   :LoopWaitForRefresh 
      /delay 0 
   /if n $char(gem,"@SpellName")<0 /goto :LoopWaitForRefresh 
/return 

Sub ClearReturnValue 
/return CAST_SUCCESS 

Sub Event_Fizzle 
/return CAST_RESTART 

Sub Event_Interrupt 
/return CAST_RESTART 

Sub Event_Recover 
   /delay 5 
/return CAST_RESTART 

Sub Event_Standing 
   /stand 
/return CAST_RESTART 

Sub Event_Collapse 
/return CAST_RESTART 

Sub Event_OutOfMana 
/return CAST_OUTOFMANA 

Sub Event_OutOfRange 
/return CAST_OUTOFRANGE 

Sub Event_NoLOS 
/return CAST_CANNOTSEE 

Sub Event_Stunned 
/return CAST_STUNNED 

Sub Event_Resisted 
/return CAST_RESISTED
into a file and named it spellcast.mac ( from http://macroquest2.com/phpBB2/viewtopic.php?t=3336)

Then I put

Code: Select all

| skspelltrain.mac - have a pet up and near by. 

#define ARCANEMAX 235 
#define MEDPOINT 30 
#define MEDDELAY 30 
#define ARCANECOUNT 4 
#define NOTMEMMED 0 

#include spellcast.mac 
#chat say 
#chat tell 

#event TargetPet "This spell only works on undead" 
#event TargetPet "You must first select a target for this spell" 
#event TargetPet "Your target is out of range" 
#event TargetPet "You cannot see your target" 

Sub Main 

  /declare MaxArcane global 
  /declare FinishedTraining global 
  /declare TrainingSpell array 
  /declare i local 

| initialize spell array 
  /varset TrainingSpell(0) "Siphon Strength" 
  /varset TrainingSpell(1) "Locate Corpse" 
  /varset TrainingSpell(2) "Disease Cloud" 
  /varset TrainingSpell(3) "Endure Cold" 
  /varset TrainingSpell(4) "Ward Undead" 
  
| determine arcane skill max 
  /varcalc MaxArcane $char(level)*5+5 
  /if n @MaxArcane>ARCANEMAX /varset MaxArcane ARCANEMAX 

| initialize loop vars and start training 
  /varset i 0 
  /varset FinishedTraining TRUE 
  :TrainingLoop 
    /doevents 

| Ye olde med loop 
    /if n $char(mana,pct)<MEDPOINT { 

        /if $char(state)!=SIT /sit 
        :MedLoop 
        /delay MEDDELAY 
        /if n $char(mana,cur)<$char(mana,max) /goto :MedLoop 
    } 

|  If ya don't want to train it, don't mem it. 
    /if n $char(gem,"@TrainingSpell(@i)")==NOTMEMMED /goto :NextSpell 

    /if n $char(skill,"$spell("@TrainingSpell(@i)",skill)")==@MaxArcane /goto :NextSpell 

   /varset FinishedTraining FALSE 
   /call Cast "@TrainingSpell(@i)" 
   :NextSpell 

| Increment/reset spell index - Check if finished training 
    /if n @i<ARCANECOUNT { 
      /varadd i 1 
    } else { 
      /if @FinishedTraining==TRUE /goto :EndMacro 
      /varset i 0 
      /varset FinishedTraining TRUE 

    } 
    /goto :TrainingLoop 

  :EndMacro 
  /endmacro keep keys 
/return 

sub Event_Chat 
  /beep 
  /beep 
  /beep 
  /mqpause 
/return 

sub Event_TargetPet 
  /target id $char(pet) 
  /delay 3 
/return 
Into a file named it spells.mac ( from this post http://macroquest2.com/phpBB2/viewtopic.php?t=3338

I cast the pet..I mem the spells..and I type /macro spells. I get the error message:

Ending macro: Subroutine Cast wasnt found
spells.mac@57 (Main): /Cast"@TrainingSpell@i)@
Cleared the following: Timers Vars Arrays
The current macro has ended


what am I doing wrong, did miss something...Im a total newb and am clueless.

Thanks for any help.

zedisdeadbaby
a ghoul
a ghoul
Posts: 83
Joined: Sun Nov 03, 2002 4:24 pm

Post by zedisdeadbaby » Sat Oct 11, 2003 5:40 am

I just started macroing for the first time in months and I had that problem too.

So I just pasted all of plaz's spellcast macro into my main macro file. It ran ok.

Guest

Post by Guest » Sat Oct 11, 2003 6:43 am

Check your spells.mac file.

Verify that you didn't typo and it's

Code: Select all

/call Cast "@TrainingSpell(@i)"
not

Code: Select all

/Cast "@TrainingSpell(@i)"

bzt
a lesser mummy
a lesser mummy
Posts: 77
Joined: Fri Oct 10, 2003 3:39 pm

Post by bzt » Sat Oct 11, 2003 1:20 pm

It is

Code: Select all

/call Cast "@TrainingSpell(@i)" 
And for zed, what main macro are you speaking of? I have one macro that is spellcast.mac, and one that is skspelltrain.mac. They are 2 seperate macs, but I think the skspelltrain.mac calls on the spellcast.mac.