Skip to content

Instantly share code, notes, and snippets.

@ultraviolet-jordan
Created October 26, 2023 23:49
Show Gist options
  • Save ultraviolet-jordan/142f23d639d5075652383bc8dd4a2ca2 to your computer and use it in GitHub Desktop.
Save ultraviolet-jordan/142f23d639d5075652383bc8dd4a2ca2 to your computer and use it in GitHub Desktop.
[debugproc,test]
def_int $radius = 1; // 1, 2 or 3
def_coord $coord = coord;
def_int $x = coordx($coord);
def_int $z = coordz($coord);
def_int $centerX = divide($x, pow(2, 3));
def_int $centerZ = divide($z, pow(2, 3));
def_int $maxX = add($centerX, $radius);
def_int $minX = sub($centerX, $radius);
def_int $totalCount = 0;
while ($maxX >= $minX) {
def_int $zoneX = multiply($maxX, pow(2, 3));
def_int $maxZ = add($centerZ, $radius);
def_int $minZ = sub($centerZ, $radius);
while ($maxZ >= $minZ) {
def_int $zoneZ = multiply($maxZ, pow(2, 3));
def_int $dx = sub($zoneX, $x);
def_int $dz = sub($zoneZ, $z);
def_coord $zoneCoord = movecoord(coord, $dx, 0, $dz);
npc_findallzone($zoneCoord);
while (npc_findnext = true) {
npc_anim(emote_dance, 0);
$totalCount = add($totalCount, 1);
}
$maxZ = sub($maxZ, 1);
}
$maxX = sub($maxX, 1);
}
mes("Total counted npcs were: <tostring($totalCount)>");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment