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

RevScripts TFS 1.5 Downgrade Nekiro - Fast Spawn PlayerOnline

Forkz

Intermediate OT User
Joined
Jun 29, 2020
Messages
528
Solutions
16
Reaction score
129
Hi otlanders,

I would like to add a "configurable" script so I can edit how many times the Spawn rate is on the server, for example if there are 0 to 50 players online it will be 1x, if there are 51~100 it will be 2x and so on.
 
Hi otlanders,

I would like to add a "configurable" script so I can edit how many times the Spawn rate is on the server, for example if there are 0 to 50 players online it will be 1x, if there are 51~100 it will be 2x and so on.
Try modyfying function void Spawn::checkSpawn() inside your c++ code
LUA:
void Spawn::checkSpawn()
{
    checkSpawnEvent = 0;
    cleanup();

    uint32_t spawnCount = 0;
    uint32_t playerCount = g_game.getPlayersOnline(); // Get number of online players

    // Dynamic scaling factors
    uint32_t baseSpawnRate = g_config.getNumber(ConfigManager::RATE_SPAWN);; // Minimum spawn rate from config
    uint32_t maxSpawnRate = 3; // Maximum spawn rate 
    uint32_t maxPlayers = 100; // Number of players needed for max spawn rate (adjustable)

    uint32_t dynamicSpawnLimit = baseSpawnRate + ((playerCount * (maxSpawnRate - baseSpawnRate)) / maxPlayers);
    dynamicSpawnLimit = std::max(baseSpawnRate, std::min(dynamicSpawnLimit, maxSpawnRate));

    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 (!spawnMonster(spawnId, sb)) {
                sb.lastSpawn = OTSYS_TIME();
                continue;
            }

            if (++spawnCount >= dynamicSpawnLimit) {
                break;
            }
        }
    }

    if (spawnedMap.size() < spawnMap.size()) {
        checkSpawnEvent = g_scheduler.addEvent(createSchedulerTask(getInterval(), std::bind(&Spawn::checkSpawn, this)));
    }

    std::cout << "[DynamicSpawn] Online Players: " << playerCount
              << ", Adjusted Spawn Rate: " << dynamicSpawnLimit
              << " (Max: " << maxSpawnRate << ")" << std::endl;
}

Didn't tested it since i don't have working server
 
Try modyfying function void Spawn::checkSpawn() inside your c++ code
LUA:
void Spawn::checkSpawn()
{
    checkSpawnEvent = 0;
    cleanup();

    uint32_t spawnCount = 0;
    uint32_t playerCount = g_game.getPlayersOnline(); // Get number of online players

    // Dynamic scaling factors
    uint32_t baseSpawnRate = g_config.getNumber(ConfigManager::RATE_SPAWN);; // Minimum spawn rate from config
    uint32_t maxSpawnRate = 3; // Maximum spawn rate
    uint32_t maxPlayers = 100; // Number of players needed for max spawn rate (adjustable)

    uint32_t dynamicSpawnLimit = baseSpawnRate + ((playerCount * (maxSpawnRate - baseSpawnRate)) / maxPlayers);
    dynamicSpawnLimit = std::max(baseSpawnRate, std::min(dynamicSpawnLimit, maxSpawnRate));

    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 (!spawnMonster(spawnId, sb)) {
                sb.lastSpawn = OTSYS_TIME();
                continue;
            }

            if (++spawnCount >= dynamicSpawnLimit) {
                break;
            }
        }
    }

    if (spawnedMap.size() < spawnMap.size()) {
        checkSpawnEvent = g_scheduler.addEvent(createSchedulerTask(getInterval(), std::bind(&Spawn::checkSpawn, this)));
    }

    std::cout << "[DynamicSpawn] Online Players: " << playerCount
              << ", Adjusted Spawn Rate: " << dynamicSpawnLimit
              << " (Max: " << maxSpawnRate << ")" << std::endl;
}

Didn't tested it since i don't have working server
I will take the test and come back with the results.
 
Back
Top