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

Solved 7.7 ot, made runes stackable, removes whole stack when used

DannyTheDog

New Member
Joined
Nov 22, 2013
Messages
12
Reaction score
0
Location
Hawaii
I'm using a 7.7 distro in which I've made runes stackable. Works like a charm.

But, it removes the whole stack when you use a rune, when it should only remove one.

I've been searching through the sources for what I think is the function responsible for this.

Any ideas what I need to change?

Code:
bool Game::removeItemOfType(Cylinder* cylinder, uint16_t itemId, int32_t count, int32_t subType /*= -1*/, bool onlyContainers /*= false*/)
{
    if(cylinder == NULL || ((int32_t)cylinder->__getItemTypeCount(itemId, subType) < count) ){
        return false;
    }

    if(count <= 0){
        return true;
    }

    std::list<Container*> listContainer;
    Container* tmpContainer = NULL;
    Thing* thing = NULL;
    Item* item = NULL;

    for(int i = cylinder->__getFirstIndex(); i < cylinder->__getLastIndex() && count > 0;){

        if((thing = cylinder->__getThing(i)) && (item = thing->getItem())){
            if(!onlyContainers && item->getID() == itemId){
                if(item->isStackable()){
                    if(item->getItemCount() > count){
                        internalRemoveItem(item, count);
                        count = 0;
                    }
                    else{
                        count -= item->getItemCount();
                        internalRemoveItem(item);
                    }
                }
                else if(subType == -1 || subType == item->getSubType()){
                    --count;
                    internalRemoveItem(item);
                }
                else //Item has subtype but not the required one.
                    ++i;
            }
            else{
                ++i;

                if((tmpContainer = item->getContainer())){
                    listContainer.push_back(tmpContainer);
                }
            }
        }
        else{
            ++i;
        }
    }

    while(!listContainer.empty() && count > 0){
        Container* container = listContainer.front();
        listContainer.pop_front();

        for(int i = 0; i < (int32_t)container->size() && count > 0;){
            Item* item = container->getItem(i);
            if(item->getID() == itemId){
                if(item->isStackable()){
                    if(item->getItemCount() > count){
                        internalRemoveItem(item, count);
                        count = 0;
                    }
                    else{
                        count-= item->getItemCount();
                        internalRemoveItem(item);
                    }
                }
                else if(subType == -1 || subType == item->getSubType()){
                    --count;
                    internalRemoveItem(item);
                }
                else //Item has subtype but not the required one.
                    ++i;
            }
            else{
                ++i;

                if((tmpContainer = item->getContainer())){
                    listContainer.push_back(tmpContainer);
                }
            }
        }
    }

    return (count == 0);
}
 
After some more searching I found the function responsible for this in spells.cpp.

Thanks anyways!

Code:
if(hasCharges && item && g_config.getNumber(ConfigManager::REMOVE_RUNE_CHARGES)){
            int32_t newCharge = std::max((int32_t)0, ((int32_t)item->getCharges()) - 1);
            g_game.transformItem(item, item->getID(), newCharge);
        }
 
Back
Top