petwarrior.mac - Ever dreamed of having an uber pet?

Macro depository for macros written before the user variable changes that broke all of them.

Moderator: MacroQuest Developers

codewarrior
orc pawn
orc pawn
Posts: 10
Joined: Mon Jun 02, 2003 8:31 am

petwarrior.mac - Ever dreamed of having an uber pet?

Post by codewarrior » Tue Jun 03, 2003 6:01 am

Its a little sloppy, but it works like a charm. I took some of my ideas from YKW-28983
and his code in this thread. http://macroquest2.com/phpBB2/viewtopic.php?t=1738

The warrior pet should act just like a magicians pet and accepts all the commands except gaurd atm. You will have to create hotbuttons to trigger the commands (very simple). Im still working on the looting procedure, though it isnt that important. This macro is best used with any priest class with the ability to heal.


Good luck

Code: Select all

|___________________________________________________________________
| petwarrior.mac 
|___________________________________________________________________
| Normal commands
|________________
| Attack
| Example: /tell a_little_warrior_01 Attack the $target(id) 
|
| Sit
| Example: /tell a_little_warrior_01 Sit 
|
| Follow
| Example: /tell a_little_warrior_01 Follow 
|
| Loot
| Example: /tell a_little_warrior_01 Loot the $target(id) 
|
| Taunt
| Example: /tell a_little_warrior_01 Taunt the $target(id)  
|___________________________________________________________________
| Commands for use while attacking
|__________________________________
| Pet Back Off
| Example: /tell a_little_warrior_01 Back 
|
| Stop
| Example: /tell a_little_warrior_01 Stop Attacking the $target(id)
|___________________________________________________________________
|TO DO:
|Set the #define Parameters Owner and BotName
|___________________________________________________________________

|**#include core.mac  I used this cause it was in prior authors code, i really dont think you need it but if its giving errors just uncomment it **|

#chat tell

#turbo 

#Event Loading "LOADING, PLEASE WAIT..." 
#Event Loading "LOADING, PLEASE WAIT..." 
#Event Enrage "has become ENRAGED." 
#Event UnEnrage "is no longer enraged." 

#define owner OwnersName 
#define BotName BotsName
#define Forward w
#define Backward s

|**----------------------------------------------------------------------------**|
|**				Main Subroutine				       **|
|**----------------------------------------------------------------------------**|

Sub Main 

/varset v0 $target(name) 
/varset v1 $target(id) 
/varset v2 0		|Variable used to determine wether or not to return to main loop

:MainLoop 
/if $gm==TRUE /tell owner There is a GM in the Zone
/varset v2 0    
/doevents 
/delay 1 s 
/goto :MainLoop 

/return

|**----------------------------------------------------------------------------**|
|**----------------------------------------------------------------------------**|

Sub Event_Loading 

/sendkey up Forward 
/sendkey up Backward
/attack off 
/varset v0 0 
/varset v1 0
/varset v2 0
/return

|**----------------------------------------------------------------------------**|
|**----------------------------------------------------------------------------**|

Sub Event_Chat 
/if $p1=="owner" { 

| Normal commands


	/if $arg(1,"$p2")==Attack { 
		/sit off 
		/target id $arg(3,"$p2") 
		/reply Attacking $target(name) 
		/call Attack
		/varset v2 1

	}
	/if $arg(1,"$p2")==Sit 	{ 
		/sit on 
		/reply I am now sitting
		/varset v2 1
	} 
	/if $arg(1,"$p2")==Follow { 
		/sit off 
		/target "owner" 
		/reply Now following you $target(name)
		/follow
		/varset v2 1
  	}
	/if $arg(1,"$p2")==Loot { 
		/sit off 
		/target id $arg(3,"$p2") 
		/reply Im going to loot $target(name) 
		/call Loot
		/varset v2 1
	} 
	/if $arg(1,"$p2")==Taunt { 
		/target id $arg(3,"$p2") 
		/reply I am taunting $target(name)
 		/call Taunt
		/varset v2 1
	} 

| Commands for use while attacking

	/if $arg(1,"$p2")==Back { 
		/reply Im comming back to the group "owner"
		/call Back
		/varset v2 1
	} 
	/if $arg(1,"$p2")==Stop { 
		/reply Im not attacking $target(name) anymore.
		/attack off
		/varset v2 1
  	}
} 
/if $p1!="owner" /tell owner BotName has a private tell.
/return

