CheckSinglePull.inc (MQ2Data enabled)

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.

Moderator: MacroQuest Developers

Landslide
orc pawn
orc pawn
Posts: 15
Joined: Sat Nov 16, 2002 4:00 pm

CheckSinglePull.inc (MQ2Data enabled)

Post by Landslide » Fri Apr 23, 2004 11:47 am

This is my first mini-contribution, so please forgive ;)

I've been using this to check for single pulls in my automated xp-gain macro. It sucks up some CPU time - on a 1GHZ system with 160 MOBs in zone it takes 2-3 seconds to execute. I'm sure this could be chopped down some (perhaps by storing the target mobs y,x coords in vars instead of dereferencing each iteration..) I've found it acceptable for the few times I use it though. Anyway, I hope someone finds it useful.

Useage: feed it the ID of the NPC you want to check and the radius, ie:
/call SubCheckSinglePull ${Target.ID} 200

Code: Select all

| Title: SubCheckSinglePull (MQ2DATA enabled)
| Author: Landslide
| Date:  2004.04.24 (Last Updated: )
| Desc: Counts the number of NPCs AND PCs near an NPC with the provided ID and radius

Sub SubCheckSinglePull(id,radius)
	
	/declare mobcount local
	/declare startid local
	/declare currentid local
	/declare targetid local
	
	/varset mobcount 0
	/varset startid ${Me.ID}
	/varset currentid @startid
	
	:SINGLEPULLLOOP

 	/varset currentid ${Spawn[@currentid].Prev.ID}
	
  	/newif (@id==@currentid) /goto :SINGLEPULLLOOP 
  	
  	/newif (!@currentid) /goto :SINGLELOOPEND
	  	
  	/newif (${Spawn[@currentid].Type.Equal[NPC]} || ${Spawn[@currentid].Type.Equal[PC]}) { 	  	
	  	/newif (${Math.Distance[${Spawn[id].Y},${Spawn[id].X}:${Spawn[@currentid].Y},${Spawn[@currentid].X}]}<@radius) /varadd mobcount 1
	}
	/goto :SINGLEPULLLOOP
	
	:SINGLELOOPEND

/return @mobcount
Last edited by Landslide on Sun Apr 25, 2004 10:59 am, edited 1 time in total.
-- Landslide

OldNecro
a ghoul
a ghoul
Posts: 136
Joined: Thu Dec 19, 2002 3:09 am

Post by OldNecro » Sat Apr 24, 2004 5:09 pm

am I missing something or would an alert have been a lot less trouble?
Saddam Hussein begins to use An Innocent Bystander as a living shield!
An Innocent Bystander ceases protecting Saddam Hussein's corpse.

Landslide
orc pawn
orc pawn
Posts: 15
Joined: Sat Nov 16, 2002 4:00 pm

Post by Landslide » Sun Apr 25, 2004 10:57 am

I wouldn't be suprised if I am completely missing something. How would you use an alert to do the same thing?
-- Landslide