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_RESISTEDThen 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
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.

