First attempt at a Macro

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

Zerosend
decaying skeleton
decaying skeleton
Posts: 6
Joined: Wed Feb 18, 2004 7:27 pm
Contact:

First attempt at a Macro

Post by Zerosend » Thu Feb 19, 2004 12:29 pm

OK this macro seems pretty simple and im sure it has been done before but i was attempting it just for practice. The idea is that i have a box cleric on another pc and a tank that im fighting with. The idea was to have my cleric heal me and such when its nessicary or when i request it. I have yet to test it because well macroquest is out of date atm i belive at least mine is not working but i wanted to see if all you could point out any mistakes or tell me if it will work or not. Thanx for the input in advance.

Code: Select all

|xxxxxx	ClericBot V 1.0  xxxxxx
|xxxxxx	Programmer: Zero xxxxxx
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Sub main


|xx     Declarations        xx|

#event HealNow "Heal me 1234"

/Declare Chealhealth global 
/Declare Chealhealth2 global
/Declare Qhealhealth global
/Declare Qhealhealth2 global
/Declare Tankname global

varset Chealhealth 45
varset Chealhealth2 35
varset Qhealhealth 34
varset Qhealhealth2 1
varset Tankname @param0

/echo "ClericBot v1.0 has started."
/echo "send a tell to me saying (Heal me 1234) and i shall cast a heal over time"
/echo "My current tank to heal is @Tankname"
/target @Tankname

:Healloop

/if n "$target(hp,pct)"<=@Chealhealth /if n "$target(hp,pct)">=@Chealhealth2 /goto :Cheal
/if n "$target(hp,pct)"<=@Qhealhealth /if n "$target(hp,pct)">=@Qhealhealth2 /goto :Qheal



/goto :healloop


:Cheal
/sit off
/pause 1
/cast "complete heal"
/pause 11s
/sit
/goto :healloop
/return

:Qheal
/sit off

DyvimTvar
orc pawn
orc pawn
Posts: 16
Joined: Wed Oct 22, 2003 1:21 pm

Chopped?

Post by DyvimTvar » Thu Feb 19, 2004 1:04 pm

Looks like the code got chopped.
DyvimTvar

User avatar
Bad Karma
a snow griffon
a snow griffon
Posts: 346
Joined: Sat Nov 22, 2003 9:34 pm
Contact:

Post by Bad Karma » Fri Feb 20, 2004 6:30 am

Maybe we need a Tutorial forum for this stuff.
Getting old seeing all these half-assed attempts at macros with no testing and no aparant effort to try posted then what appears to be an expectation that someone will just do it for them.

Search....Read...try to write...and RUN IT FIRST...then come back with your errors. THAT is asking for help....not "I can't get this to work" and pasting something from MQ (1) and saying you can't find the problem. (not this post...referring to other posts...but same general idea). Also read a post today in this forum that they gathered a bunch of macs but can't get them to paste together and work...didn't even post what he tried to do. /sigh

RTFM
[b]- Bad Karma
________________________________________[/b]

In our own quest for excellence, we should strive to take the time to help those who help themselves.

All others should [b]RTFM[/b]!!!!!!!!!

User avatar
Bad Karma
a snow griffon
a snow griffon
Posts: 346
Joined: Sat Nov 22, 2003 9:34 pm
Contact:

RE: First [HALF-ASSED] attempt at a Macro

Post by Bad Karma » Fri Feb 20, 2004 7:01 am

[NOTE]: This is meant to be studied....I am not attempting to write the macro for you.

Yeah...either the majority of the code is missing, or no, it definately won't work.

Can I suggest reading the forums and especially the "Macro Scripting for Dummies" tutorial? MacroQuest Help File is also going to be a huge help.

Yes, this has already been done before. ::Search:: is your friend.

It's ok to practice, but at least STUDY before you jump in.

Based on what you had here, I cleaned it up and shortened it. I'm not trying to write this for you, so I put LOTS of |comments in for you to learn from. This will just give you an idea of what's happening until you get your MQ working again so you can actually run the macro.

