help with my bastardized version of casterbot.mac

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

Moderator: MacroQuest Developers

gnome001
a ghoul
a ghoul
Posts: 109
Joined: Fri Jan 24, 2003 1:01 am

help with my bastardized version of casterbot.mac

Post by gnome001 » Fri Jan 24, 2003 2:50 pm

ok. this was fippy's casterbot.mac from the depot.. i bastardized it and cut out some stuff and added in some stuff to make my shammy auto cann himself.

my problem is this.. i play a mage. i tell it to cast heal target and it targets me but doesn't assist me to get my pet. (edit. actually after a bit further testing, sometimes it will target my pet (i.e. the controller's target) but sometimes it will just target the controller and sometimes it will target the bot.. (i'm weak on macroing, been playing around with some for a few weeks and have figured out some of the basics, but this script is a bit over my head really atm)

Code: Select all

| casterbot.mac 
| 

#turbo max 

#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 


| Set up number of retries is stunned or resisted 

#include spellcast.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) "-" 
   /varset a(aUsers,1) "-" 
   /varset a(aUsers,2) "-" 
   /varset a(aUsers,3) "-" 
       
   /varset TotalUsers 4 


| Spell Aliases 

   /varset a(aSpellAlias,0) "null"  | Leave this one in 
   /varset a(aSpellName,0) "null" 

   /varset a(aSpellAlias,1) "slow" 
   /varset a(aSpellName,1) "Turgur's Insects" 

   /varset a(aSpellAlias,2) "heal" 
   /varset a(aSpellName,2) "Kragg's Mending" 

   /varset a(aSpellAlias,3) "smheal" 
   /varset a(aSpellName,3) "Chloroblast"
   
   /varset a(aSpellAlias,4) "regen" 
   /varset a(aSpellName,4) "Replenishment"
   
   /varset a(aSpellAlias,5) "focus"
   /varset a(aSpellName,5) "Khura's Focusing"
   
   /varset a(aSpellAlias,6) "fos"
   /varset a(aSpellName,6) "Focus of Spirit"
   
   /varset a(aSpellAlias,7) "sta"
   /varset a(aSpellName,7) "Talisman of the Brute"

   /varset TotalSpells 8 

    
   

   /varset QueueEnd 0 

:MainLoop 
    
   /doevents 
    | Proces a command from the queue.
    /call ProcessCommand
      /if n $char(hp,pct)>30 /if n $char(mana,pct)<90 /call Canidance 
      /if n $char(hp,pct)<30 /call Heal
    
    
    
/goto :MainLoop 

/return 

sub event_chat 

   /if "$p0"=="tell" /goto :RobotChannel 
   /goto :ChatEnd 

:RobotChannel 
    /varset CheckUsers 0 
       :CheckACL    
      /if "$lcase("$p1")"=="$a(aUsers,$CheckUsers)" { 
         /goto :UserAuthorised 
      } 
      /varadd CheckUsers 1 
      /delay 1 
      /if $CheckUsers<$TotalUsers /goto :CheckACL 
    /beep 
    /goto :ChatEnd 
    
:UserAuthorised 

    
   | Save of name of command sender 
   /varset CurrentCommandSender "$p1" 

   /varset CurrentCommandLine "$p2" 
    
   | Save of name of command senders target 
   /assist $p1 
   /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" 
       
   /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"=="user"  /call UserCommand "$p0" "$p3" "$p4" 
   /if "$p2"=="exit" /call Exit "$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 
         /goto :CheckSpellAliasEnd 
      } 
      /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 
      /call Cast "$ActualSpell" 
            
      |Deal with any error 
      /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 
      
                
      :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 
      
    
/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 


Sub Canidance 
   /sit off 
   /cast "Cannibalize IV" 
   /delay 6s 
/return 


Sub Heal
   /sit off
   /press esc
   /press F1
   /cast "Kragg's Mending"
   /delay 13s
/return
(i took out the grp hp watch because it made me lag really bad for some reason.. took out the follow commands and go to loc commands too, but i don't think i took out anything from targeting and assisting stuff... and yeah. i did have my controller's names in while i was testing out the code)