Need help with a macro you are writing? Ask here!
Moderator: MacroQuest Developers
-
Tuna
- a lesser mummy

- Posts: 68
- Joined: Mon Jul 21, 2003 4:10 pm
Post
by Tuna » Sun Aug 01, 2004 1:22 pm
Howdy - I'm trying to get a list of mobs in a radius around a point. Not my character's point. This is mostly for checking how many critters are beating on my tank.
This code doesn't appear to list the mobs properly, although it does count them. I think. Any help is appeciated.
Code: Select all
turbo 30
sub Main
/declare iSpawns int local
/declare n int local
/declare c int local
/varset iSpawns ${SpawnCount[npc radius 50 loc ${Target.X}:${Target.Y}]}
/if (${iSpawns}<1) {
/echo None found
/return 0
}
/echo found ${iSpawns}
/varset n ${Spawn[radius 50 loc ${Target.X}:${Target.Y}]}
/for c 1 to ${iSpawns}
/varset n ${Spawn[${c},radius 50 loc ${Target.X}:${Target.Y}].ID}
/echo ${c} ${n} ${Spawn[${n}].CleanName}
/next c
/return
-
blueninja
- a grimling bloodguard

- Posts: 541
- Joined: Thu Aug 28, 2003 7:03 am
- Location: Göteborg, Sweden
Post
by blueninja » Sun Aug 01, 2004 2:07 pm
I believe you need to switch X and Y locs around, Y normally comes before X in eq..
-
Drumstix42
- a grimling bloodguard

- Posts: 808
- Joined: Mon May 03, 2004 4:25 pm
Post
by Drumstix42 » Sun Aug 01, 2004 3:41 pm
is SpawnCount even an object you can use?
also for ${Spawn} you may want to add in npc to it.
Maybe you could use ${NearestSpawn} and int the number? not too sure.
-
Tuna
- a lesser mummy

- Posts: 68
- Joined: Mon Jul 21, 2003 4:10 pm
Post
by Tuna » Sun Aug 01, 2004 3:51 pm
I've spent about 3 hours on this. nearestspawn gets the spawns nearest to ${Me}, not to the loc. I've tried both X and Y reversed. Might just be a limitation of the parser.
-
Drumstix42
- a grimling bloodguard

- Posts: 808
- Joined: Mon May 03, 2004 4:25 pm
Post
by Drumstix42 » Sun Aug 01, 2004 3:53 pm
with nearest loc example:
${NearestSpawn[1,npc loc 50:-40]
works fine, and if you put in 2, it gets the 2nd closest npc (what I was talkinga bout with the intervals, maybe using a variable). But I never got the radius thing to work right. I forget which way I used X and Y. I just got the .Loc of my target and used the order in which I got them.
I know tehre's definately a way to do it tho.
-
Cr4zyb4rd
- Plugins Czar
- Posts: 1449
- Joined: Tue Jul 20, 2004 11:46 am
Post
by Cr4zyb4rd » Sun Aug 01, 2004 10:07 pm
You shouldn't need to use the loc at all. Every spawn has it's own NearestSpawn member, such that something like
Code: Select all
${Spawn[${mytank}].NearestSpawn[1, npc radius 50].ID}
should do what you want. (providing mytank is set correctly)
is SpawnCount even an object you can use?
Code: Select all
SpawnCount
int SpawnCount
Total number of spawns in current zone
int SpawnCount[search]
Total number of spawns in current zone matching the search
access to type(s): int
Object used to get information on the count(s) of all spawns or specific spawn(s).
Seems so. :) I use it all the time.
edit: x3, damn you phpBB!
-
Tuna
- a lesser mummy

- Posts: 68
- Joined: Mon Jul 21, 2003 4:10 pm
Post
by Tuna » Mon Aug 02, 2004 11:31 am
Thanks for the help. It works for "targets around a target" but does not work for "targets around a location" yet. I'm still cornholed on that one.
Here is the working script for targets in a radius around a target:
Code: Select all
| -----------------
| snip_targspawns.mac
| Snippet to iterate through a list of spawns around a target
| -----------------
#turbo 30
sub Main
/declare n int local
/declare c int local
/declare r int local 50
/varset c 1
:LAB_NextSpawn
/varset n ${Spawn[${Target.ID}].NearestSpawn[${c},pc radius ${r}].ID}
/if (${n}<=0) {
/goto :LAB_Done
}
/echo ${Spawn[${n}].CleanName} L${Spawn[${n}].Level} ${Spawn[${n}].Class}
/varcalc c ${c}+1
/goto :LAB_NextSpawn
:LAB_Done
/return
-
blueninja
- a grimling bloodguard

- Posts: 541
- Joined: Thu Aug 28, 2003 7:03 am
- Location: Göteborg, Sweden
Post
by blueninja » Mon Aug 02, 2004 11:52 am
I took a peek at the source code. From what I could tell I was wrong about the order of the coordinates, X should go first and Y second. More importantly, from what I could see, : isn't the correct separator. Try separating the X and Y with a space.
-
nosaj969
- a lesser mummy