Oh...I changed your variable names just because I am tired from a 34-hour work day and didn't want to type it all out. Your names were fine, just make sure you are being consistant with your CaPiTaLiZaTiOn.

You are close on your variable comparisons, too.
This should have had quote marks (text):

Code: Select all

/target [color=cyan]"[/color]@Tankname[color=cyan]"[/color]
This does not need quote marks (numerical):

Code: Select all

/if n [color=violet]"[/color]$target(hp,pct)[color=violet]"[/color]<=@Chealhealth
Capitalization:

Code: Select all

/cast "complete heal"
Not really necessary since your low HP is 1%:

Code: Select all

/if n "$target(hp,pct)">=@Qhealhealth2

Code: Select all

|  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|  xxxxxx   ClericBot V 1.0  xxxxxx
|  xxxxxx   Programmer: Zero xxxxxx
|  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
|  Simple Cleric Bot that will watch your target and heal as needed or requested.
|
|  USAGE:
|     /macro ClericBot <TankName>
|
|  ~ This Macro will auto-target the tank name provided when the macro is started.
|  ~ When the target falls between 35% & 45% HP, it will cast Complete Healing.
|  ~ When the target falls below 35% HP, it will cast Quick Healing spells until
|    he/she is over 35% HP, then cast a Complete Heal.
|  ~ To force the Cleric to cast a spell (defined below) send a /tell with the
|    command you also define below.
|
|              USAGE:
|                 /tell <ClericName> Heal me 1234
|
|  READ ALL COMMENTS BELOW.
|  CHANGE ALL VARIABLES IN SUB MAIN TO MATCH
|  THE NAMES OF YOUR SPELLS (CaSe-SeNsItIvE)
|
|  Comments can be deleted....this is just for tutorial purposes.
|

#turbo 50

|  You REALLY should be using this to handle ALL of your spell casting in ALL of your Macros!
#include SpellCast.inc

#chat Tell

|  Set this to whatever text you want to trigger from your target.
|  Set it in a hotbutton!  When you send a /tell to your Cleric with this text in it,
|     the Cleric will cast your Heal Over Time spell, or whatever you put in here.
#event HealMe "Heal me 1234"

/declare TN global
/declare CH global
/declare QH global
/declare HOT global

Sub Main
   /echo ClericBot v1.0 has started.
   /echo send a tell to me saying (Heal me 1234) and i shall cast a heal over time.
   /echo My current Tank to heal is "@TN"

|  Sets the Tank Name to the name you provided when you started the Macro.
   /varset TN "@Param0"
|  *****************************************
|  *** SET THESE TO YOUR OWN SPELL NAMES ***
|  *****************************************
|  Set this to your Complete Heal spell name.
   /varset CH "Complete Heal Spell Name"
|  Set this to your Quick Heal for those emergency heals!
   /varset QH "Quick Heal Spell Name"
|  Set this to the "Heal Over Time" spell you will be using when you send the Bot a /tell.
   /varset HOT "Heal Over Time Spell Name"


   :HealLoop
|  Comment out this line if you do NOT want your Cleric to meditate while watching the Tank.
|  A simple /sit will work here, but I like to check to make sure we're not already sitting
|  or riding a mount so we don't sit before trying to cast.  SpellCast.inc will automatically
|  stand you up before casting, anyway.  Putting this here just ensures we are going to med.
      /if ($char(mounted)!="TRUE" && $char(state)!="SIT") /sit
|  Make sure we still have the Tank on target!
      /if "$target(name,clean)"!="@TN" /target "@TN"
|  Check to see if the Tank is requesting a Heal.
      /doevents
|  If Tank HP drops to between 35% and 45%, cast the Complete Heal spell.
      /if (n $target(hp,pct)<=45 && n $target(hp,pct)>=35) /call Cast "@CH"
