roriscrave
Advanced OT User
- Joined
- Dec 7, 2011
- Messages
- 1,210
- Solutions
- 35
- Reaction score
- 206
const Tile* creatureTile = creature->getTile();
if (creatureTile) {
if (!creatureTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
g_game.internalTeleport(this, creature->getPosition());
g_game.addMagicEffect(creature->getPosition(), CONST_ME_POFF);
} else {
g_game.removeCreature(this, true);
}...
thx for help, i'm missing more one thing?You have 2 errors there.
-On the first else a ) is missing, right after TELEPORT_PLAYER_SUMMONS)
-TELEPORT_PLAYER_SUMMONS and TELEPORT_ALL_SUMMONS are not defined on configmanager (cpp & h)
boolean[TELEPORT_PLAYER_SUMMONS] = getGlobalBoolean(L, "teleportPlayerSummons", false);
boolean[TELEPORT_ALL_SUMMONS] = getGlobalBoolean(L, "teleportAllSummons", false);
TELEPORT_PLAYER_SUMMONS,
TELEPORT_ALL_SUMMONS,
extern ConfigManager g_config;
partially worked:PlaceConfigManager::
in front of the identifiers giving you errors.
For example:ConfigManager::TELEPORT_ALL_SUMMONS
const Tile* creatureTile = creature->getTile();
if (creatureTile) {
if (!creatureTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
g_game.internalTeleport(this, creature->getPosition());
g_game.addMagicEffect(creature->getPosition(), CONST_ME_POFF);
} else {
g_game.removeCreature(this, true);
}
}
if (getMaster() == creature) {
//teleportAllSummons
if (g_config.getBoolean(ConfigManager::TELEPORT_ALL_SUMMONS)) {
const Tile* creatureTile = creature->getTile();
if (creatureTile) {
if (!creatureTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
g_game.internalTeleport(this, creature->getPosition());
g_game.addMagicEffect(creature->getPosition(), CONST_ME_POFF);
} else {
g_game.removeCreature(this, true);
}
}
} else if (g_config.getBoolean(ConfigManager::TELEPORT_PLAYER_SUMMONS)) {
Player* player = creature->getPlayer();
if (player) {
g_game.internalTeleport(this, player->getPosition());
}
} else {
//fim
//Take random steps and only use defense abilities (e.g. heal) until its master comes back
isMasterInRange = false;
}
}
void Creature::onCreatureMove(Creature* creature, const Tile* newTile, const Position& newPos,
const Tile* oldTile, const Position& oldPos, bool teleport)
{
if (creature == this) {
lastStep = OTSYS_TIME();
lastStepCost = 1;
if (!teleport) {
if (oldPos.z != newPos.z) {
//floor change extra cost
lastStepCost = 2;
} else if (Position::getDistanceX(newPos, oldPos) >= 1 && Position::getDistanceY(newPos, oldPos) >= 1) {
//diagonal extra cost
lastStepCost = 3;
}
} else {
stopEventWalk();
}
if (!summons.empty()) {
// Check if any of our summons is out of range (+/- 1 floors or 10 tiles away)
for (Creature* summon : summons) {
const Position& summonPos = summon->getPosition();
if (Position::getDistanceZ(newPos, summonPos) >= 1 ||
(std::max<int32_t>(Position::getDistanceX(newPos, summonPos), Position::getDistanceY(newPos, summonPos)) > 10)) {
// Check if the target position is a protection zone
const Tile* targetTile = g_game.map.getTile(newPos);
if (!targetTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
// Teleport the out-of-range summon back to the master's position
g_game.internalTeleport(summon, newPos);
g_game.addMagicEffect(newPos, CONST_ME_TELEPORT); // Optional visual effect
}
else {
stopEventWalk();
}
}
}
}