Tio Akima 74 Posted January 5, 2020 (edited) guys, I got the coordinate (xy) and ID of a target in my script I used getunits () to get the ID of this target and put it inside an array. .@count = getunits((BL_MOB | BL_PC), .@units, 1, .@m$,.@x ,.@y ,.@x ,.@y ); Now I'm trying to get the ID of the surrounding mobs that are 3 or 4 cells away. Does anyone know an automated way to do this? Is there a script function that makes this check circle around the target? I know that in source it is possible to do this using foreach in script I don't know maybe a special for () to check the cells as in the image: the idea is to place the found targets in the array image: https://imgur.com/JAm43aV Edited January 5, 2020 by Tio Akima Quote Share this post Link to post Share on other sites
1 meko 170 Posted January 5, 2020 // set the unit ID of the target .@target_id = XXXXX; // get the location of the target (change TYPE to PC/MOB/...) getmapxy(.@map$, .@x, .@y, UNITTYPE_{{TYPE}}, .@target_id); // get all mobs within a 3 cell radius around the target .@count = getunits(BL_MOB, .@units[0], false, .@map$, max(0, .@x - 3), max(0, .@y - 3), .@x + 3, .@y + 3); // iterate over the mob units for (.@i = 0; .@i < .@count; ++.@i) { .@unit = .@units[.@i]; // ... do something with your .@unit } 1 Tio Akima reacted to this Quote Share this post Link to post Share on other sites
0 Tio Akima 74 Posted January 5, 2020 1 hour ago, meko said: // get the unit ID of the target .@target_id = XXXXX; // get the location of the target (change TYPE to PC/MOB/...) getmapxy(.@map$, .@x, .@y, UNITTYPE_{{TYPE}}, .@target_id); // get all mobs within a 3 cell radius around the target .@count = getunits(BL_MOB, .@units[0], -1, .@map$, max(0, .@x - 3), max(0, .@y - 3), .@x + 3, .@y + 3); // iterate over the mob units for (.@i = 0; .@i < .@count; ++.@i) { .@unit = .@units[.@i]; // ... do something with your .@unit } // get the unit ID of the target .@target_id = XXXXX; // get the location of the target (change TYPE to PC/MOB/...) getmapxy(.@map$, .@x, .@y, UNITTYPE_{{TYPE}}, .@target_id); // get all mobs within a 3 cell radius around the target .@count = getunits(BL_MOB, .@units[0], -1, .@map$, max(0, .@x - 3), max(0, .@y - 3), .@x + 3, .@y + 3); // iterate over the mob units for (.@i = 0; .@i < .@count; ++.@i) { .@unit = .@units[.@i]; // ... do something with your .@unit } wow! nice getunit ... worked perfectly meko ... Thanks! topic solved ❤️ Quote Share this post Link to post Share on other sites
guys,
I got the coordinate (xy) and ID of a target in my script
I used getunits () to get the ID of this target and put it inside an array.
.@count = getunits((BL_MOB | BL_PC), .@units, 1, .@m$,.@x ,.@y ,.@x ,.@y );
Now I'm trying to get the ID of the surrounding mobs that are 3 or 4 cells away.
Does anyone know an automated way to do this? Is there a script function that makes this check circle around the target?
I know that in source it is possible to do this using foreach
in script I don't know
maybe a special for () to check the cells as in the image:
the idea is to place the found targets in the array
image:
https://imgur.com/JAm43aV
Share this post
Link to post
Share on other sites