Jump to content
  • 0
Tio Akima

search for nearby targets

Question

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 by Tio Akima

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 1
// 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
}

 

Share this post


Link to post
Share on other sites
  • 0
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 ❤️ 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.