anyone make this bot work?

Help section from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

phatj
decaying skeleton
decaying skeleton
Posts: 8
Joined: Wed Jan 08, 2003 4:45 am

anyone make this bot work?

Post by phatj » Wed Jan 08, 2003 4:55 am

i copied this bot off the website, it works great in casting heals when group members get low health, but doesnt answer when someone /tell cleric cast heal me.....like its supposed to, anyone point out why it doesnt work, or post a fix pls? should i have to have a full group to make it work maybe?

[code]
| 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) "heal"
/varset a(aSpellName,1) "Superior Healing"

/varset a(aSpellAlias,2) "cheal"
/varset a(aSpellName,2) "Complete Healing"

/varset a(aSpellAlias,3) "stun"
/varset a(aSpellName,3) "Holy Might"

/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]

User avatar
Fippy
a snow griffon
a snow griffon
Posts: 499
Joined: Tue Jul 16, 2002 10:42 am

Post by Fippy » Wed Jan 08, 2003 4:59 am

Read the post explaining what to do, you need to add the players names that it will respond to.
Fippy

This is my girl. But Rizwank had her first :-)
[img]http://www.btinternet.com/~artanor/images/fairy_bounce09.gif[/img]

phatj
decaying skeleton
decaying skeleton
Posts: 8
Joined: Wed Jan 08, 2003 4:45 am

thanks

Post by phatj » Wed Jan 08, 2003 9:44 am

i just misunderstood the original, its working great now, thanks