void cPlayer::giveGold( quint32 amount, bool inBank ) { P_ITEM pCont = NULL; if ( !inBank ) pCont = getBackpack(); else pCont = getBankbox(); if ( !pCont ) return; // Begin Spawning quint32 total = amount; while ( total > 0 ) { P_ITEM pile = cItem::createFromScript( "eed" ); pile->setAmount( wpMin<quint32>( total, static_cast<quint32>( 65535 ) ) ); total -= pile->amount(); pCont->addItem( pile ); if ( !pile->free ) { pile->update(); } } goldSound( amount, false ); }
/*! Reduces the specified \a amount of gold from the user and returns the amount reduced. If it was successfull, it will return the same value passed on \a amount parameter. */ Q_UINT32 cPlayer::takeGold( Q_UINT32 amount, bool useBank ) { P_ITEM pPack = getBackpack(); Q_UINT32 dAmount = 0; if ( pPack ) dAmount = pPack->deleteAmount( amount, 0xEED, 0 ); if ( ( dAmount > 0 ) && useBank ) { P_ITEM pBank = getBankbox(); if ( pBank ) dAmount += pBank->deleteAmount( ( amount - dAmount ), 0xEED, 0 ); } goldSound( amount, false ); return amount - dAmount; }
/*! Reduces the specified \a amount of gold from the user and returns the amount reduced. If it was successfull, it will return the same value passed on \a amount parameter. */ quint32 cPlayer::takeGold( quint32 amount, bool useBank ) { P_ITEM pPack = getBackpack(); P_ITEM pBank = getBankbox(); // Count total gold unsigned int totalGold = 0; // Change useBank if we have "Pay from pack only" enabled if (Config::instance()->payfrompackonly()) useBank = false; // Lets try global IDs QString idthird = Config::instance()->defaultThirdCoin(); QString idfirst = Config::instance()->defaultFirstCoin(); // Lets try values if (Config::instance()->usenewmonetary()) { // Lets Assign Region cTerritory* Region = this->region(); if (Config::instance()->usereversedvaluable()) { // Region Assignment if ( Region ) { idthird = Region->thirdcoin(); } // Get Amounts totalGold = pPack->countBaseItems( idthird ); if (useBank && totalGold < amount) { totalGold += pBank->countBaseItems( idthird ); } } else { // Region Assignment if ( Region ) { idfirst = Region->firstcoin(); } // Get Amounts totalGold = pPack->countBaseItems( idfirst ); if (useBank && totalGold < amount) { totalGold += pBank->countBaseItems( idfirst ); } } } else { totalGold = pPack->countItems(0xEED, 0); if (useBank && totalGold < amount) { totalGold += pBank->countItems(0xEED, 0); } } if (totalGold < amount) { return 0; } // Amount to Delete quint32 dAmount = 0; // Lets Delete if (Config::instance()->usenewmonetary()) { if (Config::instance()->usereversedvaluable()) { dAmount = pPack->removeItem( idthird, amount ); if (useBank && dAmount > 0) { pBank->removeItem( idthird, dAmount ); } } else { dAmount = pPack->removeItem( idfirst, amount ); if (useBank && dAmount > 0) { pBank->removeItem( idfirst, dAmount ); } } } else { dAmount = pPack->deleteAmount( amount, 0xEED, 0 ); if (useBank && dAmount > 0) { pBank->deleteAmount( dAmount, 0xEED, 0 ); } } goldSound(amount, false); return amount; }