• 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++ Customized Elevation

iluargrott

New Member
Joined
Sep 3, 2020
Messages
7
Reaction score
1
Hi! I'm trying to make "Has elevation" option just get my character and items get only UP effect (y pos), not diagonal (x+y). Where shoulda I edit on source ?
Also for Floorchanging on upstairs.. When player goes upstairs/downstairs theres an diagonal change, want to make it straight for the direction...
Any help? º~º
 
can i bump this old thread?

im facing the same issue

cant find the function to draw this on client. not so worried about the flloorchanging thing, tho.
 
fixed it myself, in case somebody else needs this:
edit otclient src/tile.cpp

replace this:

C++:
if(drawFlags & Otc::DrawItems) {
        // now common items in reverse order
        for(auto it = m_things.rbegin(); it != m_things.rend(); ++it) {
            const ThingPtr& thing = *it;
            if(thing->isOnTop() || thing->isOnBottom() || thing->isGroundBorder() || thing->isGround() || thing->isCreature())
                break;
            thing->draw(dest - m_drawElevation*scaleFactor, scaleFactor, animate, lightView);
            m_drawElevation += thing->getElevation();
            if(m_drawElevation > Otc::MAX_ELEVATION)
                m_drawElevation = Otc::MAX_ELEVATION;
        }
    }

with this:
C++:
int constX = 1;  //i will use this in both scenarios, items and creatures
    for (auto it = m_things.rbegin(); it != m_things.rend(); ++it) {
        const ThingPtr& thing = *it;
        if (thing->isOnTop() || thing->isOnBottom() || thing->isGroundBorder() || thing->isGround() || thing->isCreature())
            break;
        thing->draw(Point(dest.x + constX, dest.y - m_drawElevation * scaleFactor), scaleFactor, animate, lightView);
        m_drawElevation += thing->getElevation();
        if (m_drawElevation > Otc::MAX_ELEVATION)
            m_drawElevation = Otc::MAX_ELEVATION;
    }

just below, replace this :

C++:
// creatures
    if(drawFlags & Otc::DrawCreatures) {
        if(animate) {
            for(const CreaturePtr& creature : m_walkingCreatures) {
                creature->draw(Point(dest.x + ((creature->getPosition().x - m_position.x)*Otc::TILE_PIXELS - m_drawElevation)*scaleFactor,
                                     dest.y + ((creature->getPosition().y - m_position.y)*Otc::TILE_PIXELS - m_drawElevation)*scaleFactor), scaleFactor, animate, lightView);
            }
        }


        for(auto it = m_things.rbegin(); it != m_things.rend(); ++it) {
            const ThingPtr& thing = *it;
            if(!thing->isCreature())
                continue;
            CreaturePtr creature = thing->static_self_cast<Creature>();
            if(creature && (!creature->isWalking() || !animate))
                creature->draw(dest - m_drawElevation*scaleFactor, scaleFactor, animate, lightView);
        }
    }

with this :

C++:
// creatures
    if (drawFlags & Otc::DrawCreatures && animate) {
        for (const CreaturePtr& creature : m_walkingCreatures) {
            creature->draw(Point(dest.x + ((creature->getPosition().x - m_position.x) * Otc::TILE_PIXELS - m_drawElevation) * scaleFactor,
                dest.y + ((creature->getPosition().y - m_position.y) * Otc::TILE_PIXELS - m_drawElevation) * scaleFactor), scaleFactor, animate, lightView);
        }
    }
    for (auto it = m_things.rbegin(); it != m_things.rend(); ++it) {
        const ThingPtr& thing = *it;
        if (!thing->isCreature())
            continue;
        CreaturePtr creature = thing->static_self_cast<Creature>();
        if (creature && (!creature->isWalking() || !animate)) {
            creature->draw(Point(dest.x + constX, dest.y + ((creature->getPosition().y - m_position.y) * Otc::TILE_PIXELS - m_drawElevation) * scaleFactor), scaleFactor, animate, lightView);
        }
    }

it just overwrites value with constX value, so you can define horizontal movement there.

aaaaaaaa.pngand then compile. good luck!

i hope this helps somebody else..
 
Back
Top