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

7.6 Yourots XML AutoStack in Backpack

Lajsiur

New Member
Joined
Dec 29, 2008
Messages
6
Reaction score
2
Hello everyone, does any of you have a code for autostack items in backpack?

Please help or write this code to Yourots engine


Thank you in advance
 
Hello Lajsiur.
Yes, I wrote the code but I have to worry you that it's not easy task for someone who has no experience in editing YurOTS and almost no one uses this one anymore.

You need to change (check if there is an item in the container and if so, attach the item) a function in game.cpp:
C++:
//container/inventory to container/inventory
void Game::thingMoveInternal

Good luck.
 
Hello, I have quite a lot of experience with Yourots, but I have no idea how to write this code

In my source in YurOTS 0.9.4F game.cpp

Code:
/container/inventory to container/inventory
void Game::thingMove(Player *player,
    unsigned char from_cid, unsigned char from_slotid, unsigned short itemid, bool fromInventory,
    unsigned char to_cid, unsigned char to_slotid, bool toInventory,
    unsigned char count)
{
    OTSYS_THREAD_LOCK_CLASS lockClass(gameLock, "Game::thingMove() - 3");

    thingMoveInternal(player, from_cid, from_slotid, itemid, fromInventory,
        to_cid, to_slotid, toInventory, count);
}

In source OTHire 7.72 in container.cpp and found this code

Code:
bool autoStack = g_config.getBoolean(ConfigManager::CONTAINER_ITEMS_AUTO_STACK);
    if(autoStack){
        if(item->isStackable()){
            if(item->getParent() != this){
                //try find a suitable item to stack with
                uint32_t n = 0;
                for(ItemList::iterator cit = itemlist.begin(); cit != itemlist.end(); ++cit){
                    if((*cit) != item && (*cit)->getID() == item->getID() && (*cit)->getItemCount() < 100){
                        *destItem = (*cit);
                        index = n;
                        return this;
                    }

                    ++n;
                }
            }
        }
    }
 
You are using the wrong forum section. Use Request or support board
 
In my source in YurOTS 0.9.4F game.cpp

Code:
/container/inventory to container/inventory
void Game::thingMove(Player *player,
    unsigned char from_cid, unsigned char from_slotid, unsigned short itemid, bool fromInventory,
    unsigned char to_cid, unsigned char to_slotid, bool toInventory,
    unsigned char count)
{
    OTSYS_THREAD_LOCK_CLASS lockClass(gameLock, "Game::thingMove() - 3");

    thingMoveInternal(player, from_cid, from_slotid, itemid, fromInventory,
        to_cid, to_slotid, toInventory, count);
}
i dont know how much of this u need

C++:
    }
#ifdef ON_TILE
if(player) //CHANGE onWalk
{
    Tile* fromT = getTile(player->pos);
    actions.luaWalkOff(player,player->pos,fromT->ground->getID(),fromT->ground->getUniqueId(),fromT->ground->getActionId());
}
#endif //ON_TILE
    this->FreeThing(c);
    return true;
}
#ifdef MOVE_UP
void Game::thingMove(Player *player, unsigned char from_cid, unsigned char from_slotid)
{
 OTSYS_THREAD_LOCK_CLASS lockClass(gameLock, "Game::thingMove() - 0");
 
 thingMoveInternal(player, from_cid, from_slotid);
}
#endif //MOVE_UP
void Game::thingMove(Creature *creature, Thing *thing,
    unsigned short to_x, unsigned short to_y, unsigned char to_z, unsigned char count)
{
    OTSYS_THREAD_LOCK_CLASS lockClass(gameLock, "Game::thingMove() - 1");

    Tile *fromTile = map->getTile(thing->pos);

    if (fromTile)
    {
        int oldstackpos = fromTile->getThingStackPos(thing);
        thingMoveInternal(creature, thing->pos.x, thing->pos.y, thing->pos.z, oldstackpos, 0, to_x, to_y, to_z, count);
    }
}


void Game::thingMove(Creature *creature, unsigned short from_x, unsigned short from_y, unsigned char from_z,
    unsigned char stackPos, unsigned short itemid, unsigned short to_x, unsigned short to_y, unsigned char to_z, unsigned char count)
{
    OTSYS_THREAD_LOCK_CLASS lockClass(gameLock, "Game::thingMove() - 2");

    Tile *fromTile = getTile(from_x, from_y, from_z);
    if(!fromTile)
        return;

    Tile *toTile = getTile(to_x, to_y, to_z);
    if(!toTile)
        return;

#ifdef FIXY
    if (toTile->isHouse() && !fromTile->isHouse())
        return;
#endif //FIXY

    Thing* thing = fromTile->getThingByStackPos(stackPos);
    if(!thing)
        return;

    Item* item = dynamic_cast<Item*>(thing);

    if(item && (item->getID() != itemid || item != fromTile->getTopDownItem()))
        return;

    thingMoveInternal(creature, from_x, from_y, from_z, stackPos, itemid, to_x, to_y, to_z, count);
}


//container/inventory to container/inventory
void Game::thingMove(Player *player,
    unsigned char from_cid, unsigned char from_slotid, unsigned short itemid, bool fromInventory,
    unsigned char to_cid, unsigned char to_slotid, bool toInventory,
    unsigned char count)
{
    OTSYS_THREAD_LOCK_CLASS lockClass(gameLock, "Game::thingMove() - 3");

    thingMoveInternal(player, from_cid, from_slotid, itemid, fromInventory,
        to_cid, to_slotid, toInventory, count);

pm me if you want download link for this yurots sources this is engine created by baabusek
 
Back
Top