• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Feature TFS 0.4 overspawn monsters like old tibia

its possible to apply just with some monsters? by adding a flag like <flag despawn="0"/>
----------------------EDIT UPDATE-----------------
XML:
<flag lureable="1"/>
i added this line to a monster then ot crashs

i decided to edit monsters.cpp and i found the reason of crash is here:
Code:
bool Monster::inDespawnRange(const Position& pos){

XML:
if(!spawn || mType->isLureable)
        return false;

i changed to

Code:
if(!spawn)
        return false;
   
    if(mType->isLureable)
        return false;

and now monster is lureable like that video of grolam in thais, and to work with this script

add below:
Code:
void Monster::onThink(uint32_t interval)
{

This:

Code:
if(mType->isLureable && spawn)
    {  
            spawn->removeMonster(this);
            spawn->startEvent();
            spawn = NULL;
            masterRadius = -1;
    }

and i got it, but sometimes im gettin' double monsters spawn when i lure it
 
Last edited:
does somebody has this code but for latest tfs 1.4?
C++:
bool Monster::walkToSpawn()
{
    if (walkingToSpawn || !spawn || !targetList.empty()) {
        return false;
    }

    int32_t distance = std::max<int32_t>(Position::getDistanceX(position, masterPos), Position::getDistanceY(position, masterPos));
    if (distance == 0) {
        return false;
    }

    // Check if the monster is outside the walking-to-spawn area
    const int32_t walkingToSpawnRadius = 20; // Adjust this radius as needed
    if (distance > walkingToSpawnRadius) {
        // Spawn a new monster and return false to indicate that walking to spawn is not possible
        handleOverspawn();
        return false;
    }

    listWalkDir.clear();
    if (!getPathTo(masterPos, listWalkDir, 0, std::max<int32_t>(0, distance - 5), true, true, distance)) {
        return false;
    }

    walkingToSpawn = true;
    startAutoWalk();
    return true;
}

C++:
void Monster::handleOverspawn()
{
    g_game.addMagicEffect(this->getPosition(), CONST_ME_POFF);

    if (g_config.getBoolean(ConfigManager::REMOVE_ON_DESPAWN)) {
        // If you want to remove the original creature, you can keep this part
        g_game.removeCreature(this, false);
    } else {
        // If you want to keep the original creature, spawn a new one in its place
        Monster* newMonster = new Monster(/* parameters for the new monster */);
        newMonster->setSpawn(spawn); // Set the spawn for the new monster
        newMonster->setMaster(getMaster()); // Set the master for the new monster
        // Set other necessary parameters for the new monster
        // ...

        // Add the new monster to the game
        g_game.internalAddCreature(newMonster);

        // Teleport the original creature back to its spawn point
        g_game.internalTeleport(this, masterPos);
        setIdle(true);

        // Now, both the original creature and the new one are alive
    }
}

C++:
class Monster {
public:
    // Existing function declarations...

    void setIdle(bool idle);
    bool walkToSpawn();

private:
    // Other private members...

    // Declaration for the handleOverspawn function
    void handleOverspawn();
};
 
Back
Top