• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved C++// MONSTERS THAT CAN'T BE BLOCKED THE SPAWN

silveralol

Advanced OT User
Joined
Mar 16, 2010
Messages
1,484
Solutions
9
Reaction score
217
Hello everyone!
then, I'm trying make a functions to check if the monster have the flag "isCannotBlock"...
I've made some modifications in tfs 1.2 to try make it work
I already do the part of the monster.cpp and monsters.cpp about the flag
then in spawn.cpp
I've made it:
Code:
void Spawn::checkSpawn(Monster* monster)
{
    checkSpawnEvent = 0;

    cleanup();

    uint32_t spawnCount = 0;

    for (auto& it : spawnMap) {
        uint32_t spawnId = it.first;
        if (spawnedMap.find(spawnId) != spawnedMap.end()) {
            continue;
        }

        spawnBlock_t& sb = it.second;
        if (OTSYS_TIME() >= sb.lastSpawn + sb.interval) {
            if (findPlayer(sb.pos) || !monster->isCannotBlock()) {
                sb.lastSpawn = OTSYS_TIME();
                continue;
            }

            spawnMonster(spawnId, sb.mType, sb.pos, sb.direction);
            if (++spawnCount >= static_cast<uint32_t>(g_config.getNumber(ConfigManager::RATE_SPAWN))) {
                break;
            }
        }
    }

    if (spawnedMap.size() < spawnMap.size()) {
        checkSpawnEvent = g_scheduler.addEvent(createSchedulerTask(getInterval(), std::bind(&Spawn::checkSpawn, this)));
    }
}
I use "Monster* monster" in the function to "try" use check the flag
in line:
Code:
if (findPlayer(sb.pos) || !monster->isCannotBlock()) {
but when I try compile get a error:
Code:
Error    1    error C2064: term does not evaluate to a function taking 1 arguments (..\src\spawn.cpp)    C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\functional    1149    1    theforgottenserver
the function checkSpawn(Monster* monster) is already changed in spawn.h with this:
Code:
void checkSpawn(Monster* monster);
then, I don't know what I do to resolve the error and make the functions work, what I want is like the tibia global system, that you can't block the spawn of some monsters, then my idea to do it easily is using flags, here one exemple of the use of the flags that is nice...
https://otland.net/threads/passive-monsters-attack-when-attacked.232475/
 
You must pass a Monster object to the function checkSpawn if you added an argument for it (I suggest that you remove this). Why aren't you just accessing the data member through sb.mType?
Code:
if (!sb.mType->someName || findPlayer(sb.pos)) {
 
Last edited:
You must pass a Monster object to the function checkSpawn, and why aren't you just accessing the data member through sb.mType?
Code:
if (!sb.mType->someName || findPlayer(sb.pos)) {
edit: Testing, removed the param from the function CheckSpawn(), change the line
Code:
if (findPlayer(sb.pos) || !monster->isCannotBlock()) {
for
Code:
if (!sb.mType->isCannotBlock || findPlayer(sb.pos)) {
edit 2: I tested but the player still blocking the respawn of the monster @Ninja
 
Last edited:
Back
Top