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

C++ World Light Colors

Aoxomoxoa

Dev
Joined
Jun 23, 2020
Messages
95
Solutions
1
Reaction score
54
Location
USA
GitHub
TheAoxomoxoa
Hello,

I'm searching through game.cpp looking for variables targeting the day/night/sunset/sunrise colors within TFS but can only seem to find timers. Is there any explicit way to change the colors of day/night in the game?

All that I have found is this:

C++:
void Game::checkLight()
{
    g_scheduler.addEvent(createSchedulerTask(EVENT_LIGHTINTERVAL, std::bind(&Game::checkLight, this)));

    lightHour += lightHourDelta;

    if (lightHour > 1440) {
        lightHour -= 1440;
    }

    if (std::abs(lightHour - SUNRISE) < 2 * lightHourDelta) {
        lightState = LIGHT_STATE_SUNRISE;
    } else if (std::abs(lightHour - SUNSET) < 2 * lightHourDelta) {
        lightState = LIGHT_STATE_SUNSET;
    }

    int32_t newLightLevel = lightLevel;
    bool lightChange = false;

    switch (lightState) {
        case LIGHT_STATE_SUNRISE: {
            newLightLevel += (LIGHT_LEVEL_DAY - LIGHT_LEVEL_NIGHT) / 30;
            lightChange = true;
            break;
        }
        case LIGHT_STATE_SUNSET: {
            newLightLevel -= (LIGHT_LEVEL_DAY - LIGHT_LEVEL_NIGHT) / 30;
            lightChange = true;
            break;
        }
        default:
            break;
    }

    if (newLightLevel <= LIGHT_LEVEL_NIGHT) {
        lightLevel = LIGHT_LEVEL_NIGHT;
        lightState = LIGHT_STATE_NIGHT;
    } else if (newLightLevel >= LIGHT_LEVEL_DAY) {
        lightLevel = LIGHT_LEVEL_DAY;
        lightState = LIGHT_STATE_DAY;
    } else {
        lightLevel = newLightLevel;
    }

    if (lightChange) {
        LightInfo lightInfo = getWorldLightInfo();

        for (const auto& it : players) {
            it.second->sendWorldLight(lightInfo);
        }
    }
}

LightInfo Game::getWorldLightInfo() const
{
    return {lightLevel, 0xD7};
}

Is this the controller of the light color?
C++:
    return {lightLevel, 0xD7};
Where 0xD7 = 215?

If so, how could I seperate that color into different variables for day / night / sunrise / sunset color?
 
Solution
Not sure what you linked there but I don't think it has anything remotely to do with the day/night cycle.
Post automatically merged:

I found this in game.h, what exactly do these values mean?

C++:
        static constexpr int32_t LIGHT_LEVEL_DAY = 250;
        static constexpr int32_t LIGHT_LEVEL_NIGHT = 40;
        static constexpr int32_t SUNSET = 1305;
        static constexpr int32_t SUNRISE = 430;
 
Last edited:
these are my guesses.

static constexpr int32_t LIGHT_LEVEL_DAY = 250; -- how bright/how much spread light emits
static constexpr int32_t LIGHT_LEVEL_NIGHT = 40; -- same as above
static constexpr int32_t SUNSET = 1305; -- tibia time value = at what time sunset is going to begin
static constexpr int32_t SUNRISE = 430; -- same as above
 
these are my guesses.

static constexpr int32_t LIGHT_LEVEL_DAY = 250; -- how bright/how much spread light emits
static constexpr int32_t LIGHT_LEVEL_NIGHT = 40; -- same as above
static constexpr int32_t SUNSET = 1305; -- tibia time value = at what time sunset is going to begin
static constexpr int32_t SUNRISE = 430; -- same as above

So essentially there is no color control, it's just the shade of the day light? As in, like a white light that gets darker and brighter?
 
Solution
Back
Top