- Posts: 33
- Joined: Wed Apr 28, 2004 3:39 pm
- Location: Hagerstown, MD
Post
by nosaj969 » Mon Aug 02, 2004 2:14 pm
The following should work for getting the number of spawns around a set loc. When using 'loc' in a search you must include a radius, otherwise EQ things it is a radius of 0.
Code: Select all
#turbo 30
sub Main
/declare n int local
/declare c int local
/declare r int local 50
/declare X int local 600 | X loc
/declare Y int local 600 | Y loc
/varset n ${Spawn[npc loc ${X} ${Y} radius ${r}].ID}
:Loop
/if (${n}==0) {
/return
} else {
/echo ${Spawn[${n}].CleanName} L${Spawn[${n}].Level} ${Spawn[${n}].Class}
/varset n ${Spawn[${n}].NearestSpawn[${c}, npc radius ${r}].ID}
/varcalc c ${c}+1
}
/goto :Loop
/return
nosaj969
-
blueninja
- a grimling bloodguard

- Posts: 541
- Joined: Thu Aug 28, 2003 7:03 am
- Location: Göteborg, Sweden
Post
by blueninja » Mon Aug 02, 2004 3:50 pm
${SpawnCount[npc loc ${X} ${Y} radius 100]} works too. No need to loop
-
Tuna
- a lesser mummy

- Posts: 68
- Joined: Mon Jul 21, 2003 4:10 pm
Post
by Tuna » Mon Aug 02, 2004 4:16 pm
blueninja wrote:${SpawnCount[npc loc ${X} ${Y} radius 100]} works too. No need to loop
Try it with ${Spawn[]} instead of Spawncount and show me your results.

-
blueninja
- a grimling bloodguard

- Posts: 541
- Joined: Thu Aug 28, 2003 7:03 am
- Location: Göteborg, Sweden
Post
by blueninja » Mon Aug 02, 2004 6:36 pm
Try it with ${Spawn[]} instead of Spawncount and show me your results. :P
Not sure I understand what you mean.. Something like this?
Code: Select all
Sub Main
/declare X int local 0
/declare Y int local -660
/declare FirstID int local 0
/declare CurrentID int local 0
/declare Counter int local 1
/varset FirstID ${Spawn[npc loc ${X} ${Y} radius 50].ID}
:Loop
/varset CurrentID ${Spawn[id ${FirstID}].NearestSpawn[${Counter},npc loc ${X} ${Y} radius 50].ID}
/if (${CurrentID}) {
/varcalc Counter ${Counter}+1
/goto :Loop
}
/mqlog Counter:${Counter}
/mqlog SpawnCount:${SpawnCount[npc loc ${X} ${Y} radius 50]}
/return
Code: Select all
[08/03/2004 00:31:15] Counter:8
[08/03/2004 00:31:15] SpawnCount:8
-
Drumstix42
- a grimling bloodguard

- Posts: 808
- Joined: Mon May 03, 2004 4:25 pm
Post
by Drumstix42 » Mon Aug 02, 2004 6:46 pm
Tuna already said the count works fine, but listing the mobs correctly is the problem.
-
blueninja
- a grimling bloodguard

- Posts: 541
- Joined: Thu Aug 28, 2003 7:03 am
- Location: Göteborg, Sweden
Post
by blueninja » Mon Aug 02, 2004 7:24 pm
Drumstix42 wrote:Tuna already said the count works fine, but listing the mobs correctly is the problem.
Oh ok.. Take a look at this then..
Code: Select all
Sub Main
/declare X int local 0
/declare Y int local -660
/declare FirstID int local 0
/declare CurrentID int local 0
/declare Counter int local 1
/varset FirstID ${Spawn[npc loc ${X} ${Y} radius 50].ID}
/echo FirstMob: ${Spawn[id ${FirstID}].CleanName}
:Loop
/varset CurrentID ${Spawn[id ${FirstID}].NearestSpawn[${Counter},npc loc ${X} ${Y} radius 50].ID}
/if (${CurrentID}) {
/echo More Mobs: ${Spawn[id ${CurrentID}].CleanName}
/varcalc Counter ${Counter}+1
/goto :Loop
}
/return
-
Tuna
- a lesser mummy

- Posts: 68
- Joined: Mon Jul 21, 2003 4:10 pm
Post
by Tuna » Mon Aug 02, 2004 7:47 pm
Excellent!
Here are my slight mods to your code:
Code: Select all
#turbo 30
Sub Main
/declare X int local -761
/declare Y int local -1167
/declare R int local 100
/declare FirstID int local 0
/declare CurrentID int local 0
/declare Counter int local 1
/echo Checking {Spawn[npc loc ${X} ${Y} radius ${R}].ID}
/varset FirstID ${Spawn[npc loc ${X} ${Y} radius ${R}].ID}
/if (${FirstID}<=0) {
/echo None found at ${X},${Y}
/return
}
/echo FirstMob: ${Spawn[id ${FirstID}].CleanName}
:Loop
/varset CurrentID ${Spawn[id ${FirstID}].NearestSpawn[${Counter},npc loc ${X} ${Y} radius ${R}].ID}
/if (${CurrentID}) {
/echo More Mobs: ${Spawn[id ${CurrentID}].CleanName}
/varcalc Counter ${Counter}+1
/goto :Loop
}
/return