spellcast.mac - updated

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

Moderator: MacroQuest Developers

GoatFoot
a lesser mummy
a lesser mummy
Posts: 68
Joined: Fri Jan 17, 2003 1:48 am

spellcast.mac - updated

Post by GoatFoot » Thu Oct 09, 2003 3:11 am

Current code I'm using 10/12/2003:

Code: Select all

|Plazmic + 1 line change by Imperfect

|** SpellCast.inc
** 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 $char(casting) - gf
|Oct 11, 2003 - switched some logic, removed defines - 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."

Sub Cast(SpellName)
  /if n $char(gem,"@SpellName")==0 /return CAST_UNKNOWNSPELL
  :StartCast
  /call ClearReturnValue
  /if n $char(gem,"@SpellName")<0 {
	  /delay 0
	  /goto :StartCast
  }
  /cast "@SpellName"

  :WaitCast
     /if "$char(casting)"=="TRUE" {
	    /delay 1
	    /goto :WaitCast
     }
     /doevents Fizzle
     /doevents Interrupt
     /doevents Recover
     /doevents Standing
     /doevents OutOfRange
     /doevents OutOfMana
     /doevents NoLOS
     /doevents Resisted
     /if "$return"=="CAST_RESTART" /goto :StartCast
     /if "$return"!="CAST_SUCCESS" /return "$return"
/return CAST_SUCCESS

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
Last edited by GoatFoot on Sun Oct 12, 2003 7:03 am, edited 2 times in total.

GoatFoot
a lesser mummy
a lesser mummy
Posts: 68
Joined: Fri Jan 17, 2003 1:48 am

Post by GoatFoot » Thu Oct 09, 2003 3:55 am

delete

Code: Select all

 /declare tempReturn local 
and change

Code: Select all

     /if n $return>=CAST_RESTART /return @CastStatus

to

Code: Select all

     /if n $return>CAST_RESTART /return $return
and require no variable declaration?


As soon as we get a new stardard, I'll delete my post and set yours as first post of thread?

Plazmic
The One
The One
Posts: 800
Joined: Fri Jun 14, 2002 12:31 am
Contact:

Post by Plazmic » Thu Oct 09, 2003 3:59 am

That's what I get for making the actual changes in a form edit box...
Both of those were intended... tempReturn was a thought I had, but cleaned it up while editing it.. just missed removing the declare inside this edit box ;(
- Plazmic

Kaitain
a ghoul
a ghoul
Posts: 109
Joined: Fri Oct 10, 2003 1:49 pm

Post by Kaitain » Sat Oct 11, 2003 8:51 pm

<deleted>
Last edited by Kaitain on Thu Apr 15, 2004 5:32 pm, edited 1 time in total.

[40oz]
a hill giant
a hill giant
Posts: 156
Joined: Tue Nov 12, 2002 12:14 pm

Post by [40oz] » Sun Oct 12, 2003 5:37 am

Sorry about my comments using the | ** syntax. I'll fix that.

[40oz]

PS. When I first learned C++, I used the seperate line left bracket too. But I've found, since coding in both IDEs and out of vim through an ssh connection to my server, that I prefer the left brace not on it's own line. It's only bothersome for one or two lines of code, but for larger blocks of code, proper indentation is all the distinguishing I need~

PPS. Just realized I didn't need to change my comment notation. I hadn't tested my updated version yet, so I took your word on it, but upon further inspection, theres a difference between the following:

Code: Select all

|**
versus

Code: Select all

| **
The space makes all the difference in the world.

Kaitain
a ghoul
a ghoul
Posts: 109
Joined: Fri Oct 10, 2003 1:49 pm

Post by Kaitain » Sun Oct 12, 2003 8:53 am

<deleted>
Last edited by Kaitain on Thu Apr 15, 2004 5:31 pm, edited 1 time in total.

Elwood
decaying skeleton
decaying skeleton
Posts: 2
Joined: Thu Apr 17, 2003 11:24 am

Post by Elwood » Sun Oct 12, 2003 10:12 am

How can I modify this so that it will keep whatever is on the cursor? I'd love to be able to use this to enchant platinum bars, but I'm not entirely sure how to proceed.

Any Ideas?

bob_the_builder
a hill giant
a hill giant
Posts: 275
Joined: Tue Jul 22, 2003 1:22 pm

Post by bob_the_builder » Sun Oct 12, 2003 3:45 pm

Which one is the newest code to work?

Guest

Post by Guest » Sun Oct 12, 2003 3:51 pm

top of thread

Plazmic
The One
The One
Posts: 800
Joined: Fri Jun 14, 2002 12:31 am
Contact:

Post by Plazmic » Sun Oct 12, 2003 4:09 pm

Want me to zap the other 6 versions in this thread?
- Plazmic

GoatFoot
a lesser mummy
a lesser mummy
Posts: 68
Joined: Fri Jan 17, 2003 1:48 am

Post by GoatFoot » Sun Oct 12, 2003 4:35 pm

heh, yes. :)
Thanks

