search for nearby targets

Tio Akima

New member
Messages
349
Points
0
Age
36
Discord
TioAkima#0636
Github
Tio Akima
Emulator
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

 
Last edited by a moderator:
Code:
// 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
}
 
Last edited by a moderator:
// 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 ❤️ 

 
Back
Top