|**----------------------------------------------------------------------------**|
|**		Tell pet to attack 					       **|
|**----------------------------------------------------------------------------**|

Sub Attack

/attack on
/sendkey down s
/sendkey up s
/varset v1 $target(id)

:TrackLoop
/doevents
/delay 0
/face afast 
/if n $target(distance)>14 /sendkey down Forward 
/if n $target(distance)<16 {
	/sendkey up Forward
	/goto :AttackLoop
}
/goto :TrackLoop

:AttackLoop
/if "$target(id)"!="$v1" /goto :EndAttack
/doevents
/if n $v2==1 /return
/if n $v3==1 /return
/delay 0
/face nopredict fast 
/if n $target(distance)>10 /sendkey down Forward 
/if n $target(distance)<11 /sendkey up Forward
/if n $char(ability,taunt)>0 /doability taunt
/if n $char(ability,bash)>0 /doability bash 
/if n $char(ability,disarm)>0 /doability disarm 
/if n $char(ability,kick)>0 /doability kick

/if $char(ability,begging)>0 { 
   /attack off 
   /doability "Begging" 
   /attack on 
 
}
/goto :AttackLoop

:EndAttack

/target owner
/follow

/return

|**----------------------------------------------------------------------------**|
|**		Similar to "pet back off" command			       **|
|**----------------------------------------------------------------------------**|

Sub Back

/attack off
/target "owner"
/follow
/return

|**----------------------------------------------------------------------------**|
|**		Send pet warrior in to loot		         	       **|
|**----------------------------------------------------------------------------**|

Sub Loot

| yet to be implemented

/return

|**----------------------------------------------------------------------------**|
|**		Tell pet warrior to taunt		         	       **|
|**----------------------------------------------------------------------------**|

Sub Taunt

/if n $char(ability,taunt)>0 /doability taunt

/return

|**----------------------------------------------------------------------------**|
|**		Tell pet warrior stop attacking during enrage         	       **|
|**----------------------------------------------------------------------------**|

Sub Event_Enrage 

	/if "$p0"~~"BotName" /return
	/attack off 
	/varset v3 1 

/return 

|**----------------------------------------------------------------------------**|
|**		Tell pet warrior to start attacking after enrage ends  	       **|
|**----------------------------------------------------------------------------**|

Sub Event_UnEnrage 

	/attack on 
	/varset v3 0 

/return
Last edited by codewarrior on Tue Jun 03, 2003 2:41 pm, edited 4 times in total.

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Tue Jun 03, 2003 7:32 am

If y'all are gonna keep using core.mac I guess we need to CVS it into the stock macros eh?
MQ2: Think of it as Evolution in action.

fwiggles
a hill giant
a hill giant
Posts: 161
Joined: Mon Jun 17, 2002 8:29 pm

Post by fwiggles » Tue Jun 03, 2003 10:16 am

i think it would make a very good addition to the CVS =)
[color=red]Latest survey shows that 3 out of 4 people make up 75% of the world's population.[/color]

codewarrior
orc pawn
orc pawn
Posts: 10
Joined: Mon Jun 02, 2003 8:31 am

Post by codewarrior » Tue Jun 03, 2003 2:37 pm

Im not sure what im using in teh core.mac, i just used some code from another post and added alot to it. Im thinking it might be ok to remove that core.mac, i just left it in for good luck =)

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Tue Jun 03, 2003 3:39 pm

Yeah, I used to do the same thing with MacroKit. Eventually I was able to remove enough chunks of that and rewrite it so that I'm developing a stock set of files for #include.

Speaking of which, I once suggested making an Include subdirectory, the same as the Macro subdirectory. Files there would have the extension INC instead of MAC, and #include would point to that directory. That would make organizing files easier.
MQ2: Think of it as Evolution in action.

alcor75
a lesser mummy
a lesser mummy
Posts: 77
Joined: Wed Jan 29, 2003 7:35 am

Post by alcor75 » Tue Jun 03, 2003 4:00 pm

I got stuck in this error for a while, and i was about to get mad when i got the ideat to test the main loop alone, i was receaving an error telling me the Main sub was not in the macro GRRRRRRRR........ then i tested and boom


|**----------------------------------------------------------------------------**|
|** Main Subroutine **|
|**----------------------------------------------------------------------------**|


This was not working for me:

Code: Select all

#chat tell 

#turbo 

