First time macro for enc

Need help with a macro you are writing? Ask here!

Moderator: MacroQuest Developers

ultrax
orc pawn
orc pawn
Posts: 12
Joined: Tue May 04, 2010 1:55 pm

First time macro for enc

Post by ultrax » Tue May 04, 2010 3:00 pm

Enchanter.mac
I wrote this with the intention of having the enchanter cast a DOT as soon as the pulled target is in range to pull agro to get the pet to attack. Then continue to cast 2 more spells. My warrior will regain agro during this. Then cast a nuke at 15% mob health. Should be monitoring if arcane rune dropped during this and recast it automaticly.

This is my first attempt at writing. Any problem areas? I tried to add the target better be a npc part to prevent corpse casting ect. I havn't programmed in almost 18 years and it was on basic DOS. I am not sure of some of the delays (if they are needed or not or appropraite) or if I will hit a spam condition. I hope I was close!

Code: Select all

| Enchanter Macro
| casts DOT Cripple Slow when in range to pull agro for pet, No AA yet
| Nukes at 15% target
| /assist MA Name
|Casts Arcane Rune automatically
#turbo
#include spell_routines.inc
#event RuneFade “The shimmer of runes fades”

Sub Main
/declare SpellDOT         outer “Strangle”
/declare SpellCRIPPLE   outer “Cripple”
/declare SpellSLOW       outer “Shiftless Deeds”
/declare SpellNUKE        outer “Dementing Visions”
/declare SpellRUNE        outer “Arcane Rune”
/declare CharName string outer   EditYourCharacterNameOutOfYourPostAndReplaceThisWithIt
:loop
/doevents
/if (${Me.Casting.ID}) /goto :loop
/if (!${Target.ID} || ${Target.Type.Equal[PC]} || ${Target.Type.Equal[CORPSE]}) {
   /assist ${CharName}
   /delay 10
/attack off
/if (${Target.Distance}<200) {/goto :attackloop1} else {/goto :loop}

|Attack Loop 1 
:attackloop1
/call cast $(SpellDOT) gem3 3s
/goto :attackloop2

|Attack Loop 2
:attackloop2
/call cast $(SpellCRIPPLE) gem2 25
/goto :attackloop3

|Attack Loop 3
:attackloop3
/call cast $(SpellSLOW) gem1 6s
/goto :attackloop4

|Attack Loop 4
:attackloop4
/if (${Target.PctHPs}<15) {/goto :nuke} else {/goto :attackloop4}

|Nuke
:nuke
/call cast $(SpellNUKE) gem4
/if (${Me.Standing} && !${Me.Mount.ID}) /sit}
/goto :loop

|Sub events
Sub Event_RuneFade
/call cast $(SpellRUNE)
/delay 20
/return

drzoon
a hill giant
a hill giant
Posts: 239
Joined: Tue May 04, 2004 5:38 pm

Re: First time macro for enc

Post by drzoon » Wed May 05, 2010 10:25 am

A couple of things that I can see:
  • Your main sub doesn't have a /return line. The macro may work as is, but it's not a good practice to get into.
  • Your various Spell variables need to have braces on either side, not brackets. Eg. $(SpellDOT) needs to be ${SpellDOT}
  • Gotos are quite slow in MQ2 and I try to avoid them if at all possible. In a macro of this size though, the gotos won't make any difference to speed, but it's always a good practice to get into. You will need a /goto to create a loop, but any gotos that just go to the next line are unnecessary.
  • You can use conditional delays to delay until a condition is met. This can be quite useful if for example, you want to wait until casting is complete, but the cast time of the spell is variable. Something like /delay 30s !${Me.Casting.ID} will delay for up to 30s, or until you are no longer casting, whichever comes first.
  • A #turbo line with no number behind it just sets it to the default turbo, which is the same as not having the line at all. If you want it run at the fastest rate, use #turbo 40
I've quickly rewritten your macro to show you how it could be done with some conditional delays, and just a single loop. Untested of course. I don't know if the spell_routines.inc Cast sub delays until the spell has completed, but if it doesn't, you may need to add some delays after each /call cast line to ensure that you're currently casting before attempting the next spell.

Code: Select all

| Enchanter Macro
| casts DOT Cripple Slow when in range to pull agro for pet, No AA yet
| Nukes at 15% target
| /assist MA Name
|Casts Arcane Rune automatically
#turbo 40
#include spell_routines.inc
#event RuneFade “The shimmer of runes fades”

Sub Main
/declare SpellDOT         outer “Strangle”
/declare SpellCRIPPLE   outer “Cripple”
/declare SpellSLOW       outer “Shiftless Deeds”
/declare SpellNUKE        outer “Dementing Visions”
/declare SpellRUNE        outer “Arcane Rune”
/declare CharName string outer   EditYourCharacterNameOutOfYourPostAndReplaceThisWithIt
:loop
/doevents
/delay 1m !${Me.Casting.ID}
/if (!${Target.ID} || ${Target.Type.Equal[PC]} || ${Target.Type.Equal[CORPSE]}) {
  /assist ${CharName}
  /delay 10 
  /attack off
  /if (${Target.Distance}<200) {
    /call cast ${SpellDOT} gem3 3s
    /call cast ${SpellCRIPPLE} gem2 25
    /call cast ${SpellSLOW} gem1 6s
    /delay 10m ${Target.PctHPs}<15
    /if (${Target.PctHPs}<15) {
      /call cast $(SpellNUKE) gem4
      /if (${Me.Standing} && !${Me.Mount.ID}) /sit
    }
  }
}
/goto :loop
/return

|Sub events
Sub Event_RuneFade
/call cast $(SpellRUNE)
/delay 20
/return

matadormix
a ghoul
a ghoul
Posts: 132
Joined: Sun Dec 14, 2008 8:31 am

Re: First time macro for enc

Post by matadormix » Thu May 06, 2010 2:12 am

drzoon wrote:I don't know if the spell_routines.inc Cast sub delays until the spell has completed
It does.

Personally, I don't use events to find out the buffs I need in my macros. I would use something like this instead:

Code: Select all

/if (!${Me.Buff[Arcane Rune].ID} && ${Me.AltAbility[Arcane Rune].Spell.Stacks} && ${Me.AltAbilityReady[Arcane Rune]}) /Call Cast "arcane rune" alt

ultrax
orc pawn
orc pawn
Posts: 12
Joined: Tue May 04, 2010 1:55 pm

Re: First time macro for enc

Post by ultrax » Wed May 12, 2010 8:42 am

Thanks for posting some hints and corrections. I will play with these to help get more familur with the in and outs of it. This could become a fun little hobby.

ultrax
orc pawn
orc pawn
Posts: 12
Joined: Tue May 04, 2010 1:55 pm

Re: First time macro for enc

Post by ultrax » Wed May 12, 2010 1:32 pm

•Your various Spell variables need to have braces on either side, not brackets. Eg. $(SpellDOT) needs to be ${SpellDOT}

?? --> What is the difference between the brackets and braces? or is that a XML coding basic?

User avatar
pms
a grimling bloodguard
a grimling bloodguard
Posts: 663
Joined: Mon Jan 31, 2005 5:20 pm
Location: Internet, Earth
Contact:

Re: First time macro for enc

Post by pms » Wed May 12, 2010 4:09 pm

ultrax wrote:What is the difference between the brackets and braces?
http://en.wikipedia.org/wiki/Bracket#Types

Braces are for mqdata (TLOs and members), brackets are for passing data to a form, e.g. ${NearestSpawn[npc]}