Unfortunately it doesn't work
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 ...
in which file?in creaturescripts
i don't have creature.xml file, its otservbrShow me your creature XML
i delete from 495 to 513 lines and nothing :/maybe this part
otservbr-global/src/creatures/creature.cpp at afd9b13f49b23de84bb525f145390e23afc1db24 · opentibiabr/otservbr-global
OTServBR-Global datapack was migrated to Canary repository: https://github.com/opentibiabr/canary - opentibiabr/otservbr-globalgithub.com
L510-513 seems unrelated to your problem.i delete from 495 to 513 lines and nothing :/
Unfortunately it doesn't workL510-513 seems unrelated to your problem.
L495-508 is what you should remove.
have you re-compiled after removing those lines?
I don't know why, but even when I delete the whole file, nothing changesL510-513 seems unrelated to your problem.
L495-508 is what you should remove.
have you re-compiled after removing those lines?
Yes, you need to compile sources after editing.After changes i must compile new engine?
It work, but my special summon like Thundergiant also does not teleport but should teleportYes, you need to compile sources after editing.
It work, but my special summon like Thundergiant also does not teleport but should teleport
if (summon->getName() == 'Thundergiant') {
// Apply code for Thundergiant
}
// Might be more efficient to do:
if (summon->getRace() == 219) {
// Apply code for raceid 219
}
C++:if (summon->getName() == 'Thundergiant') { // Apply code for Thundergiant } // Might be more efficient to do: if (summon->getRace() == 219) { // Apply code for raceid 219 }
for (Creature* summon : summons) {
// apply code here, etc: summon->getName()
}
for (Creature* summon : summons) {
if (!summons.empty() && summon->getName() == "sorcerer familiar" || "palladin familiar" || "knight familiar" || "druid familiar"){
//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) {
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);
}
}
}
Just an observation, you got "palladin" instead "paladin"What is wrong here? the engine compiles but still summons created by "utevo res" teleports to pz
C++:for (Creature* summon : summons) { if (!summons.empty() && summon->getName() == "sorcerer familiar" || "palladin familiar" || "knight familiar" || "druid familiar"){ //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) { 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); } } }
for (Creature* summon : summons) { if (!summons.empty() && summon->getName() == "sorcerer familiar" || "palladin familiar" || "knight familiar" || "druid familiar"){ //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) { 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); } } }
for (Creature* summon : summons) {
if (!summons.empty() && summon->getName() == "sorcerer familiar" || "palladin familiar" || "knight familiar" || "druid familiar"){
//check if any of our summons is out of range (+/- 2 floors or 30 tiles away)
std::forward_list<Creature*> despawnList;
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);
}
}
}
Unfortunately it doesn't workYou loop through all summons again to teleport inside the all summons loop, so all summons will teleport if one summons is named what youve specified.
Try this, should only teleport summons named what youve specified
C++:for (Creature* summon : summons) { if (!summons.empty() && summon->getName() == "sorcerer familiar" || "palladin familiar" || "knight familiar" || "druid familiar"){ //check if any of our summons is out of range (+/- 2 floors or 30 tiles away) std::forward_list<Creature*> despawnList; 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); } } }
**Not really sure what the despawnList is, doesnt seem to do anything?? But left it in anyway.