|  If Tank HP drops to between 35% and 45%, cast the Quick Heal spell.
      /if n $target(hp,pct)<=34 /call Cast "@QH"
|  Rinse and repeat!
      /goto :HealLoop
/return

|  Got a tell...let's cast that Heal Over Time spell now!
Sub Event_HealMe
   /call Cast "@HOT"
/return
If you'd like to compare it to what you actually wrote without all the |comments to junk it up, here is the shortened version:

Code: Select all

|  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|  xxxxxx   ClericBot V 1.0  xxxxxx
|  xxxxxx   Programmer: Zero xxxxxx
|  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

#turbo 50
#include SpellCast.inc
#chat Tell
#event HealMe "Heal me 1234"

/declare TN global
/declare CH global
/declare QH global
/declare HOT global

Sub Main
   /echo ClericBot v1.0 has started.
   /echo send a tell to me saying (Heal me 1234) and i shall cast a heal over time.
   /echo My current Tank to heal is "@TN"

   /varset TN "@Param0"
   /varset CH "Complete Heal Spell Name"
   /varset QH "Quick Heal Spell Name"
   /varset HOT "Heal Over Time Spell Name"


   :HealLoop
      /if ($char(mounted)!="TRUE" && $char(state)!="SIT") /sit
      /if "$target(name,clean)"!="@TN" /target "@TN"
      /doevents
      /if (n $target(hp,pct)<=45 && n $target(hp,pct)>=35) /call Cast "@CH"
      /if n $target(hp,pct)<=34 /call Cast "@QH"
      /goto :HealLoop
/return

Sub Event_HealMe
   /call Cast "@HOT"
/return
As you can see, it's only 27 lines of actual code...24 if you take out the /echo's. And if you get rid of those damn /declares and /varsets and just hardcode the name of the spell in the script, you can get it down to a nice compact size of only 18 lines!

Code: Select all

#turbo 50
#include SpellCast.inc
#chat Tell
#event HealMe "Heal me 1234"
/declare TN global
Sub Main
   /varset TN "@Param0"
   :HealLoop
      /if ($char(mounted)!="TRUE" && $char(state)!="SIT") /sit
      /if "$target(name,clean)"!="@TN" /target "@TN"
      /doevents
      /if (n $target(hp,pct)<=45 && n $target(hp,pct)>=35) {
         /call Cast "Complete Heal Spell Name"
      } else {
         /if n $target(hp,pct)<=34 /call Cast "Quick Heal Spell Name"
      }
      /goto :HealLoop
/return
Sub Event_HealMe
   /call Cast "Heal Over Time Spell Name"
