Universal Robot[unibot.mac] Project Update [BETA]

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

Moderator: MacroQuest Developers

Gonezo
orc pawn
orc pawn
Posts: 10
Joined: Wed Nov 13, 2002 1:38 am

Universal Robot[unibot.mac] Project Update [BETA]

Post by Gonezo » Fri Nov 15, 2002 3:09 pm

Well since I scraped the last one, I started out a different way and asked differen questions. Also, I am not using any other bot macro for inspiration besides the one given to me by m0nk. It has been helpful and very useful so I thank you for that.
Here is the code for unibot.mac
|** Filename: UNIBOT.mac v.BETA[11-15-2002]
** Author: Gonezo
** Assists:m0nk for inspritation from his bitchbot code! Plazmaic for explaing so many things
** to me! Ooak for listening!
** State: BETA
** WHAT: This is the begining of my Universal Robot macro. I hope I finish it one day /sigh
** =0/
** USEAGE: /macro UNIBOT.mac "master name"
**|
|**Definitions**|
#include spellcast.mac
#include spellmem.mac
#define MASTER v99
#chat tell
Sub Main
/mqlog ======UniBot Activated======
/varset MASTER "$p0"
|**opening commands**|
/press CTRL
/press shift
/press alt

|**Verifies to the user that they are MASTER**|
/tell $MASTER You are THE Master bro!!!

|**Bot Sits!**|
/sit

|**This goes to the Events and starts to do them**|
:Loop
/if n $spawn($id("$MASTER"),hp,pct)<30 /call HEALNOW
/if n $spawn($spawn($id("$MASTER"),pet),hp,pct)<30 /call HEALNOW
/doevents
/goto :Loop
/return

Sub GATENOW

|~~~~~I DO NOT THINK THIS IS THE BEST WAY TO DO THIS BUT IT GETS THE JOB DONE~~~~~
/if "$char(gem,1)"=="Gate" /goto :spellismemed
/if "$char(gem,2)"=="Gate" /goto :spellismemed
/if "$char(gem,3)"=="Gate" /goto :spellismemed
/if "$char(gem,4)"=="Gate" /goto :spellismemed
/if "$char(gem,5)"=="Gate" /goto :spellismemed
/if "$char(gem,6)"=="Gate" /goto :spellismemed
/if "$char(gem,7)"=="Gate" /goto :spellismemed
/if "$char(gem,8)"=="Gate" /goto :spellismemed
|~~~~~the above code is horrid but it is the only way I could think of doing it on my own.
|~~~~~Sorry I am a newbie

/call loadspell "1" "gate"
:spellismemed
/call cast "gate"
/return

Sub HEALNOW
|~~~~For right now this is hard coded to the best heal spell my has hehe
|~~~~Change this as you need
/if "$char(gem,1)"=="Superior Healing" /goto :spellismemed
/if "$char(gem,2)"=="Superior Healing" /goto :spellismemed
/if "$char(gem,3)"=="Superior Healing" /goto :spellismemed
/if "$char(gem,4)"=="Superior Healing" /goto :spellismemed
/if "$char(gem,5)"=="Superior Healing" /goto :spellismemed
/if "$char(gem,6)"=="Superior Healing" /goto :spellismemed
/if "$char(gem,7)"=="Superior Healing" /goto :spellismemed
/if "$char(gem,8)"=="Superior Healing" /goto :spellismemed

/call loadspell "1" "Superior Healing"
:spellismemed
/call cast "Superior Healing"


|~~~~~~~~~~~~~~~~~|
| COMMANDS |
|~~~~~~~~~~~~~~~~~|
Sub Event_Chat
/if "$p1"!="$MASTER" /return |Checks to see if from master then do other /if's which
|hold the bot's commands
/if "$p2"~~"sit" /sit |commands bot to sit
/if "$p2"=="gate" /call GATENOW |commands bot to gate

/return


and spellmem.mac[the error occured here]
|** Filename: spellmem.mac v.BETA[11-14-2002]
** Author: Gonezo
** Assists:Phantal hehe he wrote this
** State: BETA
** WHAT: This forgets and mems spells for you
** USEAGE: /call loadspell "gem#" "spellname" can list 5 spells
** NOTE: When you use this you need to use the exact name of the spell in

the book
**|

