diff --git a/dGame/Character.cpp b/dGame/Character.cpp index 267e4577..55b37420 100644 --- a/dGame/Character.cpp +++ b/dGame/Character.cpp @@ -527,7 +527,7 @@ void Character::OnZoneLoad() */ if (HasPermission(PermissionMap::Old)) { if (GetCoins() > 1000000) { - SetCoins(1000000); + SetCoins(1000000, 0); } } @@ -567,18 +567,15 @@ const NiPoint3& Character::GetRespawnPoint(LWOMAPID map) const return pair->second; } -void Character::SetCoins(int64_t newCoins, const bool message) { +void Character::SetCoins(int64_t newCoins, int lootType) { if (newCoins < 0) { newCoins = 0; } m_Coins = newCoins; - - if (message) - { - GameMessages::SendSetCurrency(EntityManager::Instance()->GetEntity(m_ObjectID), m_Coins, 0, 0, 0, 0, true); - } + + GameMessages::SendSetCurrency(EntityManager::Instance()->GetEntity(m_ObjectID), m_Coins, 0, 0, 0, 0, true, lootType); } bool Character::HasBeenToWorld(LWOMAPID mapID) const diff --git a/dGame/Character.h b/dGame/Character.h index 57da8640..1f8f27e9 100644 --- a/dGame/Character.h +++ b/dGame/Character.h @@ -314,7 +314,7 @@ public: * @param newCoins the amount of coins to update by * @param message whether to notify the client of the change */ - void SetCoins(int64_t newCoins, bool message = true); + void SetCoins(int64_t newCoins, int lootType); /** * Get the entity this character belongs to diff --git a/dGame/TradingManager.cpp b/dGame/TradingManager.cpp index 20af95e0..294085a5 100644 --- a/dGame/TradingManager.cpp +++ b/dGame/TradingManager.cpp @@ -151,8 +151,8 @@ void Trade::Complete() if (inventoryA == nullptr || inventoryB == nullptr || characterA == nullptr || characterB == nullptr || missionsA == nullptr || missionsB == nullptr) return; - characterA->SetCoins(characterA->GetCoins() - m_CoinsA + m_CoinsB); - characterB->SetCoins(characterB->GetCoins() - m_CoinsB + m_CoinsA); + characterA->SetCoins(characterA->GetCoins() - m_CoinsA + m_CoinsB, 6); + characterB->SetCoins(characterB->GetCoins() - m_CoinsB + m_CoinsA, 6); for (const auto& tradeItem : m_ItemsA) { diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index c84e906a..6a68ce6d 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -818,7 +818,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType LootGenerator::Instance().DropLoot(m_Parent, m_Parent, -1, coinsToLoose, coinsToLoose); } - character->SetCoins(coinsTotal); + character->SetCoins(coinsTotal, 11); Entity* zoneControl = EntityManager::Instance()->GetZoneControlEntity(); for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) { diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index fad5d7de..4f2d464d 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -706,7 +706,7 @@ void GameMessages::SendBroadcastTextToChatbox(Entity* entity, const SystemAddres SEND_PACKET_BROADCAST } -void GameMessages::SendSetCurrency(Entity* entity, int64_t currency, int lootType, const LWOOBJID& sourceID, const LOT& sourceLOT, int sourceTradeID, bool overrideCurrent) { +void GameMessages::SendSetCurrency(Entity* entity, int64_t currency, int lootType, const LWOOBJID& sourceID, const LOT& sourceLOT, int sourceTradeID, bool overrideCurrent, int sourceType) { CBITSTREAM CMSGHEADER @@ -729,7 +729,6 @@ void GameMessages::SendSetCurrency(Entity* entity, int64_t currency, int lootTyp bitStream.Write(sourceTradeID != LWOOBJID_EMPTY); if (sourceTradeID != LWOOBJID_EMPTY) bitStream.Write(sourceTradeID); - int sourceType = 0; //For now. bitStream.Write(sourceType != LOOTTYPE_NONE); if (sourceType != LOOTTYPE_NONE) bitStream.Write(sourceType); @@ -4685,7 +4684,7 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti inv->RemoveItem(itemComp.currencyLOT, altCurrencyCost); } - character->SetCoins(character->GetCoins() - (coinCost)); + character->SetCoins(character->GetCoins() - (coinCost), 9); inv->AddItem(item, count); } @@ -4734,7 +4733,7 @@ void GameMessages::HandleSellToVendor(RakNet::BitStream* inStream, Entity* entit //inv->RemoveItem(count, -1, iObjID); inv->MoveItemToInventory(item, VENDOR_BUYBACK, count, true, false, true); - character->SetCoins(std::floor(character->GetCoins() + ((itemComp.baseValue * sellScalar)*count))); + character->SetCoins(std::floor(character->GetCoins() + ((itemComp.baseValue * sellScalar)*count)), 9); //EntityManager::Instance()->SerializeEntity(player); // so inventory updates GameMessages::SendVendorTransactionResult(entity, sysAddr); } @@ -4796,7 +4795,7 @@ void GameMessages::HandleBuybackFromVendor(RakNet::BitStream* inStream, Entity* //inv->RemoveItem(count, -1, iObjID); inv->MoveItemToInventory(item, Inventory::FindInventoryTypeForLot(item->GetLot()), count, true, false); - character->SetCoins(character->GetCoins() - cost); + character->SetCoins(character->GetCoins() - cost, 9); //EntityManager::Instance()->SerializeEntity(player); // so inventory updates GameMessages::SendVendorTransactionResult(entity, sysAddr); } @@ -5240,7 +5239,7 @@ void GameMessages::HandlePickupCurrency(RakNet::BitStream* inStream, Entity* ent auto* ch = entity->GetCharacter(); if (entity->CanPickupCoins(currency)) { - ch->SetCoins(ch->GetCoins() + currency); + ch->SetCoins(ch->GetCoins() + currency, 11); } } diff --git a/dGame/dGameMessages/GameMessages.h b/dGame/dGameMessages/GameMessages.h index e11f502a..993223fe 100644 --- a/dGame/dGameMessages/GameMessages.h +++ b/dGame/dGameMessages/GameMessages.h @@ -78,7 +78,7 @@ namespace GameMessages { void SendPlayFXEffect(const LWOOBJID& entity, int32_t effectID, const std::u16string& effectType, const std::string& name, LWOOBJID secondary = LWOOBJID_EMPTY, float priority = 1, float scale = 1, bool serialize = true); void SendStopFXEffect(Entity* entity, bool killImmediate, std::string name); void SendBroadcastTextToChatbox(Entity* entity, const SystemAddress& sysAddr, const std::u16string& attrs, const std::u16string& wsText); - void SendSetCurrency(Entity* entity, int64_t currency, int lootType, const LWOOBJID& sourceID, const LOT& sourceLOT, int sourceTradeID, bool overrideCurrent); + void SendSetCurrency(Entity* entity, int64_t currency, int lootType, const LWOOBJID& sourceID, const LOT& sourceLOT, int sourceTradeID, bool overrideCurrent, int sourceType); void SendRebuildNotifyState(Entity* entity, int prevState, int state, const LWOOBJID& playerID); void SendEnableRebuild(Entity* entity, bool enable, bool fail, bool success, int failReason, float duration, const LWOOBJID& playerID); diff --git a/dGame/dMission/Mission.cpp b/dGame/dMission/Mission.cpp index 7f5104e6..8f88478c 100644 --- a/dGame/dMission/Mission.cpp +++ b/dGame/dMission/Mission.cpp @@ -444,7 +444,7 @@ void Mission::YieldRewards() { auto count = pair.second > 0 ? pair.second : 1; - // Sanitfy check, 6 is the max any mission yields + // Sanity check, 6 is the max any mission yields if (count > 6) { count = 0; } @@ -453,7 +453,7 @@ void Mission::YieldRewards() { } if (info->reward_currency_repeatable > 0) { - character->SetCoins(character->GetCoins() + info->reward_currency_repeatable); + character->SetCoins(character->GetCoins() + info->reward_currency_repeatable, 2); } return; @@ -481,8 +481,10 @@ void Mission::YieldRewards() { inventoryComponent->AddItem(pair.first, count); } - if (info->reward_currency > 0) { - character->SetCoins(character->GetCoins() + info->reward_currency, info->isMission); + if (info->reward_currency > 0 && info->isMission) { + character->SetCoins(character->GetCoins() + info->reward_currency, 2); + } else if (info->reward_currency && !info->isMission) { + character->SetCoins(character->GetCoins() + info->reward_currency, 5); } if (info->reward_maxinventory > 0) { diff --git a/dGame/dUtilities/Loot.cpp b/dGame/dUtilities/Loot.cpp index 7e0f8323..892ba4d5 100644 --- a/dGame/dUtilities/Loot.cpp +++ b/dGame/dUtilities/Loot.cpp @@ -316,7 +316,7 @@ void LootGenerator::GiveActivityLoot(Entity* player, Entity* source, uint32_t ac auto* character = player->GetCharacter(); - character->SetCoins(character->GetCoins() + coins); + character->SetCoins(character->GetCoins() + coins, 10); } void LootGenerator::DropLoot(Entity* player, Entity* killedObject, uint32_t matrixIndex, uint32_t minCoins, uint32_t maxCoins) { diff --git a/dGame/dUtilities/Mail.cpp b/dGame/dUtilities/Mail.cpp index 2c3baf8c..ecfbaf7e 100644 --- a/dGame/dUtilities/Mail.cpp +++ b/dGame/dUtilities/Mail.cpp @@ -262,7 +262,7 @@ void Mail::HandleSendMail(RakNet::BitStream* packet, const SystemAddress& sysAdd } Mail::SendSendResponse(sysAddr, Mail::MailSendResponse::Success); - entity->GetCharacter()->SetCoins(entity->GetCharacter()->GetCoins() - mailCost); + entity->GetCharacter()->SetCoins(entity->GetCharacter()->GetCoins() - mailCost, 3); Game::logger->Log("Mail", "Seeing if we need to remove item with ID/count/LOT: %i %i %i\n", itemID, attachmentCount, itemLOT); diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index 8be99612..738d30fe 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -1326,7 +1326,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } auto* ch = entity->GetCharacter(); - ch->SetCoins(ch->GetCoins() + money); + ch->SetCoins(ch->GetCoins() + money, 14); } if ((chatCommand == "setcurrency") && args.size() == 1 && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) { @@ -1339,7 +1339,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } auto* ch = entity->GetCharacter(); - ch->SetCoins(money); + ch->SetCoins(money, 14); } // Allow for this on even while not a GM, as it sometimes toggles incorrrectly.