EqMule
Developer
Developer
Posts: 2697
Joined: Fri Jan 03, 2003 9:57 pm
Contact:

Post by EqMule » Wed Oct 15, 2003 8:56 am

I added cast item support... here is what i use as of 14 oct 2003 and it works like a charm...

syntax for casting jboots would be /call cast "Journeyman's boots" Item

Code: Select all

#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." 

Sub Cast(SpellName,Item) 
:StartCast
  /if "@Item"=="Item" {
  /call ClearReturnValue
  /cast item "@SpellName"
} else {
  /if n $char(gem,"@SpellName")==0 /return CAST_UNKNOWNSPELL 
  /call ClearReturnValue 
  /if n $char(gem,"@SpellName")<0 { 
     /delay 0 
     /goto :StartCast 
  }
  /cast "@SpellName"
}

  :WaitCast 
     /if "$char(casting)"=="TRUE" { 
       /delay 1 
       /goto :WaitCast 
     } 
     /doevents Fizzle 
     /doevents Interrupt 
     /doevents Recover 
     /doevents Standing 
     /doevents OutOfRange 
     /doevents OutOfMana 
     /doevents NoLOS 
     /doevents Resisted 
     /if "$return"=="CAST_RESTART" /goto :StartCast 
     /if "$return"!="CAST_SUCCESS" /return "$return" 
/return CAST_SUCCESS 

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 
My status o/
If you like MQ2 and would like to contribute, please do. My goal is 25 donations per month.
So far I've received Image donations for this month's patches.

Bitcoin: 1Aq8ackjQ4f7AUvbUL7BE6oPfT8PmNP4Zq
Krono: PM me.
I can always use characters for testing, PM me if you can donate one.

[40oz]
a hill giant
a hill giant
Posts: 156
Joined: Tue Nov 12, 2002 12:14 pm

Post by [40oz] » Wed Oct 15, 2003 1:25 pm

Quick Question:

If you're returning CAST_SUCCESS, etc. in subroutines in the function above, those are not defined to numbers anywhere... Any reason for this? Or should we just switch our code that uses this to check for strings instead?

EqMule
Developer
Developer
Posts: 2697
Joined: Fri Jan 03, 2003 9:57 pm
Contact:

Post by EqMule » Wed Oct 15, 2003 3:33 pm

yeah just look for strings its easier on your eyes as well as others reading your macros.
My status o/
If you like MQ2 and would like to contribute, please do. My goal is 25 donations per month.
So far I've received Image donations for this month's patches.

Bitcoin: 1Aq8ackjQ4f7AUvbUL7BE6oPfT8PmNP4Zq
Krono: PM me.
I can always use characters for testing, PM me if you can donate one.

GoatFoot
a lesser mummy
a lesser mummy
Posts: 68
Joined: Fri Jan 17, 2003 1:48 am

Post by GoatFoot » Wed Oct 15, 2003 11:30 pm

HA! Remembered to log in.

How about:

Code: Select all

|Plazmic + 1 line change by Imperfect

|** SpellCast.inc
** This will cast a spell reliably for you...
** Usage:
** /call Cast "spellname" [item]
** 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 $char(casting) - gf
|Oct 11, 2003 - switched some logic, removed defines - gf
|Oct 15, 2003 - Item support added by EqMule


#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."

Sub Cast(SpellName,Item)
  /if n $char(gem,"@SpellName")==0 /return CAST_UNKNOWNSPELL

  :StartCast
  /call ClearReturnValue
  /if n $char(gem,"@SpellName")<0 {
	  /delay 0
	  /goto :StartCast
  }
  [color=cyan]/if $defined(Item)==TRUE {
    /cast item "@SpellName"
  } else [/color] /cast "@SpellName"

  :WaitCast
     /if "$char(casting)"=="TRUE" {
	    /delay 1
	    /goto :WaitCast
     }
     /doevents Fizzle
     /doevents Interrupt
     /doevents Recover
     /doevents Standing
     /doevents OutOfRange
     /doevents OutOfMana
     /doevents NoLOS
     /doevents Resisted
     /if "$return"=="CAST_RESTART" /goto :StartCast
     /if "$return"!="CAST_SUCCESS" /return "$return"
/return CAST_SUCCESS

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