/return
(Even less with a few minor modifications.) What you posted of yours (looking like the whole thing didn't get posted), you're already at 49 lines. A bit much for a macro that only casts 3 spells when the target falls in specific ranges of health or sends a tell.

Note the placement of the /declares, /varsets, :loops, /returns, and the use of Sub's. Doing things this way will help keep your code organized, re-usable, and performing at its peak without eventually slowing down your system.

I generally use a #turbo of 50 for performance issues. Don't really need it in this macro.

Also, notice how the #event is set up and called. It didn't look like you had this handled in your orginal. If it was in the part that didn't get posted, it would not have worked anyway, because you had no /doevents in your main loop.

When making lables, be sure to remain consistant with your Capitalization! Spell names can also be sensitive to CaSe. If your spells don't work, check your spellbook to make sure they are spelled EXACTLY as EQ shows them, and you're using the proper symbols (` rather than ' for some spells).

Look at my SpellCast.inc found HERE. You should be able to see how it is handling the casting of spells in case you do want/need to do this in your own mac. I still suggesting always using SpellCast.inc, though. It's been tried and tested and tested and tested, and it works. While this mac simply loops through a HP check and keeps casting, more advanced mac's can't afford to have error-checking built in on every cast. SpellCast.inc handles that automatically so you don't have to.

Hope this helps your efforts in learning macro scripting.
It's late....time for bed. :) Let me know if you have any questions. I can't remember if I covered everything I wanted to or not right now. lol
[b]- Bad Karma
________________________________________[/b]

In our own quest for excellence, we should strive to take the time to help those who help themselves.

All others should [b]RTFM[/b]!!!!!!!!!

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

Post by Mckorr » Fri Feb 20, 2004 10:04 am

BK, do I need to change your title to "Grouchy Smurf"? :)

El
a ghoul
a ghoul
Posts: 108
Joined: Mon Dec 29, 2003 12:34 pm

Post by El » Fri Feb 20, 2004 11:31 am

Bad Karma, I'd like to thank you for posting that. I've not had the time to delve deeply into macroing... just enough to modify scripts that I get here to serve my needs. That was a nice post, and I learned some tricks.

Zerosend
decaying skeleton
decaying skeleton
Posts: 6
Joined: Wed Feb 18, 2004 7:27 pm
Contact:

Post by Zerosend » Fri Feb 20, 2004 4:01 pm

BK you know thank you for the information you posted in your 2nd post but the Flame you put in your first post was unnessicary. As i said in my post i couldent test the thing because macroquest wasent working atm, But trust me i did want to test it i was so anxious i posted it just to see if anyone could point out an error or 2 im not asking ANYONE to write it for me. Infact i dont want it written for me. Im new to this macro stuff and im trying to learn it by reading other peoples macros with their documentation in it. Ive looked at the manual a bit and it helps but still seeing code actually written helps. Next time do get all pissed off because someone asked for somthing. Next time if you DONT want to help then DONT i really dont care if you ansewer my post i dont care if anyone does but if someones nice enough to take 2 mins to look at the damn thing (Not test it) Look at it because it is short ass code then i would appreciate it. Im used to a compiler being able to tell me where i have errors when they come up i guess .NET spoiled me a bit.

Zerosend
decaying skeleton
decaying skeleton
Posts: 6
Joined: Wed Feb 18, 2004 7:27 pm
Contact:

Post by Zerosend » Fri Feb 20, 2004 4:08 pm

oh yes and sorry some of the code did get cut off sorry about that. Oh and BK thank you for your 2nd post i looked over it a 2nd time it will help a ton thank you for the study info

Zerosend
decaying skeleton
decaying skeleton
Posts: 6
Joined: Wed Feb 18, 2004 7:27 pm
Contact:

Post by Zerosend » Fri Feb 20, 2004 4:23 pm

Code: Select all

#turbo 50 
#include SpellCast.inc 
#chat Tell 
#event HealMe "Heal me 1234" 
/declare TN global 
Sub Main 
   /varset TN "@Param0" 
   :HealLoop 
      /if ($char(mounted)!="TRUE" && $char(state)!="SIT") /sit 
      /if "$target(name,clean)"!="@TN" /target "@TN" 
      /doevents 
      /if (n $target(hp,pct)<=45 && n $target(hp,pct)>=35) { 
         /call Cast "Complete Heal Spell Name" 
      } else { 
         /if n $target(hp,pct)<=34 /call Cast "Quick Heal Spell Name" 
      } 
      /goto :HealLoop 
/return 
Sub Event_HealMe 
   /call Cast "Heal Over Time Spell Name" 
/return
Ok very nice clean code, and i appreciate it now i do have a question. the /doevents statement will that do all the events in the code or can you specify to do a certain event? im not quite sure how that works still.

smelly wang
a lesser mummy
a lesser mummy
Posts: 54
Joined: Mon Jan 19, 2004 6:04 pm

Post by smelly wang » Fri Feb 20, 2004 5:08 pm

Code: Select all

/doevents HealMe   | Only does HealMe
/doevents flush      | Clears doevents queue
/doevents chat       | Only does chat events
/doevents              | Does all events
its all in the readme btw ;)

User avatar
Bad Karma
a snow griffon
a snow griffon
Posts: 346
Joined: Sat Nov 22, 2003 9:34 pm
Contact:

Post by Bad Karma » Fri Feb 20, 2004 6:17 pm

Mckorr wrote:BK, do I need to change your title to "Grouchy Smurf"? :)
Lol...

End result of a VERY long day at work (gotta love the military) and reading one too many stupid posts throughout the fourms. It really wasn't directed AT him...but like I said, to the people who put no effort out whatsoever.

Grouchy Smurf? Naww...I'm looking for a new Avatar, actually. Haven't found the one I have in mind yet.
[b]- Bad Karma
________________________________________[/b]

In our own quest for excellence, we should strive to take the time to help those who help themselves.

All others should [b]RTFM[/b]!!!!!!!!!

User avatar
Bad Karma
a snow griffon
a snow griffon
Posts: 346
Joined: Sat Nov 22, 2003 9:34 pm
Contact:

Post by Bad Karma » Fri Feb 20, 2004 6:38 pm

Reactionary people. Gotta love 'em. FYI: I wrote my answers to your questions in the 2nd post above BEFORE writing the little "vent" (which as I said in it was not directed specifically to you). I spent a good 30-40 minutes on it (counting intrruptions IRL) and making sure I covered everything I wanted to cover to help you out. All after a VERY long day at work when I could have just gone to bed. Then I posted it. Had a second thought, edited it and posted the flame, then re-posted it immediately after the flame. There was a reason for doing it that way. Reason was because so many times I try to help people out, just to have them post "ok, how do i do this then?" with somethign totally out of their league for just learning. They aren't reading or learning, they're asking for handouts. I didn't get that 100% warm-and-fuzzy from your first post, so I went back and posted an eye-opener.

Zerosend wrote:the /doevents statement will that do all the events in the code or can you specify to do a certain event? im not quite sure how that works still.
I actually was going to include a point on events, but didn't because you only had/needed the one.

/doevents will process all of your #events
/doevents <eventname> will process just the one specified.

If you look at SpellCast.inc, you will see that it does each event in a specific order. This is for accuracy...want to make sure we have enough mana before casting, which should be checked after a fizzle since we'll losee mana from fizzles, etc...no use in checking those if we can't see the target to begin with.

As Smelly said, it's in the documentation.
http://macroquest2.com/main.php?p=manual
It's a little outdated, but still very useful. And, it's in the readme.html file in your MQ2 folder (more up-to-date).


[Edit]:
Here's a link to the scripting tutorial, in case someone didn't see it stickied as the very first topic in this help forum.
http://macroquest2.com/phpBB2/viewtopic.php?t=3969
[b]- Bad Karma
________________________________________[/b]

In our own quest for excellence, we should strive to take the time to help those who help themselves.

All others should [b]RTFM[/b]!!!!!!!!!

Zerosend
decaying skeleton
decaying skeleton
Posts: 6
Joined: Wed Feb 18, 2004 7:27 pm
Contact:

Post by Zerosend » Sat Feb 21, 2004 12:05 am

Yah thats how i figured doevents would work but just making sure. thanks for your help sorry i was just a bit pissed off after reading your vent but i really did appreciate the help. I felt it was directed my way anyway hope no hard feelings bout my vent.

Thanks for the help
happy codeing

User avatar
Bad Karma
a snow griffon
a snow griffon
Posts: 346
Joined: Sat Nov 22, 2003 9:34 pm
Contact:

Post by Bad Karma » Sat Feb 21, 2004 5:11 pm

Zerosend wrote:anyway hope no hard feelings bout my vent.
Never! I had fun doing it. lol

I've been around message boards long before there was ever an internet (private, not even talking public). I never take this shit personally/seriously.

It's like EQ. It's only a game.
[b]- Bad Karma
________________________________________[/b]

In our own quest for excellence, we should strive to take the time to help those who help themselves.

All others should [b]RTFM[/b]!!!!!!!!!