Code: Select all
| casterbot.mac
|
#turbo 100
#define QueueEnd v60
#define QueueItem v61
#define CurrentCommandLine v62
#define CurrentCommandSender v63
#define CurrentCommandSenderTarget v64
#define CurrentCommandName v65
#define CurrentCommandArg1 v66
#define CurrentCommandArg2 v67
#define QueuedCommandSender v68
#define QueuedCommandSenderTarget v69
#define QueuedCommandName v70
#define QueuedCommandArg1 v71
#define QueuedCommandArg2 v72
#define StunCount v73
#define ResistCount v74
#define TotalSpells v75
#define CheckAlias v76
#define AliasFound v77
#define TotalUsers v78
#define CheckUsers v79
#define ActualSpell v80
#define ResistMax v81
#define StunMax v82
#define GroupMode v83
#define ActualSpellChat v84
#define GroupMember v85
#define HPWatchFlag v86
| Array references
#define aCommandSender 1
#define aCommandSenderTarget 2
#define aCommandName 3
#define aCommandArg1 4
#define aCommandArg2 5
#define aSpellAlias 6
#define aSpellName 7
#define aUsers 9
#define aWatchHP 10
#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
|#define mqlog echo
| This is the spell slot that will be used to mem a spell if you dont already have it memorized
#define PolySpellSlot 8
| Set up number of retries is stunned or resisted
#include spellcast.mac
#include spellbook.mac
#include routines.mac
#chat tell
sub main
| Authorised Users
/mqlog Started Casterbot
/em glows with mystical intelligence.
| Default recast counters
/varset ResistMax 3
/varset StunMax 3
| Set group mode off
/varset GroupMode 0
/varset a(aUsers,0) "player1"
/varset a(aUsers,1) "player2"
/varset a(aUsers,2) "player3"
/varset a(aUsers,3) "player4"
/varset a(aUsers,4) "player5"
/varset TotalUsers 5
| Spell Aliases
/varset a(aSpellAlias,0) "null" | Leave this one in
/varset a(aSpellName,0) "null"
/varset a(aSpellAlias,1) "center"
/varset a(aSpellName,1) "Center"
/varset a(aSpellAlias,2) "heal"
/varset a(aSpellName,2) "Light Healing"
/varset a(aSpellAlias,3) "nuke"
/varset a(aSpellName,3) "Furor"
/varset TotalSpells 4
| Turn on Group HP Watch by default.
/varset HPWatchFlag 1
/varset QueueEnd 0
:MainLoop
/doevents
|If in HP Watch mode then check the groupd HP's and queue a heal if required.
/if n $HPWatchFlag==1 /call grouphpwatch
| Proces a command from the queue.
/call ProcessCommand
/goto :MainLoop
/return
sub event_chat
/if "$p0"=="tell" /goto :RobotChannel
/goto :ChatEnd
:RobotChannel
/varset CheckUsers 0
/mqlog "$lcase("$p1")"=="$a(aUsers,$CheckUsers)" CheckUsers
:CheckACL
/if "$lcase("$p1")"=="$a(aUsers,$CheckUsers)" {
/mqlog $p1 is Authorised
/goto :UserAuthorised
}
/varadd CheckUsers 1
/delay 1
/if $CheckUsers<$TotalUsers /goto :CheckACL
/beep
/goto :ChatEnd
:UserAuthorised
/mqlog event_chat: "$p1" said "$p2"
| Save of name of command sender
/varset CurrentCommandSender "$p1"
/varset CurrentCommandLine "$p2"
| Save of name of command senders target
/assist $p1
/delay 10
/mqlog targeted $target(name) from $p1 assist
/mqlog its id is $target(id)
/varset CurrentCommandSenderTarget $target(id)
/varset CurrentCommandName "NULL"
/varset CurrentCommandArg1 "NULL"
/varset CurrentCommandArg2 "NULL"
| Split Command
/if $strlen("$arg(1,"$CurrentCommandLine")")>0 /varset CurrentCommandName "$lcase("$arg(1,"$CurrentCommandLine")")"
/if $strlen("$arg(2,"$CurrentCommandLine")")>0 /varset CurrentCommandArg1 "$lcase("$arg(2,"$CurrentCommandLine")")"
/if $strlen("$arg(3,"$CurrentCommandLine")")>0 /varset CurrentCommandArg2 "$lcase("$arg(3,"$CurrentCommandLine")")"
/call EnqueueCommand "$CurrentCommandSender" "$CurrentCommandSenderTarget" "$CurrentCommandName" "$CurrentCommandArg1" "$CurrentCommandArg2"
/mqlog EnqueueCommand "$CurrentCommandSender" "$CurrentCommandSenderTarget" "$CurrentCommandName" "$CurrentCommandArg1" "$CurrentCommandArg2"
/goto :ChatEnd
:ChatEnd
/return
| ParseComand
|
| Accepts p0 - Sender of command
| p1 - Sender of commands target
| p2 - Command
| p3 - arg1
| p4 - arg2
|
sub ParseCommand
/if "$p2"=="cast" /call CastCommand "$p0" "$p1" "$p3" "$p4"
/if "$p2"=="gotoloc" /call GotoLocCommand "$p0" "$p3"
/if "$p2"=="gototarget" /call GotoTargetCommand "$p0" "$p3"
/if "$p2"=="follow" /call FollowCommand "$p0" "$p3"
/if "$p2"=="med" /call MedCommand
/if "$p2"=="user" /call UserCommand "$p0" "$p3" "$p4"
/if "$p2"=="exit" /call Exit "$p0"
/if "$p2"=="groupmode" /call GroupModeCommand "$p0" "$p3"
/if "$p2"=="hpwatch" /call HPWatchCommand "$p0" "$p3"
/if "$p2"=="camp" /call CampCommand "$p0"
/if "$p2"=="mana" /call ManaCommand "$p0"
/return
sub ProcessCommand
/if $QueueEnd>0 /mqlog ProcessCommand: $QueueEnd in queue
/if n $QueueEnd==0 /goto :EmptyQueue
/varset QueuedCommandSender "$a(aCommandSender,0)"
/varset QueuedCommandSenderTarget "$a(aCommandSenderTarget,0)"
/varset QueuedCommandName "$a(aCommandName,0)"
/varset QueuedCommandArg1 "$a(aCommandArg1,0)"
/varset QueuedCommandArg2 "$a(aCommandArg2,0)"
|If it was the last command in the list set to null
/if n $QueueEnd==1 {
/varset a(aCommandSender,0) "NULL"
/varset a(aCommandSenderTarget,0) "NULL"
/varset a(aCommandName,0) "NULL"
/varset a(aCommandArg1,0) "NULL"
/varset a(aCommandArg2,0) "NULL"
/varset QueueEnd 0
/goto :EndQueue
}
:RemoveCommand
/varset QueueItem 0
:RemoveLoop
/mqlog Moved "$a(aCommandName,$calc($QueueItem+1))" "$a(aCommandArg1,$calc($QueueItem+1))" from $calc($QueueItem+1) to $QueueItem
/varset a(aCommandSender,$QueueItem) "$a(aCommandSender,$calc($QueueItem+1))"
/varset a(aCommandSenderTarget,$QueueItem) "$a(aCommandSenderTarget,$calc($QueueItem+1))"
/varset a(aCommandName,$QueueItem) "$a(aCommandName,$calc($QueueItem+1))"
/varset a(aCommandArg1,$QueueItem) "$a(aCommandArg1,$calc($QueueItem+1))"
/varset a(aCommandArg2,$QueueItem) "$a(aCommandArg2,$calc($QueueItem+1))"
/varadd QueueItem 1
/delay 1
/if n $calc($QueueItem+1)<$QueueLength /goto :RemoveLoop
/varsub QueueEnd 1
:EndQueue
/mqlog ProcessCommand: Parsing ParseCommand "$QueuedCommandSender" "$QueuedCommandSenderTarget" "$QueuedCommandName" "$QueuedCommandArg1" "$QueuedCommandArg2"
/call ParseCommand "$QueuedCommandSender" "$QueuedCommandSenderTarget" "$QueuedCommandName" "$QueuedCommandArg1" "$QueuedCommandArg2"
:EmptyQueue
/return
sub EnqueueCommand
/varset a(aCommandSender,$QueueEnd) "$p0"
/varset a(aCommandSenderTarget,$QueueEnd) "$p1"
/varset a(aCommandName,$QueueEnd) "$p2"
/varset a(aCommandArg1,$QueueEnd) "$p3"
/varset a(aCommandArg2,$QueueEnd) "$p4"
/mqlog added command "$p0" "$p1" "$p2" "$p3" "$p4" at index $QueueEnd
/varadd QueueEnd 1
/return
|
| Cast Command
|
sub CastCommand
| $p0 Sender
| $p1 Sender Target
| $p2 Spell
| $p3 Target
| First make sure we have nothing targeted
/press Esc
|Reset or stun and resist counters
/varset StunCount 0
/varset ResistCount 0
| Check if target was sender (me alias) or senders target (target alias) and target it
/mqlog $p3
/if "$p3"=="me" {
/mqlog target "$p0"
/target "$p0"
} else /if "$p3"=="target" {
/mqlog target id "$p1"
/target id "$p1"
} else {
/mqlog target "$p3"
/target "$p3"
}
| If we do not have mob targeted deal with the error
/if "$target()"!="TRUE" /goto :CastNoTarget
| Expand Spell alias
/varset CheckAlias 0
:CheckSpellAlias
| Loop through SpellAlias's array
/if "$lcase("$p2")"=="$a(aSpellAlias,$CheckAlias)" {
/varset ActualSpell "$a(aSpellName,$CheckAlias)"
/varset AliasFound 1
/mqlog "$a(aSpellAlias,$CheckAlias)" used
/goto :CheckSpellAliasEnd
}
/mqlog $CheckAlias<=$TotalSpells
/varadd CheckAlias 1
/delay 1
/if n $CheckAlias<=$TotalSpells /goto :CheckSpellAlias
| Unrecognised Spell Alias so ignore command
/goto :CastUnknownAlias
:CheckSpellAliasEnd
| Start casting
:StartCasting
| Stand up and face the target
/stand
/face
/call Cast "$ActualSpell"
/mqlog Cast: Returned $return
|Deal with any error
/if n $return==CAST_UNKNOWNSPELL /goto :CastUnknownSpell
/if n $return==CAST_OUTOFRANGE /goto :CastOutOfRange
/if n $return==CAST_CANNOTSEE /goto :CastCanNotSee
/if n $return==CAST_STUNNED /goto :CastStunned
/if n $return==CAST_RESISTED /goto :CastResisted
/goto :CastFinished
:CastUnknownSpell
/mqlog Spell Not Known
/call MemorizeSpell "$ActualSpell" PolySpellSlot
/if n $return==BOOK_NOTKNOWN {
/tell $p0 I do not have the spell $ActualSpell in my book
/goto :CastFinished
} else {
/delay 1
/goto :StartCasting
}
:CastOutOfRange
/tell $p0 target out of range whilst casting $ActualSpell
/goto :CastFinished
:CastNoTarget
/tell target no longer valid casting "$ActualSpell"
/goto :CastFinished
:CastCanNotSee
/tell $p0 I cannot see Target to cast $ActualSpell
/goto :CastFinished
:CastUnknownAlias
/tell $p0 Spell Alias $p2 is not valid
/goto :CastFinished
:CastStunned
/varadd StunCount 1
/if n $StunCount<$StunMax /goto :StartCasting
/varset StunCount 0
/goto :CastFinished
:CastResisted
/varadd ResistCount 1
/mqlog Resisted $ResistCount times
/if n $ResistCount<$ResistMax /goto :StartCasting
/varset ResistCount 0
/goto :CastFinished
:CastFinished
|Sit Back Down
/stand
/sit
/return
|
| hp watch routine
|
sub grouphpwatch
| Check Group HP's
/for GroupMember 0 to $calc($group(count)-1)
/doevents
/if n $spawn($group($GroupMember),hp,pct)<61 {
/call EnqueueCommand "$char(name)" "$group($GroupMember)" "cast" "heal" "target"
/call EnqueueCommand "$char(name)" "$group($GroupMember)" "cast" "heal" "target"
/mqlog Added heal for $spawn($group($GroupMember),name)
}
/next GroupMember
/return
|
| GotoLoc Command
|
sub GotoLocCommand
| $p0 sender
| $p1 loc in x,y
/stand
/varset v91 $rand(5)
:GotoLocLoop
/face loc $p1
/call AutoRun 1
/delay 1
/if n $distance($p1)>$calc(10+$v91) /goto :GotoLocLoop
/call AutoRun 0
/tell $p0 made it to loc $p1
/sit
/return
|
| GotoTarget Command
|
sub GotoTargetCommand
| $p0 Sender
| $p1 Target
/stand
/varset v91 $rand(5)
/target $p1
:GotoTargLoop
/face
/call AutoRun 1
/delay 1
/if n $target(distance)>$calc(10+$v91) /goto :GotoTargLoop
/call AutoRun 0
/tell $p0 made it to $p1
/sit
/return
|
| FollowCommand
|
sub FollowCommand
| $p0 target
/return
|
| Med Command
|
sub MedCommand
/mqlog Medding
/stand
/sit
/return
|
| User Command
|
sub UserCommand
| $p0 Sender
| $p1 arg
| $p2 target
/if "$lcase("$p1")"=="add" {
/varset a(aUsers,$TotalUsers) "$p2"
/varadd TotalUsers 1
/mqlog user $p1 added
/tell $p0 added user $p2
}
/if "$lcase("$p1")"=="list" {
/tell $p0 There are $TotalUsers authorised users as follows;
/for l1 0 to $calc($TotalUsers-1)
/delay 10
/tell $p0 username: $a(aUsers,$l1)
/next l1
}
/return
|
| Exit Command
|
sub exit
| $p0 Sender
| exit macro
/tell $p0 OK exiting
/endmacro
/return
|
| GroupMode Command
|
sub GroupModeCommand
| $p0 Sender
| $p1 arg
/if "$lcase("$p1")"=="on" {
/varset GroupMode 1
/tell $p0 Group mode on
}
/if "$lcase("$p1")"=="off" {
/varset GroupMode 0
/tell $p0 Group mode off
}
/return
|
| HPWatch Command
|
sub HPWatchCommand
| $p0 Sender
| $p1 arg
/if "$lcase("$p1")"=="on" {
/varset HPWatchFlag 1
/tell $p0 HP Watch mode on
}
/if "$lcase("$p1")"=="off" {
/varset HPWatchFlag 0
/tell $p0 HP Watch mode off
}
/return
|
| Med Command
|
sub CampCommand
/mqlog Camping
/stand
/sit
/tell $p0 Camping out
/camp desktop
/unload
/return
|
| Mana Command
|
sub ManaCommand
/mqlog Mana is at $char(mana,pct) pct
/tell $p0 Mana is at $char(mana,pct) pct
/return
Code: Select all
|** - spellbook.mac -
**
** This macro is an include for other macros. It deals with memorizing
** and forgetting spells.
**|
#define BOOK_MEMMED 10
#define BOOK_NOTKNOWN 11
| This function forgets a memorized spell by its spell name
sub ForgetSpellByName
/if n $char(gem,"$p0")==0 /goto :EndForgetSpellByName
:WaitRefreshFrogetSpellByName
/delay 0
/if n $char(gem,"$p0")<0 /goto :WaitRefreshFrogetSpellByName
/call ForgetSpellByNumber $char(gem,"$p0")
:EndForgetSpellByName
/return
| This function forgets a memorized spell by gem #
sub ForgetSpellByNumber
/varset l0 $mouse(x)
/varset l1 $mouse(y)
/call MousetoSpellGem $p0
| /delay 2
/click right
:WaitForGemFreeInForgetSpellByNumber
/doevents
/if "$char(gem,$p0)"!="NULL" /goto :WaitForGemFreeInForgetSpellByNumber
/mouseto $l0 $l1
/return
| This function takes two arguments; the name of the spell to memorize and the
| spell gem to put it in
sub MemorizeSpell
| Make sure we don't already have the spell memorized!
/if n $char(gem,"$p0")>0 {
/mqlog already memed
/return BOOK_MEMMED
}
| Make sure we have the spell!
/if n $char(book,"$p0")<1 {
/mqlog dont have spell
/return BOOK_NOTKNOWN
}
| Spell book # is $l9. Spell book page is $l8. Spell slot is $l7.
| Page layout is $l6
/varset l9 $int($char(book,"$p0")-1)
/varset l8 $int($l9\5+1)
/varset l7 $int($l9%5)
/varset l6 $l8
:GetPageLayout
/if n $l6>6 /varsub l6 6
/if n $l6>6 /goto :GetPageLayout
/book $l8
| In case we need to open our spell book...
/delay 3
/if n $l6==1 /call MousetoSpellSlot 1 $int($l8%2) $l7
/if n $l6==2 /call MousetoSpellSlot 2 $int($l8%2) $l7
/if n $l6==3 /call MousetoSpellSlot 3 $int($l8%2) $l7
/if n $l6==4 /call MousetoSpellSlot 3 $int($l8%2) $l7
/if n $l6==5 /call MousetoSpellSlot 3 $int($l8%2) $l7
/if n $l6==6 /call MousetoSpellSlot 4 $int($l8%2) $l7
/delay 1
/click left
/delay 2
/call MousetoSpellGem $p1
/call ForgetSpellByNumber $p1
/click left
| Wait for the spell to finish memorizing
:WaitToFinishMemorizingSpell
/doevents
/if "$char(gem,$p1)"=="NULL" /goto :WaitToFinishMemorizingSpell
/return
| Moves your mouse to the appropriate spellgem
sub MousetoSpellGem
/varcalc l0 $int($p0-1)*38+27
/mouseto 104 $l0
/return
| Moves your mouse to the appropriate spell slot for the given layout
| $p0: layout $p1: even/odd (0/1) $p2: spell slot
sub MousetoSpellSlot
/if n $p0==1 /goto :Layout1InMousetoSpellslot
/if n $p0==2 /goto :Layout2InMousetoSpellslot
/if n $p0==3 /goto :Layout3InMousetoSpellslot
/if n $p0==4 /goto :Layout4InMousetoSpellslot
:Layout1InMousetoSpellslot
/if n $p2==0 /mouseto 202 66
/if n $p2==1 /mouseto 280 60
/if n $p2==2 /mouseto 280 128
/if n $p2==3 /mouseto 202 184
/if n $p2==4 /mouseto 280 195
/goto :CheckRightPageInMousetoSpellslot
:Layout2InMousetoSpellslot
/if n $p2==0 /mouseto 200 59
/if n $p2==1 /mouseto 276 88
/if n $p2==2 /mouseto 200 127
/if n $p2==3 /mouseto 276 161
/if n $p2==4 /mouseto 200 194
/goto :CheckRightPageInMousetoSpellslot
:Layout3InMousetoSpellslot
/if n $p2==0 /mouseto 191 63
/if n $p2==1 /mouseto 284 63
/if n $p2==2 /mouseto 238 136
/if n $p2==3 /mouseto 191 189
/if n $p2==4 /mouseto 284 189
/goto :CheckRightPageInMousetoSpellslot
:Layout4InMousetoSpellslot
/if n $p2==0 /mouseto 242 61
/if n $p2==1 /mouseto 193 124
/if n $p2==2 /mouseto 281 124
/if n $p2==3 /mouseto 202 193
/if n $p2==4 /mouseto 267 193
/goto :CheckRightPageInMousetoSpellslot
:CheckRightPageInMousetoSpellslot
/if n $p1==0 /mouseto + 161 +0
/return


