• 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++ light on floor

bpm91

Intermediate OT User
Joined
May 23, 2019
Messages
958
Solutions
7
Reaction score
135
Location
Brazil
YouTube
caruniawikibr
In global tibia we can observe the light that enters the lower floor of the cave, however how can we do this in a global way?
tfs 1.5

1716648811931.png
Post automatically merged:

Does anyone know how to make the light penetrate downstairs? from level 8 to 7 for example
 
Last edited:
In global tibia we can observe the light that enters the lower floor of the cave, however how can we do this in a global way?
tfs 1.5

View attachment 84905
Post automatically merged:

Does anyone know how to make the light penetrate downstairs? from level 8 to 7 for example
Are you using OTC?

This is a client sided feature with cipsoft official game clients I believe.
 
Theoretically, you would do as follows:
--------------------------------------------------------------
TFS 1.5
"Tile" Class:
C++:
// tile.h
class Tile {
public:
    Tile(bool allowLightToPass = false);
    bool allowsLightToPass() const { return allowLightToPass; }

private:
    bool allowLightToPass;
};
"Tile::Tile" Function:
C++:
// tile.cpp
Tile::Tile(uint16_t id) {
    ItemType& it = Item::items[id];
    allowLightToPass = it.allowLightToPass;
}
"Game::PropagateLight" Function:
C++:
// game.cpp
void Game::propagateLight(const Position& pos, LightInfo& lightInfo) {
    Tile* tile = map->getTile(pos);
    if (tile && tile->allowsLightToPass()) {
        // Propagate light to the floor below
        Position belowPos = pos;
        belowPos.z += 1;
        Tile* belowTile = map->getTile(belowPos);
        if (belowTile) {
            belowTile->applyLight(lightInfo);
        }
    }
}
--------------------------------------------------------------
OTC V8
"Map::drawLight" Function:
C++:
// map.cpp
void Map::drawLight(const LightInfo& lightInfo) {
    for (const auto& tile : tiles) {
        if (tile->allowsLightToPass()) {
            // Draw light on the current floor
            drawTileLight(tile, lightInfo);

            // Draw light on the floor below
            Position belowPos = tile->getPosition();
            belowPos.z += 1;
            Tile* belowTile = getTile(belowPos);
            if (belowTile) {
                drawTileLight(belowTile, lightInfo);
            }
        }
    }
}

void Map::drawTileLight(Tile* tile, const LightInfo& lightInfo) {
    // Custom drawing logic for a tile
    if (!tile) return;

    // Determine the light intensity and color
    int lightLevel = lightInfo.level;
    int lightColor = lightInfo.color;

    // Adjust light based on the position and level
    int x = tile->getPosition().x;
    int y = tile->getPosition().y;
    int z = tile->getPosition().z;

    // Draw the light
    g_drawLight(x, y, z, lightLevel, lightColor);
}
--------------------------------------------------------------
Finally, being able to add the function to various items via simply inputting the key in items.xml:
XML:
<!-- items.xml -->
<item id="12345" name="light-permeable tile" allowLightToPass="true" />
--------------------------------------------------------------
Though, I haven't tested it obviously, but it may give you an idea.
 
Last edited:
Though, I haven't tested it obviously, but it may give you an idea.
Looks like AI hallucination. Code above for sure will not work, as 'programmer' thought that OTCv8 and TFS 1.5 are parts of same code and share C++ variables.
There is nothing to change on server side. All items (from floor above = ground level) and items information from Tibia.dat are already in OTCv8. If it does not render light from level above, it's probably not implemented in client.
 
ty bro i will try
Post automatically merged:

Looks like AI hallucination. Code above for sure will not work, as 'programmer' thought that OTCv8 and TFS 1.5 are parts of same code and share C++ variables.
There is nothing to change on server side. All items (from floor above = ground level) and items information from Tibia.dat are already in OTCv8. If it does not render light from level above, it's probably not implemented in client.
Any idea ?
 
Back
Top