ranger auto-harmony

A forum for macro code snippets to be used in writing other macros. Post routines or .inc files here only, completed macros go to the Macro Depot. MQ2Data format only!

Moderator: MacroQuest Developers

Mimatas
a hill giant
a hill giant
Posts: 262
Joined: Wed Mar 10, 2004 4:22 pm

ranger auto-harmony

Post by Mimatas » Thu Aug 12, 2004 3:38 pm

Okay.. I've seen requests for it.. but never implementation. This is a VERY rough, untested, poorly debugged piece of code... but I wanted input as to whether or not it would work.

Code: Select all

 
   /declare spawnnum int outer 1
   /declare targ int outer 0 
   /declare range int outer 20 

Sub Harmony    
 
   |Auto-harmonies mobs within a certain range of your target 
   |Directions: have a mob targeted, run the snippet, 
   |by the end of the code all of the mobs should be harmonied and your 
   |target ready to pull. 
	
   /varset targ ${Target.ID} 
   /varset spawnnum 1 
		
   :harmonyLoop 

   /if ( ${Spawn[${targ}].NearestSpawn[${spawnnum}, npc radius ${range}].ID} ) { 
      /target ${Spawn[${targ}].NearestSpawn[${spawnnum}, npc radius ${range}]} 
      /call Cast "Harmony of Nature" 
      /delay 55
      /varset spawnnum ${Math.Calc[${spawnnum}+1]} 
      /echo incremented, retargeting ${targ}
      /goto :harmonyLoop 
   } 
   /target id ${targ} 
/return
This is my first attempt to actually do something productive... I'm open to ideas/criticisms. Sorry for posting here, but it really IS more of a snippit than a macro... and will eventually be edited to become a real snippet.

edit 8/13/2004 - added blueninja's suggestion to use ${Spawn[${targ}].NearestSpawn} rather than ${Target.NearestSpawn}

edit 8/12/2004 - Untested generalized version of code that did work (changed mob name to 'radius ${range}' to work at a camp other than my specific camp}

The mob must be targeted when this is called.

I'd be interested in any feedback anyone has. The version I tested had the meat of this placed into a sub, rather than as a sub itself.

I'm also not sure if ${Target.NearestSpawn[${spawnnum}, npc radius ${range}].ID} will 1. evaluate correctly, and 2. evaluate within a 20 unit radius of me, or of the mob. Initial testing makes me think the mob, but I'm not sure.

Feedback would be good.
Last edited by Mimatas on Fri Aug 13, 2004 11:41 am, edited 3 times in total.

hiipii
a ghoul
a ghoul
Posts: 93
Joined: Sat Jun 19, 2004 5:01 pm

Post by hiipii » Thu Aug 12, 2004 6:09 pm

Pinnochio.inc tells you, 'I wish i were a real snippet!'

sorry bout that

first prob i see is that spawnnum is never declared. Maybe it doesn't need to be? iono..yea

hiipii
a ghoul
a ghoul
Posts: 93
Joined: Sat Jun 19, 2004 5:01 pm

Post by hiipii » Thu Aug 12, 2004 6:10 pm

oh yea and there are no subs

and i think

Code: Select all

 /varset spawnnum ${Math.calc[spawnnum+1]}
should be

Code: Select all

 /varset spawnnum ${Math.Calc[${spawnnum}+1]}
but im not quite sure

and as far as i can tell inner is not a valid type for a variable. loacal > outer > global

Mimatas
a hill giant
a hill giant
Posts: 262
Joined: Wed Mar 10, 2004 4:22 pm

Post by Mimatas » Thu Aug 12, 2004 6:20 pm

It's less of a .inc and more of a copy/paste piece of code.

Right now, it's in the middle of a sub for a macro I'm using. I added the #include to show that you had to have that .inc file.. but otherwise, it's not intended to be its own sub. Yet. I simply haven't achieved quite that much mastery of the macro language.

Good catch on the Math.Calc thing though. I'll edit to fix that right now.

Any logical problems? Reasons it wouldn't work as intended? More efficient ways of doing this?

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

Post by Fippy » Thu Aug 12, 2004 7:36 pm

not sure that would work. Wouldnt you end up harmonying forver with that? I think youd prolly be better adding all the id's of the spawns around your target spawn to an array then loop around that array and harmony them.
Fippy

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

Mimatas
a hill giant
a hill giant
Posts: 262
Joined: Wed Mar 10, 2004 4:22 pm

Post by Mimatas » Thu Aug 12, 2004 8:00 pm

Spawnnum increments, and NearestSpawn has a range... so it *should* (theoretically) return false once you're out of spawns within the range... I'll have to try that and see.

Mimatas
a hill giant
a hill giant
Posts: 262
Joined: Wed Mar 10, 2004 4:22 pm

Post by Mimatas » Thu Aug 12, 2004 8:02 pm

Just tried it by targeting a mob in PoTranq and /echoing it. It will return null once the next nearest spawn is out of the range.

User avatar
blueninja
a grimling bloodguard
a grimling bloodguard
Posts: 541
Joined: Thu Aug 28, 2003 7:03 am
Location: Göteborg, Sweden

Post by blueninja » Fri Aug 13, 2004 10:09 am

Fippy is right. The problem is that you use ${Target.NearestSpawn} and you keep changing targets. What you need to do is save the ID of the original target, then use ${Spawn[${OriginalID}].NearestSpawn} instead.

Mimatas
a hill giant
a hill giant
Posts: 262
Joined: Wed Mar 10, 2004 4:22 pm

Post by Mimatas » Fri Aug 13, 2004 11:37 am

hmm.. it worked when I tried it.. but I wasn't trying to pull a specific mob, I was just happy it harmonied all of them. I'll change that now.

ins
a lesser mummy
a lesser mummy
Posts: 74
Joined: Wed Jun 16, 2004 6:48 pm

Post by ins » Sat Aug 28, 2004 1:19 pm

Very very nice. Will start working this into my hunter.

loadingpleasewait
a snow griffon
a snow griffon
Posts: 332
Joined: Sat Sep 14, 2002 8:46 am

Post by loadingpleasewait » Mon Sep 20, 2004 5:38 pm

Does this snippet work now? I'd like to add it to my Arch.mac, but wanna know if it works first..


:EDIT: Tried it out, and it does indeed work. Included in the newest Arch.Mac found in the Macro Depot.
LOADING PLEASE WAIT...