• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

C++ Cant use ladder if item or field is under it

Malek

Member
Joined
Dec 25, 2009
Messages
102
Reaction score
5
I can't use the ladder if there's something under it. Distribution OTHire

in items.otb ladder have always on top, in dat editor top 2, forceuse, didint know what can do more? someone fix this??

C++:
Thing* Game::internalGetThing(Player* player, const Position& pos, int32_t index,
    uint32_t spriteId /*= 0*/, stackPosType_t type /*= STACKPOS_NORMAL*/)
{
    if(pos.x != 0xFFFF){
        Tile* tile = getTile(pos.x, pos.y, pos.z);

        if(tile){
            /*look at*/
            if(type == STACKPOS_LOOK){
                return tile->getTopVisibleThing(player);
            }

            Thing* thing = NULL;

            /*for move operations*/
            if(type == STACKPOS_MOVE){
                Item* item = tile->getTopDownItem();
                if(item && !item->isNotMoveable())
                    thing = item;
                else
                    thing = tile->getTopVisibleCreature(player);
            }
            /*use item*/
            else if(type == STACKPOS_USE){
                thing = tile->getTopDownItem();
            }
            else if(type == STACKPOS_USEITEM){
                //the first down item is usually the right item unless there is topOrder items with scripts
                Item* downItem = tile->getTopDownItem();

                //check items with topOrder 2 (ladders, signs, splashes)
                Item* topOrderItem =  tile->getItemByTopOrder(2); // <--- there im change to 1 but still not work
                if(topOrderItem && g_actions->hasAction(topOrderItem) ){
                    const ItemType& it = Item::items[topOrderItem->getID()];
                    //if the top order item has a height or allows pickupable items we use the first down item instead
                    if(!(downItem && (it.hasHeight || it.allowPickupable))){
                        thing = topOrderItem;
                    }
                }

                if(thing == NULL){
                    //first down item
                    thing = downItem;
                }

                if(thing == NULL){
                    //then items with topOrder 3 (doors etc)
                    thing = tile->getTopTopItem();
                }

                if(thing == NULL){
                    //and finally the ground
                    thing = tile->ground;
                }
            }
            else{
                thing = tile->__getThing(index);
            }

            if(player){
                //do extra checks here if the thing is accessable
                if(thing && thing->getItem()){
                    if(tile->hasProperty(ISVERTICAL)){
                        if(player->getPosition().x + 1 == tile->getPosition().x){
                            thing = NULL;
                        }
                    }
                    else if(tile->hasProperty(ISHORIZONTAL)){
                        if(player->getPosition().y + 1 == tile->getPosition().y){
                            thing = NULL;
                        }
                    }
                }
            }

            return thing;
        }
    }
    else{
        //container
        if(pos.y & 0x40){
            uint8_t fromCid = pos.y & 0x0F;
            uint8_t slot = pos.z;

            Container* parentcontainer = player->getContainer(fromCid);
            if(!parentcontainer)
                return NULL;

            return parentcontainer->getItem(slot);
        }
        else if(pos.y == 0 && pos.z == 0){
            const ItemType& it = Item::items.getItemIdByClientId(spriteId);
            if(it.id == 0){
                return NULL;
            }

            int32_t subType = -1;
            if(it.isFluidContainer()){
                subType = index;
            }

            return findItemOfType(player, it.id, true, subType);
        }
        //inventory
        else{
            slots_t slot = (slots_t)static_cast<unsigned char>(pos.y);
            return player->getInventoryItem(slot);
        }
    }

    return NULL;
}
Post automatically merged:

bump
 
Last edited:

Similar threads

Back
Top