Creaturestats and ensureCustumData

Support for running, installing or compiling OpenMW

Before you submit a bug report for the first time, please read: Bug reporting guidelines
Locked
User avatar
Jyby
Posts: 408
Joined: 10 Dec 2013, 04:16

Creaturestats and ensureCustumData

Post by Jyby »

Can someone explain to me how this works:
I want to set a stat of a creature but I do not want it to add the actual gold to that creatures inventory.
I'd like to do this : data->mNpcStats.setGoldPool(gold);
but if I run the game the gold will be found in the creatures inventory.
If I comment that line in question out the gold is not in the inventory but the creature stat is not set.

Any idea?

Code: Select all

// Relates to NPC gold reset delay
data->mNpcStats.setTradeTime(MWWorld::TimeStamp(0.0, 0));

data->mNpcStats.setGoldPool(gold);

// store
ptr.getRefData().setCustomData (data.release());

// TODO: this is not quite correct, in vanilla the merchant's gold pool is not available in his inventory.
// (except for gold you gave him)
//getContainerStore(ptr).add(MWWorld::ContainerStore::sGoldId, gold, ptr);

getInventoryStore(ptr).autoEquip(ptr);
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Creaturestats and ensureCustumData

Post by Zini »

That must be your own code interfering with something. Obviously setGoldPool does not add items to the inventory. Maybe somewhere else in your code you call getGoldPool and add that gold to the inventory?
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Creaturestats and ensureCustumData

Post by Zini »

There it is (TradeWindow::checkTradeTime):

Code: Select all

        if (MWBase::Environment::get().getWorld()->getTimeStamp() >= sellerStats.getTradeTime() + delay)
        {
            addOrRemoveGold(-store.count(MWWorld::ContainerStore::sGoldId), mPtr);
            addOrRemoveGold(+sellerStats.getGoldPool(), mPtr);
        }
Locked