#Event Loading "LOADING, PLEASE WAIT..." 
#Event Loading "LOADING, PLEASE WAIT..." 
#Event Enrage "has become ENRAGED." 
#Event UnEnrage "is no longer enraged." 

#define owner OwnersName 
#define BotName BotsName 
#define Forward w 
#define Backward s 

|**----------------------------------------------------------------------------**| 
|**            Main Subroutine                   **| 
|**----------------------------------------------------------------------------**| 

Sub Main 

/varset v0 $target(name) 
/varset v1 $target(id) 
/varset v2 0      |Variable used to determine wether or not to return to main loop 

:MainLoop 
/if $gm==TRUE /tell owner There is a GM in the Zone 
/varset v2 0    
/doevents 
/delay 1 s 
/goto :MainLoop 

/return 
This was working for me:

Code: Select all

#chat tell 

#turbo 

#Event Loading "LOADING, PLEASE WAIT..." 
#Event Loading "LOADING, PLEASE WAIT..." 
#Event Enrage "has become ENRAGED." 
#Event UnEnrage "is no longer enraged." 

#define owner OwnersName 
#define BotName BotsName 
#define Forward w 
#define Backward s 


Sub Main 

/varset v0 $target(name) 
/varset v1 $target(id) 
/varset v2 0      |Variable used to determine wether or not to return to main loop 

:MainLoop 
/if $gm==TRUE /tell owner There is a GM in the Zone 
/varset v2 0    
/doevents 
/delay 1 s 
/goto :MainLoop 

/return 
Alcor75
Last edited by alcor75 on Tue Jun 03, 2003 4:13 pm, edited 1 time in total.

codewarrior
orc pawn
orc pawn
Posts: 10
Joined: Mon Jun 02, 2003 8:31 am

Post by codewarrior » Tue Jun 03, 2003 4:05 pm

strange, ive been using this macro for about two days now... Havent had any problems with that comment bieng there.
Last edited by codewarrior on Tue Jun 03, 2003 4:54 pm, edited 1 time in total.

alcor75
a lesser mummy
a lesser mummy
Posts: 77
Joined: Wed Jan 29, 2003 7:35 am

Post by alcor75 » Tue Jun 03, 2003 4:11 pm

ok , now that let me feel like i have compiled a monster :P
Can someone else test it?
May be i made some errors somewhere since i'm not a genius (the opposite fit me more), if so, sorry for the comment.

Alcor75

codewarrior
orc pawn
orc pawn
Posts: 10
Joined: Mon Jun 02, 2003 8:31 am

Post by codewarrior » Tue Jun 03, 2003 4:55 pm

no, its not a problem at all, id like people to give some constructive feedback so i can improve it more. Thanks.

Epsilon
a lesser mummy
a lesser mummy
Posts: 61
Joined: Wed Apr 30, 2003 5:46 pm

Post by Epsilon » Fri Jun 20, 2003 8:13 am

i cant get this to work, i set owner and botname but nothing happens when i try give command

fryfrog
a hill giant
a hill giant
Posts: 271
Joined: Fri Jun 20, 2003 5:37 am

Post by fryfrog » Fri Jun 20, 2003 8:19 pm

how do you send the warrior the target(id) to attack from another char? need to be running mq on the other computer too?

fryfrog
a hill giant
a hill giant
Posts: 271
Joined: Fri Jun 20, 2003 5:37 am

Post by fryfrog » Mon Jun 23, 2003 12:34 am

It appears to work, the guard here and guard X Y seem to work okay. Attacking seems to work pretty well as well. Maybe there are more bugs somewhere :)

Using your code as an example, I am trying to re-write it so that it is a little easier to read, a tad more flexible and with a couple more abilities. I think I have made it so that if the target is mezed, it will stop attacking. I believe I have also added a "guard x y" command so that the bot can guard a loc instead of returning to the master. If the loc is set, it should auto-return to it after creature dies OR master tells to back off. I made it so that when the master says to follow, it uses /face and $distance to get pretty close to the target THEN does a /follow. This should let the bot find its way to the owner better. I also used #define to make easier to read variables. I have NOT TESTED it yet, if anyone sees any coding errors please tell me :)

Update: I fixed some fairly obvious issues after reading the manual more and going through the code. i've added a "/doevents; /delay 0" to each loop, made "/face" become "/face id" where that was what it should have been. Cleaned up the GotoLoc stuff and added a "goto" command. Removed the Loot code since i can always just hand extra crap to him in a trade window :)

Edit: I made my own thread