• 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!

TFS 1.X+ How to Disable Disappear Range From Monster

henkas

Well-Known Member
Joined
Jul 8, 2015
Messages
993
Solutions
5
Reaction score
55
TFS 1.2
Client Version 8.60
Hot to disable disappear range from specific monster, that monster could travel big distances from his spawn point, without disappearing
 
Solution
TFS 1.2
Client Version 8.60
Hot to disable disappear range from specific monster, that monster could travel big distances from his spawn point, without disappearing

under otland/forgottenserver add
C++:
bool noDespawn = false;

under otland/forgottenserver add
C++:
} else if (strcasecmp(attrName, "nodespawn") == 0) {
    mType->info.noDespawn = attr.as_bool();
}

replace otland/forgottenserver with this:

C++:
bool Monster::isInSpawnRange(const Position& pos) const
{
    if (!spawn) {
        return true;
    }

    if (mType->info.noDespawn) {
        return true;
    }

    if (Monster::despawnRadius == 0) {
        return true;
    }

    if (!Spawns::isInZone(masterPos, Monster::despawnRadius, pos)) {...
TFS 1.2
Client Version 8.60
Hot to disable disappear range from specific monster, that monster could travel big distances from his spawn point, without disappearing

under otland/forgottenserver add
C++:
bool noDespawn = false;

under otland/forgottenserver add
C++:
} else if (strcasecmp(attrName, "nodespawn") == 0) {
    mType->info.noDespawn = attr.as_bool();
}

replace otland/forgottenserver with this:

C++:
bool Monster::isInSpawnRange(const Position& pos) const
{
    if (!spawn) {
        return true;
    }

    if (mType->info.noDespawn) {
        return true;
    }

    if (Monster::despawnRadius == 0) {
        return true;
    }

    if (!Spawns::isInZone(masterPos, Monster::despawnRadius, pos)) {
        return false;
    }

    if (Monster::despawnRange == 0) {
        return true;
    }

    if (Position::getDistanceZ(pos, masterPos) > Monster::despawnRange) {
        return false;
    }

    return true;
}

in your monster xml file:
XML:
<flag nodespawn="1">
 
Solution
under otland/forgottenserver add
C++:
bool noDespawn = false;

under otland/forgottenserver add
C++:
} else if (strcasecmp(attrName, "nodespawn") == 0) {
    mType->info.noDespawn = attr.as_bool();
}

replace otland/forgottenserver with this:

C++:
bool Monster::isInSpawnRange(const Position& pos) const
{
    if (!spawn) {
        return true;
    }

    if (mType->info.noDespawn) {
        return true;
    }

    if (Monster::despawnRadius == 0) {
        return true;
    }

    if (!Spawns::isInZone(masterPos, Monster::despawnRadius, pos)) {
        return false;
    }

    if (Monster::despawnRange == 0) {
        return true;
    }

    if (Position::getDistanceZ(pos, masterPos) > Monster::despawnRange) {
        return false;
    }

    return true;
}

in your monster xml file:
XML:
<flag nodespawn="1">
1>..\src\monster.cpp(1809): error C2039: 'info': is not a member of 'MonsterType'
1> c:\test\server\src\monsters.h(90): note: see declaration of 'MonsterType'
1>..\src\monster.cpp(1809): error C2228: left of '.noDespawn' must have class/struct/union
1> monsters.cpp
1> movement.cpp
1> networkmessage.cpp
1>..\src\monsters.cpp(838): error C2039: 'info': is not a member of 'MonsterType'
1> c:\test\server\src\monsters.h(90): note: see declaration of 'MonsterType'
1>..\src\monsters.cpp(838): error C2228: left of '.noDespawn' must have class/struct/union
 
1>..\src\monster.cpp(1809): error C2039: 'info': is not a member of 'MonsterType'
1> c:\test\server\src\monsters.h(90): note: see declaration of 'MonsterType'
1>..\src\monster.cpp(1809): error C2228: left of '.noDespawn' must have class/struct/union
1> monsters.cpp
1> movement.cpp
1> networkmessage.cpp
1>..\src\monsters.cpp(838): error C2039: 'info': is not a member of 'MonsterType'
1> c:\test\server\src\monsters.h(90): note: see declaration of 'MonsterType'
1>..\src\monsters.cpp(838): error C2228: left of '.noDespawn' must have class/struct/union
try chanigng mType->info to just info
 
1st one
info.noDespawn
1>..\src\monster.cpp(1809): error C2065: 'info': undeclared identifier
1>..\src\monster.cpp(1809): error C2228: left of '.noDespawn' must have class/struct/union
1> ..\src\monster.cpp(1809): note: type is 'unknown-type'
1> monsters.cpp
1> movement.cpp
1> networkmessage.cpp
1> npc.cpp
1>..\src\monsters.cpp(838): error C2065: 'info': undeclared identifier
1>..\src\monsters.cpp(838): error C2228: left of '.noDespawn' must have class/struct/union
1> ..\src\monsters.cpp(838): note: type is 'unknown-type'
 
mmmmmmmmmmmm
now i had a chance to test locally, the first solution i gave was correct (mType->info.noDespawn works for me)
are you sure you're replacing the function in monster.cpp? and not monsters.cpp?
 
older TFS 1.2 don't have MonsterInfo struct but all the variables under MonsterType.
so instead of "mType->info.noDespawn" it should be "mType->noDespawn"
If you look in the compiler output "error C2039: 'info': is not a member of 'MonsterType'" it tells you about this.
 
mmmmmmmmmmmm
now i had a chance to test locally, the first solution i gave was correct (mType->info.noDespawn works for me)
are you sure you're replacing the function in monster.cpp? and not monsters.cpp?
Yea, solution was just like Madzix said.
older TFS 1.2 don't have MonsterInfo struct but all the variables under MonsterType.
so instead of "mType->info.noDespawn" it should be "mType->noDespawn"
If you look in the compiler output "error C2039: 'info': is not a member of 'MonsterType'" it tells you about this.
Thanks.
 
Back
Top