Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The character does not hide behind the item with flag "top" when moving #13

Open
drewnydrzew opened this issue Feb 20, 2024 · 1 comment

Comments

@drewnydrzew
Copy link

I created 2 items with the top flag. When moving between them, a character appears "for a moment" and then hides behind the "top" sprite.

otclient_x64_55sbMFQpuQ

is it supposed to be like this or is it a bug?

`void Tile::drawCreatures(const Point& dest, LightView* lightView)
{
    if (m_fill != Color::alpha)
        return;
    if (m_topDraws < m_topCorrection)
        return;

    // walking creatures
    for (const CreaturePtr& creature : m_walkingCreatures) {
        if (creature->isHidden())
            continue;
        Point creatureDest(dest.x + ((creature->getPrewalkingPosition().x - m_position.x) * g_sprites.spriteSize() - m_drawElevation * g_sprites.getOffsetFactor()),
            dest.y + ((creature->getPrewalkingPosition().y - m_position.y) * g_sprites.spriteSize() - m_drawElevation * g_sprites.getOffsetFactor()));
        creature->draw(creatureDest, true, lightView);
    }

    // creatures
    std::vector<CreaturePtr> creaturesToDraw;
    int limit = g_adaptiveRenderer.creaturesLimit();
    for (auto& thing : m_things) {
        if (!thing->isCreature() || thing->isHidden())
            continue;
        if (limit-- <= 0)
            break;
        CreaturePtr creature = thing->static_self_cast<Creature>();
        if (!creature || creature->isWalking())
            continue;
        creature->draw(dest - m_drawElevation * g_sprites.getOffsetFactor(), true, lightView);
    }
}
void Tile::drawTop(const Point& dest, LightView* lightView)
{
    if (m_fill != Color::alpha)
        return;
    if (m_topDraws++ < m_topCorrection)
        return;

    // walking creatures
    for (const CreaturePtr& creature : m_walkingCreatures) {
        if (creature->isHidden())
            continue;
        Point creatureDest(dest.x + ((creature->getPrewalkingPosition().x - m_position.x) * g_sprites.spriteSize() - m_drawElevation * g_sprites.getOffsetFactor()),
            dest.y + ((creature->getPrewalkingPosition().y - m_position.y) * g_sprites.spriteSize() - m_drawElevation * g_sprites.getOffsetFactor()));
        creature->draw(creatureDest, true, lightView);
    }

    // creatures
    std::vector<CreaturePtr> creaturesToDraw;
    int limit = g_adaptiveRenderer.creaturesLimit();
    for (auto& thing : m_things) {
        if (!thing->isCreature() || thing->isHidden())
            continue;
        if (limit-- <= 0)
            break;
        CreaturePtr creature = thing->static_self_cast<Creature>();
        if (!creature || creature->isWalking())
            continue;
        creature->draw(dest - m_drawElevation * g_sprites.getOffsetFactor(), true, lightView);
    }

    // effects
    limit = std::min<int>((int)m_effects.size() - 1, g_adaptiveRenderer.effetsLimit());
    for (int i = limit; i >= 0; --i) {
        if (m_effects[i]->isHidden())
            continue;
        m_effects[i]->draw(dest - m_drawElevation * g_sprites.getOffsetFactor(), m_position.x - g_map.getCentralPosition().x, m_position.y - g_map.getCentralPosition().y, true, lightView);
    }

    // top
    for (const ThingPtr& thing : m_things) {
        if (!thing->isOnTop() || thing->isHidden())
            continue;
        thing->draw(dest, true, lightView);
    }
}`

under the comment "// walking creatures" there is the code responsible for this. there is the same code in 2 functions.

@Wirless
Copy link

Wirless commented Nov 16, 2024

the idea of item on top is to Cover anything under neath it. you can change it in spr dat flags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants