Moderator: MacroQuest Developers

Code: Select all
|**USAGE: /macro CHCHat [channelname] [mynumber] [delayinseconds]
|**#chat defines the channel that you want.**|
|**In this case the chat channel is the channel to**|
|**trigger Event_Chat**|
#chat chat
#include SpellCast.mac
|**This will loop and be watching for any events**|
|**Thus, it will be waiting for a chat channel to become active**|
Sub Main
/varset a(2,0) $p0
/varset a(2,1) $p1
/varset a(2,2) $p2
:loop
/doevents
/delay 0
/goto :loop
/return
|**This is our Chat event sub. it is triggered evrey time**|
|**someone uses a chat channel, any chat channel**|
Sub Event_Chat
/if $p0~~$a(2,0) /if $p2~~$a(2,1) {
/delay $a(2,2)s
/sit off
/call cast "Complete Heal"
/sit on
/return
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
**|
#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 CastStatus v59
#define CastTimer t7
#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
/if n $char(gem,"$p0")==0 /return CAST_UNKNOWNSPELL
:StartCast
/if n $char(gem,"$p0")<0 /call WaitForRefresh "$p0"
/cast "$p0"
/varset CastTimer $int($spell("$p0",casttime)*10+$spell("$p0",recoverytime)*10)
/varset CastStatus CAST_SUCCESS
:WaitCast
/doevents Fizzle
/doevents Interrupt
/doevents Recover
/doevents Standing
/doevents OutOfRange
/doevents OutOfMana
/doevents NoLOS
/doevents Resisted
/if n $CastStatus==CAST_RESTART /goto :StartCast
/if n $CastStatus>=CAST_RESTART /return $CastStatus
/if n $CastTimer>0 /goto :WaitCast
/varset CastTimer 0
/return CAST_SUCCESS
Sub WaitForRefresh
:LoopWaitForRefresh
/delay 0
/if n $char(gem,"$p0")<0 /goto :LoopWaitForRefresh
/return
Sub Event_Fizzle
/varset CastStatus CAST_RESTART
/return
Sub Event_Interrupt
/varset CastStatus CAST_RESTART
/return
Sub Event_Recover
/varset CastStatus CAST_RESTART
/delay 5
/return
Sub Event_Standing
/varset CastStatus CAST_RESTART
/stand
/return
Sub Event_Collapse
/varset CastStatus CAST_RESTART
/return
Sub Event_OutOfMana
/varset CastStatus CAST_OUTOFMANA
/return
Sub Event_OutOfRange
/varset CastStatus CAST_OUTOFRANGE
/return
Sub Event_NoLOS
/varset CastStatus CAST_CANNOTSEE
/return
Sub Event_Stunned
/varset CastStatus CAST_STUNNED
/return
Sub Event_Resisted
/varset CastStatus CAST_RESISTED
/return

Code: Select all
Sub Main
:Loop
/doevents
/goto :Loop
/return
Code: Select all
| USAGE: /macro CHCHat [channelname] [mynumber] [delayinseconds]
| #chat defines the channel that you want.
| In this case the chat channel is the channel to
| trigger Event_Chat
#chat chat
#include SpellCast.mac
| This will loop and be watching for any events
| Thus, it will be waiting for a chat channel to become active
Sub Main
/varset a(2,0) $p0
/varset a(2,1) $p1
/varset a(2,2) $p2
:loop
/doevents
/delay 0
/goto :loop
/return
| This is our Chat event sub. it is triggered evrey time
| someone uses a chat channel, any chat channel
Sub Event_Chat
/if $p0~~$a(2,0) /if $p2~~$a(2,1) {
/delay $a(2,2)s
/sit off
/call cast "Complete Heal"
/sit on
/return

Code: Select all
/if $p0~~$a(2,0) /if $p2~~$a(2,1) {
/delay $a(2,2)s
/sit off
/call cast "Complete Heal"
/sit on
}Doh, see what happens when I write code off my head? good catch ap..ap50 wrote:You were missing the }Code: Select all
/if $p0~~$a(2,0) /if $p2~~$a(2,1) { /delay $a(2,2)s /sit off /call cast "Complete Heal" /sit on }

Code: Select all
#chat chat
Sub Main
/varset a(2,0) $p0
/varset a(2,1) $p1
/varset a(2,2) $p2
:loop
/doevents
/goto :loop
/return
Sub Event_Chat
/if $p0~~$a(2,0) /if "$p2"~~"$a(2,1)" {
/delay $a(2,2)s
/press 1
}
/return Code: Select all
/if $p0~~$a(2,0) /if "$p2"~~"$a(2,1)" { Code: Select all
#chat chat
Sub Main
/if "$p0"=="" {
/echo Syntax: /macro ch <"channel-to-look-in"> <"string-to-look-for"> <delay-in-tenth-of-a-second>
/echo Example: /macro ch "chhain" "888 CH on" 15
/echo Will trigger on ex: Cleric_001 tells chhain: 888 CH on MainTank_004 CH 888
/endmacro
}
/varset a(2,0) "$p0"
/varset a(2,1) "$p1"
/varset a(2,2) $p2
:loop
/doevents
/goto :loop
/return
Sub Event_Chat
/if "$p0"~~"$a(2,0)" /if "$p2"~~"$a(2,1)" {
/delay $int($a(2,2))
/press 1
}
/return