if (!summons.empty()) {
//check if any of our summons is out of range (+/- 2 floors or 30 tiles away)
std::forward_list<Creature*> despawnList;
for (Creature* summon : summons) {
//check if summon name contains "familiar"
if (summon->getName().find('familiar') != std::string::npos) {
const Position& pos = summon->getPosition();
if (Position::getDistanceZ(newPos, pos) > 0 || (std::max<int32_t>(Position::getDistanceX(newPos, pos), Position::getDistanceY(newPos, pos)) > 15)) {
g_game.internalTeleport(summon, summon->getMaster()->getPosition(), true);
}
}
}
for (Creature* despawnCreature : despawnList) {
g_game.removeCreature(despawnCreature, true);
}
}