Sub Main

Sub loadspell
/if "$p0"=="" /return
/if "$p1"=="" /return
/book
/call Memorize $p0 $p1
/if "$p2"!="" {
/call WaitSpellLoad $p0
/call Memorize $p2 $p3
} else /return
/if "$p4"!="" {
/call WaitSpellLoad $p2
/call memorize $p4 $p5
} else /return
/if "$p6"!="" {
/call WaitSpellLoad $p4
/call Memorize $p6 $p7
} else /return
/if "$p6"!="" {
/call WaitSpellLoad $p6
/call Memorize $p8 $p9
} else /return
/return

Sub Memorize
/if "$p0"=="" /return
/if "$p1"=="" /return
/click right 104 $int($p0*38-11)
/memspell $p0 "$p1"
/return

Sub WaitSpellLoad
:KeepWaiting
/if "$char(gem,$p0)"=="NULL" {
/delay 2
/goto :KeepWaiting
}
/if "$char(gem,$p0)"=="" {
/delay 2
/goto :KeepWaiting
}
/return

On the test of the unibot.mac with this execution line
"/macro unibot.mac "<classified charactername>"

this error was given to me
"Couldn't parse 'Sub loadspell'
Any ideas or help would be great I will be pondering about this.

-Gonezo
Last edited by Gonezo on Fri Nov 15, 2002 7:07 pm, edited 1 time in total.

aGuy
orc pawn
orc pawn
Posts: 18
Joined: Tue Nov 05, 2002 3:22 pm

Post by aGuy » Fri Nov 15, 2002 3:20 pm

I removed spme /returns

Code: Select all

Sub loadspell 
/if "$p0"=="" /return 
/if "$p1"=="" /return 
/book 
/call Memorize $p0 $p1 
/if "$p2"!="" { 
/call WaitSpellLoad $p0 
/call Memorize $p2 $p3 
} else
/if "$p4"!="" { 
/call WaitSpellLoad $p2 
/call memorize $p4 $p5 
} else
/if "$p6"!="" { 
/call WaitSpellLoad $p4 
/call Memorize $p6 $p7 
} else
/if "$p6"!="" { 
/call WaitSpellLoad $p6 
/call Memorize $p8 $p9 
} else
/return 

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

Post by Fippy » Fri Nov 15, 2002 3:52 pm

Gonezo

To safe my knackered old eyes could ya use code tags instead of quote for you code. I find the orange colour easier to read.

Code: Select all

|~~~~~I DO NOT THINK THIS IS THE BEST WAY TO DO THIS BUT IT GETS THE JOB DONE~~~~~ 
/if "$char(gem,1)"=="Gate" /goto :spellismemed 
/if "$char(gem,2)"=="Gate" /goto :spellismemed 
/if "$char(gem,3)"=="Gate" /goto :spellismemed 
/if "$char(gem,4)"=="Gate" /goto :spellismemed 
/if "$char(gem,5)"=="Gate" /goto :spellismemed 
/if "$char(gem,6)"=="Gate" /goto :spellismemed 
/if "$char(gem,7)"=="Gate" /goto :spellismemed 
/if "$char(gem,"=="Gate" /goto :spellismemed 
|~~~~~the above code is horrid but it is the only way I could think of doing it on my own. 
|~~~~~Sorry I am a newbie 
This could be consideribly shorter by doing

Code: Select all


/if n $char(gem,"Gate")<1  /call loadspell "1" "gate"
/call cast "gate"

$char(gem,"Gate") will return the gem that "gate" is currently memmed in. If its not memed then it will return 0. 0 is less than 1 so call loadspell to mem it. Then cast away.
Fippy

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

Gonezo
orc pawn
orc pawn
Posts: 10
Joined: Wed Nov 13, 2002 1:38 am

Universal Robot[unibot] Project Update [Parse Error...Again]

Post by Gonezo » Fri Nov 15, 2002 4:06 pm

:( :( :( :( :( :( :( :( :( :( :( :( :(

Okay after seeing that the code phantal gave me was not going to be easily fixed, I checked my macro folder. Low and behold I find a macro named spellbook.mac that does everything I want to do with spellmem.mac. So, with finding that spellmem.mac has been severed from the project[do not know if permant or not].

Now that the parse error for loadspell has been resolved here is my new problem. Now, I am getting a Couldn't Parse Sub Event_Chat. However, here is the wierd thing. I know it is executing. Cuz I am able to send the /tell to the master saying you are the master. Also, I sit down. That gets the bot to the loop. I examined the spellbook.mac file and put in what I thought would be correct "/call"s. Anyway, on with the code using the proper format.

UNIBOT.MAC[this is where the error occurs]

Code: Select all

|** Filename: UNIBOT.mac v.BETA[11-14-2002]
Author: Gonezo
Assists:m0nk for inspritation from his bitchbot code! Plazmaic for explaing so many things 
to me! Ooak for listening!
State: ALPHA
WHAT: This is the begining of my Universal Robot macro.  I hope I finish it one day /sigh =0/
USEAGE: /macro UNIBOT.mac "master name"
**|

 |**Definitions**|
    #include spellcast.mac
    #include spellbook.mac
    #define MASTER v99
    #chat tell
Sub Main
	/mqlog ======UniBot Activated======
	/varset MASTER "$p0"
 |**opening commands**|
	/press CTRL 
	/press shift 
	/press alt
	 
 |**Verifies to the user that they are MASTER**|
	/tell $MASTER You are THE Master bro!!!

 |**Bot Sits!**|
	/sit

 |**This goes to the Events and starts to do them**|
	:Loop
		/if n $spawn($id("$MASTER"),hp,pct)<30 /call HEALNOW
		/if n $spawn($spawn($id("$MASTER"),pet),hp,pct)<30 /call HEALNOW
     	  /doevents
   	/goto :Loop
 /return

Sub GATENOW
  	/if n $char(gem,"Gate")<1 	
	/call MemorizeSpell "1" "gate"
	:spellismemed
	/call cast "gate"
 /return

Sub HEALNOW
	/if n $char(gem,"Gate")<1
	/call MemorizeSpell "1" "Superior Healing"
	:spellismemed
	/call cast "Superior Healing"
/return
|~~~~~~~~~~~~~~~~~|
|  COMMANDS       |
|~~~~~~~~~~~~~~~~~|
Sub Event_Chat
	/if "$p1"!="$MASTER" /return  |Checks to see if from master then do other /if's which 
				      |hold the bot's commands
	/if "$p2"~~"sit" 	/sit  |commands bot to sit 
	/if "$p2"=="gate"	/call GATENOW |commands bot to gate

 /return
Here is spellbook.mac so you do nto have to go hunting for it.

Code: Select all

|** - spellbook.mac - 
** 
** This macro is an include for other macros.  It deals with memorizing 
** and forgetting spells. 
**| 

| 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 "$char(gem,"$p0")"!="NULL" /return 
   | Make sure we have the spell! 
   /if "$char(book,"$p0")"=="NULL" /return 

   /varset l0 $mouse(x) 
   /varset l1 $mouse(y) 

   | 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 

   /mouseto $l0 $l1 
/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
Working Dilgently to solve this myself. However, your help is appreciated and noted.
thanks
-Gonezo
#macroquest channel on irc.krisp.com [USE IT]

EDIT**Thanks Fippy for that section of code I knew there was a better way to do it :)

Gonezo
orc pawn
orc pawn
Posts: 10
Joined: Wed Nov 13, 2002 1:38 am

I need some help again.

Post by Gonezo » Fri Nov 15, 2002 7:13 pm

Okay with all the wonderful help from all the guy in the chat channel I was able to get the bot to Gate on command, however after learning about a abug involved with that I commented the sections that delt with that command out, and to sit. Now, for some dern reason the bot will not calling the healnow routine. I checked the logic on the statement and it is valid code. here are the lines in question

Code: Select all

      /if n $spawn($id("$MASTER"),hp,pct)<=30 /target $v99 /call HEALNOW
       /if n $spawn($spawn($id("$MASTER"),pet),hp,pct)<30 /call HEALNOW 
this is the sub rountine

Code: Select all

Sub HEALNOW
	/if n $char(gem,"Superior Healing")<1 /call MemorizeSpell "superior healing" 1
	/call cast "superior healing"
 /return
I have not summoned a pet yet but I think what will happen is that the bot will just switch targets. Any help will be much appreciated.
thanks a lot you guys with this.
-Gonezo